+ function logclient()
+ {
+ if ($log = @fopen("{$this->dir}/last.log", 'w')) {
+ $line = $_SERVER['REMOTE_ADDR'].' '.$_SERVER['HTTP_USER_AGENT'];
+ fwrite($log, $line."\n");
+ }
+ }
+}
+
+function login_password_verify($input, $test)
+{
+ if (substr($test, 0, 1) != '$') {
+ # plaintext match for uncrypted passwords
+ return $input === $test;
+ }
+ return password_verify($input, $test);
+}
+
+function login_setcookie()
+{
+ global $User;
+ return setcookie('login', $User->auth, 0, '/');
+}
+
+function login($inuser, $inpass = NULL)
+{
+ if (empty($inuser)) return;
+ if (!isset($inpass)) {
+ @list ($inuser, $inauth) = explode(':', $inuser, 2);
+ }
+
+ # find password data by user name
+ $userdir = 'profile/'.preg_replace('/[^a-z0-9]+/', '-', strtolower($inuser));
+ $pwfile = "$userdir/.passwd";
+ if (!file_exists($pwfile)) return;
+ $usertest = trim(file_get_contents($pwfile));