Jump to content

[SOLVED] If not included "oh heck no!"


robindean

Recommended Posts

Two ways I used in the past:

 

1) If it's not a php file, place the file in a directory that has a .htaccess that contains the line:

Deny from all

 

2) Do it this way (this is for including php files):

<?php
//this is includer.php -> The file that includes the other file

$include = 1;
include("included-file.php");
?>

<?php
//this is included-file.php -> The file being included

if(!isset($include)) die("No direct access!");
else
{
//...
}

?>

 

 

Orio.

You can do a variable check and just make sure that the variable is what was intended IE:

 

file to be included
<?php
if (isset($_POST['varCheck']) || isset($_GET['varCheck'])) {
    die('You should not be here'); // prevent people from hacking their way in via post and get.
}elseif ($varCheck == "someString") {
   print "display this data.";
}else {
   die('you should not be here');
}

?>

 

file that includes the file
<?php
$varCheck = "someString";
include('fileinclude.php');
?>

 

--FrosT

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.