help!
| From: | TheDngo | Date: | Thu, 24 Aug 2000 16:49:30 +0000 |
| Subject: | help! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13407@lists.php.net to get a copy of this message | ||
I have a script that goes like this:
<?php
// File Name: login.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="Saint Johns Church Intranet"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {
// If non-empty, open file containing valid user info
$filename = "authuser.txt";
$fp = fopen($filename, "r");
$file_contents = fread($fp, filesize($filename));
fclose($fp);
// Place each line in user info file into an array
$line = explode("\n", $file_contents);
// For as long as $i is <= the size of the $line array,
// explode each array element into a username and password pair
$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="Saint Johns Church Intranet"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
?>
I'm getting a "parse error" on the last line, the closing tag. What's
wrong?