Example from some website.
Why would I get an error:
Parse error: parse error in /home/sites/site19/web/auth03.php on line 61
There is only 60 lines in this file, hmmm!
<?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="AMBL Login"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {
// If non-empty, open file containing valid user info
// YES THIS FILE DOES EXIST AND IS IN THE SAME DIRECTORY
// contents:
/
admin:lucky
user:notgood
/
$filename = "auth.dat";
$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="AMBL Login"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
?>