2 $expectedUsername = isset($_GET['username']) ?
$_GET['username'] : 'username';
3 $expectedPassword = isset($_GET['password']) ?
$_GET['password'] : 'password';
4 $realm = isset($_GET['realm']) ?
$_GET['realm'] : $_SERVER['REQUEST_URI'];
6 header("Cache-Control: no-store");
7 header("Connection: close");
8 if (!isset($_SERVER['PHP_AUTH_USER']) ||
$_SERVER['PHP_AUTH_USER'] != $expectedUsername ||
9 !isset($_SERVER['PHP_AUTH_PW']) ||
$_SERVER['PHP_AUTH_PW'] != $expectedPassword) {
10 header("WWW-Authenticate: Basic realm=\"" . $realm . "\"");
11 header('HTTP/1.0 401 Unauthorized');
12 print 'Sent username:password of (' . $_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW'] . ') which is not what was expected';
16 Authenticated
as user
: <?php
print (string)$_SERVER['PHP_AUTH_USER']?
> password
: <?php
print (string)$_SERVER['PHP_AUTH_PW']?
>