'.$string.'

'; } if(isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW)) { // Read the entire file into the variable $file_contents $filename = $opts['log']['users']; // $filename = '/path/to/file.txt'; if($fp = fopen($filename, 'r')){ $file_contents = fread($fp, filesize($filename)); fclose($fp); // Explode: Unix \n and Windows \r\n $lines = explode("\r\n", $file_contents ); // Place the individual lines from the file contents into an array. // Split each of the lines into a username and a password pair and attempt to match them to $PHP_AUTH_USER and $PHP_AUTH_PW. foreach($lines as $line) { @list($username, $password) = explode(':', $line); if(($username == "$PHP_AUTH_USER") && ($password == "$PHP_AUTH_PW")) { $auth = true; // A match is found, meaning the user is authenticated. break; // Stop the search. } } }else{ header('WWW-Authenticate: Basic realm="Private"'); header('HTTP/1.0 401 Unauthorized'); echo_html('User List Unavailable'); exit; } }; if(!$auth) { header('WWW-Authenticate: Basic realm="Private"'); header('HTTP/1.0 401 Unauthorized'); echo_html('Authentication Required'); exit; }else{ // echo $PHP_AUTH_USER; } ?>