Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-04-19 14:03:31 +0300
committerdiosmosis <benaka@piwik.pro>2015-05-10 08:44:11 +0300
commitff8fa3f3ffdfdc12e0bbf4aaec4a86843dc97d24 (patch)
treed13dd613a9cad1d77284950472dd5b0323c3d85e /misc
parente2d14cd5581ee3681c8daa28029df286def712f7 (diff)
Add cron archiving API method only visible to superusers, use this in archive.php script and re-add php-cgi support to Console, which did not get merged in the past for some reason.
Diffstat (limited to 'misc')
-rw-r--r--misc/cron/archive.php53
1 files changed, 14 insertions, 39 deletions
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index bb23083f03..b2528ecf04 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -27,10 +27,10 @@ if (!defined('PIWIK_USER_PATH')) {
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
}
-define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
-require_once PIWIK_INCLUDE_PATH . "/index.php";
+
+require_once PIWIK_INCLUDE_PATH . "/core/bootstrap.php";
if (!empty($_SERVER['argv'][0])) {
$callee = $_SERVER['argv'][0];
@@ -52,8 +52,9 @@ try 'php archive.php --url=http://your.piwik/path'
-------------------------------------------------------
\n\n";
}
-
-if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) {
+// TODO: manual test against php-cgi + ArchiveWebTest
+// => test w/ token auth & w/o token auth
+if (Piwik\Common::isPhpCliMode()) {
$console = new Piwik\Console();
// manipulate command line arguments so CoreArchiver command will be executed
@@ -64,41 +65,15 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) {
$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
- $environment = new \Piwik\Application\Environment('cli');
- $environment->init();
-
- /** @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)
- $environment = new \Piwik\Application\Environment(null);
- $environment->init();
-
- /** @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);
- }
-
- \Piwik\FrontController::getInstance()->init();
-
- $archiver = new Piwik\CronArchive();
-
- if (!Piwik\Common::isPhpCliMode()) {
- $token_auth = Piwik\Common::getRequestVar('token_auth', '', 'string');
+ // 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);
- 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>');
- }
- }
+ $_GET['module'] = 'API';
+ $_GET['method'] = 'CoreAdminHome.runCronArchiving';
- $archiver->main();
+ require_once PIWIK_INCLUDE_PATH . "/index.php";
} \ No newline at end of file