/** * W3 writable error * * @param string $path * @return string */ function w3_writable_error($path) { $reactivate_url = nxt_nonce_url('plugins.php?action=activate&plugin=' . W3TC_FILE, 'activate-plugin_' . W3TC_FILE); $reactivate_button = sprintf('<input type="button" value="re-activate plugin" onclick="top.location.href = \'%s\'" />', addslashes($reactivate_url)); require_once W3TC_INC_DIR . '/functions/file.php'; if (w3_check_open_basedir($path)) { $error = sprintf('<strong>%s</strong> could not be created, please run following command:<br /><strong style="color: #f00;">chmod 777 %s</strong><br />then %s.', $path, file_exists($path) ? $path : dirname($path), $reactivate_button); } 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><br />then %s.', $path, ini_get('open_basedir'), $reactivate_button); } w3_activate_error($error); }
/** * W3 writable error * * @param string $path * @param string[] $chmod_dirs Directories that should be chmod 777 inorder to write * @throws FileOperationException */ function w3_throw_on_write_error($path, $chmod_dirs = array()) { w3_require_once(W3TC_INC_DIR . '/functions/file.php'); $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 (w3_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 FileOperationException($error, 'create', 'file', $path); }