diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-11-04 02:20:02 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-11-04 02:20:02 +0300 |
commit | 7f7a64993d82d5baf36035f44e7a07e784bd3351 (patch) | |
tree | 6b3694d785faf12d118ccf4dc537d3327e2f0d80 | |
parent | 0de3ff0782bebc64793b7c18c29afd9c00e86eb4 (diff) |
Make updatetoken.php script work in single codebase with --piwik-domain
fixes https://github.com/PiwikPRO/plugin-EnterpriseAdmin/issues/4 and #6584
-rw-r--r-- | misc/cron/updatetoken.php | 22 | ||||
-rwxr-xr-x | misc/log-analytics/import_logs.py | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/misc/cron/updatetoken.php b/misc/cron/updatetoken.php index 3936f04f9d..ff02e4f30a 100644 --- a/misc/cron/updatetoken.php +++ b/misc/cron/updatetoken.php @@ -32,16 +32,36 @@ if (!Common::isPhpCliMode()) { $testmode = in_array('--testmode', $_SERVER['argv']); if ($testmode) { require_once PIWIK_INCLUDE_PATH . "/tests/PHPUnit/TestingEnvironment.php"; - \Piwik_TestingEnvironment::addHooks(); } + +function getPiwikDomain() +{ + foreach($_SERVER['argv'] as $param) { + $pattern = '--piwik-domain='; + $equalSign = strpos($param, $pattern); + if($equalSign !== false) { + return substr($param, strlen($pattern)); + } + } + return null; +} + +$piwikDomain = getPiwikDomain(); +if($piwikDomain) { + Url::setHost($piwikDomain); +} + $token = Db::get()->fetchOne("SELECT token_auth FROM " . Common::prefixTable("user") . " WHERE superuser_access = 1 ORDER BY date_registered ASC"); $filename = PIWIK_INCLUDE_PATH . '/tmp/cache/token.php'; + +$filename = SettingsPiwik::rewriteTmpPathWithInstanceId($filename); + $content = "<?php exit; //\t" . $token; file_put_contents($filename, $content); echo $filename;
\ No newline at end of file diff --git a/misc/log-analytics/import_logs.py b/misc/log-analytics/import_logs.py index 9d797efcc9..90a7f4f709 100755 --- a/misc/log-analytics/import_logs.py +++ b/misc/log-analytics/import_logs.py @@ -630,6 +630,9 @@ class Configuration(object): if self.options.enable_testmode: command.append('--testmode') + hostname = urlparse.urlparse( self.options.piwik_url ).hostname + command.append('--piwik-domain=' + hostname ) + command = subprocess.list2cmdline(command) process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) [stdout, stderr] = process.communicate() |