Execute PHP script automatically for each page request
Moderator: General Moderators
Execute PHP script automatically for each page request
Hi Guys,
I have a problem and really need help asap.
I am using Apache web server.
I would like to know how to make the apache execute my PHP script automatically for every page request.
at the same time, it has to pass the requested page filename to my PHP Script.
I hope somebody can really help me. I am newbie to this kind of stuff.
Thank you
I have a problem and really need help asap.
I am using Apache web server.
I would like to know how to make the apache execute my PHP script automatically for every page request.
at the same time, it has to pass the requested page filename to my PHP Script.
I hope somebody can really help me. I am newbie to this kind of stuff.
Thank you
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
im not really sure I understand what you mean...
if it is a funtion you want to run everytime a page loads then you could put the function in a separate file, include the file in every page you want it to run along with a function call:
if by
to
the argument inside the () will pass the current page to the function.
by no means am i an expert but that is how i would do it
rj
if it is a funtion you want to run everytime a page loads then you could put the function in a separate file, include the file in every page you want it to run along with a function call:
Code: Select all
include "myfunctionfile.php";
myfunction();if by
you mean the current page or the page that has called the function changeit has to pass the requested page filename to my PHP Script.
Code: Select all
myfunction();Code: Select all
myfunction($_SERVER['PHP_SELF');by no means am i an expert but that is how i would do it
rj
hi thanks for your reply.
actually for every page request apache receives, whether it is a html page or php page, before displaying the page, i want it to execute another php script. I want the requested filename to be sent to the script to
In that script I am receiving filename using S_GET.
Once the script is executed, then it goes back to the requested page.
actually for every page request apache receives, whether it is a html page or php page, before displaying the page, i want it to execute another php script. I want the requested filename to be sent to the script to
In that script I am receiving filename using S_GET.
Once the script is executed, then it goes back to the requested page.
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
hi,
will u pls explain it a bit with an example? i am not sure what's ur problem.
is that what u want? if so check the manual.
will u pls explain it a bit with an example? i am not sure what's ur problem.
Code: Select all
header("Location: <somelocation>"); //redirect browserok assuming in my html page now, i am calling Football.html.
before apache displays the requested page, I want it to execute my php script which i have written (AuthenticationModule.php)
I also want it to pass the requested page filename (in this case, Football.html) to my script
In my script, I am accepting the filename parameter using GET. However i am willing to change the way i accept the parameter, if there is another possible way.
So i want this to happen for every page request. Is it possible???
Thanks in advance...Help really needed
before apache displays the requested page, I want it to execute my php script which i have written (AuthenticationModule.php)
I also want it to pass the requested page filename (in this case, Football.html) to my script
In my script, I am accepting the filename parameter using GET. However i am willing to change the way i accept the parameter, if there is another possible way.
So i want this to happen for every page request. Is it possible???
Thanks in advance...Help really needed
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It is possible, but the requested file must be processed by php for it to work.
Have a look at the auto_prepend_file directive.
Have a look at the auto_prepend_file directive.
hi,
the thing is i want it to work for html files too.
besides if i am using auto_prepand, how do i send the requested page filename. i know u can use $_SERVER[PHP_SELF] to get the filename of the current script, but how do i join that together with my auto_prepand?
like this ?? (it doesnt work:p)
auto_prepand_file ="c:/Apache/include/AuthenticationModule.php?filename+($_SERVER["PHP_SELF"))"
I am accepting the parameter using GET in Authenticationmodule
the thing is i want it to work for html files too.
besides if i am using auto_prepand, how do i send the requested page filename. i know u can use $_SERVER[PHP_SELF] to get the filename of the current script, but how do i join that together with my auto_prepand?
like this ?? (it doesnt work:p)
auto_prepand_file ="c:/Apache/include/AuthenticationModule.php?filename+($_SERVER["PHP_SELF"))"
I am accepting the parameter using GET in Authenticationmodule
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You cannot send get request information to the prepend script through the reference to it. Why? Because the prepended file is apart of the same request. The data is available in $_SERVER et al already.pooh14 wrote:besides if i am using auto_prepand, how do i send the requested page filename. i know u can use $_SERVER[PHP_SELF] to get the filename of the current script, but how do i join that together with my auto_prepand?
hi feyd,
i am really sorry, but I have no idea on how to do it at all.
I know this really sounds dumb.
Can you give me a more detail explain?
where do i call the script? how do i pass the $_Server[PHP_SELF] variable to it?
How do i accept in my script (at the moment i am using GET to accept parameter)
i am really sorry, but I have no idea on how to do it at all.
I know this really sounds dumb.
Can you give me a more detail explain?
where do i call the script? how do i pass the $_Server[PHP_SELF] variable to it?
How do i accept in my script (at the moment i am using GET to accept parameter)
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
hi,
ok let me explain more. I am a student and this is for my project (which is why i am rushing to meet the deadline)
my aim of the project is to verify the integrity of a webpage and if any aunthorized changes has been made to it, it would restore to the original content. besides all pages are encrypted and stored. thus for each request it needs to be decrypted.
so i did a module, AuthenticationModule which will do all this stuff and i successfully did it.
but now my problem part is how am i going to call it for each page request without much changes made to the original page.
so i was hoping if i can just change one main configuration file. thus all pages before being displayed it is verified.
ok let me explain more. I am a student and this is for my project (which is why i am rushing to meet the deadline)
my aim of the project is to verify the integrity of a webpage and if any aunthorized changes has been made to it, it would restore to the original content. besides all pages are encrypted and stored. thus for each request it needs to be decrypted.
so i did a module, AuthenticationModule which will do all this stuff and i successfully did it.
but now my problem part is how am i going to call it for each page request without much changes made to the original page.
so i was hoping if i can just change one main configuration file. thus all pages before being displayed it is verified.
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
can you link to the authmodule and send the page in the URL
say a link like this is on your home page
and then in the authmodule
will extract 'football.html'
rj
say a link like this is on your home page
Code: Select all
<a href="AuthenticationModule.php?page=football.html">FOOTBALL</a>Code: Select all
$_REQUEST['page']rj
Hi john
thanks. ya that I can do. but the thing is, my project focuses on authentication module.
my main aim is to provide a system which can verify integrity of page before displaying it.
however, i would like to make sure, the already design web pages, need not be altered much inorder for my module to be incorporated as this would reflect bad design.
so i was thinking if there is a way i just change one main configuration file, n not all the links in every page
thanks. ya that I can do. but the thing is, my project focuses on authentication module.
my main aim is to provide a system which can verify integrity of page before displaying it.
however, i would like to make sure, the already design web pages, need not be altered much inorder for my module to be incorporated as this would reflect bad design.
so i was thinking if there is a way i just change one main configuration file, n not all the links in every page