2 global $User, $editable;
6 if (isset($_SERVER['PHP_AUTH_USER'])) {
7 $authinfo = [ $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] ];
9 elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
11 $authinfo = explode(':' , base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)));
17 $pwdata = file_get_contents(__DIR__.'/.htpasswd');
19 foreach (explode("\n", $pwdata) as $line) {
21 list ($username, $pass) = explode(':', $line);
22 $pwlist[$username] = $pass;
25 list ($authname, $authpass) = $authinfo;
26 $usertest = $pwlist[ strtolower($authname) ];
27 if (!$usertest) return;
29 $salt = substr($usertest, 0, 2);
30 if (crypt($authpass, $salt) != $usertest) return;
32 $GLOBALS['User'] = $authname;
37 $editable = !empty($User) && $User != 'lid';