/** * Sets the global board last visit timestamp. */ public function setLastVisitTime($timestamp) { $this->lastVisitTime = $timestamp; // cookie HeaderUtil::setCookie('boardLastVisitTime', $this->lastVisitTime, TIME_NOW + 365 * 24 * 3600); // session SessionFactory::getActiveSession()->register('boardLastVisitTime', $this->lastVisitTime); }
/** * @see LogoutAction::doLogout() */ protected function doLogout() { parent::doLogout(); // remove cookies if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) { HeaderUtil::setCookie('userID', 0); } if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) { HeaderUtil::setCookie('password', ''); } }
/** * Examines whether cookies are enabled. */ protected function handleCookie() { if (isset($_COOKIE[COOKIE_PREFIX . 'cookieHash'])) { if ($_COOKIE[COOKIE_PREFIX . 'cookieHash'] != $this->sessionID) { $this->useCookies = false; } } else { $this->useCookies = false; } if (!$this->useCookies) { HeaderUtil::setCookie('cookieHash', $this->sessionID); } }
/** * @see UserAuth::loginAutomatically() */ public function loginAutomatically($persistent = false, $userClassname = 'UserSession') { if (!$persistent) { return null; } $user = null; if (isset($_COOKIE[COOKIE_PREFIX . 'userID']) && isset($_COOKIE[COOKIE_PREFIX . 'password'])) { if (!($user = $this->getUserAutomatically(intval($_COOKIE[COOKIE_PREFIX . 'userID']), $_COOKIE[COOKIE_PREFIX . 'password'], $userClassname))) { $user = null; // reset cookie HeaderUtil::setCookie('userID', ''); HeaderUtil::setCookie('password', ''); } } return $user; }
/** * Initialises the session. */ public function init() { parent::init(); // handle style id if ($this->user->userID) { $this->styleID = $this->user->styleID; } if (($styleID = $this->getVar('styleID')) !== null) { $this->styleID = $styleID; } if ($this->userID) { // user // update board / thread visits if ($this->user->boardLastActivityTime > $this->user->boardLastVisitTime && $this->user->boardLastActivityTime < TIME_NOW - SESSION_TIMEOUT) { $this->user->setLastVisitTime($this->user->boardLastActivityTime); // remove unnecessary board and thread visits $sql = "DELETE FROM\twbb" . WBB_N . "_thread_visit\n\t\t\t\t\tWHERE\t\tuserID = " . $this->userID . "\n\t\t\t\t\t\t\tAND lastVisitTime <= " . $this->user->boardLastMarkAllAsReadTime; WCF::getDB()->registerShutdownUpdate($sql); $sql = "DELETE FROM\twbb" . WBB_N . "_board_visit\n\t\t\t\t\tWHERE\t\tuserID = " . $this->userID . "\n\t\t\t\t\t\t\tAND lastVisitTime <= " . $this->user->boardLastMarkAllAsReadTime; WCF::getDB()->registerShutdownUpdate($sql); // reset user data $this->resetUserData(); } // update global last activity time if ($this->lastActivityTime < TIME_NOW - USER_ONLINE_TIMEOUT + 299) { WBBUserSession::updateLastActivityTime($this->userID); } } else { // guest $boardLastActivityTime = 0; $boardLastVisitTime = $this->user->getLastVisitTime(); if (isset($_COOKIE[COOKIE_PREFIX . 'boardLastActivityTime'])) { $boardLastActivityTime = intval($_COOKIE[COOKIE_PREFIX . 'boardLastActivityTime']); } if ($boardLastActivityTime != 0 && $boardLastActivityTime < $boardLastVisitTime && $boardLastActivityTime < TIME_NOW - SESSION_TIMEOUT) { $this->user->setLastVisitTime($boardLastActivityTime); $this->resetUserData(); } HeaderUtil::setCookie('boardLastActivityTime', TIME_NOW, TIME_NOW + 365 * 24 * 3600); } }
/** * @see Form::save() */ public function save() { parent::save(); // get user editor $editor = WCF::getUser()->getEditor(); $success = array(); // quit if (WCF::getUser()->getPermission('user.profile.canQuit')) { if (!WCF::getUser()->quitStarted && $this->quit == 1) { $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->sendQuery($sql); $this->quitStarted = TIME_NOW; $success[] = 'wcf.user.quit.success'; } else { if (WCF::getUser()->quitStarted && $this->cancelQuit == 1) { $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = 0\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->sendQuery($sql); $this->quitStarted = 0; $success[] = 'wcf.user.quit.cancel.success'; } } } // username if ($this->canChangeUsername && $this->username != WCF::getUser()->username) { $fields = array(); if (StringUtil::toLowerCase($this->username) != StringUtil::toLowerCase(WCF::getUser()->username)) { if (!$this->canChangeUsername) { $this->username = WCF::getUser()->username; return; } $fields = array('lastUsernameChange' => TIME_NOW, 'oldUsername' => $editor->username); } $editor->update($this->username, '', '', null, null, $fields); $success[] = 'wcf.user.rename.success'; } // email if (WCF::getUser()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) { if (REGISTER_ACTIVATION_METHOD == 0 || REGISTER_ACTIVATION_METHOD == 2 || StringUtil::toLowerCase($this->email) == StringUtil::toLowerCase(WCF::getUser()->email)) { // update email $editor->update('', $this->email); $success[] = 'wcf.user.emailChange.success'; } else { if (REGISTER_ACTIVATION_METHOD == 1) { // get reactivation code $activationCode = UserRegistrationUtil::getActivationCode(); // save as new email $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\treactivationCode = " . $activationCode . ",\n\t\t\t\t\t\tnewEmail = '" . escapeString($this->email) . "'\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->registerShutdownUpdate($sql); $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE)); $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => WCF::getUser()->username, '$userID' => WCF::getUser()->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail', $messageData)); $mail->send(); $success[] = 'wcf.user.emailChange.needReactivation'; } } } // password if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) { $editor->update('', '', $this->newPassword); // update cookie if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) { HeaderUtil::setCookie('password', StringUtil::getSaltedHash($this->newPassword, $editor->salt), TIME_NOW + 365 * 24 * 3600); } $success[] = 'wcf.user.passwordChange.success'; } // reset session WCF::getSession()->resetUserData(); $this->saved(); // show success message WCF::getTPL()->assign('success', $success); // reset password $this->password = ''; $this->newPassword = $this->confirmNewPassword = ''; }
public static function logout($newSite = false) { global $game_config; require_once WCF_DIR . 'lib/system/session/UserSession.class.php'; WCF::getSession()->changeUser(new UserSession()); // remove cookies if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) { HeaderUtil::setCookie('userID', 0); } if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) { HeaderUtil::setCookie('password', ''); } setcookie($game_config['COOKIE_NAME'], "", time() - 100000, "/", "", 0); if ($newSite === false) { return; } echo '<html> <head> <script language="JavaScript" > top.location.href = \'' . $newSite . '?time=' . TIME_NOW . '\'; </script> </head> <body> <center> <a href="javascript:top.location.href=\'' . $newSite . '?time=' . TIME_NOW . '\'"> Du wurdest ausgeloggt. Hier klicken, um wieder auf die Startseite zu kommen. </a> </center> </body> </html>'; exit; }