Example #1
0
 public function generalSettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('generalSettings');
     if (Piwik::isUserIsSuperUser()) {
         $enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
         $todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
         $showWarningCron = false;
         if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
             $showWarningCron = true;
         }
         $view->showWarningCron = $showWarningCron;
         $view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
         $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
         $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
         if (!Zend_Registry::get('config')->isFileWritable()) {
             $view->configFileNotWritable = true;
         }
         $view->mail = Zend_Registry::get('config')->mail->toArray();
     }
     $this->setBasicVariablesView($view);
     $view->topMenu = Piwik_GetTopMenu();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
 public function generalSettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('generalSettings');
     if (Piwik::isUserIsSuperUser()) {
         $enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
         $todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
         $showWarningCron = false;
         if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
             $showWarningCron = true;
         }
         $view->showWarningCron = $showWarningCron;
         $view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
         $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
         if (!Piwik_Config::getInstance()->isFileWritable()) {
             $view->configFileNotWritable = true;
         }
         $view->mail = Piwik_Config::getInstance()->mail;
         $view->branding = Piwik_Config::getInstance()->branding;
         $directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/themes/');
         $logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo.png') && is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo-header.png');
         $view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;
     }
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->topMenu = Piwik_GetTopMenu();
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Example #3
0
 /**
  * Returns contents of general (global) cache
  *
  * @return array
  */
 protected static function getCacheGeneral()
 {
     $cache = self::getTrackerCache();
     $cacheId = 'general';
     $expectedRows = 3;
     if (($cacheContent = $cache->get($cacheId)) !== false && count($cacheContent) == $expectedRows) {
         return $cacheContent;
     }
     self::initCorePiwikInTrackerMode();
     $cacheContent = array('isBrowserTriggerArchivingEnabled' => Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled(), 'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'), 'currentLocationProviderId' => Piwik_UserCountry_LocationProvider::getCurrentProviderId());
     return $cacheContent;
 }
Example #4
0
 private function oneClick_Copy()
 {
     /*
      * Make sure the execute bit is set for this shell script
      */
     if (!Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled()) {
         @chmod($this->pathRootExtractedPiwik . '/misc/cron/archive.sh', 0755);
     }
     /*
      * Copy all files to PIWIK_INCLUDE_PATH.
      * These files are accessed through the dispatcher.
      */
     Piwik::copyRecursive($this->pathRootExtractedPiwik, PIWIK_INCLUDE_PATH);
     /*
      * These files are visible in the web root and are generally
      * served directly by the web server.  May be shared.
      */
     if (PIWIK_INCLUDE_PATH !== PIWIK_DOCUMENT_ROOT) {
         /*
          * Copy PHP files that expect to be in the document root
          */
         $specialCases = array('/index.php', '/piwik.php', '/js/index.php');
         foreach ($specialCases as $file) {
             Piwik::copy($this->pathRootExtractedPiwik . $file, PIWIK_DOCUMENT_ROOT . $file);
         }
         /*
          * Copy the non-PHP files (e.g., images, css, javascript)
          */
         Piwik::copyRecursive($this->pathRootExtractedPiwik, PIWIK_DOCUMENT_ROOT, true);
     }
     /*
      * Config files may be user (account) specific
      */
     if (PIWIK_INCLUDE_PATH !== PIWIK_USER_PATH) {
         Piwik::copyRecursive($this->pathRootExtractedPiwik . '/config', PIWIK_USER_PATH . '/config');
     }
     Piwik::unlinkRecursive($this->pathRootExtractedPiwik, true);
 }
Example #5
0
 protected function initStateFromParameters()
 {
     // Detect parameters
     $reset = $this->isParameterSet("force-all-periods", $valuePossible = true);
     $forceAll = $this->isParameterSet("force-all-websites");
     $forceTimeoutPeriod = $this->isParameterSet("force-timeout-for-periods", $valuePossible = true);
     if (!empty($forceTimeoutPeriod) && $forceTimeoutPeriod !== true) {
         // Ensure the cache for periods is at least as high as cache for today
         $todayTTL = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
         if ($forceTimeoutPeriod < $todayTTL) {
             $this->log("WARNING: Automatically increasing --force-timeout-for-periods from {$forceTimeoutPeriod} to " . $todayTTL . " to match the cache timeout for Today's report specified in Piwik UI > Settings > General Settings");
             $forceTimeoutPeriod = $todayTTL;
         }
         $this->processPeriodsMaximumEverySeconds = $forceTimeoutPeriod;
     }
     // Recommend to disable browser archiving when using this script
     if (Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled()) {
         $this->log("NOTE: if you execute this script at least once per hour (or more often) in a crontab, you may disable 'Browser trigger archiving' in Piwik UI > Settings > General Settings. ");
         $this->log("      see doc at: http://piwik.org/docs/setup-auto-archiving/");
     }
     if ($reset) {
         $this->log("--force-all-periods was detected: the script will run as if it was its first run, and will trigger archiving for all periods.");
         $this->shouldResetState = true;
         if (!$forceAll && is_numeric($reset) && $reset > 0) {
             $this->firstRunActiveWebsitesWithTraffic = (int) $reset;
         }
     }
     if ($forceAll) {
         $this->log("--force-all-websites was detected: the script will archive all websites and all periods sequentially");
         $this->shouldArchiveAllWebsites = true;
     }
     $this->timeLastCompleted = Piwik_GetOption(self::OPTION_ARCHIVING_FINISHED_TS);
     if ($this->shouldResetState) {
         $this->timeLastCompleted = false;
     }
 }