note 61720 deleted from function.include by aidan

From: Date: Sat, 15 Apr 2006 16:23:12 +0000
Subject: note 61720 deleted from function.include by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108145@lists.php.net to get a copy of this message
Note Submitter: zaphod at StripspaM gresak dot net ---- A basic and simple feature to make sure a script is available only for inclusion and can not be accessed directly via url. Include this snippet before the beginning of the script on the top of your page: <? if (basename($_SERVER['PHP_SELF']) == basename ( __FILE__ ) ) { $home = 'http://' . $_SERVER['SERVER_NAME'] . '/'; header ("Location: $home"); die(); } ?> Instead of redirecting to homepage you could of course do anything else like send a 404 or 403 header.

« previous php.notes (#108145) next »