From: Mischa POSLAWSKY Date: Mon, 2 Oct 2017 20:24:53 +0000 (+0200) Subject: login: store passwords in separate user files X-Git-Tag: v2.3~2 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/9728cd7e14c36120d5446823ae100cc80512c079 login: store passwords in separate user files Instead of unneeded .htpasswd compatibility, move password hashes into simple login/$username/.passwd files. --- diff --git a/auth.inc.php b/auth.inc.php index 363fc71..e849da9 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -6,17 +6,10 @@ function login($inuser, $inpass = NULL) @list ($inuser, $inauth) = explode(':', $inuser, 2); } - # create pwlist table from htpasswd - $pwdata = file_get_contents('./.htpasswd'); - $pwlist = []; - foreach (explode("\n", $pwdata) as $line) { - if (!$line) continue; - list ($username, $pass) = explode(':', $line); - $pwlist[$username] = $pass; - } - - # find user by name - $usertest = @$pwlist[ strtolower($inuser) ]; + # find password data by user name + $pwfile = sprintf('login/%s/.passwd', strtolower($inuser)); + if (!file_exists($pwfile)) return; + $usertest = trim(file_get_contents($pwfile)); if (!$usertest) return; # verify password