login: store passwords in separate user files
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 2 Oct 2017 20:24:53 +0000 (22:24 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 2 Oct 2017 20:50:31 +0000 (22:50 +0200)
Instead of unneeded .htpasswd compatibility, move password hashes into
simple login/$username/.passwd files.

auth.inc.php

index 363fc71538b0527be14ac901fe3fb9c99692c604..e849da9b997957c7fc81a2cfb2266f86baeb2230 100644 (file)
@@ -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