| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\Diagnostics\Diagnostic; |
|
|
| use Piwik\Translation\Translator; |
|
|
| |
| |
| |
| class PhpFunctionsCheck implements Diagnostic |
| { |
| |
| |
| |
| private $translator; |
|
|
| public function __construct(Translator $translator) |
| { |
| $this->translator = $translator; |
| } |
|
|
| 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); |
| } |
|
|
| |
| |
| |
| private function getRequiredFunctions() |
| { |
| return array( |
| 'debug_backtrace', |
| 'escapeshellarg', |
| 'eval', |
| 'hash', |
| 'gzcompress', |
| 'gzuncompress', |
| 'pack', |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public static function functionExists($function) |
| { |
| |
| if ($function == 'eval') { |
| |
| if (extension_loaded('suhosin')) { |
| return @ini_get("suhosin.executor.disable_eval") != "1"; |
| } |
| return true; |
| } |
|
|
| $exists = function_exists($function); |
|
|
| if (extension_loaded('suhosin')) { |
| $blacklist = @ini_get("suhosin.executor.func.blacklist"); |
| if (!empty($blacklist)) { |
| $blacklistFunctions = array_map('strtolower', array_map('trim', explode(',', $blacklist))); |
| return $exists && !in_array($function, $blacklistFunctions); |
| } |
| } |
|
|
| return $exists; |
| } |
|
|
| private function getHelpMessage($missingFunction) |
| { |
| $messages = array( |
| 'debug_backtrace' => 'Installation_SystemCheckDebugBacktraceHelp', |
| 'eval' => 'Installation_SystemCheckEvalHelp', |
| 'hash' => 'Installation_SystemCheckHashHelp', |
| 'gzcompress' => 'Installation_SystemCheckGzcompressHelp', |
| 'gzuncompress' => 'Installation_SystemCheckGzuncompressHelp', |
| 'pack' => 'Installation_SystemCheckPackHelp', |
| ); |
|
|
| return $this->translator->translate($messages[$missingFunction]); |
| } |
| } |
|
|