Jump to content

Security Help


Archadian

Recommended Posts

a simple but very brutish way to do this is to check for a defined var.  for example:

 

<?php
$included = TRUE;
include("file.php");
?>

 

and in file.php, do:

 

<?php
if ($included !== TRUE)
{
  exit;
}
?>

 

this will ensure that the file exist unless $included (which can be anything you name it) is defined.  as i said, this is a very inelegant solution - for a more fundamental solution, a cursory glance at the $_SERVER predefined vars may help.  i vaguely recall one of them telling you the actual script in which the current file is running (which will tell you whether another script is calling the page or whether it's being executed directly).

Link to comment
Share on other sites

i figured it out :) for anyone that would like to know for future reference here it is:

 

put this at the top of your index page between <?php ?>:

 


define('SOMETHING_HERE', true);

 

then on any of your scripts that you only want your server to use it put this:

 


if (!defined('SOMETHING_HERE')) {	

die('Restricted!');

}
else {

// your code here


}

 

This works even if they visit your index.php. Thanks everyone for the help :)

Link to comment
Share on other sites

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.