Help with PHP included files - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: Help with PHP included files (/showthread.php?tid=50504) Help with PHP included files by Choli on 09-14-2005 at 08:09 PM
Hi, i need some help with PHP... code: and I want to write some code to produce an error when the user goes to http://my_server/a.php but that everything goes well when the page is loaded through b.php Thanks RE: Help with PHP included files by hmaster on 09-14-2005 at 08:17 PM
in a.php code: in b.php code: Or do you mean when they access a.php from http://my_server.com/a.php its an error but when it is accessed from http://my_server.com/b.php it runs the correct a.php page, if so you might wanna try $_SERVER['HTTP_REFERER'] RE: Help with PHP included files by Choli on 09-14-2005 at 08:42 PM
quote:i think it's something like that... a.php contains code needed by b.php, but it should produce an error when accessed alone. how does that $_SERVER['HTTP_REFERER'] work? is it the url that the user is requesting to apache? RE: Help with PHP included files by KeyStorm on 09-14-2005 at 08:45 PM
No, you have to compare the constant __FILE__ with $_SERVER['PHP_SELF']. RE: Help with PHP included files by hmaster on 09-14-2005 at 08:48 PM
A friend (Zero1) has told me you need to create a session RE: Help with PHP included files by Choli on 09-14-2005 at 09:29 PM thanks you, guys... I tihnk KS' solution will do the work RE: Help with PHP included files by surfichris on 09-14-2005 at 10:27 PM
quote:What kind of dodgy way is that? Why do something like that when it can be accomplised like this: a.php code: b.php code: Easy! RE: Help with PHP included files by KeyStorm on 09-14-2005 at 10:29 PM
quote: quote:I'm quite afraid your friend is kidding you. The example doesn't work as Choli expects, for sure. And sessions don't have anything to do with includes... quote:But a dirty workaround anyway There is also a function that tells you how many includes there have been, then break on zero.. but that's too much of a hassle. RE: Help with PHP included files by Choli on 09-14-2005 at 10:32 PM
quote:I tought on that, but i'd like not to modify the file where the include statment is. (also, because there are many files that include the "a.php" file, and those files may be changed by others than me ) Thanks anyway, Chris. RE: Help with PHP included files by surfichris on 09-14-2005 at 10:34 PM
Okay, you could do: code: That would work too RE: Help with PHP included files by KeyStorm on 09-14-2005 at 10:39 PM
code: Is a universal solution to the problem. RE: Help with PHP included files by wj on 09-15-2005 at 04:20 PM That would be a NICE way to protect CSS files..... |