Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
commit5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch)
tree5f30daf7bc14373fb1bbd0504ce11a771dafc02f /misc
parentae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff)
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'misc')
-rw-r--r--misc/cron/archive.php29
-rw-r--r--misc/others/api_internal_call.php7
-rwxr-xr-xmisc/others/geoipUpdateRows.php14
-rw-r--r--misc/others/iframeWidget_localhost.php8
-rw-r--r--misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php3
-rw-r--r--misc/others/test_generateLotsVisitsWebsites.php5
6 files changed, 40 insertions, 26 deletions
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index 45e8abe88a..391cbc5f6f 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -4,6 +4,11 @@ use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\FrontController;
+use Piwik\Http;
+use Piwik\Version;
+use Piwik\Url;
+use Piwik\Timer;
$USAGE = "
Usage:
@@ -118,7 +123,7 @@ class Archiving
$this->logSection("INIT");
$this->log("Querying Piwik API at: {$this->piwikUrl}");
- $this->log("Running Piwik " . Piwik_Version::VERSION . " as Super User: " . $this->login);
+ $this->log("Running Piwik " . Version::VERSION . " as Super User: " . $this->login);
$this->acceptInvalidSSLCertificate = $this->isParameterSet("accept-invalid-ssl-certificate");
@@ -187,7 +192,7 @@ class Archiving
$skipped =
$processed =
$archivedPeriodsArchivesWebsite = 0;
- $timer = new Piwik_Timer;
+ $timer = new Timer;
$this->logSection("START");
$this->log("Starting Piwik reports archiving...");
@@ -200,7 +205,7 @@ class Archiving
continue;
}
- $timerWebsite = new Piwik_Timer;
+ $timerWebsite = new Timer;
$lastTimestampWebsiteProcessedPeriods = $lastTimestampWebsiteProcessedDay = false;
if (!$this->shouldResetState) {
@@ -412,12 +417,12 @@ class Archiving
* @param $idsite int
* @param $period
* @param $lastTimestampWebsiteProcessed
- * @param Piwik_Timer $timerWebsite
+ * @param Timer $timerWebsite
* @return bool True on success, false if some request failed
*/
- private function archiveVisitsAndSegments($idsite, $period, $lastTimestampWebsiteProcessed, Piwik_Timer $timerWebsite = null)
+ private function archiveVisitsAndSegments($idsite, $period, $lastTimestampWebsiteProcessed, Timer $timerWebsite = null)
{
- $timer = new Piwik_Timer;
+ $timer = new Timer;
$aCurl = array();
$mh = false;
$url = $this->piwikUrl . $this->getVisitsRequestUrl($idsite, $period, $lastTimestampWebsiteProcessed) . $this->requestPrepend;
@@ -485,8 +490,8 @@ class Archiving
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
- curl_setopt($ch, CURLOPT_USERAGENT, Piwik_Http::getUserAgent());
- Piwik_Http::configCurlCertificate($ch);
+ curl_setopt($ch, CURLOPT_USERAGENT, Http::getUserAgent());
+ Http::configCurlCertificate($ch);
return $ch;
}
@@ -541,7 +546,7 @@ class Archiving
$url = $this->piwikUrl . $url . $this->requestPrepend;
//$this->log($url);
try {
- $response = Piwik_Http::sendHttpRequestBy('curl', $url, $timeout = 300, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSSLCertificate = $this->acceptInvalidSSLCertificate);
+ $response = Http::sendHttpRequestBy('curl', $url, $timeout = 300, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSSLCertificate = $this->acceptInvalidSSLCertificate);
} catch (Exception $e) {
return $this->logNetworkError($url, $e->getMessage());
}
@@ -611,7 +616,7 @@ class Archiving
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
$config->log['logger_message'] = array("logger_message" => "screen");
- Piwik::createLogObject();
+ \Piwik\Log::make();
if (!function_exists("curl_multi_init")) {
$this->log("ERROR: this script requires curl extension php_curl enabled in your CLI php.ini");
@@ -644,7 +649,7 @@ class Archiving
private function initCore()
{
try {
- Piwik_FrontController::getInstance()->init();
+ FrontController::getInstance()->init();
} catch (Exception $e) {
echo "ERROR: During Piwik init, Message: " . $e->getMessage();
exit;
@@ -787,7 +792,7 @@ class Archiving
// If archive.php run as a web cron, we use the current hostname
if (!Common::isPhpCliMode()) {
// example.org/piwik/misc/cron/
- $piwikUrl = Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName());
+ $piwikUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
// example.org/piwik/
$piwikUrl = $piwikUrl . "../../";
} // If archive.php run as CLI/shell we require the piwik url to be set
diff --git a/misc/others/api_internal_call.php b/misc/others/api_internal_call.php
index 8a2b8ad481..09c4702a66 100644
--- a/misc/others/api_internal_call.php
+++ b/misc/others/api_internal_call.php
@@ -1,4 +1,7 @@
<?php
+use Piwik\API\Request;
+use Piwik\FrontController;
+
define('PIWIK_INCLUDE_PATH', realpath('../..'));
define('PIWIK_USER_PATH', realpath('../..'));
define('PIWIK_ENABLE_DISPATCH', false);
@@ -10,10 +13,10 @@ define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
-Piwik_FrontController::getInstance()->init();
+FrontController::getInstance()->init();
// This inits the API Request with the specified parameters
-$request = new Piwik_API_Request('
+$request = new Request('
method=UserSettings.getResolution
&idSite=7
&date=yesterday
diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php
index 979ff5e8f7..7a2a3de32e 100755
--- a/misc/others/geoipUpdateRows.php
+++ b/misc/others/geoipUpdateRows.php
@@ -2,6 +2,8 @@
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\FrontController;
+use Piwik\IP;
ini_set("memory_limit", "512M");
error_reporting(E_ALL | E_NOTICE);
@@ -29,10 +31,10 @@ $GLOBALS['PIWIK_TRACKER_DEBUG'] = false;
define('PIWIK_ENABLE_DISPATCH', false);
Config::getInstance()->log['logger_message'][] = 'screen';
-Piwik_FrontController::getInstance()->init();
+FrontController::getInstance()->init();
$query = "SELECT count(*) FROM " . Common::prefixTable('log_visit');
-$count = Piwik_FetchOne($query);
+$count = Db::fetchOne($query);
// when script run via browser, check for Super User & output html page to do conversion via AJAX
if (!Common::isPhpCliMode()) {
@@ -182,7 +184,7 @@ if ($displayNotes) {
}
flush();
for (; $start < $end; $start += $limit) {
- $rows = Piwik_FetchAll("SELECT idvisit, location_ip, " . implode(',', array_keys($logVisitFieldsToUpdate)) . "
+ $rows = Db::fetchAll("SELECT idvisit, location_ip, " . implode(',', array_keys($logVisitFieldsToUpdate)) . "
FROM " . Common::prefixTable('log_visit') . "
LIMIT $start, $limit");
if (!count($rows)) {
@@ -202,7 +204,7 @@ for (; $start < $end; $start += $limit) {
continue;
}
- $ip = Piwik_IP::N2P($row['location_ip']);
+ $ip = IP::N2P($row['location_ip']);
$location = $provider->getLocation(array('ip' => $ip));
if (!empty($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY])) {
@@ -232,13 +234,13 @@ for (; $start < $end; $start += $limit) {
$sql = "UPDATE " . Common::prefixTable('log_visit') . "
SET " . implode(', ', $columnsToSet) . "
WHERE idvisit = ?";
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
// update log_conversion
$sql = "UPDATE " . Common::prefixTable('log_conversion') . "
SET " . implode(', ', $columnsToSet) . "
WHERE idvisit = ?";
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
}
Piwik::log(round($start * 100 / $count) . "% done...");
flush();
diff --git a/misc/others/iframeWidget_localhost.php b/misc/others/iframeWidget_localhost.php
index ef22366cf8..bcaef1a2b6 100644
--- a/misc/others/iframeWidget_localhost.php
+++ b/misc/others/iframeWidget_localhost.php
@@ -1,5 +1,7 @@
<?php
use Piwik\Common;
+use Piwik\FrontController;
+use Piwik\Url;
exit;
$date = date('Y-m-d');
@@ -30,8 +32,8 @@ define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
-Piwik_FrontController::getInstance()->init();
-$widgets = Piwik_GetWidgetsList();
+FrontController::getInstance()->init();
+$widgets = WidgetsList::get();
foreach ($widgets as $category => $widgetsInCategory) {
echo '<h2>' . $category . '</h2>';
foreach ($widgetsInCategory as $widget) {
@@ -48,7 +50,7 @@ foreach ($widgets as $category => $widgetsInCategory) {
}
$widgetUrl[$name] = $value;
}
- $widgetUrl = Piwik_Url::getQueryStringFromParameters($widgetUrl);
+ $widgetUrl = Url::getQueryStringFromParameters($widgetUrl);
echo '<div id="widgetIframe"><iframe width="500" height="350"
src="' . $widgetUrl . '" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
diff --git a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
index 2af3cab420..e9c6b32449 100644
--- a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
+++ b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
@@ -3,6 +3,7 @@
// Used initially to test how to handle cookies for this use case (see http://dev.piwik.org/trac/ticket/409)
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\FrontController;
exit;
@@ -14,7 +15,7 @@ require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php";
-Piwik_FrontController::getInstance()->init();
+FrontController::getInstance()->init();
Piwik::setUserIsSuperUser();
$count = 100;
for ($i = 0; $i <= $count; $i++) {
diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php
index abc4115ea6..260b146851 100644
--- a/misc/others/test_generateLotsVisitsWebsites.php
+++ b/misc/others/test_generateLotsVisitsWebsites.php
@@ -2,6 +2,7 @@
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\FrontController;
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
define('PIWIK_ENABLE_DISPATCH', false);
@@ -11,7 +12,7 @@ require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php";
-Piwik_FrontController::getInstance()->init();
+FrontController::getInstance()->init();
// SECURITY: DO NOT DELETE THIS LINE!
if (!Common::isPhpCliMode()) {
@@ -30,7 +31,7 @@ class Piwik_StressTests_CopyLogs
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
$config->log['logger_message'] = array("logger_message" => "screen");
- Piwik::createLogObject();
+ \Piwik\Log::make();
}
function run()