diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-07-25 01:49:11 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-07-25 01:49:11 +0400 |
commit | f0b1ce21bf4a0f13824e002855eccf9ac1ac7c33 (patch) | |
tree | ba7710513f98fdd2c5351e9e6a42b6698e607e15 | |
parent | 9e15da48d84fa00bcb1fe7367f955171384d8460 (diff) | |
parent | 96c02ccf5b5e6feea034f28e6295661dd8946896 (diff) |
0.4.20.4.2
-rw-r--r-- | core/Piwik.php | 14 | ||||
-rw-r--r-- | core/Tracker.php | 40 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 12 | ||||
-rw-r--r-- | piwik.php | 22 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Controller.php | 7 |
5 files changed, 61 insertions, 34 deletions
diff --git a/core/Piwik.php b/core/Piwik.php index a2ba4d5fcb..e79853fbe3 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -219,9 +219,12 @@ class Piwik static public function printSqlProfilingReportTracker( $db = null ) { - function maxSumMsFirst($a,$b) + if(!function_exists('maxSumMsFirst')) { - return $a['sum_time_ms'] < $b['sum_time_ms']; + function maxSumMsFirst($a,$b) + { + return $a['sum_time_ms'] < $b['sum_time_ms']; + } } if(is_null($db)) @@ -278,9 +281,12 @@ class Piwik 'sumTimeMs' => $existing['count'] + $query->getElapsedSecs() * 1000); $infoIndexedByQuery[$query->getQuery()] = $new; } - function sortTimeDesc($a,$b) + if(!function_exists('sortTimeDesc')) { - return $a['sumTimeMs'] < $b['sumTimeMs']; + function sortTimeDesc($a,$b) + { + return $a['sumTimeMs'] < $b['sumTimeMs']; + } } uasort( $infoIndexedByQuery, 'sortTimeDesc'); diff --git a/core/Tracker.php b/core/Tracker.php index a807ac8e9e..96e6ab0843 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -31,7 +31,8 @@ class Piwik_Tracker const STATE_NOTHING_TO_NOTICE = 1; const STATE_TO_REDIRECT_URL = 2; const STATE_LOGGING_DISABLE = 10; - const STATE_NO_GET_VARIABLE = 11; + const STATE_EMPTY_REQUEST = 11; + const STATE_TRACK_ONLY = 12; const COOKIE_INDEX_IDVISITOR = 1; const COOKIE_INDEX_TIMESTAMP_LAST_ACTION = 2; @@ -45,9 +46,9 @@ class Piwik_Tracker const COOKIE_INDEX_REFERER_KEYWORD = 10; const COOKIE_INDEX_VISITOR_RETURNING = 11; - public function __construct() + public function __construct($args = null) { - $this->request = $_GET + $_POST; + $this->request = $args ? $args : $_GET + $_POST; } public function main() @@ -85,9 +86,10 @@ class Piwik_Tracker { $this->loadTrackerPlugins(); $this->handleDisabledTracker(); - $this->handleEmptyGetVariable(); + $this->handleEmptyRequest(); $this->handleDownloadRedirect(); $this->handleOutlinkRedirect(); + $this->handleDataPush(); } // display the logo or pixel 1*1 GIF @@ -103,8 +105,8 @@ class Piwik_Tracker $this->outputTransparentGif(); break; - case self::STATE_NO_GET_VARIABLE: - printDebug("No get variables => Piwik page"); + case self::STATE_EMPTY_REQUEST: + printDebug("Empty request => Piwik page"); echo "<a href='index.php'>Piwik</a> is a free open source <a href='http://piwik.org'>web analytics</a> alternative to Google analytics."; break; @@ -112,6 +114,10 @@ class Piwik_Tracker $this->sendHeader('Location: ' . $this->getUrlToRedirect()); break; + case self::STATE_TRACK_ONLY: + printDebug("Data push, tracking only"); + break; + case self::STATE_NOTHING_TO_NOTICE: default: printDebug("Nothing to notice => default behaviour"); @@ -217,7 +223,7 @@ class Piwik_Tracker protected function isVisitValid() { return $this->stateValid !== self::STATE_LOGGING_DISABLE - && $this->stateValid !== self::STATE_NO_GET_VARIABLE; + && $this->stateValid !== self::STATE_EMPTY_REQUEST; } protected function getState() @@ -257,6 +263,14 @@ class Piwik_Tracker } } + protected function handleDataPush() + { + if( Piwik_Common::getRequestVar( 'data_push', 0, 'int', $this->request) == 1) + { + $this->setState( self::STATE_TRACK_ONLY ); + } + } + protected function handleDownloadRedirect() { $downloadVariableName = Piwik_Tracker_Config::getInstance()->Tracker['download_url_var_name']; @@ -288,12 +302,12 @@ class Piwik_Tracker } } } - - protected function handleEmptyGetVariable() + + protected function handleEmptyRequest() { - if( count($_GET) == 0) + if( count($this->request) == 0) { - $this->setState(self::STATE_NO_GET_VARIABLE); + $this->setState(self::STATE_EMPTY_REQUEST); } } @@ -313,9 +327,9 @@ function printDebug( $info = '' ) { if(is_array($info)) { - print("<PRE>"); + print("<pre>"); print(var_export($info,true)); - print("</PRE>"); + print("</pre>"); } else { diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index b61c729993..ea936d66a2 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -50,8 +50,10 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface protected $refererUrlParse; protected $currentUrlParse; - function __construct() + function setRequest($requestArray) { + $this->request = $requestArray; + $idsite = Piwik_Common::getRequestVar('idsite', 0, 'int', $this->request); if($idsite <= 0) { @@ -59,15 +61,11 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface } $this->idsite = $idsite; } - function setRequest($requestArray) - { - $this->request = $requestArray; - } /** - * Main algorith to handle the visit. + * Main algorithm to handle the visit. * - * Once we have the visitor information, we have to define if the visit is a new or a known visit. + * Once we have the visitor information, we have to determine if the visit is a new or a known visit. * * 1) When the last action was done more than 30min ago, * or if the visitor is new, then this is a new visit. @@ -8,14 +8,13 @@ */ $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; -if(defined('PIWIK_ENABLE_TRACKING') && !PIWIK_ENABLE_TRACKING) -{ - return; -} define('PIWIK_TRACKER_MODE', true); error_reporting(E_ALL|E_NOTICE); -define('PIWIK_INCLUDE_PATH', dirname(__FILE__)); +if(!defined('PIWIK_INCLUDE_PATH')) +{ + define('PIWIK_INCLUDE_PATH', dirname(__FILE__)); +} @ignore_user_abort(true); if((@include "Version.php") === false || !class_exists('Piwik_Version', false)) @@ -43,8 +42,8 @@ session_cache_limiter('nocache'); ob_start(); if($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) { - require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; @date_default_timezone_set(date_default_timezone_get()); + require_once PIWIK_INCLUDE_PATH .'/core/Loader.php'; require_once PIWIK_INCLUDE_PATH .'/core/ErrorHandler.php'; require_once PIWIK_INCLUDE_PATH .'/core/ExceptionHandler.php'; set_error_handler('Piwik_ErrorHandler'); @@ -55,7 +54,10 @@ if($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) Piwik::createLogObject(); } -$process = new Piwik_Tracker(); -$process->main(); -ob_end_flush(); -printDebug($_COOKIE); +if(!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) +{ + $process = new Piwik_Tracker(); + $process->main(); + ob_end_flush(); + printDebug($_COOKIE); +} diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index beabbe7d20..42f0d04707 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -32,6 +32,12 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller header("Location:index.php?module=" . $module); } + protected function setGeneralVariablesView($view) + { + parent::setGeneralVariablesView($view); + $view->menu = Piwik_GetMenu(); + } + public function index() { Piwik::checkUserIsSuperUser(); @@ -43,6 +49,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller { $view = new Piwik_View('CoreAdminHome/templates/index.tpl'); $view->content = ''; + $this->setGeneralVariablesView($view); $view->menu = Piwik_GetAdminMenu(); return $view; } |