예제 #1
0
 public function init()
 {
     $this->initCore();
     $this->initTokenAuth();
     $this->initCheckCli();
     $this->initLog();
     $this->displayHelp();
     $this->initPiwikHost();
     $this->initStateFromParameters();
     Piwik::setUserIsSuperUser(true);
     $this->logSection("INIT");
     $this->log("Querying Piwik API at: {$this->piwikUrl}");
     $this->log("Running as Super User: "******"accept-invalid-ssl-certificate");
     // Test the specified piwik URL is valid
     $response = $this->request("?module=API&method=API.getDefaultMetricTranslations&format=php");
     $responseUnserialized = @unserialize($response);
     if ($response === false || !is_array($responseUnserialized)) {
         $this->logFatalError("The Piwik URL {$this->piwikUrl} does not seem to be pointing to a Piwik server. Response was '{$response}'.");
     }
     $this->log("Notes");
     // Information about timeout
     $this->todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
     $this->log("- Reports for today will be processed at most every " . Piwik_ArchiveProcessing::getTodayArchiveTimeToLive() . " seconds. You can change this value in Piwik UI > Settings > General Settings.");
     $this->log("- Reports for the current week/month/year will be refreshed at most every " . $this->processPeriodsMaximumEverySeconds . " seconds.");
     // Fetching segments to process
     $this->segments = Piwik_CoreAdminHome_API::getInstance()->getKnownSegmentsToArchive();
     if (empty($this->segments)) {
         $this->segments = array();
     }
     if (!empty($this->segments)) {
         $this->log("- Segments to pre-process for each website and each period: " . implode(", ", $this->segments));
     }
     // Try and not request older data we know is already archived
     if ($this->timeLastCompleted !== false) {
         $dateLast = time() - $this->timeLastCompleted;
         $this->log("- Archiving was last executed without error " . Piwik::getPrettyTimeFromSeconds($dateLast, true, $isHtml = false) . " ago");
     }
     $this->initWebsitesToProcess();
     flush();
 }