Re: Preventing execution without inclusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux