diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index af319680c3..d46f61fedd 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -8,10 +8,10 @@ if ( !empty($setmodules) ) } $filename = basename(__FILE__); - $module['Styles']['Edit_Styles'] = $filename . "$SID&mode=newstyle"; - $module['Styles']['Edit_Templates'] = $filename . "$SID&mode=edittemplate"; - $module['Styles']['Edit_Themes'] = $filename . "$SID&mode=newstyle"; - $module['Styles']['Edit_Imagesets'] = $filename . "$SID&mode=editimageset"; + $module['Styles']['Edit_Style'] = $filename . "$SID&mode=newstyle"; + $module['Styles']['Edit_Template'] = $filename . "$SID&mode=edittemplate"; + $module['Styles']['Edit_Theme'] = $filename . "$SID&mode=edittheme"; + $module['Styles']['Edit_Imageset'] = $filename . "$SID&mode=editimageset"; return; } @@ -50,187 +50,298 @@ closedir($dp); // $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; -if ( $mode == 'editimageset' ) +switch ( $mode ) { - $imgroot = ( isset($HTTP_POST_VARS['imgroot']) ) ? $HTTP_POST_VARS['imgroot'] : 'subSilver'; + case 'editimageset': + $imgroot = ( isset($HTTP_POST_VARS['imgroot']) ) ? $HTTP_POST_VARS['imgroot'] : 'subSilver'; - if ( isset($HTTP_POST_VARS['img_root']) ) - { - $sql = "SELECT * + if ( isset($HTTP_POST_VARS['img_root']) ) + { + $sql = "SELECT * + FROM " . STYLES_IMAGE_TABLE . " + WHERE imageset_path LIKE '" . $HTTP_POST_VARS['imgroot'] . "'"; + $result = $db->sql_query($sql); + + $images = $db->sql_fetchrow($result); + } + if ( isset($HTTP_POST_VARS['img_addconfig']) ) + { + } + else if ( isset($HTTP_POST_VARS['img_addlocal']) ) + { + } + + $imageset = array('imageset_path', 'post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_profile', 'icon_pm', 'icon_delete', 'icon_ip', 'icon_quote', 'icon_search', 'icon_edit', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm', 'goto_post', 'goto_post_new', 'goto_post_latest', 'goto_post_newest', 'forum', 'forum_new', 'forum_locked', 'folder', 'folder_new', 'folder_hot', 'folder_hot_new', 'folder_locked', 'folder_locked_new', 'folder_sticky', 'folder_sticky_new', 'folder_announce', 'folder_announce_new', 'topic_watch', 'topic_unwatch', 'poll_left', 'poll_center', 'poll_right', 'rating'); + + $sql = "SELECT imageset_name, imageset_path FROM " . STYLES_IMAGE_TABLE . " - WHERE imageset_path LIKE '" . $HTTP_POST_VARS['imgroot'] . "'"; + ORDER BY imageset_name"; $result = $db->sql_query($sql); - $images = $db->sql_fetchrow($result); - } - if ( isset($HTTP_POST_VARS['img_addconfig']) ) - { - } - else if ( isset($HTTP_POST_VARS['img_addlocal']) ) - { - } - - $imageset = array('imageset_path', 'post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_profile', 'icon_pm', 'icon_delete', 'icon_ip', 'icon_quote', 'icon_search', 'icon_edit', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm', 'goto_post', 'goto_post_new', 'goto_post_latest', 'goto_post_newest', 'forum', 'forum_new', 'forum_locked', 'folder', 'folder_new', 'folder_hot', 'folder_hot_new', 'folder_locked', 'folder_locked_new', 'folder_sticky', 'folder_sticky_new', 'folder_announce', 'folder_announce_new', 'topic_watch', 'topic_unwatch', 'poll_left', 'poll_center', 'poll_right', 'rating'); - - $sql = "SELECT imageset_name, imageset_path - FROM " . STYLES_IMAGE_TABLE . " - ORDER BY imageset_name"; - $result = $db->sql_query($sql); - - $imgroot_options = ''; - while ( $row = $db->sql_fetchrow($result) ) - { - $selected = ( $imgroot == $row['imageset_path'] ) ? ' selected="selected"' : ''; - $imgroot_options .= ''; - } - - $imgname_options = ''; - $dp = opendir($phpbb_root_path . 'imagesets/' . $imgroot . '/'); - while ( $file = readdir($dp) ) - { - if ( preg_match('#\.(gif|png|jpg|jpeg)$#', $file) && is_file($phpbb_root_path . 'imagesets/' . $imgroot . '/' . $file) ) + $imgroot_options = ''; + while ( $row = $db->sql_fetchrow($result) ) { - $selected = ( $imgname == $file ) ? ' selected="selected"' : ''; - $imgname_options .= ''; + $selected = ( $imgroot == $row['imageset_path'] ) ? ' selected="selected"' : ''; + $imgroot_options .= ''; } - } - closedir($dp); - // - // Output page - // - page_header($lang['Styles']); + $imgname_options = ''; + $dp = opendir($phpbb_root_path . 'imagesets/' . $imgroot . '/'); + while ( $file = readdir($dp) ) + { + if ( preg_match('#\.(gif|png|jpg|jpeg)$#', $file) && is_file($phpbb_root_path . 'imagesets/' . $imgroot . '/' . $file) ) + { + $selected = ( $imgname == $file ) ? ' selected="selected"' : ''; + $imgname_options .= ''; + } + } + closedir($dp); - echo '
'; + page_footer(); - if ( isset($HTTP_POST_VARS['tpl_download']) ) - { - header("Content-Type: text/html; name=\"" . $tplname . ".html\""); - header("Content-disposition: attachment; filename=" . $tplname . ".html"); - echo $str; - exit; + break; - } + case 'edittemplate': - $tplroot_options = get_templates($tplroot); + $tplcols = ( isset($HTTP_POST_VARS['tplcols']) ) ? max(60, intval($HTTP_POST_VARS['tplcols'])) : 90; + $tplrows = ( isset($HTTP_POST_VARS['tplrows']) ) ? max(4, intval($HTTP_POST_VARS['tplrows'])) : 30; + $tplname = ( isset($HTTP_POST_VARS['tplname']) ) ? $HTTP_POST_VARS['tplname'] : ''; + $tplroot = ( isset($HTTP_POST_VARS['tplroot']) ) ? $HTTP_POST_VARS['tplroot'] : 'subSilver'; - $tplname_options = ''; - $dp = opendir($phpbb_root_path . 'templates/cache/' . $tplroot . '/'); - while ( $file = readdir($dp) ) - { - if ( strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $file) ) + $str = ''; + if ( isset($HTTP_POST_VARS['tpl_compile']) && !empty($HTTP_POST_VARS['decompile']) ) { - $tpl = substr($file, 0, strpos($file, '.')); - $selected = ( $tplname == $tpl ) ? ' selected="selected"' : ''; - $tplname_options .= ''; + $str = "compile(stripslashes($HTTP_POST_VARS['decompile'])) . "\n?".">"; + + $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); + fwrite ($fp, $str); + fclose($fp); + + @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); + + add_admin_log('log_template_edit', $tplname, $tplroot); + + exit; } - } - closedir($dp); + else if ( !empty($tplname) && isset($HTTP_POST_VARS['tpl_name']) ) + { + $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); + while ( !feof($fp) ) + { + $str .= fread($fp, 4096); + } + @fclose($fp); - // - // - // - page_header($lang['Styles']); + $template->decompile($str); + } + else + { + $str = ( !empty($HTTP_POST_VARS['decompile']) ) ? stripslashes($HTTP_POST_VARS['decompile']) : ''; + } - echo ''; + // + // + // + page_header($lang['Edit_template']); - page_footer(); +?> + + + + + + + +sql_query($sql); + + if ( $row = $db->sql_fetchrow($result) ) + { + $theme_name = $row['theme_name']; + + $css_data = ( !empty($HTTP_POST_VARS['css_data']) ) ? htmlentities($HTTP_POST_VARS['css_data']) : ''; + $css_external = ( !empty($HTTP_POST_VARS['css_external']) ) ? $HTTP_POST_VARS['css_external'] : ''; + + $sql = "UPDATE " . STYLES_CSS_TABLE . " + SET css_data = '$css_data', css_external = '$css_external' + WHERE theme_id = $theme_id"; + $db->sql_query($sql); + + add_admin_log('log_theme_edit', $theme_name); + + message_die(MESSAGE, $lang['Success_theme_update']); + } + } + + page_header($lang['Edit_theme']); + + $sql = "SELECT theme_id, theme_name + FROM " . STYLES_CSS_TABLE; + $result = $db->sql_query($sql); + + $theme_options = ''; + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $theme_options .= ( ( $theme_options != '' ) ? ', ' : '' ) . ''; + } + while ( $row = $db->sql_fetchrow($result) ); + } + $db->sql_freeresult($result); + +?> + + + + + + +not altered, only the compiled versions are affected. Therefore you should download any altered files if you wish to keep them for future use and for archival purposes.'; +$lang['Select_template'] = 'Select template'; +$lang['Template'] = 'Select template'; $lang['Download'] = 'Download'; $lang['Edit_theme'] = 'Edit Theme'; -$lang['Edit_theme_explain'] = 'In the form below you can edit the settings for the selected theme'; +$lang['Edit_theme_explain'] = 'Use this panel to edit an existing theme. You can modify (or add) both CSS to be included within each page output by the forum (subject to the template including it) and an externally linked stylesheet. Remember, the location of the stylesheet is relative to the phpBB root directory.'; +$lang['Select_theme'] = 'Select theme'; +$lang['CSS_data'] = 'CSS Data'; +$lang['CSS_data_explain'] = 'This CSS is output to the template and may be included within the header of each page.'; +$lang['CSS_sheet'] = 'CSS Stylesheet'; +$lang['Success_theme_update'] = 'The theme has been successfully updated.'; + +$lang['Edit_imageset'] = 'Edit Imageset'; +$lang['Edit_imageset_explain'] = ''; + + + $lang['Create_theme'] = 'Create Theme'; $lang['Create_theme_explain'] = 'Use the form below to create a new theme for a selected template. When entering colours (for which you should use hexadecimal notation) you must not include the initial #, i.e.. CCCCCC is valid, #CCCCCC is not';