Skip to content
Extraits de code Groupes Projets
Valider 8c48c25f rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fix CronArchive token_auth refactor.

parent 9cd63ae9
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -211,6 +211,8 @@ class CronArchive
{
$this->initLog();
$this->initPiwikHost($piwikUrl);
$this->initCore();
$this->initTokenAuth();
}
/**
......@@ -230,8 +232,6 @@ class CronArchive
public function init()
{
// Note: the order of methods call matters here.
$this->initCore();
$this->initTokenAuth();
$this->initStateFromParameters();
$this->logInitInfo();
......@@ -948,6 +948,11 @@ class CronArchive
$this->token_auth = $token;
}
public function getTokenAuth()
{
return $this->token_auth;
}
private function initPiwikHost($piwikUrl = false)
{
// If core:archive command run as a web cron, we use the current hostname+path
......
......@@ -56,9 +56,11 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) {
$console->run();
} else { // if running via web request, use CronArchive directly
$archiver = new Piwik\CronArchive();
$token_auth = Piwik\Common::getRequestVar('token_auth', '', 'string');
if ($token_auth !== $this->token_auth
if ($token_auth !== $archiver->getTokenAuth()
|| strlen($token_auth) != 32
) {
die('<b>You must specify the Super User token_auth as a parameter to this script, eg. <code>?token_auth=XYZ</code> if you wish to run this script through the browser. </b><br>
......@@ -67,6 +69,5 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) {
<code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>');
}
$archiver = new Piwik\CronArchive();
$archiver->main();
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter