aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_language.php65
-rw-r--r--phpBB/includes/acp/acp_styles.php1611
-rw-r--r--phpBB/includes/acp/info/acp_styles.php1
-rw-r--r--phpBB/includes/error_collector.php12
-rw-r--r--phpBB/includes/functions.php93
-rw-r--r--phpBB/includes/functions_display.php1
-rw-r--r--phpBB/includes/functions_messenger.php26
-rw-r--r--phpBB/includes/mcp/mcp_forum.php1
-rw-r--r--phpBB/includes/session.php233
-rw-r--r--phpBB/includes/template/filter.php70
-rw-r--r--phpBB/includes/template/template.php2
-rw-r--r--phpBB/includes/ucp/ucp_main.php3
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php1
13 files changed, 265 insertions, 1854 deletions
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 8df8e5c8e5..ffa8df1848 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -797,11 +797,6 @@ class acp_language
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
$db->sql_query($sql);
- $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
- $result = $db->sql_query($sql);
-
- $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
-
add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']);
trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
@@ -866,66 +861,6 @@ class acp_language
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$lang_id = $db->sql_nextid();
- $valid_localized = array(
- 'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
- );
-
- $sql_ary = array();
-
- $sql = 'SELECT *
- FROM ' . STYLES_IMAGESET_TABLE;
- $result = $db->sql_query($sql);
- while ($imageset_row = $db->sql_fetchrow($result))
- {
- if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg"))
- {
- $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg");
- foreach ($cfg_data_imageset_data as $image_name => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($image_name, 'img_') === 0 && $image_filename)
- {
- $image_name = substr($image_name, 4);
- if (in_array($image_name, $valid_localized))
- {
- $sql_ary[] = array(
- 'image_name' => (string) $image_name,
- 'image_filename' => (string) $image_filename,
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $imageset_row['imageset_id'],
- 'image_lang' => (string) $lang_pack['iso'],
- );
- }
- }
- }
- }
- }
- $db->sql_freeresult($result);
-
- if (sizeof($sql_ary))
- {
- $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
- $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
- }
-
// Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 18a90fb8e8..fc9acbbcb8 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -26,8 +26,6 @@ class acp_styles
var $style_cfg;
var $template_cfg;
var $theme_cfg;
- var $imageset_cfg;
- var $imageset_keys;
function main($id, $mode)
{
@@ -58,7 +56,7 @@ class acp_styles
$style_id = request_var('id', 0);
// Fill the configuration variables
- $this->style_cfg = $this->template_cfg = $this->theme_cfg = $this->imageset_cfg = '
+ $this->style_cfg = $this->template_cfg = $this->theme_cfg = '
#
# phpBB {MODE} configuration file
#
@@ -83,19 +81,6 @@ copyright = {COPYRIGHT}
version = {VERSION}
';
- $this->theme_cfg .= '
-# Some configuration options
-
-#
-# You have to turn this option on if you want to use the
-# path template variables ({T_IMAGESET_PATH} for example) within
-# your css file.
-# This is mostly the case if you want to use language specific
-# images within your css file.
-#
-parse_css_file = {PARSE_CSS_FILE}
-';
-
$this->template_cfg .= '
# Some configuration options
@@ -105,33 +90,6 @@ parse_css_file = {PARSE_CSS_FILE}
# Templates cannot inherit from inheriting templates.
#';
- $this->imageset_keys = array(
- 'logos' => array(
- 'site_logo',
- ),
- 'buttons' => array(
- 'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
- ),
- 'icons' => array(
- 'icon_post_target', 'icon_post_target_unread', 'icon_topic_attach', 'icon_topic_latest', 'icon_topic_newest', 'icon_topic_reported', 'icon_topic_unapproved', 'icon_friend', 'icon_foe',
- ),
- 'forums' => array(
- 'forum_link', 'forum_read', 'forum_read_locked', 'forum_read_subforum', 'forum_unread', 'forum_unread_locked', 'forum_unread_subforum', 'subforum_read', 'subforum_unread'
- ),
- 'folders' => array(
- 'topic_moved', 'topic_read', 'topic_read_mine', 'topic_read_hot', 'topic_read_hot_mine', 'topic_read_locked', 'topic_read_locked_mine', 'topic_unread', 'topic_unread_mine', 'topic_unread_hot', 'topic_unread_hot_mine', 'topic_unread_locked', 'topic_unread_locked_mine', 'sticky_read', 'sticky_read_mine', 'sticky_read_locked', 'sticky_read_locked_mine', 'sticky_unread', 'sticky_unread_mine', 'sticky_unread_locked', 'sticky_unread_locked_mine', 'announce_read', 'announce_read_mine', 'announce_read_locked', 'announce_read_locked_mine', 'announce_unread', 'announce_unread_mine', 'announce_unread_locked', 'announce_unread_locked_mine', 'global_read', 'global_read_mine', 'global_read_locked', 'global_read_locked_mine', 'global_unread', 'global_unread_mine', 'global_unread_locked', 'global_unread_locked_mine', 'pm_read', 'pm_unread',
- ),
- 'polls' => array(
- 'poll_left', 'poll_center', 'poll_right',
- ),
- 'ui' => array(
- 'upload_bar',
- ),
- 'user' => array(
- 'user_icon1', 'user_icon2', 'user_icon3', 'user_icon4', 'user_icon5', 'user_icon6', 'user_icon7', 'user_icon8', 'user_icon9', 'user_icon10',
- ),
- );
-
// Execute overall actions
switch ($action)
{
@@ -174,8 +132,6 @@ parse_css_file = {PARSE_CSS_FILE}
{
switch ($mode)
{
- case 'imageset':
- return $this->edit_imageset($style_id);
case 'template':
return $this->edit_template($style_id);
case 'theme':
@@ -251,7 +207,7 @@ parse_css_file = {PARSE_CSS_FILE}
switch ($action)
{
- // Refresh template data stored in db and clear cache
+ // Clear cache
case 'refresh':
$sql = 'SELECT *
@@ -268,49 +224,13 @@ parse_css_file = {PARSE_CSS_FILE}
if (confirm_box(true))
{
- $template_refreshed = '';
-
- // Only refresh database if the template is stored in the database
- if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/"))
- {
- $filelist = array('' => array());
-
- $sql = 'SELECT template_filename, template_mtime
- FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $style_id";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
-// if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime'])
-// {
- // get folder info from the filename
- if (($slash_pos = strrpos($row['template_filename'], '/')) === false)
- {
- $filelist[''][] = $row['template_filename'];
- }
- else
- {
- $filelist[substr($row['template_filename'], 0, $slash_pos + 1)][] = substr($row['template_filename'], $slash_pos + 1, strlen($row['template_filename']) - $slash_pos - 1);
- }
-// }
- }
- $db->sql_freeresult($result);
-
- $this->store_templates('update', $style_id, $template_row['template_path'], $filelist);
- unset($filelist);
-
- $template_refreshed = $user->lang['TEMPLATE_REFRESHED'] . '<br />';
- add_log('admin', 'LOG_TEMPLATE_REFRESHED', $template_row['template_name']);
- }
-
$this->clear_template_cache($template_row);
- trigger_error($template_refreshed . $user->lang['TEMPLATE_CACHE_CLEARED'] . adm_back_link($this->u_action));
+ trigger_error($user->lang['TEMPLATE_CACHE_CLEARED'] . adm_back_link($this->u_action));
}
else
{
- confirm_box(false, ($template_row['template_storedb']) ? $user->lang['CONFIRM_TEMPLATE_REFRESH'] : $user->lang['CONFIRM_TEMPLATE_CLEAR_CACHE'], build_hidden_fields(array(
+ confirm_box(false, $user->lang['CONFIRM_TEMPLATE_CLEAR_CACHE'], build_hidden_fields(array(
'i' => $id,
'mode' => $mode,
'action' => $action,
@@ -325,209 +245,7 @@ parse_css_file = {PARSE_CSS_FILE}
break;
case 'theme':
-
- switch ($action)
- {
- // Refresh theme data stored in the database
- case 'refresh':
-
- $sql = 'SELECT *
- FROM ' . STYLES_THEME_TABLE . "
- WHERE theme_id = $style_id";
- $result = $db->sql_query($sql);
- $theme_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (!$theme_row)
- {
- trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- if (!$theme_row['theme_storedb'])
- {
- trigger_error($user->lang['THEME_ERR_REFRESH_FS'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- if (confirm_box(true))
- {
- if ($theme_row['theme_storedb'] && file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css"))
- {
- // Save CSS contents
- $sql_ary = array(
- 'theme_mtime' => (int) filemtime("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css"),
- 'theme_data' => $this->db_theme_data($theme_row)
- );
-
- $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE theme_id = $style_id";
- $db->sql_query($sql);
-
- $cache->destroy('sql', STYLES_THEME_TABLE);
-
- add_log('admin', 'LOG_THEME_REFRESHED', $theme_row['theme_name']);
- trigger_error($user->lang['THEME_REFRESHED'] . adm_back_link($this->u_action));
- }
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_THEME_REFRESH'], build_hidden_fields(array(
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'id' => $style_id
- )));
- }
- break;
- }
-
- $this->frontend('theme', array('edit', 'details'), array('refresh', 'export', 'delete'));
- break;
-
- case 'imageset':
-
- switch ($action)
- {
- case 'refresh':
-
- $sql = 'SELECT *
- FROM ' . STYLES_IMAGESET_TABLE . "
- WHERE imageset_id = $style_id";
- $result = $db->sql_query($sql);
- $imageset_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (!$imageset_row)
- {
- trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- if (confirm_box(true))
- {
- $sql_ary = array();
-
- $imageset_definitions = array();
- foreach ($this->imageset_keys as $topic => $key_array)
- {
- $imageset_definitions = array_merge($imageset_definitions, $key_array);
- }
-
- $cfg_data_imageset = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/imageset.cfg");
-
- $db->sql_transaction('begin');
-
- $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . '
- WHERE imageset_id = ' . $style_id;
- $result = $db->sql_query($sql);
-
- foreach ($cfg_data_imageset as $image_name => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($image_name, 'img_') === 0 && $image_filename)
- {
- $image_name = substr($image_name, 4);
- if (in_array($image_name, $imageset_definitions))
- {
- $sql_ary[] = array(
- 'image_name' => (string) $image_name,
- 'image_filename' => (string) $image_filename,
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $style_id,
- 'image_lang' => '',
- );
- }
- }
- }
-
- $sql = 'SELECT lang_dir
- FROM ' . LANG_TABLE;
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg"))
- {
- $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg");
- foreach ($cfg_data_imageset_data as $image_name => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($image_name, 'img_') === 0 && $image_filename)
- {
- $image_name = substr($image_name, 4);
- if (in_array($image_name, $imageset_definitions))
- {
- $sql_ary[] = array(
- 'image_name' => (string) $image_name,
- 'image_filename' => (string) $image_filename,
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $style_id,
- 'image_lang' => (string) $row['lang_dir'],
- );
- }
- }
- }
- }
- }
- $db->sql_freeresult($result);
-
- $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
-
- $db->sql_transaction('commit');
-
- $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
- $cache->destroy('imageset_site_logo_md5');
-
- add_log('admin', 'LOG_IMAGESET_REFRESHED', $imageset_row['imageset_name']);
- trigger_error($user->lang['IMAGESET_REFRESHED'] . adm_back_link($this->u_action));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_IMAGESET_REFRESH'], build_hidden_fields(array(
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'id' => $style_id
- )));
- }
- break;
- }
-
- $this->frontend('imageset', array('edit', 'details'), array('refresh', 'export', 'delete'));
+ $this->frontend('theme', array('edit', 'details'), array('export', 'delete'));
break;
}
}
@@ -567,10 +285,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$l_prefix = strtoupper($mode);
@@ -720,7 +434,7 @@ parse_css_file = {PARSE_CSS_FILE}
$template_file = preg_replace('#\.{2,}#', '.', $template_file);
// Retrieve some information about the template
- $sql = 'SELECT template_storedb, template_path, template_name
+ $sql = 'SELECT template_path, template_name
FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE template_id = $template_id";
$result = $db->sql_query($sql);
@@ -732,6 +446,32 @@ parse_css_file = {PARSE_CSS_FILE}
trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
+ // Get the filesystem location of the current file
+ $template_path = "{$phpbb_root_path}styles/{$template_info['template_path']}/template";
+ $file = "$template_path/$template_file";
+
+ if ($template_file)
+ {
+ $l_not_writable = sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action);
+
+ if ($safe_mode)
+ {
+ trigger_error($l_not_writable, E_USER_WARNING);
+ }
+
+ if (file_exists($file) && is_file($file) && is_readable($file))
+ {
+ if (!phpbb_is_writable($file))
+ {
+ trigger_error($l_not_writable, E_USER_WARNING);
+ }
+ }
+ else
+ {
+ trigger_error($user->lang['NO_TEMPLATE'] . 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);
@@ -744,50 +484,14 @@ parse_css_file = {PARSE_CSS_FILE}
// 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 = '';
-
- // If the template is stored on the filesystem try to write the file else store it in the database
- if (!$safe_mode && !$template_info['template_storedb'] && file_exists($file) && phpbb_is_writable($file))
+ // Try to write the 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);
- }
- fwrite($fp, $template_data);
- fclose($fp);
- }
- else
- {
- $db->sql_transaction('begin');
-
- // If it's not stored in the db yet, then update the template setting and store all template files in the db
- if (!$template_info['template_storedb'])
- {
- if ($super = $this->get_super('template', $template_id))
- {
- $this->store_in_db('template', $super['template_id']);
- }
- else
- {
- $this->store_in_db('template', $template_id);
- }
-
- add_log('admin', 'LOG_TEMPLATE_EDIT_DETAILS', $template_info['template_name']);
- $additional .= '<br />' . $user->lang['EDIT_TEMPLATE_STORED_DB'];
- }
-
- // Update the template_data table entry for this template file
- $sql = 'UPDATE ' . STYLES_TEMPLATE_DATA_TABLE . "
- SET template_data = '" . $db->sql_escape($template_data) . "', template_mtime = " . time() . "
- WHERE template_id = $template_id
- AND template_filename = '" . $db->sql_escape($template_file) . "'";
- $db->sql_query($sql);
-
- $db->sql_transaction('commit');
+ // File exists and is writeable, but still not able to be written to
+ trigger_error($l_not_writable, 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)));
@@ -795,56 +499,22 @@ parse_css_file = {PARSE_CSS_FILE}
$cache->destroy('sql', STYLES_TABLE);
add_log('admin', 'LOG_TEMPLATE_EDIT', $template_info['template_name'], $template_file);
- trigger_error($user->lang['TEMPLATE_FILE_UPDATED'] . $additional . adm_back_link($this->u_action . "&amp;action=edit&amp;id=$template_id&amp;text_rows=$text_rows&amp;template_file=$template_file"));
+ trigger_error($user->lang['TEMPLATE_FILE_UPDATED'] . adm_back_link($this->u_action . "&amp;action=edit&amp;id=$template_id&amp;text_rows=$text_rows&amp;template_file=$template_file"));
}
// Generate a category array containing template filenames
- if (!$template_info['template_storedb'])
- {
- $template_path = "{$phpbb_root_path}styles/{$template_info['template_path']}/template";
- $filelist = filelist($template_path, '', 'html');
- $filelist[''] = array_diff($filelist[''], array('bbcode.html'));
+ $filelist = filelist($template_path, '', 'html');
+ $filelist[''] = array_diff($filelist[''], array('bbcode.html'));
- if ($template_file)
- {
- if (!file_exists($template_path . "/$template_file") || !($template_data = file_get_contents($template_path . "/$template_file")))
- {
- trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
- }
- }
- else
+ if ($template_file)
{
- $sql = 'SELECT *
- FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $template_id";
- $result = $db->sql_query($sql);
+ $template_data = file_get_contents($file);
- $filelist = array('' => array());
- while ($row = $db->sql_fetchrow($result))
+ if (!$template_data)
{
- $file_info = pathinfo($row['template_filename']);
-
- if (($file_info['basename'] != 'bbcode') && ($file_info['extension'] == 'html'))
- {
- if (($file_info['dirname'] == '.') || empty($file_info['dirname']))
- {
- $filelist[''][] = $row['template_filename'];
- }
- else
- {
- $filelist[$file_info['dirname'] . '/'][] = $file_info['basename'];
- }
- }
-
- if ($row['template_filename'] == $template_file)
- {
- $template_data = $row['template_data'];
- }
+ trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $db->sql_freeresult($result);
- unset($file_info);
}
if (empty($filelist['']))
@@ -1015,35 +685,6 @@ parse_css_file = {PARSE_CSS_FILE}
adm_page_footer();
}
- $filemtime = array();
- if ($template_row['template_storedb'])
- {
- $ids = array();
- if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id'])
- {
- $ids[] = $template_row['template_inherits_id'];
- }
- $ids[] = $template_row['template_id'];
-
- $filemtime = array();
- $file_template_db = array();
-
- foreach ($ids as $id)
- {
- $sql = 'SELECT template_filename, template_mtime
- FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $id";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $filemtime[$row['template_filename']] = $row['template_mtime'];
- $file_template_db[$row['template_filename']] = $id;
- }
- $db->sql_freeresult($result);
- }
- }
-
// Get a list of cached template files and then retrieve additional information about them
$file_ary = $this->template_cache_filelist($template_row['template_path']);
@@ -1066,30 +707,10 @@ parse_css_file = {PARSE_CSS_FILE}
$file_tpl = "{$phpbb_root_path}styles/{$template_row['template_path']}/template/$tpl_file.html";
$inherited = false;
- if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id'])
- {
- if (!$template_row['template_storedb'])
- {
- if (!file_exists($file_tpl))
- {
- $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/$tpl_file.html";
- $inherited = true;
- }
- }
- else
- {
- if ($file_template_db[$file . '.html'] == $template_row['template_inherits_id'])
- {
- $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/$tpl_file.html";
- $inherited = true;
- }
- }
- }
-
- // Correct the filename if it is stored in database and the file is in a subfolder.
- if ($template_row['template_storedb'])
+ if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id'] && !file_exists($file_tpl))
{
- $file = str_replace('.', '/', $file);
+ $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/$tpl_file.html";
+ $inherited = true;
}
$template->assign_block_vars('file', array(
@@ -1099,10 +720,9 @@ parse_css_file = {PARSE_CSS_FILE}
'FILENAME' => $file,
'FILENAME_PATH' => $file_tpl,
'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")),
- 'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html']))
- );
+ 'MODIFIED' => $user->format_date(filemtime($file_tpl)),
+ ));
}
- unset($filemtime);
$template->assign_vars(array(
'S_CACHE' => true,
@@ -1136,7 +756,7 @@ parse_css_file = {PARSE_CSS_FILE}
$theme_file = str_replace('..', '.', $theme_file);
// Retrieve some information about the theme
- $sql = 'SELECT theme_storedb, theme_path, theme_name, theme_data
+ $sql = 'SELECT theme_path, theme_name
FROM ' . STYLES_THEME_TABLE . "
WHERE theme_id = $theme_id";
$result = $db->sql_query($sql);
@@ -1147,71 +767,62 @@ parse_css_file = {PARSE_CSS_FILE}
}
$db->sql_freeresult($result);
- // save changes to the theme if the user submitted any
- if ($save_changes)
+ // Get the filesystem location of the current file
+ $theme_path = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme";
+ $file = "$theme_path/$theme_file";
+
+ if ($theme_file)
{
- // 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'];
+ $l_not_writable = sprintf($user->lang['THEME_FILE_NOT_WRITABLE'], htmlspecialchars($theme_file)) . adm_back_link($this->u_action);
- // If the theme is stored on the filesystem try to write the file else store it in the database
- if (!$safe_mode && !$theme_info['theme_storedb'] && file_exists($file) && phpbb_is_writable($file))
+ if ($safe_mode)
{
- if (!($fp = @fopen($file, 'wb')))
+ trigger_error($l_not_writable, E_USER_WARNING);
+ }
+
+ if (file_exists($file) && is_file($file) && is_readable($file))
+ {
+ if (!phpbb_is_writable($file))
{
- trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
+ trigger_error($l_not_writable, E_USER_WARNING);
}
- fwrite($fp, $theme_data);
- fclose($fp);
}
else
{
- // Write stylesheet to db
- $sql_ary = array(
- 'theme_mtime' => time(),
- 'theme_storedb' => 1,
- 'theme_data' => $this->db_theme_data($theme_info, $theme_data),
- );
- $sql = 'UPDATE ' . STYLES_THEME_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
- WHERE theme_id = ' . $theme_id;
- $db->sql_query($sql);
+ trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+ }
- $cache->destroy('sql', STYLES_THEME_TABLE);
+ // save changes to the theme if the user submitted any
+ if ($save_changes && $theme_file)
+ {
+ $message = $user->lang['THEME_UPDATED'];
- // notify the user if the theme was not stored in the db before his modification
- if (!$theme_info['theme_storedb'])
- {
- add_log('admin', 'LOG_THEME_EDIT_DETAILS', $theme_info['theme_name']);
- $message .= '<br />' . $user->lang['EDIT_THEME_STORED_DB'];
- }
+ if (!($fp = @fopen($file, 'wb')))
+ {
+ trigger_error($l_not_writable, E_USER_WARNING);
}
+ fwrite($fp, $theme_data);
+ fclose($fp);
+
$cache->destroy('sql', STYLES_THEME_TABLE);
- add_log('admin', (!$theme_info['theme_storedb']) ? 'LOG_THEME_EDIT_FILE' : 'LOG_THEME_EDIT', $theme_info['theme_name'], (!$theme_info['theme_storedb']) ? $theme_file : '');
+ add_log('admin', 'LOG_THEME_EDIT_FILE', $theme_info['theme_name'], $theme_file);
trigger_error($message . adm_back_link($this->u_action . "&amp;action=edit&amp;id=$theme_id&amp;template_file=$theme_file&amp;text_rows=$text_rows"));
}
// Generate a category array containing theme filenames
- if (!$theme_info['theme_storedb'])
- {
- $theme_path = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme";
+ $filelist = filelist($theme_path, '', 'css');
- $filelist = filelist($theme_path, '', 'css');
+ if ($theme_file)
+ {
+ $theme_data = file_get_contents($file);
- if ($theme_file)
+ if (!$theme_data)
{
- if (!file_exists($theme_path . "/$theme_file") || !($theme_data = file_get_contents($theme_path . "/$theme_file")))
- {
- trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
+ trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
- else
- {
- $theme_data = &$theme_info['theme_data'];
- }
// Now create the categories
$filelist_cats[''] = array();
@@ -1274,7 +885,6 @@ parse_css_file = {PARSE_CSS_FILE}
$template->assign_vars(array(
'S_EDIT_THEME' => true,
'S_HIDDEN_FIELDS' => build_hidden_fields(array('template_file' => $theme_file)),
- 'S_THEME_IN_DB' => $theme_info['theme_storedb'],
'S_TEMPLATES' => $tpl_options,
'U_ACTION' => $this->u_action . "&amp;action=edit&amp;id=$theme_id&amp;text_rows=$text_rows",
@@ -1292,289 +902,12 @@ parse_css_file = {PARSE_CSS_FILE}
'SELECTED_TEMPLATE' => $theme_info['theme_name'],
'TEMPLATE_FILE' => $theme_file,
'TEMPLATE_DATA' => utf8_htmlspecialchars($theme_data),
- 'TEXT_ROWS' => $text_rows)
- );
- }
-
- /**
- * Edit imagesets
- *
- * @param int $imageset_id specifies which imageset is being edited
- */
- function edit_imageset($imageset_id)
- {
- global $db, $user, $phpbb_root_path, $cache, $template;
-
- $this->page_title = 'EDIT_IMAGESET';
-
- if (!$imageset_id)
- {
- trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- $update = (isset($_POST['update'])) ? true : false;
-
- $imgname = request_var('imgname', 'site_logo');
- $imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname);
- $sql_extra = $imgnamelang = '';
-
- $sql = 'SELECT imageset_path, imageset_name
- FROM ' . STYLES_IMAGESET_TABLE . "
- WHERE imageset_id = $imageset_id";
- $result = $db->sql_query($sql);
- $imageset_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (!$imageset_row)
- {
- trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- $imageset_path = $imageset_row['imageset_path'];
- $imageset_name = $imageset_row['imageset_name'];
-
- if (strpos($imgname, '-') !== false)
- {
- list($imgname, $imgnamelang) = explode('-', $imgname);
- $sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')";
- }
-
- $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id
- FROM ' . STYLES_IMAGESET_DATA_TABLE . "
- WHERE imageset_id = $imageset_id
- AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra";
- $result = $db->sql_query($sql);
- $imageset_data_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $image_filename = $imageset_data_row['image_filename'];
- $image_width = $imageset_data_row['image_width'];
- $image_height = $imageset_data_row['image_height'];
- $image_lang = $imageset_data_row['image_lang'];
- $image_id = $imageset_data_row['image_id'];
- $imgsize = ($imageset_data_row['image_width'] && $imageset_data_row['image_height']) ? 1 : 0;
-
- // Check to see whether the selected image exists in the table
- $valid_name = ($update) ? false : true;
-
- foreach ($this->imageset_keys as $category => $img_ary)
- {
- if (in_array($imgname, $img_ary))
- {
- $valid_name = true;
- break;
- }
- }
-
- if ($update && isset($_POST['imgpath']) && $valid_name)
- {
- // If imgwidth and imgheight are non-zero grab the actual size
- // from the image itself ... we ignore width settings for the poll center image
- $imgwidth = request_var('imgwidth', 0);
- $imgheight = request_var('imgheight', 0);
- $imgsize = request_var('imgsize', 0);
- $imgpath = request_var('imgpath', '');
- $imgpath = str_replace('..', '.', $imgpath);
-
- // If no dimensions selected, we reset width and height to 0 ;)
- if (!$imgsize)
- {
- $imgwidth = $imgheight = 0;
- }
-
- $imglang = '';
-
- if ($imgpath && !file_exists("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"))
- {
- trigger_error($user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- // Determine width/height. If dimensions included and no width/height given, we detect them automatically...
- if ($imgsize && $imgpath)
- {
- if (!$imgwidth || !$imgheight)
- {
- list($imgwidth_file, $imgheight_file) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath");
- $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file;
- $imgheight = ($imgheight) ? $imgheight : $imgheight_file;
- }
- $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0;
- $imgheight = (int) $imgheight;
- }
-
- if (strpos($imgpath, '/') !== false)
- {
- list($imglang, $imgfilename) = explode('/', $imgpath);
- }
- else
- {
- $imgfilename = $imgpath;
- }
-
- $sql_ary = array(
- 'image_filename' => (string) $imgfilename,
- 'image_width' => (int) $imgwidth,
- 'image_height' => (int) $imgheight,
- 'image_lang' => (string) $imglang,
- );
-
- // already exists
- if ($imageset_data_row)
- {
- $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE image_id = $image_id";
- $db->sql_query($sql);
- }
- // does not exist
- else if (!$imageset_data_row)
- {
- $sql_ary['image_name'] = $imgname;
- $sql_ary['imageset_id'] = (int) $imageset_id;
- $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
- }
-
- $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
-
- add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name);
-
- $template->assign_var('SUCCESS', true);
-
- $image_filename = $imgfilename;
- $image_width = $imgwidth;
- $image_height = $imgheight;
- $image_lang = $imglang;
- }
-
- $imglang = '';
- $imagesetlist = array('nolang' => array(), 'lang' => array());
- $langs = array();
-
- $dir = "{$phpbb_root_path}styles/$imageset_path/imageset";
- $dp = @opendir($dir);
-
- if ($dp)
- {
- while (($file = readdir($dp)) !== false)
- {
- if ($file[0] != '.' && strtoupper($file) != 'CVS' && !is_file($dir . '/' . $file) && !is_link($dir . '/' . $file))
- {
- $langs[] = $file;
- }
- else if (preg_match('#\.(?:gif|jpg|png)$#', $file))
- {
- $imagesetlist['nolang'][] = $file;
- }
- }
-
- if ($sql_extra)
- {
- $dp2 = @opendir("$dir/$imgnamelang");
-
- if ($dp2)
- {
- while (($file2 = readdir($dp2)) !== false)
- {
- if (preg_match('#\.(?:gif|jpg|png)$#', $file2))
- {
- $imagesetlist['lang'][] = "$imgnamelang/$file2";
- }
- }
- closedir($dp2);
- }
- }
- closedir($dp);
- }
-
- // Generate list of image options
- $img_options = '';
- foreach ($this->imageset_keys as $category => $img_ary)
- {
- $template->assign_block_vars('category', array(
- 'NAME' => $user->lang['IMG_CAT_' . strtoupper($category)]
- ));
-
- foreach ($img_ary as $img)
- {
- if ($category == 'buttons')
- {
- foreach ($langs as $language)
- {
- $template->assign_block_vars('category.images', array(
- 'SELECTED' => ($img == $imgname && $language == $imgnamelang),
- 'VALUE' => $img . '-' . $language,
- 'TEXT' => $user->lang['IMG_' . strtoupper($img)] . ' [ ' . $language . ' ]'
- ));
- }
- }
- else
- {
- $template->assign_block_vars('category.images', array(
- 'SELECTED' => ($img == $imgname),
- 'VALUE' => $img,
- 'TEXT' => (($category == 'custom') ? $img : $user->lang['IMG_' . strtoupper($img)])
- ));
- }
- }
- }
-
- // Make sure the list of possible images is sorted alphabetically
- sort($imagesetlist['lang']);
- sort($imagesetlist['nolang']);
-
- $image_found = false;
- $img_val = '';
- foreach ($imagesetlist as $type => $img_ary)
- {
- if ($type !== 'lang' || $sql_extra)
- {
- $template->assign_block_vars('imagesetlist', array(
- 'TYPE' => ($type == 'lang')
- ));
- }
-
- foreach ($img_ary as $img)
- {
- $imgtext = preg_replace('/^([^\/]+\/)/', '', $img);
- $selected = (!empty($imgname) && strpos($image_filename, $imgtext) !== false);
- if ($selected)
- {
- $image_found = true;
- $img_val = htmlspecialchars($img);
- }
- $template->assign_block_vars('imagesetlist.images', array(
- 'SELECTED' => $selected,
- 'TEXT' => $imgtext,
- 'VALUE' => htmlspecialchars($img)
- ));
- }
- }
-
- $imgsize_bool = (!empty($imgname) && $image_width && $image_height) ? true : false;
- $image_request = '../styles/' . $imageset_path . '/imageset/' . ($image_lang ? $imgnamelang . '/' : '') . $image_filename;
-
- $template->assign_vars(array(
- 'S_EDIT_IMAGESET' => true,
- 'L_TITLE' => $user->lang[$this->page_title],
- 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
- 'IMAGE_OPTIONS' => $img_options,
- 'IMAGE_SIZE' => $image_width,
- 'IMAGE_HEIGHT' => $image_height,
- 'IMAGE_REQUEST' => (empty($image_filename)) ? 'images/no_image.png' : $image_request,
- 'U_ACTION' => $this->u_action . "&amp;action=edit&amp;id=$imageset_id",
- 'U_BACK' => $this->u_action,
- 'NAME' => $imageset_name,
- 'A_NAME' => addslashes($imageset_name),
- 'PATH' => $imageset_path,
- 'A_PATH' => addslashes($imageset_path),
- 'ERROR' => !$valid_name,
- 'IMG_SRC' => ($image_found) ? '../styles/' . $imageset_path . '/imageset/' . $img_val : 'images/no_image.png',
- 'IMAGE_SELECT' => $image_found
+ 'TEXT_ROWS' => $text_rows,
));
}
/**
- * Remove style/template/theme/imageset
+ * Remove style/template/theme
*/
function remove($mode, $style_id)
{
@@ -1588,23 +921,18 @@ parse_css_file = {PARSE_CSS_FILE}
{
case 'style':
$sql_from = STYLES_TABLE;
- $sql_select = 'style_id, style_name, template_id, theme_id, imageset_id';
+ $sql_select = 'style_id, style_name, template_id, theme_id';
$sql_where = 'AND style_active = 1';
break;
case 'template':
$sql_from = STYLES_TEMPLATE_TABLE;
- $sql_select = 'template_id, template_name, template_path, template_storedb';
+ $sql_select = 'template_id, template_name, template_path';
break;
case 'theme':
$sql_from = STYLES_THEME_TABLE;
- $sql_select = 'theme_id, theme_name, theme_path, theme_storedb';
- break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- $sql_select = 'imageset_id, imageset_name, imageset_path';
+ $sql_select = 'theme_id, theme_name, theme_path';
break;
}
@@ -1658,7 +986,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
// Remove the components
- $components = array('template', 'theme', 'imageset');
+ $components = array('template', 'theme');
foreach ($components as $component)
{
$new_id = request_var('new_' . $component . '_id', 0);
@@ -1707,7 +1035,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
/**
- * Remove template/theme/imageset entry from the database
+ * Remove template/theme entry from the database
*/
function remove_component($component, $component_id, $new_id, $style_id = false)
{
@@ -1731,13 +1059,6 @@ parse_css_file = {PARSE_CSS_FILE}
return;
}
- if ($component == 'imageset')
- {
- $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . "
- WHERE imageset_id = $component_id";
- $db->sql_query($sql);
- }
-
switch ($component)
{
case 'template':
@@ -1747,10 +1068,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;;
- break;
}
$sql = "DELETE FROM $sql_from
@@ -1764,7 +1081,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
/**
- * Display the options which can be used to replace a style/template/theme/imageset
+ * Display the options which can be used to replace a style/template/theme
*/
function display_component_options($component, $component_id, $style_row = false, $style_id = false)
{
@@ -1792,10 +1109,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$s_options = '';
@@ -1844,7 +1157,7 @@ parse_css_file = {PARSE_CSS_FILE}
$template->assign_var('S_REPLACE_OPTIONS', $s_options);
if ($component == 'style')
{
- $components = array('template', 'theme', 'imageset');
+ $components = array('template', 'theme');
foreach ($components as $component)
{
$this->display_component_options($component, $style_row[$component . '_id'], false, $component_id, true);
@@ -1906,7 +1219,6 @@ parse_css_file = {PARSE_CSS_FILE}
$inc_template = request_var('inc_template', 0);
$inc_theme = request_var('inc_theme', 0);
- $inc_imageset = request_var('inc_imageset', 0);
$store = request_var('store', 0);
$format = request_var('format', '');
@@ -1932,7 +1244,7 @@ parse_css_file = {PARSE_CSS_FILE}
switch ($mode)
{
case 'style':
- if ($update && ($inc_template + $inc_theme + $inc_imageset) < 1)
+ if ($update && ($inc_template + $inc_theme) < 1)
{
$error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS'];
}
@@ -1942,9 +1254,8 @@ parse_css_file = {PARSE_CSS_FILE}
$sql_select = 's.style_id, s.style_name, s.style_copyright';
$sql_select .= ($inc_template) ? ', t.*' : ', t.template_name';
$sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name';
- $sql_select .= ($inc_imageset) ? ', i.*' : ', i.imageset_name';
- $sql_from = STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . ' i';
- $sql_where = "s.style_id = $style_id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id";
+ $sql_from = STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c';
+ $sql_where = "s.style_id = $style_id AND t.template_id = s.template_id AND c.theme_id = s.theme_id";
$l_prefix = 'STYLE';
break;
@@ -1968,16 +1279,6 @@ parse_css_file = {PARSE_CSS_FILE}
$l_prefix = 'THEME';
break;
-
- case 'imageset':
- $name = 'imageset_name';
-
- $sql_select = '*';
- $sql_from = STYLES_IMAGESET_TABLE;
- $sql_where = "imageset_id = $style_id";
-
- $l_prefix = 'IMAGESET';
- break;
}
if ($update && !sizeof($error))
@@ -1994,7 +1295,7 @@ parse_css_file = {PARSE_CSS_FILE}
trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_storedb', 'template_inherits_id', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_storedb', 'theme_mtime', 'theme_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright');
+ $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_inherits_id', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright');
foreach ($var_ary as $var)
{
@@ -2012,7 +1313,6 @@ parse_css_file = {PARSE_CSS_FILE}
$style_cfg .= (!$inc_template) ? "\nrequired_template = {$style_row['template_name']}" : '';
$style_cfg .= (!$inc_theme) ? "\nrequired_theme = {$style_row['theme_name']}" : '';
- $style_cfg .= (!$inc_imageset) ? "\nrequired_imageset = {$style_row['imageset_name']}" : '';
$data[] = array(
'src' => $style_cfg,
@@ -2050,31 +1350,12 @@ parse_css_file = {PARSE_CSS_FILE}
);
// This is potentially nasty memory-wise ...
- if (!$style_row['template_storedb'])
- {
- $files[] = array(
- 'src' => "styles/{$style_row['template_path']}/template/",
- 'prefix-' => "styles/{$style_row['template_path']}/",
- 'prefix+' => false,
- 'exclude' => 'template.cfg'
- );
- }
- else
- {
- $sql = 'SELECT template_filename, template_data
- FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = {$style_row['template_id']}";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $data[] = array(
- 'src' => $row['template_data'],
- 'prefix' => 'template/' . $row['template_filename']
- );
- }
- $db->sql_freeresult($result);
- }
+ $files[] = array(
+ 'src' => "styles/{$style_row['template_path']}/template/",
+ 'prefix-' => "styles/{$style_row['template_path']}/",
+ 'prefix+' => false,
+ 'exclude' => 'template.cfg'
+ );
unset($template_cfg);
}
@@ -2087,130 +1368,21 @@ parse_css_file = {PARSE_CSS_FILE}
$items = $cache->obtain_cfg_items($style_row);
$items = $items['theme'];
- if (!isset($items['parse_css_file']))
- {
- $items['parse_css_file'] = 'off';
- }
-
- $theme_cfg = str_replace(array('{PARSE_CSS_FILE}'), array($items['parse_css_file']), $theme_cfg);
-
$files[] = array(
'src' => "styles/{$style_row['theme_path']}/theme/",
'prefix-' => "styles/{$style_row['theme_path']}/",
'prefix+' => false,
- 'exclude' => ($style_row['theme_storedb']) ? 'stylesheet.css,theme.cfg' : 'theme.cfg'
+ 'exclude' => 'theme.cfg',
);
$data[] = array(
'src' => $theme_cfg,
- 'prefix' => 'theme/theme.cfg'
+ 'prefix' => 'theme/theme.cfg',
);
- if ($style_row['theme_storedb'])
- {
- $data[] = array(
- 'src' => $style_row['theme_data'],
- 'prefix' => 'theme/stylesheet.css'
- );
- }
-
unset($items, $theme_cfg);
}
- // Export imageset core code
- if ($mode == 'imageset' || $inc_imageset)
- {
- $imageset_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['imageset_name'], $style_row['imageset_copyright'], $config['version']), $this->imageset_cfg);
-
- $imageset_main = array();
-
- $sql = 'SELECT image_filename, image_name, image_height, image_width
- FROM ' . STYLES_IMAGESET_DATA_TABLE . "
- WHERE imageset_id = $style_id
- AND image_lang = ''";
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
- {
- $imageset_main[$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: '');
- }
- $db->sql_freeresult($result);
-
- foreach ($this->imageset_keys as $topic => $key_array)
- {
- foreach ($key_array as $key)
- {
- if (isset($imageset_main[$key]))
- {
- $imageset_cfg .= "\nimg_" . $key . ' = ' . str_replace("styles/{$style_row['imageset_path']}/imageset/", '{PATH}', $imageset_main[$key]);
- }
- }
- }
-
- $files[] = array(
- 'src' => "styles/{$style_row['imageset_path']}/imageset/",
- 'prefix-' => "styles/{$style_row['imageset_path']}/",
- 'prefix+' => false,
- 'exclude' => 'imageset.cfg'
- );
-
- $data[] = array(
- 'src' => trim($imageset_cfg),
- 'prefix' => 'imageset/imageset.cfg'
- );
-
- end($data);
-
- $imageset_root = "{$phpbb_root_path}styles/{$style_row['imageset_path']}/imageset/";
-
- if ($dh = @opendir($imageset_root))
- {
- while (($fname = readdir($dh)) !== false)
- {
- if ($fname[0] != '.' && $fname != 'CVS' && is_dir("$imageset_root$fname"))
- {
- $files[key($files)]['exclude'] .= ',' . $fname . '/imageset.cfg';
- }
- }
- closedir($dh);
- }
-
- $imageset_lang = array();
-
- $sql = 'SELECT image_filename, image_name, image_height, image_width, image_lang
- FROM ' . STYLES_IMAGESET_DATA_TABLE . "
- WHERE imageset_id = $style_id
- AND image_lang <> ''";
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
- {
- $imageset_lang[$row['image_lang']][$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: '');
- }
- $db->sql_freeresult($result);
-
- foreach ($imageset_lang as $lang => $imageset_localized)
- {
- $imageset_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['imageset_name'], $style_row['imageset_copyright'], $config['version']), $this->imageset_cfg);
-
- foreach ($this->imageset_keys as $topic => $key_array)
- {
- foreach ($key_array as $key)
- {
- if (isset($imageset_localized[$key]))
- {
- $imageset_cfg .= "\nimg_" . $key . ' = ' . str_replace("styles/{$style_row['imageset_path']}/imageset/", '{PATH}', $imageset_localized[$key]);
- }
- }
- }
-
- $data[] = array(
- 'src' => trim($imageset_cfg),
- 'prefix' => 'imageset/' . $lang . '/imageset.cfg'
- );
- }
-
- unset($imageset_cfg);
- }
-
switch ($format)
{
case 'tar':
@@ -2335,7 +1507,7 @@ parse_css_file = {PARSE_CSS_FILE}
$l_type = strtoupper($mode);
$error = array();
- $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE);
+ $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE);
switch ($mode)
{
@@ -2350,10 +1522,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$sql = "SELECT *
@@ -2377,11 +1545,9 @@ parse_css_file = {PARSE_CSS_FILE}
$template_id = request_var('template_id', 0);
$theme_id = request_var('theme_id', 0);
- $imageset_id = request_var('imageset_id', 0);
$style_active = request_var('style_active', 0);
$style_default = request_var('style_default', 0);
- $store_db = request_var('store_db', 0);
// If the admin selected the style to be the default style, but forgot to activate it... we will do it for him
if ($style_default)
@@ -2397,7 +1563,7 @@ parse_css_file = {PARSE_CSS_FILE}
$conflict = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if ($mode == 'style' && (!$template_id || !$theme_id || !$imageset_id))
+ if ($mode == 'style' && (!$template_id || !$theme_id))
{
$error[] = $user->lang['STYLE_ERR_NO_IDS'];
}
@@ -2412,29 +1578,6 @@ parse_css_file = {PARSE_CSS_FILE}
$error[] = $user->lang[$l_type . '_ERR_STYLE_NAME'];
}
- if ($mode === 'theme' || $mode === 'template')
- {
- // a rather elaborate check we have to do here once to avoid trouble later
- $check = "{$phpbb_root_path}styles/" . $style_row["{$mode}_path"] . (($mode === 'theme') ? '/theme/stylesheet.css' : '/template');
- if (($style_row["{$mode}_storedb"] != $store_db) && !$store_db && ($safe_mode || !phpbb_is_writable($check)))
- {
- $error[] = $user->lang['EDIT_' . strtoupper($mode) . '_STORED_DB'];
- $store_db = 1;
- }
-
- // themes which have to be parsed have to go into db
- if ($mode == 'theme')
- {
- $cfg = parse_cfg_file("{$phpbb_root_path}styles/" . $style_row["{$mode}_path"] . "/theme/theme.cfg");
-
- if (isset($cfg['parse_css_file']) && $cfg['parse_css_file'] && !$store_db)
- {
- $error[] = $user->lang['EDIT_THEME_STORE_PARSED'];
- $store_db = 1;
- }
- }
- }
-
if (!sizeof($error))
{
// Check length settings
@@ -2455,9 +1598,7 @@ parse_css_file = {PARSE_CSS_FILE}
$style_row = array_merge($style_row, array(
'template_id' => $template_id,
'theme_id' => $theme_id,
- 'imageset_id' => $imageset_id,
'style_active' => $style_active,
- $mode . '_storedb' => $store_db,
$mode . '_name' => $name,
$mode . '_copyright' => $copyright)
);
@@ -2478,81 +1619,14 @@ parse_css_file = {PARSE_CSS_FILE}
$sql_ary += array(
'template_id' => (int) $template_id,
'theme_id' => (int) $theme_id,
- 'imageset_id' => (int) $imageset_id,
'style_active' => (int) $style_active,
);
break;
- case 'imageset':
- break;
-
case 'theme':
-
- if ($style_row['theme_storedb'] != $store_db)
- {
- $theme_data = '';
-
- if (!$style_row['theme_storedb'])
- {
- $theme_data = $this->db_theme_data($style_row);
- }
- else if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css"))
- {
- $store_db = 1;
- $theme_data = $style_row['theme_data'];
-
- if ($fp = @fopen("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css", 'wb'))
- {
- $store_db = (@fwrite($fp, str_replace("styles/{$style_row['theme_path']}/theme/", './', $theme_data))) ? 0 : 1;
- }
- fclose($fp);
- }
-
- $sql_ary += array(
- 'theme_mtime' => ($store_db) ? filemtime("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css") : 0,
- 'theme_storedb' => $store_db,
- 'theme_data' => ($store_db) ? $theme_data : '',
- );
- }
break;
case 'template':
-
- if ($style_row['template_storedb'] != $store_db)
- {
- if ($super = $this->get_super($mode, $style_row['template_id']))
- {
- $error[] = (sprintf($user->lang["{$l_type}_INHERITS"], $super['template_name']));
- $sql_ary = array();
- }
- else
- {
- if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['template_path']}/template"))
- {
- $err = $this->store_in_fs('template', $style_row['template_id']);
- if ($err)
- {
- $error += $err;
- }
- }
- else if ($store_db)
- {
- $this->store_in_db('template', $style_row['template_id']);
- }
- else
- {
- // We no longer store within the db, but are also not able to update the file structure
- // Since the admin want to switch this, we adhere to his decision. But we also need to remove the cache
- $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $style_id";
- $db->sql_query($sql);
- }
-
- $sql_ary += array(
- 'template_storedb' => $store_db,
- );
- }
- }
break;
}
@@ -2619,16 +1693,12 @@ parse_css_file = {PARSE_CSS_FILE}
'S_STYLE' => ($mode == 'style') ? true : false,
'S_TEMPLATE' => ($mode == 'template') ? true : false,
'S_THEME' => ($mode == 'theme') ? true : false,
- 'S_IMAGESET' => ($mode == 'imageset') ? true : false,
- 'S_STORE_DB' => (isset($style_row[$mode . '_storedb'])) ? $style_row[$mode . '_storedb'] : 0,
- 'S_STORE_DB_DISABLED' => (isset($style_row[$mode . '_inherits_id'])) ? $style_row[$mode . '_inherits_id'] : 0,
'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0,
'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0,
'S_SUPERTEMPLATE' => (isset($style_row[$mode . '_inherits_id']) && $style_row[$mode . '_inherits_id']) ? $super['template_name'] : 0,
'S_TEMPLATE_OPTIONS' => ($mode == 'style') ? $template_options : '',
'S_THEME_OPTIONS' => ($mode == 'style') ? $theme_options : '',
- 'S_IMAGESET_OPTIONS' => ($mode == 'style') ? $imageset_options : '',
'U_ACTION' => $this->u_action . '&amp;action=details&amp;id=' . $style_id,
'U_BACK' => $this->u_action,
@@ -2636,8 +1706,6 @@ parse_css_file = {PARSE_CSS_FILE}
'L_TITLE' => $user->lang[$this->page_title],
'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
'L_NAME' => $user->lang[$l_type . '_NAME'],
- 'L_LOCATION' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION'] : '',
- 'L_LOCATION_EXPLAIN' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION_EXPLAIN'] : '',
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'NAME' => $style_row[$mode . '_name'],
@@ -2724,84 +1792,6 @@ parse_css_file = {PARSE_CSS_FILE}
}
/**
- * Store template files into db
- */
- function store_templates($mode, $style_id, $template_path, $filelist)
- {
- global $phpbb_root_path, $phpEx, $db;
-
- $template_path = $template_path . '/template/';
- $includes = array();
- foreach ($filelist as $pathfile => $file_ary)
- {
- foreach ($file_ary as $file)
- {
- if (!($fp = @fopen("{$phpbb_root_path}styles/$template_path$pathfile$file", 'r')))
- {
- trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR);
- }
-
- $filesize = filesize("{$phpbb_root_path}styles/$template_path$pathfile$file");
-
- if ($filesize)
- {
- $template_data = fread($fp, $filesize);
- }
-
- fclose($fp);
-
- if (!$filesize)
- {
- // File is empty
- continue;
- }
-
- if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches))
- {
- foreach ($matches[1] as $match)
- {
- $includes[trim($match)][] = $file;
- }
- }
- }
- }
-
- foreach ($filelist as $pathfile => $file_ary)
- {
- foreach ($file_ary as $file)
- {
- // Skip index.
- if (strpos($file, 'index.') === 0)
- {
- continue;
- }
-
- // We could do this using extended inserts ... but that could be one
- // heck of a lot of data ...
- $sql_ary = array(
- 'template_id' => (int) $style_id,
- 'template_filename' => "$pathfile$file",
- 'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '',
- 'template_mtime' => (int) filemtime("{$phpbb_root_path}styles/$template_path$pathfile$file"),
- 'template_data' => (string) file_get_contents("{$phpbb_root_path}styles/$template_path$pathfile$file"),
- );
-
- if ($mode == 'insert')
- {
- $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- }
- else
- {
- $sql = 'UPDATE ' . STYLES_TEMPLATE_DATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE template_id = $style_id
- AND template_filename = '" . $db->sql_escape("$pathfile$file") . "'";
- }
- $db->sql_query($sql);
- }
- }
- }
-
- /**
* Returns an array containing all template filenames for one template that are currently cached.
*
* @param string $template_path contains the name of the template's folder in /styles/
@@ -2876,7 +1866,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
/**
- * Install Style/Template/Theme/Imageset
+ * Install Style/Template/Theme
*/
function install($mode)
{
@@ -2886,7 +1876,7 @@ parse_css_file = {PARSE_CSS_FILE}
$error = $installcfg = $style_row = array();
$root_path = $cfg_file = '';
- $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE);
+ $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE);
$install_path = request_var('path', '');
$update = (isset($_POST['update'])) ? true : false;
@@ -2932,7 +1922,6 @@ parse_css_file = {PARSE_CSS_FILE}
$reqd_template = (isset($installcfg['required_template'])) ? $installcfg['required_template'] : false;
$reqd_theme = (isset($installcfg['required_theme'])) ? $installcfg['required_theme'] : false;
- $reqd_imageset = (isset($installcfg['required_imageset'])) ? $installcfg['required_imageset'] : false;
// Check to see if each element is already installed, if it is grab the id
foreach ($element_ary as $element => $table)
@@ -2958,7 +1947,7 @@ parse_css_file = {PARSE_CSS_FILE}
$cfg_contents = parse_cfg_file($cfg_file);
// Merge only specific things. We may need them later.
- foreach (array('inherit_from', 'parse_css_file') as $key)
+ foreach (array('inherit_from') as $key)
{
if (!empty($cfg_contents[$key]) && !isset($installcfg[$key]))
{
@@ -2977,10 +1966,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$this->test_installed('theme', $error, $root_path, false, $style_row['theme_id'], $style_row['theme_name'], $style_row['theme_copyright']);
break;
-
- case 'imageset':
- $this->test_installed('imageset', $error, $root_path, false, $style_row['imageset_id'], $style_row['imageset_name'], $style_row['imageset_copyright']);
- break;
}
}
else
@@ -2988,7 +1973,6 @@ parse_css_file = {PARSE_CSS_FILE}
trigger_error($user->lang['NO_' . $l_type] . adm_back_link($this->u_action), E_USER_WARNING);
}
- $style_row['store_db'] = request_var('store_db', 0);
$style_row['style_active'] = request_var('style_active', 1);
$style_row['style_default'] = request_var('style_default', 0);
@@ -3002,19 +1986,18 @@ parse_css_file = {PARSE_CSS_FILE}
${$element . '_root_path'} = (${'reqd_' . $element}) ? $phpbb_root_path . 'styles/' . ${'reqd_' . $element} . '/' : false;
${$element . '_path'} = (${'reqd_' . $element}) ? ${'reqd_' . $element} : false;
}
- $this->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $install_path, $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row, $template_root_path, $template_path, $theme_root_path, $theme_path, $imageset_root_path, $imageset_path);
+ $this->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $install_path, $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row, $template_root_path, $template_path, $theme_root_path, $theme_path);
}
else
{
- $style_row['store_db'] = $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $install_path, $style_row[$mode . '_copyright'], $style_row['store_db']);
+ $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $install_path, $style_row[$mode . '_copyright']);
}
if (!sizeof($error))
{
$cache->destroy('sql', STYLES_TABLE);
- $message = ($style_row['store_db']) ? '_ADDED_DB' : '_ADDED';
- trigger_error($user->lang[$l_type . $message] . adm_back_link($this->u_action));
+ trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action));
}
}
@@ -3030,7 +2013,6 @@ parse_css_file = {PARSE_CSS_FILE}
'S_SUPERTEMPLATE' => (isset($installcfg['inherit_from'])) ? $installcfg['inherit_from'] : '',
'S_THEME' => ($mode == 'theme') ? true : false,
- 'S_STORE_DB' => (isset($style_row[$mode . '_storedb'])) ? $style_row[$mode . '_storedb'] : 0,
'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0,
'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0,
@@ -3040,15 +2022,12 @@ parse_css_file = {PARSE_CSS_FILE}
'L_TITLE' => $user->lang[$this->page_title],
'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
'L_NAME' => $user->lang[$l_type . '_NAME'],
- 'L_LOCATION' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION'] : '',
- 'L_LOCATION_EXPLAIN' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION_EXPLAIN'] : '',
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'NAME' => $style_row[$mode . '_name'],
'COPYRIGHT' => $style_row[$mode . '_copyright'],
'TEMPLATE_NAME' => ($mode == 'style') ? $style_row['template_name'] : '',
- 'THEME_NAME' => ($mode == 'style') ? $style_row['theme_name'] : '',
- 'IMAGESET_NAME' => ($mode == 'style') ? $style_row['imageset_name'] : '')
+ 'THEME_NAME' => ($mode == 'style') ? $style_row['theme_name'] : '')
);
}
@@ -3060,7 +2039,7 @@ parse_css_file = {PARSE_CSS_FILE}
global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template;
$l_type = strtoupper($mode);
- $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE);
+ $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE);
$error = array();
$style_row = array(
@@ -3068,8 +2047,6 @@ parse_css_file = {PARSE_CSS_FILE}
$mode . '_copyright' => utf8_normalize_nfc(request_var('copyright', '', true)),
'template_id' => 0,
'theme_id' => 0,
- 'imageset_id' => 0,
- 'store_db' => request_var('store_db', 0),
'style_active' => request_var('style_active', 1),
'style_default' => request_var('style_default', 0),
);
@@ -3082,7 +2059,7 @@ parse_css_file = {PARSE_CSS_FILE}
switch ($mode)
{
case 'style':
- $sql_select = 'template_id, theme_id, imageset_id';
+ $sql_select = 'template_id, theme_id';
$sql_from = STYLES_TABLE;
break;
@@ -3095,11 +2072,6 @@ parse_css_file = {PARSE_CSS_FILE}
$sql_select = 'theme_id';
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_select = 'imageset_id';
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$sql = "SELECT $sql_select
@@ -3118,7 +2090,6 @@ parse_css_file = {PARSE_CSS_FILE}
{
$style_row['template_id'] = (isset($row['template_id'])) ? $row['template_id'] : $style_row['template_id'];
$style_row['theme_id'] = (isset($row['theme_id'])) ? $row['theme_id'] : $style_row['theme_id'];
- $style_row['imageset_id'] = (isset($row['imageset_id'])) ? $row['imageset_id'] : $style_row['imageset_id'];
}
}
@@ -3126,9 +2097,8 @@ parse_css_file = {PARSE_CSS_FILE}
{
$style_row['template_id'] = request_var('template_id', $style_row['template_id']);
$style_row['theme_id'] = request_var('theme_id', $style_row['theme_id']);
- $style_row['imageset_id'] = request_var('imageset_id', $style_row['imageset_id']);
- if ($mode == 'style' && (!$style_row['template_id'] || !$style_row['theme_id'] || !$style_row['imageset_id']))
+ if ($mode == 'style' && (!$style_row['template_id'] || !$style_row['theme_id']))
{
$error[] = $user->lang['STYLE_ERR_NO_IDS'];
}
@@ -3148,8 +2118,7 @@ parse_css_file = {PARSE_CSS_FILE}
{
$cache->destroy('sql', STYLES_TABLE);
- $message = ($style_row['store_db']) ? '_ADDED_DB' : '_ADDED';
- trigger_error($user->lang[$l_type . $message] . adm_back_link($this->u_action));
+ trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action));
}
}
@@ -3183,12 +2152,10 @@ parse_css_file = {PARSE_CSS_FILE}
'S_THEME' => ($mode == 'theme') ? true : false,
'S_BASIS' => ($basis) ? true : false,
- 'S_STORE_DB' => (isset($style_row['storedb'])) ? $style_row['storedb'] : 0,
'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0,
'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0,
'S_TEMPLATE_OPTIONS' => ($mode == 'style') ? $template_options : '',
'S_THEME_OPTIONS' => ($mode == 'style') ? $theme_options : '',
- 'S_IMAGESET_OPTIONS' => ($mode == 'style') ? $imageset_options : '',
'U_ACTION' => $this->u_action . '&amp;action=add&amp;basis=' . $basis,
'U_BACK' => $this->u_action,
@@ -3196,8 +2163,6 @@ parse_css_file = {PARSE_CSS_FILE}
'L_TITLE' => $user->lang[$this->page_title],
'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
'L_NAME' => $user->lang[$l_type . '_NAME'],
- 'L_LOCATION' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION'] : '',
- 'L_LOCATION_EXPLAIN' => ($mode == 'template' || $mode == 'theme') ? $user->lang[$l_type . '_LOCATION_EXPLAIN'] : '',
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'NAME' => $style_row[$mode . '_name'],
@@ -3210,7 +2175,6 @@ parse_css_file = {PARSE_CSS_FILE}
$reqd_template = (isset($installcfg['required_template'])) ? $installcfg['required_template'] : false;
$reqd_theme = (isset($installcfg['required_theme'])) ? $installcfg['required_theme'] : false;
- $reqd_imageset = (isset($installcfg['required_imageset'])) ? $installcfg['required_imageset'] : false;
// Check to see if each element is already installed, if it is grab the id
foreach ($element_ary as $element => $table)
@@ -3237,10 +2201,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$l_element = strtoupper($element);
@@ -3279,11 +2239,11 @@ parse_css_file = {PARSE_CSS_FILE}
/**
* Install/Add style
*/
- function install_style(&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false, $imageset_root_path = false, $imageset_path = false)
+ function install_style(&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false)
{
global $config, $db, $user;
- $element_ary = array('template', 'theme', 'imageset');
+ $element_ary = array('template', 'theme');
if (!$name)
{
@@ -3329,7 +2289,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
}
- if (!$style_row['template_id'] || !$style_row['theme_id'] || !$style_row['imageset_id'])
+ if (!$style_row['template_id'] || !$style_row['theme_id'])
{
$error[] = $user->lang['STYLE_ERR_NO_IDS'];
}
@@ -3347,7 +2307,6 @@ parse_css_file = {PARSE_CSS_FILE}
'style_active' => (int) $active,
'template_id' => (int) $style_row['template_id'],
'theme_id' => (int) $style_row['theme_id'],
- 'imageset_id' => (int) $style_row['imageset_id'],
);
$sql = 'INSERT INTO ' . STYLES_TABLE . '
@@ -3374,7 +2333,7 @@ parse_css_file = {PARSE_CSS_FILE}
/**
* Install/add an element, doing various checks as we go
*/
- function install_element($mode, &$error, $action, $root_path, &$id, $name, $path, $copyright, $store_db = 0)
+ function install_element($mode, &$error, $action, $root_path, &$id, $name, $path, $copyright)
{
global $phpbb_root_path, $db, $user;
@@ -3390,10 +2349,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$l_type = strtoupper($mode);
@@ -3445,7 +2400,7 @@ parse_css_file = {PARSE_CSS_FILE}
$select_bf = '';
}
- $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, {$mode}_storedb $select_bf
+ $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, $select_bf
FROM $sql_from
WHERE {$mode}_name = '" . $db->sql_escape($cfg_data['inherit_from']) . "'
AND {$mode}_inherits_id = 0";
@@ -3461,8 +2416,6 @@ parse_css_file = {PARSE_CSS_FILE}
$inherit_id = $row["{$mode}_id"];
$inherit_path = $row["{$mode}_path"];
$inherit_bf = ($mode === 'template') ? $row["bbcode_bitfield"] : false;
- $cfg_data['store_db'] = $row["{$mode}_storedb"];
- $store_db = $row["{$mode}_storedb"];
}
}
else
@@ -3500,10 +2453,6 @@ parse_css_file = {PARSE_CSS_FILE}
$sql_ary['bbcode_bitfield'] = $this->template_bitfield;
}
- // We set a pre-defined bitfield here which we may use further in 3.2
- $sql_ary += array(
- 'template_storedb' => $store_db,
- );
if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from'])
{
$sql_ary += array(
@@ -3514,22 +2463,6 @@ parse_css_file = {PARSE_CSS_FILE}
break;
case 'theme':
- // We are only interested in the theme configuration for now
-
- if (isset($cfg_data['parse_css_file']) && $cfg_data['parse_css_file'])
- {
- $store_db = 1;
- }
-
- $sql_ary += array(
- 'theme_storedb' => $store_db,
- 'theme_data' => ($store_db) ? $this->db_theme_data($sql_ary, false, $root_path) : '',
- 'theme_mtime' => (int) filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css")
- );
- break;
-
- // all the heavy lifting is done later
- case 'imageset':
break;
}
@@ -3541,119 +2474,9 @@ parse_css_file = {PARSE_CSS_FILE}
$id = $db->sql_nextid();
- if ($mode == 'template' && $store_db)
- {
- $filelist = filelist("{$root_path}template", '', 'html');
- $this->store_templates('insert', $id, $path, $filelist);
- }
- else if ($mode == 'imageset')
- {
- $cfg_data = parse_cfg_file("$root_path$mode/imageset.cfg");
-
- $imageset_definitions = array();
- foreach ($this->imageset_keys as $topic => $key_array)
- {
- $imageset_definitions = array_merge($imageset_definitions, $key_array);
- }
-
- foreach ($cfg_data as $key => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($key, 'img_') === 0 && $image_filename)
- {
- $key = substr($key, 4);
- if (in_array($key, $imageset_definitions))
- {
- $sql_ary = array(
- 'image_name' => $key,
- 'image_filename' => str_replace('{PATH}', "styles/$path/imageset/", trim($image_filename)),
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $id,
- 'image_lang' => '',
- );
- $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
- }
- }
- }
- unset($cfg_data);
-
- $sql = 'SELECT lang_dir
- FROM ' . LANG_TABLE;
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (@file_exists("$root_path$mode/{$row['lang_dir']}/imageset.cfg"))
- {
- $cfg_data_imageset_data = parse_cfg_file("$root_path$mode/{$row['lang_dir']}/imageset.cfg");
- foreach ($cfg_data_imageset_data as $image_name => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($image_name, 'img_') === 0 && $image_filename)
- {
- $image_name = substr($image_name, 4);
- if (in_array($image_name, $imageset_definitions))
- {
- $sql_ary = array(
- 'image_name' => $image_name,
- 'image_filename' => $image_filename,
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $id,
- 'image_lang' => $row['lang_dir'],
- );
- $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
- }
- }
- }
- unset($cfg_data_imageset_data);
- }
- }
- $db->sql_freeresult($result);
- }
-
$db->sql_transaction('commit');
- $log = ($store_db) ? 'LOG_' . $l_type . '_ADD_DB' : 'LOG_' . $l_type . '_ADD_FS';
- add_log('admin', $log, $name);
-
- // Return store_db in case it had to be altered
- return $store_db;
+ add_log('admin', 'LOG_' . $l_type . '_ADD_FS', $name);
}
/**
@@ -3679,10 +2502,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path
@@ -3735,10 +2554,6 @@ parse_css_file = {PARSE_CSS_FILE}
case 'theme':
$sql_from = STYLES_THEME_TABLE;
break;
-
- case 'imageset':
- $sql_from = STYLES_IMAGESET_TABLE;
- break;
}
$sql = "SELECT {$mode}_inherits_id
@@ -3770,180 +2585,4 @@ parse_css_file = {PARSE_CSS_FILE}
return false;
}
-
- /**
- * Moves a template set and its subtemplates to the database
- *
- * @access public
- * @param string $mode The component to move - only template is supported
- * @param int $id The template id
- */
- function store_in_db($mode, $id)
- {
- global $db, $user;
-
- $error = array();
- $l_type = strtoupper($mode);
- if ($super = $this->get_super($mode, $id))
- {
- $error[] = (sprintf($user->lang["{$l_type}_INHERITS"], $super['template_name']));
- return $error;
- }
-
- $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path
- FROM " . STYLES_TEMPLATE_TABLE . '
- WHERE template_id = ' . (int) $id;
-
- $result = $db->sql_query_limit($sql, 1);
- if ($row = $db->sql_fetchrow($result))
- {
- $db->sql_freeresult($result);
- $subs = $this->check_inheritance($mode, $id);
-
- $this->_store_in_db($mode, $id, $row["{$mode}_path"]);
- if ($subs && sizeof($subs))
- {
- foreach ($subs as $sub_id => $sub)
- {
- if ($err = $this->_store_in_db($mode, $sub["{$mode}_id"], $sub["{$mode}_path"]))
- {
- $error[] = $err;
- }
- }
- }
- }
- if (sizeof($error))
- {
- return $error;
- }
-
- return false;
- }
-
- /**
- * Moves a template set to the database
- *
- * @access private
- * @param string $mode The component to move - only template is supported
- * @param int $id The template id
- * @param string $path TThe path to the template files
- */
- function _store_in_db($mode, $id, $path)
- {
- global $phpbb_root_path, $db;
-
- $filelist = filelist("{$phpbb_root_path}styles/{$path}/template", '', 'html');
- $this->store_templates('insert', $id, $path, $filelist);
-
- // Okay, we do the query here -shouldn't be triggered often.
- $sql = 'UPDATE ' . STYLES_TEMPLATE_TABLE . '
- SET template_storedb = 1
- WHERE template_id = ' . $id;
- $db->sql_query($sql);
- }
-
- /**
- * Moves a template set and its subtemplates to the filesystem
- *
- * @access public
- * @param string $mode The component to move - only template is supported
- * @param int $id The template id
- */
- function store_in_fs($mode, $id)
- {
- global $db, $user;
-
- $error = array();
- $l_type = strtoupper($mode);
- if ($super = $this->get_super($mode, $id))
- {
- $error[] = (sprintf($user->lang["{$l_type}_INHERITS"], $super['template_name']));
- return($error);
- }
-
- $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path
- FROM " . STYLES_TEMPLATE_TABLE . '
- WHERE template_id = ' . (int) $id;
-
- $result = $db->sql_query_limit($sql, 1);
- if ($row = $db->sql_fetchrow($result))
- {
- $db->sql_freeresult($result);
- if (!sizeof($error))
- {
- $subs = $this->check_inheritance($mode, $id);
-
- $this->_store_in_fs($mode, $id, $row["{$mode}_path"]);
-
- if ($subs && sizeof($subs))
- {
- foreach ($subs as $sub_id => $sub)
- {
- $this->_store_in_fs($mode, $sub["{$mode}_id"], $sub["{$mode}_path"]);
- }
- }
- }
- if (sizeof($error))
- {
- $this->store_in_db($id, $mode);
- return $error;
- }
- }
- return false;
- }
-
- /**
- * Moves a template set to the filesystem
- *
- * @access private
- * @param string $mode The component to move - only template is supported
- * @param int $id The template id
- * @param string $path The path to the template
- */
- function _store_in_fs($mode, $id, $path)
- {
- global $phpbb_root_path, $db, $user, $safe_mode;
-
- $store_db = 0;
- $error = array();
- if (!$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$path}/template"))
- {
- $sql = 'SELECT *
- FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $id";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (!($fp = @fopen("{$phpbb_root_path}styles/{$path}/template/" . $row['template_filename'], 'wb')))
- {
- $store_db = 1;
- $error[] = $user->lang['EDIT_TEMPLATE_STORED_DB'];
- break;
- }
-
- fwrite($fp, $row['template_data']);
- fclose($fp);
- }
- $db->sql_freeresult($result);
-
- if (!$store_db)
- {
- $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
- WHERE template_id = $id";
- $db->sql_query($sql);
- }
- }
- if (sizeof($error))
- {
- return $error;
- }
- $sql = 'UPDATE ' . STYLES_TEMPLATE_TABLE . '
- SET template_storedb = 0
- WHERE template_id = ' . $id;
- $db->sql_query($sql);
-
- return false;
- }
-
}
diff --git a/phpBB/includes/acp/info/acp_styles.php b/phpBB/includes/acp/info/acp_styles.php
index d6afd53cef..bdcceb1b7d 100644
--- a/phpBB/includes/acp/info/acp_styles.php
+++ b/phpBB/includes/acp/info/acp_styles.php
@@ -23,7 +23,6 @@ class acp_styles_info
'style' => array('title' => 'ACP_STYLES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_MANAGEMENT')),
'template' => array('title' => 'ACP_TEMPLATES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_COMPONENTS')),
'theme' => array('title' => 'ACP_THEMES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_COMPONENTS')),
- 'imageset' => array('title' => 'ACP_IMAGESETS', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_COMPONENTS')),
),
);
}
diff --git a/phpBB/includes/error_collector.php b/phpBB/includes/error_collector.php
index 55834f354c..3c0a89a1f3 100644
--- a/phpBB/includes/error_collector.php
+++ b/phpBB/includes/error_collector.php
@@ -49,13 +49,15 @@ class phpbb_error_collector
{
$text .= "<br />\n";
}
+
list($errno, $msg_text, $errfile, $errline) = $error;
- $text .= "Errno $errno: $msg_text";
- if (defined('DEBUG_EXTRA') || defined('IN_INSTALL'))
- {
- $text .= " at $errfile line $errline";
- }
+
+ // Prevent leakage of local path to phpBB install
+ $errfile = phpbb_filter_root_path($errfile);
+
+ $text .= "Errno $errno: $msg_text at $errfile line $errline";
}
+
return $text;
}
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 0d0b431cc2..5ccb9edd07 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3156,61 +3156,44 @@ function add_log()
}
/**
-* Return a nicely formatted backtrace (parts from the php manual by diz at ysagoon dot com)
+* Return a nicely formatted backtrace.
+*
+* Turns the array returned by debug_backtrace() into HTML markup.
+* Also filters out absolute paths to phpBB root.
+*
+* @return string HTML markup
*/
function get_backtrace()
{
- global $phpbb_root_path;
-
$output = '<div style="font-family: monospace;">';
$backtrace = debug_backtrace();
- $path = phpbb_realpath($phpbb_root_path);
- foreach ($backtrace as $number => $trace)
- {
- // We skip the first one, because it only shows this file/function
- if ($number == 0)
- {
- continue;
- }
+ // We skip the first one, because it only shows this file/function
+ unset($backtrace[0]);
+ foreach ($backtrace as $trace)
+ {
// Strip the current directory from path
- if (empty($trace['file']))
- {
- $trace['file'] = '';
- }
- else
- {
- $trace['file'] = str_replace(array($path, '\\'), array('', '/'), $trace['file']);
- $trace['file'] = substr($trace['file'], 1);
- }
- $args = array();
+ $trace['file'] = (empty($trace['file'])) ? '(not given by php)' : htmlspecialchars(phpbb_filter_root_path($trace['file']));
+ $trace['line'] = (empty($trace['line'])) ? '(not given by php)' : $trace['line'];
- // If include/require/include_once is not called, do not show arguments - they may contain sensible information
- if (!in_array($trace['function'], array('include', 'require', 'include_once')))
- {
- unset($trace['args']);
- }
- else
+ // Only show function arguments for include etc.
+ // Other parameters may contain sensible information
+ $argument = '';
+ if (!empty($trace['args'][0]) && in_array($trace['function'], array('include', 'require', 'include_once', 'require_once')))
{
- // Path...
- if (!empty($trace['args'][0]))
- {
- $argument = htmlspecialchars($trace['args'][0]);
- $argument = str_replace(array($path, '\\'), array('', '/'), $argument);
- $argument = substr($argument, 1);
- $args[] = "'{$argument}'";
- }
+ $argument = htmlspecialchars(phpbb_filter_root_path($trace['args'][0]));
}
$trace['class'] = (!isset($trace['class'])) ? '' : $trace['class'];
$trace['type'] = (!isset($trace['type'])) ? '' : $trace['type'];
$output .= '<br />';
- $output .= '<b>FILE:</b> ' . htmlspecialchars($trace['file']) . '<br />';
+ $output .= '<b>FILE:</b> ' . $trace['file'] . '<br />';
$output .= '<b>LINE:</b> ' . ((!empty($trace['line'])) ? $trace['line'] : '') . '<br />';
- $output .= '<b>CALL:</b> ' . htmlspecialchars($trace['class'] . $trace['type'] . $trace['function']) . '(' . ((sizeof($args)) ? implode(', ', $args) : '') . ')<br />';
+ $output .= '<b>CALL:</b> ' . htmlspecialchars($trace['class'] . $trace['type'] . $trace['function']);
+ $output .= '(' . (($argument !== '') ? "'$argument'" : '') . ')<br />';
}
$output .= '</div>';
return $output;
@@ -3759,9 +3742,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
{
- // remove complete path to installation, with the risk of changing backslashes meant to be there
- $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
- $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
+ $errfile = phpbb_filter_root_path($errfile);
+ $msg_text = phpbb_filter_root_path($msg_text);
$error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice';
echo '<b>[phpBB Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
@@ -3940,6 +3922,29 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
/**
+* Removes absolute path to phpBB root directory from error messages
+* and converts backslashes to forward slashes.
+*
+* @param string $errfile Absolute file path
+* (e.g. /var/www/phpbb3/phpBB/includes/functions.php)
+* Please note that if $errfile is outside of the phpBB root,
+* the root path will not be found and can not be filtered.
+* @return string Relative file path
+* (e.g. /includes/functions.php)
+*/
+function phpbb_filter_root_path($errfile)
+{
+ static $root_path;
+
+ if (empty($root_path))
+ {
+ $root_path = phpbb_realpath(dirname(__FILE__) . '/../');
+ }
+
+ return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile);
+}
+
+/**
* Queries the session table to get information about online guests
* @param int $item_id Limits the search to the item with this id
* @param string $item The name of the item which is stored in the session table as session_{$item}_id
@@ -4554,8 +4559,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme',
'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template',
'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template',
- 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset',
- 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->lang_name,
'T_IMAGES_PATH' => "{$web_path}images/",
'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/",
'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/",
@@ -4563,14 +4566,14 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/",
'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/",
- 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&amp;lang=' . $user->lang_name),
+ 'T_STYLESHEET_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css',
+ 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css',
'T_STYLESHEET_NAME' => $user->theme['theme_name'],
'T_THEME_NAME' => $user->theme['theme_path'],
+ 'T_THEME_LANG_NAME' => $user->data['user_lang'],
'T_TEMPLATE_NAME' => $user->theme['template_path'],
'T_SUPER_TEMPLATE_NAME' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? $user->theme['template_inherit_path'] : $user->theme['template_path'],
- 'T_IMAGESET_NAME' => $user->theme['imageset_path'],
- 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'],
'T_IMAGES' => 'images',
'T_SMILIES' => $config['smilies_path'],
'T_AVATAR' => $config['avatar_path'],
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 131e3c1321..08442f0913 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -458,7 +458,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$l_post_click_count => $post_click_count,
'FORUM_IMG_STYLE' => $folder_image,
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
- 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '',
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 1866733545..b94957a85f 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -976,9 +976,16 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
$smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
// Ok we have error checked as much as we can to this point let's get on it already.
- ob_start();
+ if (!class_exists('phpbb_error_collector'))
+ {
+ global $phpbb_root_path, $phpEx;
+ include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
+ }
+ $collector = new phpbb_error_collector;
+ $collector->install();
$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
- $error_contents = ob_get_clean();
+ $collector->uninstall();
+ $error_contents = $collector->format_errors();
if (!$smtp->socket)
{
@@ -1609,18 +1616,27 @@ function mail_encode($str, $eol = "\r\n")
*/
function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg)
{
- global $config;
+ global $config, $phpbb_root_path, $phpEx;
// We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used...
// Reference: http://bugs.php.net/bug.php?id=15841
$headers = implode($eol, $headers);
- ob_start();
+ if (!class_exists('phpbb_error_collector'))
+ {
+ include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
+ }
+
+ $collector = new phpbb_error_collector;
+ $collector->install();
+
// On some PHP Versions mail() *may* fail if there are newlines within the subject.
// Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8.
// Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used)
$result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
- $err_msg = ob_get_clean();
+
+ $collector->uninstall();
+ $err_msg = $collector->format_errors();
return $result;
}
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index f170dd68eb..8206a183f3 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -227,7 +227,6 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'TOPIC_IMG_STYLE' => $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
- 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index e734c8074f..bd2257c139 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -1655,12 +1655,11 @@ class user extends session
$style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']);
}
- $sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
- FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
+ $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_name, c.theme_id
+ FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c
WHERE s.style_id = $style
AND t.template_id = s.template_id
- AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id";
+ AND c.theme_id = s.theme_id";
$result = $db->sql_query($sql, 3600);
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -1675,12 +1674,11 @@ class user extends session
WHERE user_id = {$this->data['user_id']}";
$db->sql_query($sql);
- $sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
- FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
+ $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_id
+ FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c
WHERE s.style_id = $style
AND t.template_id = s.template_id
- AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id";
+ AND c.theme_id = s.theme_id";
$result = $db->sql_query($sql, 3600);
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -1698,7 +1696,6 @@ class user extends session
$parsed_items = $parsed_items['theme'];
$check_for = array(
- 'parse_css_file' => (int) 0,
'pagination_sep' => (string) ', '
);
@@ -1713,143 +1710,9 @@ class user extends session
}
}
- // If the style author specified the theme needs to be cached
- // (because of the used paths and variables) than make sure it is the case.
- // For example, if the theme uses language-specific images it needs to be stored in db.
- if (!$this->theme['theme_storedb'] && $this->theme['parse_css_file'])
- {
- $this->theme['theme_storedb'] = 1;
-
- $stylesheet = file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/stylesheet.css");
- // Match CSS imports
- $matches = array();
- preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);
-
- if (sizeof($matches))
- {
- $content = '';
- foreach ($matches[0] as $idx => $match)
- {
- if ($content = @file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/" . $matches[1][$idx]))
- {
- $content = trim($content);
- }
- else
- {
- $content = '';
- }
- $stylesheet = str_replace($match, $content, $stylesheet);
- }
- unset($content);
- }
-
- $stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet);
-
- $sql_ary = array(
- 'theme_data' => $stylesheet,
- 'theme_mtime' => time(),
- 'theme_storedb' => 1
- );
-
- $sql = 'UPDATE ' . STYLES_THEME_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
- WHERE theme_id = ' . $this->theme['theme_id'];
- $db->sql_query($sql);
-
- unset($sql_ary);
- }
-
$template->set_template();
- $this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang'];
-
- // Same query in style.php
- $sql = 'SELECT *
- FROM ' . STYLES_IMAGESET_DATA_TABLE . '
- WHERE imageset_id = ' . $this->theme['imageset_id'] . "
- AND image_filename <> ''
- AND image_lang IN ('" . $db->sql_escape($this->img_lang) . "', '')";
- $result = $db->sql_query($sql, 3600);
-
- $localised_images = false;
- while ($row = $db->sql_fetchrow($result))
- {
- if ($row['image_lang'])
- {
- $localised_images = true;
- }
-
- $row['image_filename'] = rawurlencode($row['image_filename']);
- $this->img_array[$row['image_name']] = $row;
- }
- $db->sql_freeresult($result);
-
- // there were no localised images, try to refresh the localised imageset for the user's language
- if (!$localised_images)
- {
- // Attention: this code ignores the image definition list from acp_styles and just takes everything
- // that the config file contains
- $sql_ary = array();
-
- $db->sql_transaction('begin');
-
- $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . '
- WHERE imageset_id = ' . $this->theme['imageset_id'] . '
- AND image_lang = \'' . $db->sql_escape($this->img_lang) . '\'';
- $result = $db->sql_query($sql);
-
- if (@file_exists("{$phpbb_root_path}styles/{$this->theme['imageset_path']}/imageset/{$this->img_lang}/imageset.cfg"))
- {
- $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$this->theme['imageset_path']}/imageset/{$this->img_lang}/imageset.cfg");
- foreach ($cfg_data_imageset_data as $image_name => $value)
- {
- if (strpos($value, '*') !== false)
- {
- if (substr($value, -1, 1) === '*')
- {
- list($image_filename, $image_height) = explode('*', $value);
- $image_width = 0;
- }
- else
- {
- list($image_filename, $image_height, $image_width) = explode('*', $value);
- }
- }
- else
- {
- $image_filename = $value;
- $image_height = $image_width = 0;
- }
-
- if (strpos($image_name, 'img_') === 0 && $image_filename)
- {
- $image_name = substr($image_name, 4);
- $sql_ary[] = array(
- 'image_name' => (string) $image_name,
- 'image_filename' => (string) $image_filename,
- 'image_height' => (int) $image_height,
- 'image_width' => (int) $image_width,
- 'imageset_id' => (int) $this->theme['imageset_id'],
- 'image_lang' => (string) $this->img_lang,
- );
- }
- }
- }
-
- if (sizeof($sql_ary))
- {
- $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
- $db->sql_transaction('commit');
- $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
-
- add_log('admin', 'LOG_IMAGESET_LANG_REFRESHED', $this->theme['imageset_name'], $this->img_lang);
- }
- else
- {
- $db->sql_transaction('commit');
- add_log('admin', 'LOG_IMAGESET_LANG_MISSING', $this->theme['imageset_name'], $this->img_lang);
- }
- }
+ $this->img_lang = $this->lang_name;
// Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes...
// After calling it we continue script execution...
@@ -2284,89 +2147,11 @@ class user extends session
/**
* Specify/Get image
- * $suffix is no longer used - we know it. ;) It is there for backward compatibility.
*/
- function img($img, $alt = '', $width = false, $suffix = '', $type = 'full_tag')
+ function img($img, $alt = '')
{
- static $imgs;
- global $phpbb_root_path;
-
- $img_data = &$imgs[$img];
-
- if (empty($img_data))
- {
- if (!isset($this->img_array[$img]))
- {
- // Do not fill the image to let designers decide what to do if the image is empty
- $img_data = '';
- return $img_data;
- }
-
- // Use URL if told so
- $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
-
- $path = 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename'];
-
- $img_data['src'] = $root_path . $path;
- $img_data['width'] = $this->img_array[$img]['image_width'];
- $img_data['height'] = $this->img_array[$img]['image_height'];
-
- // We overwrite the width and height to the phpbb logo's width
- // and height here if the contents of the site_logo file are
- // really equal to the phpbb_logo
- // This allows us to change the dimensions of the phpbb_logo without
- // modifying the imageset.cfg and causing a conflict for everyone
- // who modified it for their custom logo on updating
- if ($img == 'site_logo' && file_exists($phpbb_root_path . $path))
- {
- global $cache;
-
- $img_file_hashes = $cache->get('imageset_site_logo_md5');
-
- if ($img_file_hashes === false)
- {
- $img_file_hashes = array();
- }
-
- $key = $this->theme['imageset_path'] . '::' . $this->img_array[$img]['image_lang'];
- if (!isset($img_file_hashes[$key]))
- {
- $img_file_hashes[$key] = md5(file_get_contents($phpbb_root_path . $path));
- $cache->put('imageset_site_logo_md5', $img_file_hashes);
- }
-
- $phpbb_logo_hash = '0c461a32cd3621643105f0d02a772c10';
-
- if ($phpbb_logo_hash == $img_file_hashes[$key])
- {
- $img_data['width'] = '149';
- $img_data['height'] = '52';
- }
- }
- }
-
$alt = (!empty($this->lang[$alt])) ? $this->lang[$alt] : $alt;
-
- switch ($type)
- {
- case 'src':
- return $img_data['src'];
- break;
-
- case 'width':
- return ($width === false) ? $img_data['width'] : $width;
- break;
-
- case 'height':
- return $img_data['height'];
- break;
-
- default:
- $use_width = ($width === false) ? $img_data['width'] : $width;
-
- return '<img src="' . $img_data['src'] . '"' . (($use_width) ? ' width="' . $use_width . '"' : '') . (($img_data['height']) ? ' height="' . $img_data['height'] . '"' : '') . ' alt="' . $alt . '" title="' . $alt . '" />';
- break;
- }
+ return '<span class="imageset ' . $img . '">' . $alt . '</span>';
}
/**
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index 1d1d92378e..f24c3f4d09 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -307,12 +307,13 @@ class phpbb_template_filter extends php_user_filter
}
/**
- * Compile variables
+ * Convert template variables into PHP varrefs
*
* @param string $text_blocks Variable reference in source template
- * @return string compiled template code
+ * @param bool $is_expr Returns whether the source was an expression type variable (i.e. S_FIRST_ROW)
+ * @return string PHP variable name
*/
- private function compile_var_tags(&$text_blocks)
+ private function get_varref($text_blocks, &$is_expr)
{
// change template varrefs into PHP varrefs
$varrefs = array();
@@ -324,17 +325,38 @@ class phpbb_template_filter extends php_user_filter
{
$namespace = $var_val[1];
$varname = $var_val[3];
- $new = $this->generate_block_varref($namespace, $varname, true, $var_val[2]);
+ $new = $this->generate_block_varref($namespace, $varname, $is_expr, $var_val[2]);
$text_blocks = str_replace($var_val[0], $new, $text_blocks);
}
- // Handle special language tags L_ and LA_
- $this->compile_language_tags($text_blocks);
+ // Language variables cannot be reduced to a single varref, so they must be skipped
+ // These two replacements would break language variables, so we can only run them on non-language types
+ if (strpos($text_blocks, '{L_') === false && strpos($text_blocks, '{LA_') === false)
+ {
+ // This will handle the remaining root-level varrefs
+ $text_blocks = preg_replace('#\{(' . self::REGEX_VAR . ')\}#', "\$_rootref['\\1']", $text_blocks);
+ $text_blocks = preg_replace('#\{\$(' . self::REGEX_VAR . ')\}#', "\$_tpldata['DEFINE']['.']['\\1']", $text_blocks);
+ }
- // This will handle the remaining root-level varrefs
- $text_blocks = preg_replace('#\{(' . self::REGEX_VAR . ')\}#', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; /**/?>", $text_blocks);
- $text_blocks = preg_replace('#\{\$(' . self::REGEX_VAR . ')\}#', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; /**/?>", $text_blocks);
+ return $text_blocks;
+ }
+
+ /**
+ * Compile variables
+ *
+ * @param string $text_blocks Variable reference in source template
+ * @return string compiled template code
+ */
+ private function compile_var_tags(&$text_blocks)
+ {
+ $text_blocks = $this->get_varref($text_blocks, $is_expr);
+ $lang_replaced = $this->compile_language_tags($text_blocks);
+
+ if(!$lang_replaced)
+ {
+ $text_blocks = '<?php echo ' . ($is_expr ? "$text_blocks" : "(isset($text_blocks)) ? $text_blocks : ''") . '; /**/?>';
+ }
return $text_blocks;
}
@@ -343,21 +365,28 @@ class phpbb_template_filter extends php_user_filter
* Handles special language tags L_ and LA_
*
* @param string $text_blocks Variable reference in source template
+ * @return bool Whether a replacement occurred or not
*/
private function compile_language_tags(&$text_blocks)
{
+ $replacements = 0;
+
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
if (strpos($text_blocks, '{L_') !== false)
{
- $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks);
+ $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
+ return (bool) $replacements;
}
// Handle addslashed language variables prefixed with LA_
// If a template variable already exist, it will be used in favor of it...
if (strpos($text_blocks, '{LA_') !== false)
{
- $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks);
+ $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
+ return (bool) $replacements;
}
+
+ return false;
}
/**
@@ -725,6 +754,18 @@ class phpbb_template_filter extends php_user_filter
*/
private function compile_tag_include($tag_args)
{
+ // Process dynamic includes
+ if ($tag_args[0] == '{')
+ {
+ $var = $this->get_varref($tag_args, $is_expr);
+
+ // Make sure someone didn't try to include S_FIRST_ROW or similar
+ if (!$is_expr)
+ {
+ return "if (isset($var)) { \$_template->_tpl_include($var); }";
+ }
+ }
+
return "\$_template->_tpl_include('$tag_args');";
}
@@ -822,17 +863,16 @@ class phpbb_template_filter extends php_user_filter
*
* @param string $namespace Namespace to access (expects a trailing "." on the namespace)
* @param string $varname Variable name to use
- * @param bool $echo If true return an echo statement, otherwise a reference to the internal variable
+ * @param bool $expr Returns whether the source was an expression type
* @param bool $defop If true this is a variable created with the DEFINE construct, otherwise template variable
* @return string Code to access variable or echo it if $echo is true
*/
- private function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
+ private function generate_block_varref($namespace, $varname, &$expr, $defop = false)
{
// Strip the trailing period.
$namespace = substr($namespace, 0, -1);
$expr = true;
- $isset = false;
// S_ROW_COUNT is deceptive, it returns the current row number now the number of rows
// hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM
@@ -868,11 +908,9 @@ class phpbb_template_filter extends php_user_filter
$varref .= "['$varname']";
$expr = false;
- $isset = true;
break;
}
// @todo Test the !$expr more
- $varref = ($echo) ? '<?php echo ' . ($isset ? "isset($varref) ? $varref : ''" : $varref) . '; /**/?>' : (($expr || isset($varref)) ? $varref : '');
return $varref;
}
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 4007b77db8..0495ade9c5 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -122,7 +122,7 @@ class phpbb_template
{
$this->locator->set_custom_template($template_path, $fallback_template_path);
- $this->cachepath = $this->phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $style_name) . '_';
+ $this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $style_name) . '_';
$this->context = new phpbb_template_context();
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index f4fdb50ecd..738da62158 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -161,7 +161,6 @@ class ucp_main
'TOPIC_IMG_STYLE' => $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
- 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '',
'S_USER_POSTED' => (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false,
@@ -348,7 +347,6 @@ class ucp_main
'FORUM_ID' => $forum_id,
'FORUM_IMG_STYLE' => $folder_image,
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
- 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
'FORUM_NAME' => $row['forum_name'],
@@ -825,7 +823,6 @@ class ucp_main
'TOPIC_IMG_STYLE' => $folder_img,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
- 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 1758bb5eb1..c74574f361 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -166,7 +166,6 @@ function view_folder($id, $mode, $folder_id, $folder)
'PM_ICON_URL' => (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '',
'FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'FOLDER_IMG_STYLE' => $folder_img,
- 'FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',