Hey guys!
Okay so at the moment I'm half way through working on a huge web script, and I have files that are included in certain pages.
But I don't want these pages to be accessed individually, as they just display an error anyway.
So how would I create a script that displayed an error message if say getposts.php was accessed?
Protecting PHP Files!
Started by Bioshox, Mar 06 2010 02:09 PM
3 replies to this topic
#1
Posted 06 March 2010 - 02:09 PM
|
|
|
#2
Posted 06 March 2010 - 03:06 PM
You could set a variable in index.php and check it with each page as the first step.
#3
Posted 06 March 2010 - 03:20 PM
Okay, so could I create a file named protect.php and within that have the code
And then another file named protectmsg.php with the code
and if I don't want the file public accessible just include protectmsg.php and if I do want the script to be ran include protect.php?
<?php
define('protect', 1);
?>
And then another file named protectmsg.php with the code
<?php
if(!defined('protect')){
echo 'Denied.';
die;
}
?>
and if I don't want the file public accessible just include protectmsg.php and if I do want the script to be ran include protect.php?
#4
Guest_Jaan_*
Posted 06 March 2010 - 03:57 PM
Guest_Jaan_*
Yea.. here I made a little tutorial months ago that explains Bioshox's method :
Protect Php Files - Trill Designs
Protect Php Files - Trill Designs


Sign In
Create Account


Back to top









