From c3b51d93a7849a91887346945a6dd3cefdaf3ca7 Mon Sep 17 00:00:00 2001 From: diosmosis <benakamoorthi@fastmail.fm> Date: Sat, 15 Feb 2014 17:09:24 +0000 Subject: [PATCH] Move common startup code of Piwik PHP CLI scripts to file in misc/others and use in geoipUpdateRows.php --- misc/others/cli-script-bootstrap.php | 36 ++++++++++++++++++++++++++++ misc/others/geoipUpdateRows.php | 29 ++-------------------- 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 misc/others/cli-script-bootstrap.php diff --git a/misc/others/cli-script-bootstrap.php b/misc/others/cli-script-bootstrap.php new file mode 100644 index 0000000000..0cfd5b787c --- /dev/null +++ b/misc/others/cli-script-bootstrap.php @@ -0,0 +1,36 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +error_reporting(E_ALL | E_NOTICE); + +define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__) . '/../..'); +if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { + require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; +} +if (!defined('PIWIK_USER_PATH')) { + define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); +} +if (!defined('PIWIK_INCLUDE_PATH')) { + define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); +} + +ignore_user_abort(true); +set_time_limit(0); +@date_default_timezone_set('UTC'); + +require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; +require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; +require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; + +$GLOBALS['PIWIK_TRACKER_DEBUG'] = false; +define('PIWIK_ENABLE_DISPATCH', false); + +Config::getInstance()->log['log_writers'][] = 'screen'; +Config::getInstance()->log['log_level'] = 'VERBOSE'; +FrontController::getInstance()->init(); \ No newline at end of file diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index cc1d03d11f..6dffefc8d3 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -10,34 +10,9 @@ use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl; use Piwik\Plugins\UserCountry\LocationProvider; use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php; -ini_set("memory_limit", "512M"); -error_reporting(E_ALL | E_NOTICE); - -define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__) . '/../..'); -if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { - require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; -} -if (!defined('PIWIK_USER_PATH')) { - define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); -} -if (!defined('PIWIK_INCLUDE_PATH')) { - define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); -} +require_once './cli-script-bootstrap.php' -ignore_user_abort(true); -set_time_limit(0); -@date_default_timezone_set('UTC'); - -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; - -$GLOBALS['PIWIK_TRACKER_DEBUG'] = false; -define('PIWIK_ENABLE_DISPATCH', false); - -Config::getInstance()->log['log_writers'][] = 'screen'; -Config::getInstance()->log['log_level'] = 'VERBOSE'; -FrontController::getInstance()->init(); +ini_set("memory_limit", "512M"); $query = "SELECT count(*) FROM " . Common::prefixTable('log_visit'); $count = Db::fetchOne($query); -- GitLab