View Full Version : The best idea of denied access file directly?
tonyinabox
Oct 13th 2006, 1:03 am
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.
:)
mad4
Oct 13th 2006, 1:07 am
You could do something like this:
<?php
$green="yes";
include('yourfile.php');
?>
and in the file yourfile.php have:
if($green!="yes"){
exit();
}
else
{
//do something
}
There may be a better/more secure solution depending what you need to do.
tonyinabox
Oct 13th 2006, 1:22 am
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.' );
Do you know how does it work?
tonyinabox
Oct 13th 2006, 1:26 am
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;
}
tonyinabox
Oct 13th 2006, 5:07 am
ok I know now. hehehe.. very same as the code you gave above. :p
thank you.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.