public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckWriteDirs');
     $result = new DiagnosticResult($label);
     $directories = Filechecks::checkDirectoriesWritable($this->getDirectories());
     $error = false;
     foreach ($directories as $directory => $isWritable) {
         if ($isWritable) {
             $status = DiagnosticResult::STATUS_OK;
         } else {
             $status = DiagnosticResult::STATUS_ERROR;
             $error = true;
         }
         $result->addItem(new DiagnosticResultItem($status, $directory));
     }
     if ($error) {
         $longErrorMessage = $this->translator->translate('Installation_SystemCheckWriteDirsHelp');
         $longErrorMessage .= '<ul>';
         foreach ($directories as $directory => $isWritable) {
             if (!$isWritable) {
                 $longErrorMessage .= sprintf('<li><pre>chmod a+w %s</pre></li>', $directory);
             }
         }
         $longErrorMessage .= '</ul>';
         $result->setLongErrorMessage($longErrorMessage);
     }
     return array($result);
 }
Beispiel #2
0
    public function execute()
    {
        $label = $this->translator->translate('Installation_SystemCheckSettings');

        $result = new DiagnosticResult($label);

        foreach ($this->getRequiredSettings() as $setting) {
            list($settingName, $requiredValue) = explode('=', $setting);

            $currentValue = (int) ini_get($settingName);

            if ($currentValue != $requiredValue) {
                $status = DiagnosticResult::STATUS_ERROR;
                $comment = sprintf(
                    '%s <br/><br/><em>%s</em><br/><em>%s</em><br/>',
                    $setting,
                    $this->translator->translate('Installation_SystemCheckPhpSetting', array($setting)),
                    $this->translator->translate('Installation_RestartWebServer')
                );
            } else {
                $status = DiagnosticResult::STATUS_OK;
                $comment = $setting;
            }

            $result->addItem(new DiagnosticResultItem($status, $comment));
        }

        return array($result);
    }
Beispiel #3
0
    public function execute()
    {
        $label = $this->translator->translate('Installation_SystemCheckExtensions');

        $result = new DiagnosticResult($label);
        $longErrorMessage = '';

        $requiredExtensions = $this->getRequiredExtensions();

        foreach ($requiredExtensions as $extension) {
            if (! extension_loaded($extension)) {
                $status = DiagnosticResult::STATUS_ERROR;
                $comment = $extension . ': ' . $this->translator->translate('Installation_RestartWebServer');
                $longErrorMessage .= '<p>' . $this->getHelpMessage($extension) . '</p>';
            } else {
                $status = DiagnosticResult::STATUS_OK;
                $comment = $extension;
            }

            $result->addItem(new DiagnosticResultItem($status, $comment));
        }

        $result->setLongErrorMessage($longErrorMessage);

        return array($result);
    }
 public function execute()
 {
     $isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
     if ($isPiwikInstalling) {
         // Skip the diagnostic if Piwik is being installed
         return array();
     }
     $label = $this->translator->translate('Installation_DatabaseAbilities');
     $optionTable = Common::prefixTable('option');
     $testOptionNames = array('test_system_check1', 'test_system_check2');
     $loadDataInfile = false;
     $errorMessage = null;
     try {
         $loadDataInfile = Db\BatchInsert::tableInsertBatch($optionTable, array('option_name', 'option_value'), array(array($testOptionNames[0], '1'), array($testOptionNames[1], '2')), $throwException = true);
     } catch (\Exception $ex) {
         $errorMessage = str_replace("\n", "<br/>", $ex->getMessage());
     }
     // delete the temporary rows that were created
     Db::exec("DELETE FROM `{$optionTable}` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')");
     if ($loadDataInfile) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, 'LOAD DATA INFILE'));
     }
     $comment = sprintf('LOAD DATA INFILE<br/>%s<br/>%s', $this->translator->translate('Installation_LoadDataInfileUnavailableHelp', array('LOAD DATA INFILE', 'FILE')), $this->translator->translate('Installation_LoadDataInfileRecommended'));
     if ($errorMessage) {
         $comment .= sprintf('<br/><strong>%s:</strong> %s<br/>%s', $this->translator->translate('General_Error'), $errorMessage, 'Troubleshooting: <a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org/faq/troubleshooting/%23faq_194">FAQ on piwik.org</a>');
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function test_singleResult_shouldReturnAResultWithASingleItem()
 {
     $result = DiagnosticResult::singleResult('Label', DiagnosticResult::STATUS_ERROR);
     $this->assertInstanceOf('Piwik\\Plugins\\Diagnostics\\Diagnostic\\DiagnosticResult', $result);
     $this->assertEquals('Label', $result->getLabel());
     $this->assertEquals(DiagnosticResult::STATUS_ERROR, $result->getStatus());
 }
 public function test_getAllResults()
 {
     $report = new DiagnosticReport(array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment')), array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment')));
     $this->assertCount(1, $report->getMandatoryDiagnosticResults());
     $this->assertCount(1, $report->getOptionalDiagnosticResults());
     $this->assertCount(2, $report->getAllResults());
 }
