note 93255 added to features.http-auth
| From: | s dot i dot g at gmx dot com | Date: | Sun, 30 Aug 2009 23:49:33 +0000 |
| Subject: | note 93255 added to features.http-auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160067@lists.php.net to get a copy of this message | ||
<?php
// try to mimic cpanel logout style
// only diff is usr & pwd field is cleared when re-login
// tested with ff2 & ie8
session_start();
$username = "test";
$password = "test";
if(isset($_GET['logout']))
{
unset($_SESSION["login"]);
echo "You have logout ... ";
echo "[<a href='" . $_SERVER['PHP_SELF'] .
"'>Login</a>]";
exit;
}
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
!isset($_SESSION["login"]))
{
header("WWW-Authenticate: Basic realm=\"Test\"");
header("HTTP/1.0 401 Unauthorized");
$_SESSION["login"] = true;
echo "You are unauthorized ... ";
echo "[<a href='" . $_SERVER['PHP_SELF'] .
"'>Login</a>]";
exit;
}
else
{
if($_SERVER['PHP_AUTH_USER'] == $username && $_SERVER['PHP_AUTH_PW']
== $password)
{
echo "You have logged in ... ";
echo "[<a href='" . $_SERVER['PHP_SELF'] .
"?logout'>Logout</a>]";
}
else
{
unset($_SESSION["login"]);
header("Location: " . $_SERVER['PHP_SELF']);
}
}
// content here
?>
----
Server IP: 209.41.74.194
Probable Submitter: 115.134.184.134
----
Manual Page -- http://www.php.net/manual/en/features.http-auth.php
Edit -- https://master.php.net/note/edit/93255
Del: integrated -- https://master.php.net/note/delete/93255/integrated
Del: useless -- https://master.php.net/note/delete/93255/useless
Del: bad code -- https://master.php.net/note/delete/93255/bad+code
Del: spam -- https://master.php.net/note/delete/93255/spam
Del: non-english -- https://master.php.net/note/delete/93255/non-english
Del: in docs -- https://master.php.net/note/delete/93255/in+docs
Del: other reasons-- https://master.php.net/note/delete/93255
Reject -- https://master.php.net/note/reject/93255
Search -- https://master.php.net/manage/user-notes.php