Kent. Guest
|
Posted: Sat Jan 25, 2003 6:07 am Post subject: PHP auth user script |
|
|
This is a nice php script for those of you that are having trouble setting up your server settings on user and group authentications.....
Its pretty simple cut and paste, alter the refresh meta tag to where you want the user sent to... and alter the username and password section where it says 'change' put your new login info there. ;) enjoy the script. Please remember though it does not block people from bookmarking the page they are sent to 'YET'....Im working on a solution.
<?php
// File Name: auth.php // Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="Secured Login"');
header('HTTP/1.0 401 Unauthorized');
echo 'Bad Authorization Proper username & password are Required.'; exit;
} else if (isset($PHP_AUTH_USER)) {
if (($PHP_AUTH_USER != "change") || ($PHP_AUTH_PW != "change")) {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.'; exit;
}
else
{
echo " <P><META http-equiv='refresh' content='1;URL=http://your.com/page u want to protect'>
</p> ";
}
}
?> |
|