admin: disallow access to unauthorised visitors
[minimedit.git] / auth.inc.php
index b20331ac60ceb15d2f785d0301881e3f1f31b3ce..94f0dcc8547f190d5758e7fdad1881a56ce72717 100644 (file)
@@ -16,7 +16,12 @@ function login($inuser, $inpass = NULL)
        # verify password
        $authhash = md5($usertest);
        if (isset($inpass)) {
-               if (!password_verify($inpass, $usertest)) return;
+               if (substr($usertest, 0, 1) == '$') {
+                       if (!password_verify($inpass, $usertest)) return;
+               }
+               else {
+                       if ($inpass !== $usertest) return;
+               }
        }
        else {
                if ($inauth !== $authhash) return;
@@ -24,6 +29,10 @@ function login($inuser, $inpass = NULL)
 
        if (function_exists('apache_note')) apache_note('user', $inuser);
 
+       if ($log = @fopen("$userdir/last.log", 'w')) {
+               fwrite($log, "{$_SERVER['REMOTE_ADDR']} {$_SERVER['HTTP_USER_AGENT']}\n");
+       }
+
        return [
                'name'  => $inuser,
                'admin' => file_exists("$userdir/.admin"),