/** * Calculates the number of current visitors and users * @return null */ private function calculateVisitorStats() { $this->numUsers = 0; $this->numVisitors = 0; $this->currentUsers = array(); $sessionPath = $this->session->getPath(); $sessionLifeTime = $this->session->getLifeTime(); $sessionTimeOutTime = time() - $sessionLifeTime; $sessionFiles = $sessionPath->read(); foreach ($sessionFiles as $sessionFile) { if ($sessionFile->getModificationTime() < $sessionTimeOutTime || !$sessionFile->isReadable()) { continue; } $content = $sessionFile->read(); if (!$content) { continue; } $content = substr($content, strlen(Session::SESSION_NAME) + 1); try { $content = unserialize($content); $this->numVisitors++; if (array_key_exists(self::SESSION_USERNAME, $content)) { $username = $content[self::SESSION_USERNAME]; $this->numUsers++; $this->currentUsers[$username] = $username; } } catch (Exception $exception) { } } sort($this->currentUsers); }