note 61720 added to function.include
| From: | zaphod at StripspaMgresak dot net | Date: | Fri, 10 Feb 2006 09:48:59 +0000 |
| Subject: | note 61720 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103421@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 193.77.159.244
Probable Submitter: 193.77.114.1
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61720
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61720&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61720&report=yes
Search -- http://master.php.net/manage/user-notes.php