4 call_user_func(function () {
5 if (isset($_SERVER['PHP_AUTH_USER'])) {
6 $authinfo = [ $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] ];
8 elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
10 $authinfo = explode(':' , base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)));
16 $pwdata = file_get_contents(__DIR__.'/.htpasswd');
18 foreach (explode("\n", $pwdata) as $line) {
20 list ($username, $pass) = explode(':', $line);
21 $pwlist[$username] = $pass;
24 list ($authname, $authpass) = $authinfo;
25 $usertest = $pwlist[ strtolower($authname) ];
26 if (!$usertest) return;
28 $salt = substr($usertest, 0, 2);
29 if (crypt($authpass, $salt) != $usertest) return;
33 $Admin = !empty($User) && $User != 'lid' ? $User : FALSE;