Here's an odd one:
I have recently added a simple authentication script to several of my web pages:
<?
// Header 401 Sender
function theGuard() {
header('WWW-Authenticate: Basic realm="Secure Area"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
// Check to see if $PHP_AUTH_USER has a value
if (!isset($PHP_AUTH_USER)) {
// If no value send header 401 Unauthorized
theGuard();
} else if (isset($PHP_AUTH_USER)) {
// If it has a value
$pwFile = "/opt/apache/htdocs/support/inc/auth.txt";
$fp = fopen($pwFile, "r");
$fileContents = fread($fp, filesize($pwFile));
fclose($fp);
// Put each line into an array
$line = explode("\n", $fileContents);
// As long as $i is less than or equal to the size of $line
// seperate each array element into a key/value pair
$i = 0;
while($i <= sizeof($line)) {
$dataPair = explode(":", $line[$i]);
if (($dataPair[0] == "$PHP_AUTH_USER") && ($dataPair[1] == "$PHP_AUTH_PW")) {
$auth = 1;
break;
} else {
$auth = 0;
}
$i++;
}
if ($auth !="1") {
theGuard();
}
}
?>
<HEAD>
.....etc
The problem is, the dialog box pops-up as expected, but after entering the username and password, the box reappears after a few seconds regardless of whether or nor you enter the correct information.
Thanks in advance.