Пример #1
0
 /**
  * W3 writable error
  *
  * @param string  $path
  * @param string[] $chmod_dirs Directories that should be chmod 777 inorder to write
  */
 public static function throw_on_write_error($path, $chmod_dirs = array())
 {
     $chmods = '';
     if ($chmod_dirs) {
         $chmods = '<ul>';
         foreach ($chmod_dirs as $dir) {
             $chmods .= sprintf(__('<li><strong style="color: #f00;">chmod 777 %s</strong></li>', 'w3-total-cache'), $dir);
         }
     } else {
         $chmods = sprintf('<strong style="color: #f00;">chmod 777 %s</strong>', file_exists($path) ? $path : dirname($path));
     }
     if (Util_File::check_open_basedir($path)) {
         $error = sprintf(__('<strong>%s</strong> could not be created, please run following command:<br />%s', 'w3-total-cache'), $path, $chmods);
     } else {
         $error = sprintf(__('<strong>%s</strong> could not be created, <strong>open_basedir
                     </strong> restriction in effect, please check your php.ini settings:<br />
                     <strong style="color: #f00;">open_basedir = "%s"</strong>', 'w3-total-cache'), $path, ini_get('open_basedir'));
     }
     throw new \Exception($error);
 }