diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 7fbf6a9e0d..953052f207 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -8,10 +8,10 @@ if ( !empty($setmodules) ) } $filename = basename(__FILE__); - $module['STYLE']['EDIT_STYLE'] = $filename . "$SID&mode=newstyle"; - $module['STYLE']['EDIT_TEMPLATE'] = $filename . "$SID&mode=edittemplate"; - $module['STYLE']['EDIT_THEME'] = $filename . "$SID&mode=edittheme"; - $module['STYLE']['EDIT_IMAGESET'] = $filename . "$SID&mode=editimageset"; + $module['STYLE']['EDIT_STYLE'] = $filename . "$SID&mode=styles"; + $module['STYLE']['EDIT_TEMPLATE'] = $filename . "$SID&mode=templates"; + $module['STYLE']['EDIT_THEME'] = $filename . "$SID&mode=themes"; + $module['STYLE']['EDIT_IMAGESET'] = $filename . "$SID&mode=imagesets"; return; } @@ -30,6 +30,7 @@ if (!$auth->acl_get('a_styles')) // $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; +$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : ''; @@ -135,88 +136,102 @@ switch ($mode) break; - case 'edittemplate': - $tplcols = (isset($_POST['tplcols'])) ? max(60, intval($_POST['tplcols'])) : 90; - $tplrows = (isset($_POST['tplrows'])) ? max(4, intval($_POST['tplrows'])) : 30; - $tplname = (isset($_POST['tplname'])) ? $_POST['tplname'] : ''; - $tplroot = (isset($_POST['tplroot'])) ? $_POST['tplroot'] : 'subSilver'; - $str = ''; - if (isset($_POST['tpl_compile']) && !empty($_POST['decompile'])) + + + case 'templates': + + $template_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + + switch ($action) { - $str = "compile(stripslashes($_POST['decompile'])) . "\n?".">"; + case 'preview': - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); - fwrite ($fp, $str); - fclose($fp); + break; - @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); + case 'edit': - add_log('admin', 'log_template_edit', $tplname, $tplroot); + $tplcols = (isset($_POST['tplcols'])) ? max(60, intval($_POST['tplcols'])) : 76; + $tplrows = (isset($_POST['tplrows'])) ? max(4, intval($_POST['tplrows'])) : 30; + $tplname = (isset($_POST['tplname'])) ? $_POST['tplname'] : ''; + $tplroot = (isset($_POST['tplroot'])) ? $_POST['tplroot'] : 'subSilver'; - exit; - } - else if (!empty($tplname) && isset($_POST['tpl_name'])) - { - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); - while (!feof($fp)) - { - $str .= fread($fp, 4096); - } - @fclose($fp); + $str = ''; + if (isset($_POST['tpl_compile']) && !empty($_POST['decompile'])) + { + $str = "compile(stripslashes($_POST['decompile'])) . "\n?".">"; - $match_preg = array( - '#\$this\->_tpl_include\(\'(.*?)\'\);#', - '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', - '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', - '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', - '#\$_(.*?)_count.*?;if \(.*?\)\{#', - ); + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); + fwrite ($fp, $str); + fclose($fp); - $replace_preg = array( - '', - '{$1}', - '{$1}', - '', - '', - ); + @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); - $str = preg_replace($match_preg, $replace_preg, $str); - $str = str_replace('', '', $str); - } - else - { - $str = (!empty($_POST['decompile'])) ? stripslashes($_POST['decompile']) : ''; - } + add_log('admin', 'log_template_edit', $tplname, $tplroot); - if (isset($_POST['tpl_download'])) - { - header("Content-Type: text/html; name=\"" . $tplname . ".html\""); - header("Content-disposition: attachment; filename=" . $tplname . ".html"); - echo $str; - exit; + exit; + } + else if (!empty($tplname) && isset($_POST['tpl_name'])) + { + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); + while (!feof($fp)) + { + $str .= fread($fp, 4096); + } + @fclose($fp); - } + $match_preg = array( + '#\$this\->_tpl_include\(\'(.*?)\'\);#', + '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', + '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', + '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', + '#\$_(.*?)_count.*?;if \(.*?\)\{#', + ); - $tplroot_options = get_templates($tplroot); + $replace_preg = array( + '', + '{$1}', + '{$1}', + '', + '', + ); - $tplname_options = ''; - $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); - while ($file = readdir($dp)) - { - if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) - { - $tpl = substr($file, 0, strpos($file, '.')); - $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; - $tplname_options .= ''; - } - } - closedir($dp); + $str = preg_replace($match_preg, $replace_preg, $str); + $str = str_replace('', '', $str); + } + else + { + $str = (!empty($_POST['decompile'])) ? stripslashes($_POST['decompile']) : ''; + } - // - adm_page_header($user->lang['Edit_template']); + if (isset($_POST['tpl_download'])) + { + header("Content-Type: text/html; name=\"" . $tplname . ".html\""); + header("Content-disposition: attachment; filename=" . $tplname . ".html"); + echo $str; + exit; + + } + +// $tplroot_options = get_templates($tplroot); + + $tplname_options = ''; + $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); + while ($file = readdir($dp)) + { + if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) + { + $tpl = substr($file, 0, strpos($file, '.')); + $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; + $tplname_options .= ''; + } + } + closedir($dp); + + // + adm_page_header($user->lang['Edit_template']); ?> @@ -224,11 +239,7 @@ switch ($mode)
lang['Edit_template_explain']; ?>
-