/** * 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 - tracks the visit/action * * @param array $args Optional Request Array */ public function main($args = null) { $displayedGIF = false; $this->initRequests($args); if (!empty($this->requests)) { // handle all visits foreach ($this->requests as $request) { $this->init($request); if (!$displayedGIF && !$this->authenticated) { $this->outputTransparentGif(); $displayedGIF = true; } try { if ($this->isVisitValid()) { self::connectDatabaseIfNotConnected(); $visit = $this->getNewVisitObject(); $visit->setRequest($request); $visit->handle(); unset($visit); } else { printDebug("The request is invalid: empty request, or maybe tracking is disabled in the config.ini.php via record_statistics=0"); } } catch (Piwik_Tracker_Db_Exception $e) { printDebug("<b>" . $e->getMessage() . "</b>"); $this->exitWithException($e, $this->authenticated); } catch (Piwik_Tracker_Visit_Excluded $e) { } catch (Exception $e) { $this->exitWithException($e, $this->authenticated); } $this->clear(); // increment successfully logged request count. make sure to do this after try-catch, // since an excluded visit is considered 'successfully logged' ++$this->countOfLoggedRequests; } if (!$displayedGIF) { $this->outputTransparentGif(); $displayedGIF = true; } } else { $this->handleEmptyRequest($_GET + $_POST); } // run scheduled task try { // 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 (Exception $e) { $this->exitWithException($e, $this->authenticated); } $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(); }