function setRequest($requestArray) { $this->request = $requestArray; $idsite = Piwik_Common::getRequestVar('idsite', 0, 'int', $this->request); Piwik_PostEvent('Tracker.setRequest.idSite', $idsite); if ($idsite <= 0) { Piwik_Tracker_ExitWithException(new Exception('Invalid idSite')); } $this->idsite = $idsite; // When the 'url' and referer url parameter are not given, we might be in the 'Simple Image Tracker' mode. // The URL can default to the Referer, which will be in this case // the URL of the page containing the Simple Image beacon if (empty($this->request['urlref']) && empty($this->request['url'])) { $this->request['url'] = @$_SERVER['HTTP_REFERER']; } }
/** * Echos an error message & other information, then exits. * * @param Exception $e * @param bool $authenticated */ protected function exitWithException($e, $authenticated) { if ($this->usingBulkTracking) { // when doing bulk tracking we return JSON so the caller will know how many succeeded $result = array('succeeded' => $this->countOfLoggedRequests); // send error when in debug mode or when authenticated (which happens when doing log importing, // for example) if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG'] || $authenticated) { $result['error'] = Piwik_Tracker_GetErrorMessage($e); } echo Piwik_Common::json_encode($result); exit; } else { Piwik_Tracker_ExitWithException($e, $authenticated); } }
/** * Main */ public function main() { $this->init(); try { if ($this->isVisitValid()) { self::connectDatabase(); $visit = $this->getNewVisitObject(); $visit->setRequest($this->request); $visit->handle(); unset($visit); } Piwik_Common::runScheduledTasks($now = $this->getCurrentTimestamp()); } catch (Piwik_Tracker_Db_Exception $e) { printDebug("<b>" . $e->getMessage() . "</b>"); } catch (Piwik_Tracker_Visit_Excluded $e) { } catch (Exception $e) { Piwik_Tracker_ExitWithException($e); } $this->end(); }
/** * Main */ public function main() { $this->init(); try { if( $this->isVisitValid() ) { self::connectDatabase(); $visit = $this->getNewVisitObject(); $visit->setRequest($this->request); $visit->handle(); unset($visit); } // don't run scheduled tasks in CLI mode from Tracker, this is the case // where we bulk load logs & don't want to lose time with tasks if(!Piwik_Common::isPhpCliMode() && !$this->authenticated) { Piwik_Common::runScheduledTasks($now = $this->getCurrentTimestamp()); } } catch (Piwik_Tracker_Db_Exception $e) { printDebug("<b>".$e->getMessage()."</b>"); } catch(Piwik_Tracker_Visit_Excluded $e) { } catch(Exception $e) { Piwik_Tracker_ExitWithException($e); } $this->end(); }