Jump to content

Making some files access denied if there accessed directly?


Demonic

Recommended Posts

I believe you are looking for .htaccess and "hot linking" - you can google that.

if this is not what you are looking for, you may be looking for something related to permissins which you need to talk to your hosting company to see how your server is set up - probably not the best.

The last option is to store the files our site of the web root.
There are ways but it really depends how your doing things. For instance, in every page of my applications I firstly invoke my config.inc.php file. Within this file I define the constant HASCONFIG to true. Then, in any other included file (say db.lib.php) I check for this constant. eg;

[code=php:0]
if (!HASCONFIG) {
  echo "This file is unable to be called directly";
  exit();
}
[/code]

This meens that trying to browse to db.lib.php will get you the above error. However, in my pages I can use it as long as I include it after my config.inc.php. eg;

index.php
[code=php:0]
<?php
  require_once "config.inc.php";
  require_once "db.lib.php";
  // rest of code.
?>
[/code]

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.