* * @category Piwik * @package Piwik */ if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../..")); } if (!defined('PIWIK_USER_PATH')) { define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); } if (!class_exists('Piwik\\Console', false)) { define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; } if (!empty($_SERVER['argv'][0])) { $callee = $_SERVER['argv'][0]; } else { $callee = ''; } if (false !== strpos($callee, 'archive.php')) { $piwikHome = PIWIK_INCLUDE_PATH; echo "\n-------------------------------------------------------\nUsing this 'archive.php' script is no longer recommended.\nPlease use '/path/to/php {$piwikHome}/console core:archive " . implode(' ', array_slice($_SERVER['argv'], 1)) . "' instead.\nTo get help use '/path/to/php {$piwikHome}/console core:archive --help'\nSee also: http://piwik.org/docs/setup-auto-archiving/\n-------------------------------------------------------\n\n\n"; } $archiving = new Piwik\CronArchive(); try { $archiving->main(); } catch (Exception $e) { $archiving->logFatalError($e->getMessage()); }
require_once PIWIK_INCLUDE_PATH . "/index.php"; } if (!empty($_SERVER['argv'][0])) { $callee = $_SERVER['argv'][0]; } else { $callee = ''; } if (false !== strpos($callee, 'archive.php')) { $piwikHome = PIWIK_INCLUDE_PATH; echo "\n-------------------------------------------------------\nUsing this 'archive.php' script is no longer recommended.\nPlease use '/path/to/php {$piwikHome}/console core:archive " . implode('', array_slice($_SERVER['argv'], 1)) . "' instead.\nTo get help use '/path/to/php {$piwikHome}/console core:archive --help'\nSee also: http://piwik.org/docs/setup-auto-archiving/\n\nIf you cannot use the console because it requires CLI\ntry 'php archive.php -- url=http://your.piwik/path'\n-------------------------------------------------------\n\n\n"; } if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) { $console = new Piwik\Console(); $console->init(); // manipulate command line arguments so CoreArchiver command will be executed $script = array_shift($_SERVER['argv']); array_unshift($_SERVER['argv'], 'core:archive'); array_unshift($_SERVER['argv'], $script); $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 !== $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> However it is recommended to run it <a href="http://piwik.org/docs/setup-auto-archiving/">via cron in the command line</a>, since it can take a long time to run.<br/> In a shell, execute for example the following to trigger archiving on the local Piwik server:<br/> <code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>'); } $archiver->main(); }
if (!defined('PIWIK_USER_PATH')) { define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); } if (!class_exists('Piwik\\Console', false)) { define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; } if (!empty($_SERVER['argv'][0])) { $callee = $_SERVER['argv'][0]; } else { $callee = ''; } if (false !== strpos($callee, 'archive.php')) { $piwikHome = PIWIK_INCLUDE_PATH; echo "\n-------------------------------------------------------\nUsing this 'archive.php' script is no longer recommended.\nPlease use '/path/to/php {$piwikHome}/console core:archive " . implode('', array_slice($_SERVER['argv'], 1)) . "' instead.\nTo get help use '/path/to/php {$piwikHome}/console core:archive --help'\nSee also: http://piwik.org/docs/setup-auto-archiving/\n\nIf you cannot use the console because it requires CLI\ntry 'php archive.php -- url=http://your.piwik/path'\n-------------------------------------------------------\n\n\n"; } if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) { $console = new Piwik\Console(); $console->init(); // manipulate command line arguments so CoreArchiver command will be executed $script = array_shift($_SERVER['argv']); array_unshift($_SERVER['argv'], 'core:archive'); array_unshift($_SERVER['argv'], $script); $console->run(); } else { // if running via web request, use CronArchive directly $archiver = new Piwik\CronArchive(); $archiver->main(); }
array_unshift($_SERVER['argv'], $script); $console->run(); } else { // if running via web request, use CronArchive directly if (Piwik\Common::isPhpCliMode()) { // We can run the archive in CLI with `php-cgi` so we have to configure the container/logger // just like for CLI StaticContainer::setEnvironment('cli'); /** @var ConsoleHandler $consoleLogHandler */ $consoleLogHandler = StaticContainer::get('Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler'); $consoleLogHandler->setOutput(new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE)); } else { // HTTP request: logs needs to be dumped in the HTTP response (on top of existing log destinations) /** @var \Monolog\Logger $logger */ $logger = StaticContainer::get('Psr\\Log\\LoggerInterface'); $handler = new StreamHandler('php://output', Logger::INFO); $handler->setFormatter(StaticContainer::get('Piwik\\Plugins\\Monolog\\Formatter\\LineMessageFormatter')); $logger->pushHandler($handler); } $archiver = new Piwik\CronArchive(); if (!Piwik\Common::isPhpCliMode()) { $token_auth = Piwik\Common::getRequestVar('token_auth', '', 'string'); if (!$archiver->isTokenAuthSuperUserToken($token_auth)) { 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> However it is recommended to run it <a href="http://piwik.org/docs/setup-auto-archiving/">via cron in the command line</a>, since it can take a long time to run.<br/> In a shell, execute for example the following to trigger archiving on the local Piwik server:<br/> <code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>'); } } $archiver->main(); }