function __construct($ipAddress, $startTime) { global $configArray; if (!isset($configArray)) { die("You must load configuration before creating a tracker"); } global $interface; if (!isset($interface)) { die("You must setup the interface before creating a tracker"); } //Make sure that we don't track visits from bots if (BotChecker::isRequestFromBot() == true) { //$logger->log("Disabling logging because the request is from a bot", PEAR_LOG_DEBUG); $this->trackingDisabled = true; $this->finished = true; return; } //Check to see if analytics is enabled if (isset($configArray['System']['enableAnalytics']) && $configArray['System']['enableAnalytics'] == false) { $this->trackingDisabled = true; return; } //Check to see if we are in maintenance mode if (isset($configArray['System']['available']) && $configArray['System']['available'] == false) { $this->trackingDisabled = true; return; } $session = new Analytics_Session(); //disable error handler since the tables may not be installed yet. disableErrorHandler(); $sessionId = session_id(); $session->session_id = $sessionId; if ($session->find(true)) { $this->session = $session; if ($this->session->ip != $ipAddress) { $this->session->ip = $ipAddress; $this->doGeoIP(); } } else { $this->session = $session; $this->session->sessionStartTime = $startTime; $this->session->lastRequestTime = $startTime; $this->session->ip = $ipAddress; $this->doGeoIP(); $this->session->insert(); } $this->pageView = new Analytics_PageView(); $this->pageView->sessionId = $this->session->id; $this->pageView->pageStartTime = $startTime; $this->pageView->fullUrl = $_SERVER['REQUEST_URI']; enableErrorHandler(); }