Hi all,
This is a simply code to protect folders script and/or files whithout htaccess.
Some hosts aren't configured to accept htaccess file.
To protect folder, try this code and rename file "relogin.php" and upload into the folder.
don't forget to change login and pass ;)
sorry for my english and sorry if this post already exist :)
This is a simply code to protect folders script and/or files whithout htaccess.
Some hosts aren't configured to accept htaccess file.
To protect folder, try this code and rename file "relogin.php" and upload into the folder.
<?
// Login and the password to access:
$name = "login"; // Login
$pass = "pass"; // Password
// $auth = 1; Definition of authenticity is included
// $auth = 0; Definition of authenticity is switched off
$auth = 1;
if($auth == 1) {
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!==$name || $_SERVER['PHP_AUTH_PW']!==$pass)
{
header('WWW-Authenticate: Basic realm="Protect"');
header('HTTP/1.0 401 Unauthorized');
exit("<b>Access Denied</b>");
}
}
?>and add this at the start of your index file just after "<?"require_once("relogin.php");
for example, if you want to protect admincp.php file just copy this code and add to the start of your admincp file just after "<?"
// Login and the password to access:
$name = "login"; // Login
$pass = "pass"; // Password
// $auth = 1; Definition of authenticity is included
// $auth = 0; Definition of authenticity is switched off
$auth = 1;
if($auth == 1) {
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!==$name || $_SERVER['PHP_AUTH_PW']!==$pass)
{
header('WWW-Authenticate: Basic realm="AdminCP-Protect"');
header('HTTP/1.0 401 Unauthorized');
exit("<b>Access Denied</b>");
}
}don't forget to change login and pass ;)
sorry for my english and sorry if this post already exist :)