PHP redirect of direct access to include files

Ffiona
August 27, 2006, 1:53 pm
PHP redirect of direct access to include files
I have 5 php files that are included into an index.php file. How can I use php to ensure that these include files are not accessed directly in anyway, except from the include DIR?
Veselin
August 27, 2006, 1:57 pm
Re:
In your index.php file before including the files you can set a variable like

$INCLUDE_PASS = 'somepass';

then in the includes files you can have

if ($INCLUDE_PASS = 'somepass') {
/// include file content
} else {
echo "Error message";
};

this way if someone opens http://www.domain.com/include1.php it will do nothing because if ($INCLUDE_PASS = 'somepass') statement will be false and will show the error message.
anton
July 1, 2008, 6:35 pm
Re:
thanks
Reply
Title:
Your name:
Your email: (email address will not be posted on the web site)
Reply:
Verification