Пример #1
0
 protected function checkSqlitePermissions()
 {
     $config = $this->registry->getConfig();
     if (!isset($config['components']['db']['connection']['dsn'])) {
         return;
     }
     $dsn = $config['components']['db']['connection']['dsn'];
     if (preg_match('#^sqlite:(.+)#', $dsn, $matches)) {
         $path = $matches[1];
         $dir = dirname($path);
         if (!is_file($path) && !is_writable($dir)) {
             $view = $this->getViewToShowError();
             echo $view->render('errors/error', ['error' => 'Directory "' . $dir . '" is not <b>writable</b>! Please make it readable and writable for this script process.']);
             exit;
         }
         if (!is_file($path)) {
             return;
         }
         if (!is_readable($path)) {
             $view = $this->getViewToShowError();
             echo $view->render('errors/error', ['error' => 'File "' . $path . '" is not <b>readable</b>! Please make it readable and writable for this script process.']);
             exit;
         }
         if (!is_writable($path)) {
             $view = $this->getViewToShowError();
             echo $view->render('errors/error', ['error' => 'File "' . $path . '" is not <b>writable</b>! Please make it readable and writable for this script process.']);
             exit;
         }
         if (!is_writable($dir)) {
             $view = $this->getViewToShowError();
             echo $view->render('errors/error', ['error' => 'Directory "' . $dir . '" is not <b>writable</b>! Please make it readable and writable for this script process.']);
             exit;
         }
     }
 }