コード例 #1
0
 /**
  * Updates the user session.
  */
 public function update()
 {
     // update global last activity timestamp
     WBBUserSession::updateLastActivityTime($this->userID);
     if (!$this->wbbUserID) {
         // define default values
         $this->data['boardLastVisitTime'] = TIME_NOW;
         $this->data['boardLastActivityTime'] = TIME_NOW;
         $this->data['boardLastMarkAllAsReadTime'] = TIME_NOW - VISIT_TIME_FRAME;
         // create wbb user record
         $sql = "INSERT IGNORE INTO\twbb" . WBB_N . "_user\n\t\t\t\t\t\t\t(userID, boardLastVisitTime, boardLastActivityTime, boardLastMarkAllAsReadTime)\n\t\t\t\tVALUES\t\t\t(" . $this->userID . ", " . $this->boardLastVisitTime . ", " . $this->boardLastActivityTime . ", " . $this->boardLastMarkAllAsReadTime . ")";
         WCF::getDB()->registerShutdownUpdate($sql);
     } else {
         WBBUserSession::updateBoardLastActivityTime($this->userID);
     }
     $this->getClosedCategories();
     $this->getIgnoredBoards();
     $this->getBoardSubscriptions();
     $this->getBoardVisits();
 }
コード例 #2
0
 /**
  * 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);
     }
 }