PHP 4.0 Bug #5622: Access Violation when using HTTP Authentication
| From: | david at interpont dot hu | Date: | Sun, 16 Jul 2000 12:32:35 +0000 |
| Subject: | PHP 4.0 Bug #5622: Access Violation when using HTTP Authentication | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-24652@lists.php.net to get a copy of this message | ||
From: david@interpont.hu
Operating system: NT4 SP6, IIS 4
PHP version: 4.0.1pl2
PHP Bug Type: Reproduceable crash
Bug description: Access Violation when using HTTP Authentication
Hi!
My problem is that when I use HTTP Authentication, PHP displays an Access Violation. After this the
computer slows down and IIS stops working.
When I use the script above, first the browser (both IE5.01 and NS4.7) displays the name/pass login
window correctly but if I hit the Cancel button, then a PHP Access Violation message comes.
I have installed PHP and IIS as described in the manuals. Everything else seems to be fine.
Please tell me the solution and tell me if you have the same problem or works fine for you.
Please drop me an e-mail in case of reply as I can't check this page frequently! Thanks!
Regards,
David Szilagyi
The script:
<?
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="test"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required. - I';
exit;
} else {
$filename = "./users.txt";
$fp = fopen($filename, "r");
$file_contents = fread($fp, filesize($filename));
fclose($fp);
$line = explode("\n", $file_contents);
$i = 0;
while($i <= sizeof($line)) {
$data_pair = explode(":", $line[$i]);
if (($data_pair[0] == "$PHP_AUTH_USER") && ($data_pair[1] ==
"$PHP_AUTH_PW")) {
$auth = 1;
break;
} else {
$auth = 0;
}
$i++;
}
if ($auth == "1") {
echo "<P>You're authorized!</p>";
exit;
} else {
header('WWW-Authenticate: Basic realm="test"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required. - II';
exit;
}
}
?>