note 36319 deleted from function.require by sniper

From: Date: Tue, 04 Nov 2003 00:44:43 +0000
Subject: note 36319 deleted from function.require by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59818@lists.php.net to get a copy of this message
Note Submitter: LOSTTWARE.com ---- 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.

« previous php.notes (#59818) next »