Beispiel #7
0
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckFunctions');
     $result = new DiagnosticResult($label);
     foreach ($this->getRequiredFunctions() as $function) {
         if (!self::functionExists($function)) {
             $status = DiagnosticResult::STATUS_ERROR;
             $comment = sprintf('%s <br/><br/><em>%s</em><br/><em>%s</em><br/>', $function, $this->getHelpMessage($function), $this->translator->translate('Installation_RestartWebServer'));
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $function;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOtherFunctions');
     $result = new DiagnosticResult($label);
     foreach ($this->getRecommendedFunctions() as $function) {
         if (!PhpFunctionsCheck::functionExists($function)) {
             $status = DiagnosticResult::STATUS_WARNING;
             $comment = $function . '<br/>' . $this->getHelpMessage($function);
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $function;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOtherExtensions');
     $result = new DiagnosticResult($label);
     $loadedExtensions = @get_loaded_extensions();
     foreach ($this->getRecommendedExtensions() as $extension) {
         if (!in_array($extension, $loadedExtensions)) {
             $status = DiagnosticResult::STATUS_WARNING;
             $comment = $extension . '<br/>' . $this->getHelpMessage($extension);
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $extension;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }
Beispiel #10
0
 public function execute()
 {
     $label = $this->translator->translate('SitesManager_Timezone');
     if (SettingsServer::isTimezoneSupportEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = sprintf('%s<br />%s.', $this->translator->translate('SitesManager_AdvancedTimezoneSupportNotFound'), '<a href="http://php.net/manual/en/datetime.installation.php" rel="noreferrer" target="_blank">Timezone PHP documentation</a>');
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckUpdateHttps');
     if (CoreUpdater\Controller::isUpdatingOverHttps()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = $this->translator->translate('Installation_SystemCheckUpdateHttpsNotSupported');
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckPageSpeedDisabled');
     if (!$this->isPageSpeedEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = $this->translator->translate('Installation_SystemCheckPageSpeedWarn', array('(eg. Apache, Nginx or IIS)'));
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckGDFreeType');
     if (SettingsServer::isGdExtensionEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = sprintf('%s<br />%s', $this->translator->translate('Installation_SystemCheckGDFreeType'), $this->translator->translate('Installation_SystemCheckGDHelp'));
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
Beispiel #14
0
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckCronArchiveProcess');
     $comment = $this->translator->translate('Installation_SystemCheckCronArchiveProcessCLI') . ': ';
     $process = new CliMulti();
     if ($process->supportsAsync()) {
         $comment .= $this->translator->translate('General_Ok');
     } else {
         $comment .= $this->translator->translate('Installation_NotSupported') . ' ' . $this->translator->translate('Goals_Optional');
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, $comment));
 }
Beispiel #15
0
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckTracker');
     $trackerStatus = Common::getRequestVar('trackerStatus', 0, 'int');
     if ($trackerStatus == 0) {
         $status = DiagnosticResult::STATUS_OK;
         $comment = '';
     } else {
         $status = DiagnosticResult::STATUS_WARNING;
         $comment = sprintf('%s<br />%s<br />%s', $trackerStatus, $this->translator->translate('Installation_SystemCheckTrackerHelp'), $this->translator->translate('Installation_RestartWebServer'));
     }
     return array(DiagnosticResult::singleResult($label, $status, $comment));
 }
Beispiel #16
0
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckMemoryLimit');
     SettingsServer::raiseMemoryLimitIfNecessary();
     $memoryLimit = SettingsServer::getMemoryLimitValue();
     $comment = $memoryLimit . 'M';
     if ($memoryLimit >= $this->minimumMemoryLimit) {
         $status = DiagnosticResult::STATUS_OK;
     } else {
         $status = DiagnosticResult::STATUS_WARNING;
         $comment .= sprintf('<br />%s<br />%s', $this->translator->translate('Installation_SystemCheckMemoryLimitHelp'), $this->translator->translate('Installation_RestartWebServer'));
     }
     return array(DiagnosticResult::singleResult($label, $status, $comment));
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOpenURL');
     $httpMethod = Http::getTransportMethod();
     if ($httpMethod) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, $httpMethod));
     }
     $canAutoUpdate = Filechecks::canAutoUpdate();
     $comment = $this->translator->translate('Installation_SystemCheckOpenURLHelp');
     if (!$canAutoUpdate) {
         $comment .= '<br/>' . $this->translator->translate('Installation_SystemCheckAutoUpdateHelp');
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
Beispiel #18
0
 public function execute()
 {
     global $piwik_minimumPHPVersion;
     $actualVersion = PHP_VERSION;
     $label = sprintf('%s >= %s', $this->translator->translate('Installation_SystemCheckPhp'), $piwik_minimumPHPVersion);
     if ($this->isPhpVersionValid($piwik_minimumPHPVersion, $actualVersion)) {
         $status = DiagnosticResult::STATUS_OK;
         $comment = $actualVersion;
     } else {
         $status = DiagnosticResult::STATUS_ERROR;
         $comment = sprintf('%s: %s', $this->translator->translate('General_Error'), $this->translator->translate('General_Required', array($label)));
     }
     return array(DiagnosticResult::singleResult($label, $status, $comment));
 }
Beispiel #19
0
 public function execute()
 {
     $label = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsWritable');
     $file = new File(PIWIK_DOCUMENT_ROOT . '/piwik.js');
     if ($file->hasWriteAccess()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, ''));
     }
     $comment = $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsNotWritable');
     if (!SettingsServer::isWindows()) {
         $realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/piwik.js');
         $command = "<br/><code> chmod +w {$realpath}<br/> chown " . Filechecks::getUserAndGroup() . " " . $realpath . "</code><br />";
         $comment .= $this->translator->translate('CustomPiwikJs_DiagnosticPiwikJsMakeWritable', $command);
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_Filesystem');
     if (!Filesystem::checkIfFileSystemIsNFS()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
     if ($isPiwikInstalling) {
         $help = 'Installation_NfsFilesystemWarningSuffixInstall';
     } else {
         $help = 'Installation_NfsFilesystemWarningSuffixAdmin';
     }
     $comment = sprintf('%s<br />%s', $this->translator->translate('Installation_NfsFilesystemWarning'), $this->translator->translate($help));
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
Beispiel #21
0
 private function checkDbAdapters()
 {
     $results = array();
     $adapters = Adapter::getAdapters();
     foreach ($adapters as $adapter => $port) {
         $label = $adapter . ' ' . $this->translator->translate('Installation_Extension');
         $results[] = DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK);
     }
     if (empty($adapters)) {
         $label = $this->translator->translate('Installation_SystemCheckDatabaseExtensions');
         $comment = $this->translator->translate('Installation_SystemCheckDatabaseHelp');
         $result = DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_ERROR, $comment);
         $result->setLongErrorMessage($this->getLongErrorMessage());
         $results[] = $result;
     }
     return $results;
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckFileIntegrity');
     $messages = Filechecks::getFileIntegrityInformation();
     $ok = array_shift($messages);
     if (empty($messages)) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     if ($ok) {
         $status = DiagnosticResult::STATUS_WARNING;
         return array(DiagnosticResult::singleResult($label, $status, $messages[0]));
     }
     $comment = $this->translator->translate('General_FileIntegrityWarningExplanation');
     // Keep only the 20 first lines else it becomes unmanageable
     if (count($messages) > 20) {
         $messages = array_slice($messages, 0, 20);
         $messages[] = '...';
     }
     $comment .= '<br/><br/><pre style="overflow-x: scroll;max-width: 600px;">' . implode("\n", $messages) . '</pre>';
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     $isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
     if ($isPiwikInstalling) {
         // Skip the diagnostic if Piwik is being installed
         return array();
     }
     $label = $this->translator->translate('UserCountry_Geolocation');
     $currentProviderId = LocationProvider::getCurrentProviderId();
     $allProviders = LocationProvider::getAllProviderInfo();
     $isRecommendedProvider = in_array($currentProviderId, array(LocationProvider\GeoIp\Php::ID, $currentProviderId == LocationProvider\GeoIp\Pecl::ID));
     $isProviderInstalled = $allProviders[$currentProviderId]['status'] == LocationProvider::INSTALLED;
     if ($isRecommendedProvider && $isProviderInstalled) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     if ($isProviderInstalled) {
         $comment = $this->translator->translate('UserCountry_GeoIpLocationProviderNotRecomnended') . ' ';
         $comment .= $this->translator->translate('UserCountry_GeoIpLocationProviderDesc_ServerBased2', array('<a href="http://piwik.org/docs/geo-locate/" rel="noreferrer" target="_blank">', '', '', '</a>'));
     } else {
         $comment = $this->translator->translate('UserCountry_DefaultLocationProviderDesc1') . ' ';
         $comment .= $this->translator->translate('UserCountry_DefaultLocationProviderDesc2', array('<a href="http://piwik.org/docs/geo-locate/" rel="noreferrer" target="_blank">', '', '', '</a>'));
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
 public function execute()
 {
     return array(DiagnosticResult::singleResult('Success', DiagnosticResult::STATUS_OK, 'Comment'));
 }
 public function execute()
 {
     return array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment'));
 }