| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\Diagnostics\Diagnostic; |
|
|
| use Piwik\Container\StaticContainer; |
| use Piwik\DbHelper; |
| use Piwik\Filechecks; |
| use Piwik\Translation\Translator; |
|
|
| |
| |
| |
| class WriteAccessCheck implements Diagnostic |
| { |
| |
| |
| |
| private $translator; |
|
|
| |
| |
| |
| |
| private $tmpPath; |
|
|
| |
| |
| |
| public function __construct(Translator $translator, $tmpPath) |
| { |
| $this->translator = $translator; |
| $this->tmpPath = $tmpPath; |
| } |
|
|
| 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); |
| } |
|
|
| |
| |
| |
| private function getDirectories() |
| { |
| $directoriesToCheck = array( |
| $this->tmpPath, |
| $this->tmpPath . '/assets/', |
| $this->tmpPath . '/cache/', |
| $this->tmpPath . '/climulti/', |
| $this->tmpPath . '/latest/', |
| $this->tmpPath . '/logs/', |
| $this->tmpPath . '/logos/', |
| $this->tmpPath . '/sessions/', |
| $this->tmpPath . '/tcpdf/', |
| StaticContainer::get('path.tmp.templates') |
| , |
| ); |
|
|
| if (! DbHelper::isInstalled()) { |
| |
| $directoriesToCheck[] = PIWIK_USER_PATH . '/config/'; |
| } |
|
|
| return $directoriesToCheck; |
| } |
| } |
|
|