function write($user, $key, $value) { if (!$key && !$value) { $map = new MapFile(); return $map->write($GLOBALS['pie']['run_path'] . "/user/pref.map", $user, ''); } // Read and update the cache. $this->cache = array(); $this->user = $user; $this->read($user, $key); $this->cache[$key] = $value; if (!@$this->cache['stamp']) { $this->cache['stamp'] = time(); } $data = ""; ksort($this->cache); foreach ($this->cache as $k => $v) { $v = str_replace("|", "/", $v); $data .= "|{$k}={$v}"; } $data = substr($data, 1); $map = new MapFile(); return $map->write($GLOBALS['pie']['run_path'] . "/user/pref.map", $user, $data); }
if ($pw != crypt($_REQUEST['password'], $salt)) { // The entered password is just wrong. pieLog("error"); pieHead("browse"); pieError("FailureForm"); } // Update user record with new style password. $user->write($_REQUEST['username'], $user->encrypt($_REQUEST['password'])); } // The login succeeded. $session = new Session(); if (!$session->start()) { pieHead("browse"); pieError("SessionError"); } $_SESSION['user'] = $_REQUEST['username']; $map = new MapFile(); $lastlogin = $map->read($GLOBALS['pie']['run_path'] . '/user/login.map', $_REQUEST['username']); $map->write($GLOBALS['pie']['run_path'] . '/user/login.map', $_REQUEST['username'], time()); pieLog("user"); pieHead("browse"); if (!$_REQUEST['todo']) { $_REQUEST['todo'] = 'page'; $_REQUEST['page'] = $GLOBALS['pie']['default_page']; } pieError("SuccessForm", array('lastlogin' => date($GLOBALS['pie']['time_format'], $lastlogin))); } else { // Print the login form. pieHead("browse"); pieError("LoginForm"); }
function write($user, $password) { $map = new MapFile(); return $map->write($this->root . '/password.map', $user, $password); }