|
|
|
@ -207,7 +207,7 @@ version = {VERSION}
|
|
|
|
|
|
|
|
|
|
switch ($action)
|
|
|
|
|
{
|
|
|
|
|
// Refresh template data stored in db and clear cache
|
|
|
|
|
// Clear cache
|
|
|
|
|
case 'refresh':
|
|
|
|
|
|
|
|
|
|
$sql = 'SELECT *
|
|
|
|
@ -224,49 +224,13 @@ version = {VERSION}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
@ -526,7 +490,7 @@ version = {VERSION}
|
|
|
|
|
$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);
|
|
|
|
@ -554,8 +518,8 @@ version = {VERSION}
|
|
|
|
|
$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 (!$safe_mode && file_exists($file) && phpbb_is_writable($file))
|
|
|
|
|
{
|
|
|
|
|
if (!($fp = @fopen($file, 'wb')))
|
|
|
|
|
{
|
|
|
|
@ -567,32 +531,8 @@ version = {VERSION}
|
|
|
|
|
}
|
|
|
|
|
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');
|
|
|
|
|
// @todo
|
|
|
|
|
trigger_error('Cannot write template file.', E_USER_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// destroy the cached version of the template (filename without extension)
|
|
|
|
@ -605,53 +545,18 @@ version = {VERSION}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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'));
|
|
|
|
|
|
|
|
|
|
if ($template_file)
|
|
|
|
|
{
|
|
|
|
|
$template_path = "{$phpbb_root_path}styles/{$template_info['template_path']}/template";
|
|
|
|
|
|
|
|
|
|
$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")))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT *
|
|
|
|
|
FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
|
|
|
|
|
WHERE template_id = $template_id";
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$filelist = array('' => array());
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
$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'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
unset($file_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($filelist['']))
|
|
|
|
|
{
|
|
|
|
@ -821,35 +726,6 @@ version = {VERSION}
|
|
|
|
|
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']);
|
|
|
|
|
|
|
|
|
@ -905,10 +781,9 @@ version = {VERSION}
|
|
|
|
|
'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,
|
|
|
|
@ -1123,7 +998,7 @@ version = {VERSION}
|
|
|
|
|
|
|
|
|
|
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':
|
|
|
|
@ -1491,7 +1366,7 @@ version = {VERSION}
|
|
|
|
|
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');
|
|
|
|
|
$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', 'theme_storedb', 'theme_mtime', 'theme_data');
|
|
|
|
|
|
|
|
|
|
foreach ($var_ary as $var)
|
|
|
|
|
{
|
|
|
|
@ -1546,31 +1421,12 @@ version = {VERSION}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1772,7 +1628,6 @@ version = {VERSION}
|
|
|
|
|
|
|
|
|
|
$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)
|
|
|
|
@ -1803,23 +1658,6 @@ version = {VERSION}
|
|
|
|
|
$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 (!sizeof($error))
|
|
|
|
|
{
|
|
|
|
|
// Check length settings
|
|
|
|
@ -1841,7 +1679,6 @@ version = {VERSION}
|
|
|
|
|
'template_id' => $template_id,
|
|
|
|
|
'theme_id' => $theme_id,
|
|
|
|
|
'style_active' => $style_active,
|
|
|
|
|
$mode . '_storedb' => $store_db,
|
|
|
|
|
$mode . '_name' => $name,
|
|
|
|
|
$mode . '_copyright' => $copyright)
|
|
|
|
|
);
|
|
|
|
@ -1867,72 +1704,9 @@ version = {VERSION}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1999,8 +1773,6 @@ version = {VERSION}
|
|
|
|
|
'S_STYLE' => ($mode == 'style') ? true : false,
|
|
|
|
|
'S_TEMPLATE' => ($mode == 'template') ? true : false,
|
|
|
|
|
'S_THEME' => ($mode == 'theme') ? 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,
|
|
|
|
@ -2101,84 +1873,6 @@ version = {VERSION}
|
|
|
|
|
return str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
@ -2361,7 +2055,6 @@ version = {VERSION}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
@ -2379,15 +2072,14 @@ version = {VERSION}
|
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2403,7 +2095,6 @@ version = {VERSION}
|
|
|
|
|
'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,
|
|
|
|
|
|
|
|
|
@ -2440,7 +2131,6 @@ version = {VERSION}
|
|
|
|
|
$mode . '_copyright' => utf8_normalize_nfc(request_var('copyright', '', true)),
|
|
|
|
|
'template_id' => 0,
|
|
|
|
|
'theme_id' => 0,
|
|
|
|
|
'store_db' => request_var('store_db', 0),
|
|
|
|
|
'style_active' => request_var('style_active', 1),
|
|
|
|
|
'style_default' => request_var('style_default', 0),
|
|
|
|
|
);
|
|
|
|
@ -2512,8 +2202,7 @@ version = {VERSION}
|
|
|
|
|
{
|
|
|
|
|
$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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2547,7 +2236,6 @@ version = {VERSION}
|
|
|
|
|
'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 : '',
|
|
|
|
@ -2853,10 +2541,6 @@ version = {VERSION}
|
|
|
|
|
$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(
|
|
|
|
@ -2885,12 +2569,6 @@ version = {VERSION}
|
|
|
|
|
|
|
|
|
|
$id = $db->sql_nextid();
|
|
|
|
|
|
|
|
|
|
if ($mode == 'template' && $store_db)
|
|
|
|
|
{
|
|
|
|
|
$filelist = filelist("{$root_path}template", '', 'html');
|
|
|
|
|
$this->store_templates('insert', $id, $path, $filelist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
|
|
|
|
$log = ($store_db) ? 'LOG_' . $l_type . '_ADD_DB' : 'LOG_' . $l_type . '_ADD_FS';
|
|
|
|
|