note 36319 added to function.require
| From: | LOSTTWARE dot com at rn2 dot php dot net | Date: | Sun, 05 Oct 2003 07:01:52 +0000 |
| Subject: | note 36319 added to function.require | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57827@lists.php.net to get a copy of this message | ||
I've noticed allot of these posts are trying to make one file as the viewer file, and another
as a file that can be used by the first, but not accessed directly by the user. Here is a very easy
way of doing that.
Your first file, the one users may access:
test.php
<?php
function DoShow()
{
global $File;
$File = 'hidden.php';
$includedfile = true; // sets a variable for the other file
include($File);}
DoShow();
?>
Now you make your other php file, the one that you do not want users to be able to view directly.
hidden.php
<?php
if ($includedfile == false) { //checks to see if this file is being opened by itself
echo "Bad"; // if the file is opened by itself, the outbut is put here, I have
"Bad"
exit; // stops the php file there, your total output in a browser will be what you have in the echo
above, you may add more there if you would like.
}
else {
echo "Showing Files"; } ?> // Replace shoing files with whatever you want, even a
blank space
HTML HERE // now you can go about with HTML or php code, and you viewer will see it.
----
Manual Page -- http://www.php.net/manual/en/function.require.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36319
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36319&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36319&report=yes
Search Tool -- http://master.php.net/manage/user-notes.php