File Include Check
By: Daniel
Does your website have several files that are included? Do you not want to have them output anything if they are addressed directly? Here is a very simple script to do that:
function amIincluded() { $requestedURL = parse_url($_SERVER['REQUEST_URI']); if(basename($requestedURL['path']) != basename(__FILE__)) return true; return false; }
This amIincluded function gets the address of the page in your browser. Then it parses that into its parts and gets the filename. If that filename is the same as the filename of the file, it returns true otherwise it returns false.
A sample usage of this is:
if(amIincluded()) { echo 'Included'; } else { echo 'Not Included'; }




August 19th, 2006 at 5:15 am
That is somewhat useless since it won’t be parsed if it is not included.
August 19th, 2006 at 6:50 am
Nevermind what I said before it is late, I contracted some sort of temporary retardation due to lack of sleep.