Does a php include() 'know' its requester? -


is possible put code @ top of php included file prevent being included in directory below level in directory tree? considering following directory structure:

|--myapp    |--includes       |include-this-in-my-app-only.php    |--index-for-my-app.php    |--contact-for-my-app.php    |--tenant-1-directory       |--index-for-tenant-1.php       |--contact-for-tenant-1.php    |--tenant-2-directory       |--index-for-tenant-2.php       |--contact-for-tenant-2.php    |--tenant-3-directory       |--index-for-tenant-3.php       |--contact-for-tenant-3.php 

can add @ top of include file forbids being included if being requested directory below own? or there approach? using vps.

you can define global constant in code , in included file check if set false or undefined die(); block direct access file this:

define('direct', false); 

in file block access to:

if(!direct || !defined('direct')){ die('direct access not allowed'); } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -