diff options
author | Chris Smith <toonarmy@phpbb.com> | 2011-09-20 22:18:06 +0100 |
---|---|---|
committer | Chris Smith <toonarmy@phpbb.com> | 2011-09-20 22:18:06 +0100 |
commit | 6d24a7191f2f4ba0b4cb8c079dfa0a78c3dc3ef0 (patch) | |
tree | f67274af89ec3a23e87eb064f6d0d4fb0263bf3a /phpBB/includes/acp | |
parent | cb245f5d04bcd36dd1ad8d3a95d7718ef5b15858 (diff) | |
download | forums-6d24a71.tar forums-6d24a71.tar.gz forums-6d24a71.tar.bz2 forums-6d24a71.tar.xz forums-6d24a71.zip |
[feature/remove-db-styles] Add error if template/theme file is unwritable.
PHPBB3-9741
Diffstat (limited to 'phpBB/includes/acp')
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 388f340e07..be442c96d9 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -446,6 +446,14 @@ version = {VERSION} trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); } + // Get the filesystem location of the current file + $file = "{$phpbb_root_path}styles/{$template_info['template_path']}/template/$template_file"; + + if ($template_file && ($safe_mode || !is_file($file) || !phpbb_is_writable($file))) + { + trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); + } + if ($save_changes && !check_form_key('acp_styles')) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -458,26 +466,16 @@ version = {VERSION} // save changes to the template if the user submitted any if ($save_changes && $template_file) { - // Get the filesystem location of the current file - $file = "{$phpbb_root_path}styles/{$template_info['template_path']}/template/$template_file"; $additional = ''; // Try to write the file - if (!$safe_mode && file_exists($file) && phpbb_is_writable($file)) - { - if (!($fp = @fopen($file, 'wb'))) - { - // File exists and is writeable, but still not able to be written to - trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); - } - fwrite($fp, $template_data); - fclose($fp); - } - else + if (!($fp = @fopen($file, 'wb'))) { - // @todo - trigger_error('Cannot write template file.', E_USER_ERROR); + // File exists and is writeable, but still not able to be written to + trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); } + fwrite($fp, $template_data); + fclose($fp); // destroy the cached version of the template (filename without extension) $this->clear_template_cache($template_info, array(substr($template_file, 0, -5))); @@ -752,28 +750,26 @@ version = {VERSION} } $db->sql_freeresult($result); + // Get the filesystem location of the current file + $file = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme/$theme_file"; + + if ($theme_file && ($safe_mode || !is_file($file) || !phpbb_is_writable($file))) + { + trigger_error(sprintf($user->lang['THEME_FILE_NOT_WRITABLE'], htmlspecialchars($theme_file)) . adm_back_link($this->u_action), E_USER_WARNING); + } + // save changes to the theme if the user submitted any if ($save_changes) { - // Get the filesystem location of the current file - $file = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme/$theme_file"; $additional = ''; $message = $user->lang['THEME_UPDATED']; - if (!$safe_mode && file_exists($file) && phpbb_is_writable($file)) - { - if (!($fp = @fopen($file, 'wb'))) - { - trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - fwrite($fp, $theme_data); - fclose($fp); - } - else + if (!($fp = @fopen($file, 'wb'))) { - // @todo Proper error - trigger_error('Cannot write to theme file.', E_USER_ERROR); + trigger_error(sprintf($user->lang['THEME_FILE_NOT_WRITABLE'], htmlspecialchars($theme_file)) . adm_back_link($this->u_action), E_USER_WARNING); } + fwrite($fp, $theme_data); + fclose($fp); $cache->destroy('sql', STYLES_THEME_TABLE); add_log('admin', 'LOG_THEME_EDIT_FILE', $theme_info['theme_name'], $theme_file); |