Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.