laavanya14 Posted April 9, 2006 Share Posted April 9, 2006 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 (whether php or html pages).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 Quote Link to comment Share on other sites More sharing options...
theteenager Posted April 9, 2006 Share Posted April 9, 2006 Just have more types assigned to PHP. For example, if you want html and html files to be parsed by PHP, just add the following to httpd.conf:[code]AddType application/x-httpd-php .htm .html[/code]The requested filename will be in the variable $_SERVER["PHP_SELF"] Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 9, 2006 Author Share Posted April 9, 2006 [!--quoteo(post=362945:date=Apr 9 2006, 03:30 AM:name=Honzoo)--][div class=\'quotetop\']QUOTE(Honzoo @ Apr 9 2006, 03:30 AM) [snapback]362945[/snapback][/div][div class=\'quotemain\'][!--quotec--]Just have more types assigned to PHP. For example, if you want html and html files to be parsed by PHP, just add the following to httpd.conf:[code]AddType application/x-httpd-php .htm .html[/code]The requested filename will be in the variable $_SERVER["PHP_SELF"][/quote]Hi, but how do i automatically call another script??and how do i pass the requested filename to it, even if it is html file..sorry if it a silly question but desperate for help :pthanks alooooooooot Quote Link to comment Share on other sites More sharing options...
SomeGuy1337 Posted April 9, 2006 Share Posted April 9, 2006 auto_prepend_fileauto_append_filethese are in the php.ini config fileand you can use basename($_SERVER["PHP_SELF"]) to get just the filename and strip the direcotry Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 9, 2006 Author Share Posted April 9, 2006 [!--quoteo(post=362976:date=Apr 9 2006, 08:36 AM:name=SomeGuy1337)--][div class=\'quotetop\']QUOTE(SomeGuy1337 @ Apr 9 2006, 08:36 AM) [snapback]362976[/snapback][/div][div class=\'quotemain\'][!--quotec--]auto_prepend_fileauto_append_filethese are in the php.ini config fileand you can use basename($_SERVER["PHP_SELF"]) to get just the filename and strip the direcotry[/quote]hey using auto_prepand_file, would it work if my requested page is html????my script name is AuthenticationModule, n in my script i am accepted the requested page filename using GET method. if there is any other way of accepting, i dun mind changing.auto_prepand_file ="c:/Apache/include/AuthenticationModule.php?filename+($_SERVER["PHP_SELF"))is that how i do it?? Quote Link to comment Share on other sites More sharing options...
SomeGuy1337 Posted April 9, 2006 Share Posted April 9, 2006 the php.ini is static, its jsut to setup php variables u cant exciute php code in itim not sure entirely wat u want to do?as teh afore mentoined by honzoo:AddType application/x-httpd-php .htm .htmlthis will make any html page be sent thru the php interpreterauto_prepend and append file will mean any file sent thru the php interprter will have those files added in before and afterwards as if you had include "somefile.php" at the top and bottom of every php filebasename($_SERVER["PHP_SELF"]) will tell you the current filename in use for example if you had[a href=\"http://localhost/dir/myfile.php\" target=\"_blank\"]http://localhost/dir/myfile.php[/a]it would be "myfile.php" as the variablebut i am unsure ezactly wat you are tyring to do could you be more specific about ezactly what you want to achive Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 9, 2006 Author Share Posted April 9, 2006 ok 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 scriptIn my script, I am accepting the filename parameter using GET. However i am willing to change the way i accept the parameter, if needed too. Once processed, the requested page is displayed.Just to let you know what AuthenticationModule is doing, it verifies the intergrity of the page. Once verified, the normal process goes, meaning the page is displayed. This is for my university project. I am suppose to do an AuthenticationModule which verifies webpages before displaying it. So I have already done the module but now I am not sure how to link it for every requestThe easy but not so good way would be [code]a href='authenticationmodule.php?file=football.html'[/code]but in this case, i need to change each and every link which is not good in the design part of my system.i just would like to make it one main configuration change and it does for every link.Thanks in advance...Help really needed Quote Link to comment Share on other sites More sharing options...
SomeGuy1337 Posted April 9, 2006 Share Posted April 9, 2006 ok if you preappend Auth.php (or the filename doenst matter.)browser requests [a href=\"http://site.com/mypage.html?var=value\" target=\"_blank\"]http://site.com/mypage.html?var=value[/a]you site will run auth.phpfrom auth.php:basename($_SERVER["PHP_SELF"]) = mypage.html$_GET['var'] = 'value'at this point i hvae to say i have not peronsaly used the preappend and append php.ini settings.but to my knwoladge they shud perform just as if you had used include "preappend.php" inside mypage.htmlsetup your authmodule to echo those variables and set it as the preappend fileif all goes well when you access football.html?var=value it should show you those valuestry setting this up it shud solve your problem. Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 9, 2006 Author Share Posted April 9, 2006 [!--quoteo(post=363031:date=Apr 9 2006, 11:37 AM:name=SomeGuy1337)--][div class=\'quotetop\']QUOTE(SomeGuy1337 @ Apr 9 2006, 11:37 AM) [snapback]363031[/snapback][/div][div class=\'quotemain\'][!--quotec--]ok if you preappend Auth.php (or the filename doenst matter.)browser requests [a href=\"http://site.com/mypage.html?var=value\" target=\"_blank\"]http://site.com/mypage.html?var=value[/a]you site will run auth.phpfrom auth.php:basename($_SERVER["PHP_SELF"]) = mypage.html$_GET['var'] = 'value'at this point i hvae to say i have not peronsaly used the preappend and append php.ini settings.but to my knwoladge they shud perform just as if you had used include "preappend.php" inside mypage.htmlsetup your authmodule to echo those variables and set it as the preappend fileif all goes well when you access football.html?var=value it should show you those valuestry setting this up it shud solve your problem.[/quote]hi, by doing basename($_SERVER["PHP_SELF"]) , it works only for normal link call, however if i doing include('football.html'), it doesnt show football.html instead the page calling include file Quote Link to comment Share on other sites More sharing options...
SomeGuy1337 Posted April 10, 2006 Share Posted April 10, 2006 if you preappend auto file then it will contain football.htmlalternativly if you authmodule fetches football.html then shouldnt u have that value?like authmodule.php?get=football.html Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 11, 2006 Author Share Posted April 11, 2006 Hi Guys,I partially manage to solve my problem by using auto_prepend_file and $_SERVER('PHP_SELF');if auto_prepend my AuthenticationModule and inside that script i write $filename=$_Server('PHP_SELF')) i can get my calling script.assuming i have page1, AuthenticationModule, page3.in page1, i have a link [code]<a href="page3.html">Page3</a>[/code], then the solution works fine.however, if in page1, instead of link i have [code]include('page3'); [/code]then in my AuthenticationModule, [code]$filename=$_SERVER('PHP_SELF'); [/code] then filename would be page1, instead of my requesting page, which is page3.Is there anyway i can solve this problem for include file situations? Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 12, 2006 Author Share Posted April 12, 2006 Helo again.I realize the if i include files, the php doesnt treat it like another file request. Meaning, the auto prepend file is not being executed before......assuming in page1.php i have[code]<?php include('page3.php'); ?>[/code]thus if i have auto_prepend page2.php, it does not get executed before calling of page3. Can I solve this problem??? Quote Link to comment Share on other sites More sharing options...
SomeGuy1337 Posted April 12, 2006 Share Posted April 12, 2006 all u need to do is get a system that handles this all for you.every file that uses this system will haverequire "mysystem.php"oro something like thatthis script can get the PHP_SELF variable for calling page, and it can then assess which extra files it needs to include, such as teh atuhmodule.php as standered.this is also far more pratical, than using auto_prepend Quote Link to comment Share on other sites More sharing options...
laavanya14 Posted April 12, 2006 Author Share Posted April 12, 2006 Hi Ya,thats what i am doing normal.For every requested page, I parse to check if there is include or require statements.....thanks aloooot anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.