Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $auth = false; // Assume user is not authenticated
- if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
- $filename = 'passfile.txt';
- $file_contents = file($filename);
- foreach ($file_contents as $line) {
- list($username, $password) = explode(':', $line);
- $username = trim($username);
- $password = trim($password);
- if (($username == "$PHP_AUTH_USER") && ($password == "$PHP_AUTH_PW")) {
- $auth = true;
- break;
- }
- }
- }
- if (!$auth) {
- header('WWW-Authenticate: Basic realm="Calendar"');
- header('HTTP/1.0 401 Unauthorized');
- die('<p> </p><p><center><h1><font color ="red">Authorization Required.</h1><br>Please close this window to try again.</center></font></P>');
- } else {
- // do something
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement