Exemple #1
0
 public function __construct()
 {
     $this->checkCompatibility();
     parent::__construct();
     $option = new InputOption('piwik-domain', null, InputOption::VALUE_OPTIONAL, 'Piwik URL (protocol and domain) eg. "http://piwik.example.org"');
     $this->getDefinition()->addOption($option);
     $option = new InputOption('xhprof', null, InputOption::VALUE_NONE, 'Enable profiling with XHProf');
     $this->getDefinition()->addOption($option);
     StaticContainer::setEnvironment('cli');
 }
<?php

/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
use Piwik\Container\StaticContainer;
use Piwik\FrontController;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Output\ConsoleOutput;
define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__) . '/../..');
if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) {
    require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
}
if (!defined('PIWIK_INCLUDE_PATH')) {
    define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT);
}
require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php';
ignore_user_abort(true);
set_time_limit(0);
$GLOBALS['PIWIK_TRACKER_DEBUG'] = false;
define('PIWIK_ENABLE_DISPATCH', false);
if (Piwik\Common::isPhpCliMode()) {
    StaticContainer::setEnvironment('cli');
    /** @var ConsoleHandler $consoleLogHandler */
    $consoleLogHandler = StaticContainer::get('Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler');
    $consoleLogHandler->setOutput(new ConsoleOutput());
}
FrontController::getInstance()->init();
Exemple #3
0
 /**
  * We will be simulating an HTTP request here (by including index.php).
  *
  * To avoid weird side-effects (e.g. the logging output messing up the HTTP response on the CLI output)
  * we need to recreate the container with the default environment instead of the CLI environment.
  */
 private function recreateContainerWithWebEnvironment()
 {
     StaticContainer::setEnvironment(null);
     StaticContainer::clearContainer();
     Log::unsetInstance();
 }
Exemple #4
0
require_once PIWIK_INCLUDE_PATH . '/core/Plugin/Manager.php';
require_once PIWIK_INCLUDE_PATH . '/core/Plugin.php';
require_once PIWIK_INCLUDE_PATH . '/core/Common.php';
require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php';
require_once PIWIK_INCLUDE_PATH . '/core/IP.php';
require_once PIWIK_INCLUDE_PATH . '/core/UrlHelper.php';
require_once PIWIK_INCLUDE_PATH . '/core/Url.php';
require_once PIWIK_INCLUDE_PATH . '/core/SettingsPiwik.php';
require_once PIWIK_INCLUDE_PATH . '/core/SettingsServer.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker.php';
require_once PIWIK_INCLUDE_PATH . '/core/Config.php';
require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Cache.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Request.php';
require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php';
\Piwik\Container\StaticContainer::setEnvironment('tracker');
Tracker::loadTrackerEnvironment();
$tracker = new Tracker();
$requestSet = new RequestSet();
ob_start();
try {
    $handler = Handler\Factory::make();
    $response = $tracker->main($handler, $requestSet);
    if (!is_null($response)) {
        echo $response;
    }
} catch (Exception $e) {
    echo "Error:" . $e->getMessage();
    exit(1);
}
if (ob_get_level() > 1) {