mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-09 04:48:53 +00:00
[feature/remove-db-styles] Add error if template/theme file is unwritable.
PHPBB3-9741
This commit is contained in:
parent
cb245f5d04
commit
6d24a7191f
2 changed files with 26 additions and 29 deletions
|
@ -446,6 +446,14 @@ version = {VERSION}
|
||||||
trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
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'))
|
if ($save_changes && !check_form_key('acp_styles'))
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
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
|
// save changes to the template if the user submitted any
|
||||||
if ($save_changes && $template_file)
|
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 = '';
|
$additional = '';
|
||||||
|
|
||||||
// Try to write the file
|
// Try to write the file
|
||||||
if (!$safe_mode && file_exists($file) && phpbb_is_writable($file))
|
if (!($fp = @fopen($file, 'wb')))
|
||||||
{
|
{
|
||||||
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);
|
||||||
// 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
|
|
||||||
{
|
|
||||||
// @todo
|
|
||||||
trigger_error('Cannot write template file.', E_USER_ERROR);
|
|
||||||
}
|
}
|
||||||
|
fwrite($fp, $template_data);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
// destroy the cached version of the template (filename without extension)
|
// destroy the cached version of the template (filename without extension)
|
||||||
$this->clear_template_cache($template_info, array(substr($template_file, 0, -5)));
|
$this->clear_template_cache($template_info, array(substr($template_file, 0, -5)));
|
||||||
|
@ -752,28 +750,26 @@ version = {VERSION}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$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
|
// save changes to the theme if the user submitted any
|
||||||
if ($save_changes)
|
if ($save_changes)
|
||||||
{
|
{
|
||||||
// Get the filesystem location of the current file
|
|
||||||
$file = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme/$theme_file";
|
|
||||||
$additional = '';
|
$additional = '';
|
||||||
$message = $user->lang['THEME_UPDATED'];
|
$message = $user->lang['THEME_UPDATED'];
|
||||||
|
|
||||||
if (!$safe_mode && file_exists($file) && phpbb_is_writable($file))
|
if (!($fp = @fopen($file, 'wb')))
|
||||||
{
|
{
|
||||||
if (!($fp = @fopen($file, 'wb')))
|
trigger_error(sprintf($user->lang['THEME_FILE_NOT_WRITABLE'], htmlspecialchars($theme_file)) . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
{
|
|
||||||
trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
||||||
}
|
|
||||||
fwrite($fp, $theme_data);
|
|
||||||
fclose($fp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// @todo Proper error
|
|
||||||
trigger_error('Cannot write to theme file.', E_USER_ERROR);
|
|
||||||
}
|
}
|
||||||
|
fwrite($fp, $theme_data);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
$cache->destroy('sql', STYLES_THEME_TABLE);
|
$cache->destroy('sql', STYLES_THEME_TABLE);
|
||||||
add_log('admin', 'LOG_THEME_EDIT_FILE', $theme_info['theme_name'], $theme_file);
|
add_log('admin', 'LOG_THEME_EDIT_FILE', $theme_info['theme_name'], $theme_file);
|
||||||
|
|
|
@ -372,6 +372,7 @@ $lang = array_merge($lang, array(
|
||||||
'THEME_ERR_REFRESH_FS' => 'This theme is stored on the filesystem so there is no need to refresh it.',
|
'THEME_ERR_REFRESH_FS' => 'This theme is stored on the filesystem so there is no need to refresh it.',
|
||||||
'THEME_ERR_STYLE_NAME' => 'You must supply a name for this theme.',
|
'THEME_ERR_STYLE_NAME' => 'You must supply a name for this theme.',
|
||||||
'THEME_FILE' => 'Theme file',
|
'THEME_FILE' => 'Theme file',
|
||||||
|
'THEME_FILE_NOT_WRITABLE' => 'Unable to write to theme file %s. Please check the permissions for the directory and the files.',
|
||||||
'THEME_EXPORT' => 'Export Theme',
|
'THEME_EXPORT' => 'Export Theme',
|
||||||
'THEME_EXPORT_EXPLAIN' => 'Here you can export a theme in the form of an archive. This archive will contain all the data necessary to install the theme on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.',
|
'THEME_EXPORT_EXPLAIN' => 'Here you can export a theme in the form of an archive. This archive will contain all the data necessary to install the theme on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.',
|
||||||
'THEME_EXPORTED' => 'Theme exported successfully and stored in %s.',
|
'THEME_EXPORTED' => 'Theme exported successfully and stored in %s.',
|
||||||
|
|
Loading…
Add table
Reference in a new issue