Re: Preventing execution without inclusion
| From: | Jacek Blech | Date: | Fri, 14 Jan 2005 07:42:21 +0000 |
| Subject: | Re: Preventing execution without inclusion | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206356@lists.php.net to get a copy of this message | ||
Adam Hubscher wrote:
I am trying to prevent 2 from even occuring, utilizing a piece of code that would check if index.php had included it, or not. This code would be in the beginning of all the class files, at the top, before any other code was to be executed.use the 2 constants/variables available in PHP scripts to check if the class file has been included by another php script: __FILE__ // the name of the file the current codeline is a part of $_SERVER["SCRIPT_FILENAME"] // the name of the primary php file, that has included the current file so it may be enough for you to do something like this in you class files: <?php if ( basename(__FILE__) != 'index.php' ) { // redirection to index.php ... } class Join {} ?>
As of yet, it has eluded me... hth, bye.