(не тестировалось)
session_start();
error_reporting(2047);
$user = '112';
$pass = 'test';
$authorized = false;
if(isset($_GET['logout']) && (0!=$_SESSION['user_id'])) {
$_SESSION['auth'] = false;
unset($_SESSION['user_id']);
header("Location: ./googby.html");
// session_destroy();
echo "logging out...";
}
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
if (($user == $_SERVER['PHP_AUTH_USER']) && ($pass == ($_SERVER['PHP_AUTH_PW'])) && $_SESSION['auth']) {
$authorized = true;
$_SESSION['user_id']=intval($_SERVER['PHP_AUTH_USER']);
}
}
if ((! $authorized)) {
header('WWW-Authenticate: Basic Realm="Login please"');
header('HTTP/1.0 401 Unauthorized');
$_SESSION['auth'] = true;
print('Login now or forever hold your clicks...');
// header("Location: ./access_denied.html");
exit;
}
?>
?logout">exit
Комментариев нет:
Отправить комментарий