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 /misc/cron | |
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
Diffstat (limited to 'misc/cron')
-rw-r--r-- | misc/cron/updatetoken.php | 22 |
1 files changed, 21 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 |