Пример #1
0
/**
 * Forward to login page.
 *
 * @param string $errorid	Error id to output
 *
 * @return void
 */
function forwardToLogin($errorid)
{
    if (LOGIN_REQUIRED) {
        $login = BASE_URL . "?error=" . $errorid;
        Hook::event("ForwardToLoginPage", array(&$login, $errorid));
        doHeaderRedirection($login, false);
    }
    Logger::addMessage($errorid);
    Core::getTPL()->display("login");
    return;
}
Пример #2
0
 /**
  * Start a new session and destroy old sessions.
  *
  * @return Login
  */
 public function startSession()
 {
     if (!$this->dataChecked) {
         $this->checkData();
     }
     // Disables old sessions.
     if ($this->cacheActive) {
         Core::getCache()->cleanUserCache($this->userid);
     }
     Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
     // Start new session.
     $sessionSeed = Str::encode((string) microtime(1));
     $this->sid = Str::substring($sessionSeed, 0, $this->getSessionLength());
     unset($sessionSeed);
     $spec = array("sessionid" => $this->sid, "userid" => $this->userid, "ipaddress" => IPADDRESS, "useragent" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "time" => TIME, "logged" => 1);
     Core::getQuery()->insert("sessions", $spec);
     if ($this->canLogin) {
         if (COOKIE_SESSION) {
             Core::getRequest()->setCookie("sid", $this->sid, $this->getCookieExpire());
             $this->sessionUrl = $this->redirection;
         } else {
             if (Str::inString("?", $this->redirection)) {
                 $this->sessionUrl = $this->redirection . "&sid=" . $this->sid . "&login=true";
             } else {
                 $this->sessionUrl = $this->redirection . "?sid=" . $this->sid . "&login=true";
             }
         }
         if ($this->cacheActive) {
             Core::getCache()->buildUserCache($this->sid);
         }
         Hook::event("StartSession", array($this, $this->sessionUrl));
         if ($this->redirectOnSuccess) {
             doHeaderRedirection($this->sessionUrl, true);
         }
     } else {
         $this->loginFailed("CANNOT_LOGIN");
     }
     return $this;
 }