- $pwdata = file_get_contents(__DIR__.'/.htpasswd');
- $pwlist = [];
- foreach (explode("\n", $pwdata) as $line) {
- if (!$line) continue;
- list ($username, $pass) = explode(':', $line);
- $pwlist[$username] = $pass;
- }
-
- list ($authname, $authpass) = $authinfo;
- $usertest = $pwlist[ strtolower($authname) ];
- if (!$usertest) return;
-
- $salt = substr($usertest, 0, 2);
- if (crypt($authpass, $salt) != $usertest) return;
+ return [
+ 'name' => $inuser,
+ 'admin' => !empty($inuser) && strtolower($inuser) != 'lid',
+ 'auth' => "$inuser:$authhash",
+ ];
+}