diff options
author | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-07-18 13:45:02 +0400 |
---|---|---|
committer | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-07-18 13:45:02 +0400 |
commit | 03b4953f008c1063e6d7166143ba844e8c6e89cc (patch) | |
tree | 7b9f0fef13d75417c551f813c98dba1a22f2fff3 /misc | |
parent | 9b2c0a7a450fff3b634f8119c8003ae1d20b97d0 (diff) |
Refactor class Piwik_Common to \Piwik\Core\Common
Notice that auto refactoring has created a nested namespace. Not sure this is what we want - so we might have to edit those nested namespaces afterwards (I think they don't look so good)
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cron/archive.php | 14 | ||||
-rwxr-xr-x | misc/others/geoipUpdateRows.php | 26 | ||||
-rw-r--r-- | misc/others/iframeWidget_localhost.php | 4 | ||||
-rw-r--r-- | misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php | 4 | ||||
-rw-r--r-- | misc/others/test_generateLotsVisitsWebsites.php | 32 |
5 files changed, 40 insertions, 40 deletions
diff --git a/misc/cron/archive.php b/misc/cron/archive.php index 8985087491..88dfb56851 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -1,7 +1,7 @@ <?php use Piwik\Core\Config; use Piwik\Core\Piwik; -use Piwik\Core\Piwik_Common; +use Piwik\Core\Common; $USAGE = " Usage: @@ -623,8 +623,8 @@ class Archiving */ private function initCheckCli() { - if (!Piwik_Common::isPhpCliMode()) { - $token_auth = Piwik_Common::getRequestVar('token_auth', '', 'string'); + if (!Common::isPhpCliMode()) { + $token_auth = Common::getRequestVar('token_auth', '', 'string'); if ($token_auth != $this->token_auth || strlen($token_auth) != 32 ) { @@ -783,16 +783,16 @@ class Archiving private function initPiwikHost() { // If archive.php run as a web cron, we use the current hostname - if (!Piwik_Common::isPhpCliMode()) { + if (!Common::isPhpCliMode()) { // example.org/piwik/misc/cron/ - $piwikUrl = Piwik_Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName()); + $piwikUrl = Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName()); // example.org/piwik/ $piwikUrl = $piwikUrl . "../../"; } // If archive.php run as CLI/shell we require the piwik url to be set else { $piwikUrl = $this->isParameterSet("url", true); if (!$piwikUrl - || !Piwik_Common::isLookLikeUrl($piwikUrl) + || !Common::isLookLikeUrl($piwikUrl) ) { $this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ ", $backtrace = false); } @@ -819,7 +819,7 @@ class Archiving */ private function isParameterSet($parameter, $valuePossible = false) { - if (!Piwik_Common::isPhpCliMode()) { + if (!Common::isPhpCliMode()) { return false; } $parameters = array( diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index 137b2bd1d0..3f42dc3855 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -1,7 +1,7 @@ <?php use Piwik\Core\Config; use Piwik\Core\Piwik; -use Piwik\Core\Piwik_Common; +use Piwik\Core\Common; ini_set("memory_limit", "512M"); error_reporting(E_ALL | E_NOTICE); @@ -31,11 +31,11 @@ define('PIWIK_ENABLE_DISPATCH', false); Config::getInstance()->log['logger_message'][] = 'screen'; Piwik_FrontController::getInstance()->init(); -$query = "SELECT count(*) FROM " . Piwik_Common::prefixTable('log_visit'); +$query = "SELECT count(*) FROM " . Common::prefixTable('log_visit'); $count = Piwik_FetchOne($query); // when script run via browser, check for Super User & output html page to do conversion via AJAX -if (!Piwik_Common::isPhpCliMode()) { +if (!Common::isPhpCliMode()) { try { Piwik::checkUserIsSuperUser(); } catch (Exception $e) { @@ -44,7 +44,7 @@ if (!Piwik_Common::isPhpCliMode()) { } // the 'start' query param will be supplied by the AJAX requests, so if it's not there, the // user is viewing the page in the browser. - if (Piwik_Common::getRequestVar('start', false) === false) { + if (Common::getRequestVar('start', false) === false) { // output HTML page that runs update via AJAX ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> @@ -92,8 +92,8 @@ if (!Piwik_Common::isPhpCliMode()) { <?php exit; } else { - $start = Piwik_Common::getRequestVar('start', 0, 'int'); - $end = min($count, Piwik_Common::getRequestVar('end', $count, 'int')); + $start = Common::getRequestVar('start', 0, 'int'); + $end = min($count, Common::getRequestVar('end', $count, 'int')); $limit = $end - $start; } } else // command line @@ -106,7 +106,7 @@ if (!Piwik_Common::isPhpCliMode()) { function geoipUpdateError($message) { Piwik::log($message); - if (!Piwik_Common::isPhpCliMode()) { + if (!Common::isPhpCliMode()) { @header('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500); } exit; @@ -130,7 +130,7 @@ if (!$provider->isAvailable()) { if ($displayNotes) { Piwik::log("[note] The GeoIP PECL extension is broken: $workingOrError"); } - if (Piwik_Common::isPhpCliMode()) { + if (Common::isPhpCliMode()) { Piwik::log("[note] Make sure your command line PHP is configured to use the PECL extension."); } $provider = null; @@ -177,13 +177,13 @@ $logVisitFieldsToUpdate = array('location_country' => Piwik_UserCountry_Locati 'location_longitude' => Piwik_UserCountry_LocationProvider::LONGITUDE_KEY); if ($displayNotes) { - Piwik::log("\n$count rows to process in " . Piwik_Common::prefixTable('log_visit') - . " and " . Piwik_Common::prefixTable('log_conversion') . "..."); + Piwik::log("\n$count rows to process in " . Common::prefixTable('log_visit') + . " and " . Common::prefixTable('log_conversion') . "..."); } flush(); for (; $start < $end; $start += $limit) { $rows = Piwik_FetchAll("SELECT idvisit, location_ip, " . implode(',', array_keys($logVisitFieldsToUpdate)) . " - FROM " . Piwik_Common::prefixTable('log_visit') . " + FROM " . Common::prefixTable('log_visit') . " LIMIT $start, $limit"); if (!count($rows)) { continue; @@ -229,13 +229,13 @@ for (; $start < $end; $start += $limit) { $bind[] = $row['idvisit']; // update log_visit - $sql = "UPDATE " . Piwik_Common::prefixTable('log_visit') . " + $sql = "UPDATE " . Common::prefixTable('log_visit') . " SET " . implode(', ', $columnsToSet) . " WHERE idvisit = ?"; Piwik_Query($sql, $bind); // update log_conversion - $sql = "UPDATE " . Piwik_Common::prefixTable('log_conversion') . " + $sql = "UPDATE " . Common::prefixTable('log_conversion') . " SET " . implode(', ', $columnsToSet) . " WHERE idvisit = ?"; Piwik_Query($sql, $bind); diff --git a/misc/others/iframeWidget_localhost.php b/misc/others/iframeWidget_localhost.php index 7b4d87db9d..4e7c4b72ad 100644 --- a/misc/others/iframeWidget_localhost.php +++ b/misc/others/iframeWidget_localhost.php @@ -1,5 +1,5 @@ <?php -use Piwik\Core\Piwik_Common; +use Piwik\Core\Common; exit; $date = date('Y-m-d'); @@ -36,7 +36,7 @@ foreach ($widgets as $category => $widgetsInCategory) { echo '<h2>' . $category . '</h2>'; foreach ($widgetsInCategory as $widget) { echo '<h3>' . $widget['name'] . '</h3>'; - $widgetUrl = Piwik_Common::getArrayFromQueryString($url); + $widgetUrl = Common::getArrayFromQueryString($url); $widgetUrl['moduleToWidgetize'] = $widget['parameters']['module']; $widgetUrl['actionToWidgetize'] = $widget['parameters']['action']; $parameters = $widget['parameters']; diff --git a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php index 1b6ecf5361..5af16983d6 100644 --- a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php +++ b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php @@ -2,7 +2,7 @@ // Script that creates 100 websites, then outputs a IMG that records a pageview in each website // Used initially to test how to handle cookies for this use case (see http://dev.piwik.org/trac/ticket/409) use Piwik\Core\Piwik; -use Piwik\Core\Piwik_Common; +use Piwik\Core\Common; exit; @@ -18,7 +18,7 @@ Piwik_FrontController::getInstance()->init(); Piwik::setUserIsSuperUser(); $count = 100; for ($i = 0; $i <= $count; $i++) { - $id = Piwik_SitesManager_API::getInstance()->addSite(Piwik_Common::getRandomString(), 'http://piwik.org'); + $id = Piwik_SitesManager_API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org'); $t = new PiwikTracker($id, 'http://localhost/trunk/piwik.php'); echo $id . " <img width=100 height=10 border=1 src='" . $t->getUrlTrackPageView('title') . "'><br/>"; } diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php index 44d5bc031a..a2e11deb78 100644 --- a/misc/others/test_generateLotsVisitsWebsites.php +++ b/misc/others/test_generateLotsVisitsWebsites.php @@ -1,7 +1,7 @@ <?php use Piwik\Core\Config; use Piwik\Core\Piwik; -use Piwik\Core\Piwik_Common; +use Piwik\Core\Common; define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../..")); define('PIWIK_ENABLE_DISPATCH', false); @@ -14,7 +14,7 @@ require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php"; Piwik_FrontController::getInstance()->init(); // SECURITY: DO NOT DELETE THIS LINE! -if (!Piwik_Common::isPhpCliMode()) { +if (!Common::isPhpCliMode()) { die("ERROR: Must be executed in CLI"); } @@ -52,32 +52,32 @@ class Piwik_StressTests_CopyLogs $this->log(" Conversions today: " . $initialConversions); $this->log(" Now copying visits between '$startDate' and '$endDate'..."); - $sql = "INSERT INTO " . Piwik_Common::prefixTable('log_visit') . " (`idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, `visit_first_action_time`, `visit_last_action_time`, `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first`) + $sql = "INSERT INTO " . Common::prefixTable('log_visit') . " (`idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, `visit_first_action_time`, `visit_last_action_time`, `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first`) SELECT `idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first` - FROM `" . Piwik_Common::prefixTable('log_visit') . "` + FROM `" . Common::prefixTable('log_visit') . "` WHERE idsite >= 1 AND date(visit_last_action_time) between '$startDate' and '$endDate' ;"; $result = $db->query($sql); $this->log(" Copying actions..."); - $sql = "INSERT INTO " . Piwik_Common::prefixTable('log_link_visit_action') . " (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`) + $sql = "INSERT INTO " . Common::prefixTable('log_link_visit_action') . " (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`) SELECT `idsite`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5` - FROM `" . Piwik_Common::prefixTable('log_link_visit_action') . "` + FROM `" . Common::prefixTable('log_link_visit_action') . "` WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; // LIMIT 1000000 $result = $db->query($sql); $this->log(" Copying conversions..."); - $sql = "INSERT IGNORE INTO `" . Piwik_Common::prefixTable('log_conversion') . "` (`idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, `server_time`, `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, `buster`, `idorder`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount`) + $sql = "INSERT IGNORE INTO `" . Common::prefixTable('log_conversion') . "` (`idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, `server_time`, `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, `buster`, `idorder`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount`) SELECT `idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, FLOOR(`buster` * RAND()), CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount` - FROM `" . Piwik_Common::prefixTable('log_conversion') . "` + FROM `" . Common::prefixTable('log_conversion') . "` WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; $result = $db->query($sql); $this->log(" Copying purchased items..."); - $sql = "INSERT INTO `" . Piwik_Common::prefixTable('log_conversion_item') . "` (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idorder`, `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted`) + $sql = "INSERT INTO `" . Common::prefixTable('log_conversion_item') . "` (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idorder`, `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted`) SELECT `idsite`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", TIME(`server_time`)), `idvisit`, CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted` - FROM `" . Piwik_Common::prefixTable('log_conversion_item') . "` + FROM `" . Common::prefixTable('log_conversion_item') . "` WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; $result = $db->query($sql); @@ -102,15 +102,15 @@ class Piwik_StressTests_CopyLogs { $this->log("Deleting logs for today..."); $db = Zend_Registry::get('db'); - $sql = "DELETE FROM " . Piwik_Common::prefixTable('log_visit') . " + $sql = "DELETE FROM " . Common::prefixTable('log_visit') . " WHERE date(visit_last_action_time) = CURRENT_DATE();"; $db->query($sql); foreach (array('log_link_visit_action', 'log_conversion', 'log_conversion_item') as $table) { - $sql = "DELETE FROM " . Piwik_Common::prefixTable($table) . " + $sql = "DELETE FROM " . Common::prefixTable($table) . " WHERE date(server_time) = CURRENT_DATE();"; $db->query($sql); } - $sql = "OPTIMIZE TABLE " . Piwik_Common::prefixTable('log_link_visit_action') . ", " . Piwik_Common::prefixTable('log_conversion') . ", " . Piwik_Common::prefixTable('log_conversion_item') . ", " . Piwik_Common::prefixTable('log_visit') . ""; + $sql = "OPTIMIZE TABLE " . Common::prefixTable('log_link_visit_action') . ", " . Common::prefixTable('log_conversion') . ", " . Common::prefixTable('log_conversion_item') . ", " . Common::prefixTable('log_visit') . ""; $db->query($sql); $this->log("done"); } @@ -122,13 +122,13 @@ class Piwik_StressTests_CopyLogs function getVisitsToday() { - $sql = "SELECT count(*) FROM `" . Piwik_Common::prefixTable('log_visit') . "` WHERE idsite >= 1 AND DATE(`visit_last_action_time`) = CURRENT_DATE;"; + $sql = "SELECT count(*) FROM `" . Common::prefixTable('log_visit') . "` WHERE idsite >= 1 AND DATE(`visit_last_action_time`) = CURRENT_DATE;"; return Zend_Registry::get('db')->fetchOne($sql); } function getConversionItemsToday($table = 'log_conversion_item') { - $sql = "SELECT count(*) FROM `" . Piwik_Common::prefixTable($table) . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;"; + $sql = "SELECT count(*) FROM `" . Common::prefixTable($table) . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;"; return Zend_Registry::get('db')->fetchOne($sql); } @@ -139,7 +139,7 @@ class Piwik_StressTests_CopyLogs function getActionsToday() { - $sql = "SELECT count(*) FROM `" . Piwik_Common::prefixTable('log_link_visit_action') . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;"; + $sql = "SELECT count(*) FROM `" . Common::prefixTable('log_link_visit_action') . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;"; return Zend_Registry::get('db')->fetchOne($sql); } } |