I am looking for the idea for php code to denied the accessing directly to a file. The file i am talking about will be use for include(); so basically not allow to access the file directly.
You could do something like this: <?php $green="yes"; include('yourfile.php'); ?> PHP: and in the file yourfile.php have: if($green!="yes"){ exit(); } else { //do something } PHP: There may be a better/more secure solution depending what you need to do.
it is going to be in opensource project so. do you have an idea for more secure? I saw in mambo use defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); Code (markup): Do you know how does it work?
oh I on the file will have this line, but still thinking about what to check //check direct access if ($something to check not correct) { echo "This file can't access directly"; exit; } Code (markup):