acl_get('a_styles')) { return; } $filename = basename(__FILE__); $module['STYLE']['MANAGE_STYLE'] = $filename . "$SID&mode=styles"; $module['STYLE']['MANAGE_TEMPLATE'] = $filename . "$SID&mode=templates"; $module['STYLE']['MANAGE_THEME'] = $filename . "$SID&mode=themes"; $module['STYLE']['MANAGE_IMAGESET'] = $filename . "$SID&mode=imagesets"; return; } define('IN_PHPBB', 1); // Include files $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); // Do we have styles admin permissions? if (!$auth->acl_get('a_styles')) { trigger_error($user->lang['NO_ADMIN']); } // Get and set some vars $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; if (isset($_REQUEST['action'])) { $action = htmlspecialchars($_REQUEST['action']); } else { if (isset($_POST['add'])) { $action = 'add'; } else if (isset($_POST['preview'])) { $action = 'preview'; } else { $action = ''; } } $error = array(); // What shall we do today then? switch ($mode) { case 'styles': $style_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : ''; switch ($action) { case 'activate': case 'deactivate': // TODO ... reset user_styles if their style is deactivated $sql = 'UPDATE ' . STYLES_TABLE . ' SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' WHERE style_id = ' . $style_id; $db->sql_query($sql); break; case 'delete': break; case 'export': break; case 'add': case 'edit': if (isset($_POST['update'])) { $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; $style_copyright = (isset($_POST['style_copyright'])) ? stripslashes(htmlspecialchars($_POST['style_copyright'])) : ''; $style_active = (!empty($_POST['style_active'])) ? 1 : 0; $template_id = (!empty($_POST['template_id'])) ? intval($_POST['template_id']) : 0; $theme_id = (!empty($_POST['theme_id'])) ? intval($_POST['theme_id']) : 0; $imageset_id = (!empty($_POST['imageset_id'])) ? intval($_POST['imageset_id']) : 0; if (empty($style_name)) { $error[] = $user->lang['STYLE_ERR_STYLE_NAME']; } if (strlen($style_name) > 30) { $error[] = $user->lang['STYLE_ERR_NAME_LONG']; } if (strlen($style_copyright) > 60) { $error[] = $user->lang['STYLE_ERR_COPY_LONG']; } if (!$template_id || !$theme_id || !$imageset_id) { $error[] = $user->lang['STYLE_ERR_NO_IDS']; } if ($action == 'add') { $sql = 'SELECT style_name FROM ' . STYLES_TABLE . " WHERE style_name = '" . $db->sql_escape($style_name) . "'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $error[] = $user->lang['STYLE_ERR_NAME_EXIST']; } $db->sql_freeresult($result); } if (!sizeof($error)) { $sql_ary = array( 'style_name' => $style_name, 'style_copyright' => $style_copyright, 'template_id' => $template_id, 'theme_id' => $theme_id, 'imageset_id' => $imageset_id, ); $sql = ($action == 'add') ? 'INSERT INTO ' . STYLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE style_id = $style_id"; $db->sql_query($sql); $log = ($action == 'add') ? 'LOG_ADD_STYLE' : 'LOG_EDIT_STYLE'; add_log('admin', $log, addslashes($style_name)); $message = ($action == 'add') ? 'STYLED_ADDED' : 'STYLE_EDITED'; trigger_error($user->lang[$message]); } } if (!sizeof($error)) { if ($style_id) { $sql = 'SELECT * FROM ' . STYLES_TABLE . " WHERE style_id = $style_id"; $result = $db->sql_query($sql); if (!extract($db->sql_fetchrow($result))) { die("ERROR"); } $db->sql_freeresult($result); } else { $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; $style_copyright = ''; $style_active = 1; $template_id = $theme_id = $imageset_id = 0; } } $style_options = array(); $field_ary = array(STYLES_CSS_TABLE => 'theme', STYLES_TPL_TABLE => 'template', STYLES_IMAGE_TABLE => 'imageset'); foreach ($field_ary as $table => $field) { $sql = "SELECT {$field}_id, {$field}_name FROM $table ORDER BY {$field}_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $selected = ($row[$field . '_id'] == ${$field . '_id'}) ? ' selected="selected"' : ''; ${$field . '_options'} .= ''; } $db->sql_freeresult($result); } // Output the page adm_page_header($user->lang['EDIT_STYLE']); ?>
lang['EDIT_STYLE_EXPLAIN']; ?>
lang['MANAGE_STYLE']); ?>lang['MANAGE_STYLE_EXPLAIN']; ?>
lang['MANAGE_IMAGESET']); ?>lang['MANAGE_IMAGESET_EXPLAIN']; ?>
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)) { $selected = ($imgname == $file) ? ' selected="selected"' : ''; $imgname_options .= ''; } } closedir($dp); // Output page adm_page_header($user->lang['Edit_Imageset']); ?> array( 'confirm_body.html', 'faq_body.html', 'index_body.html', 'message_body.html', 'viewonline_body.html', ), 'includes' => array( 'overall_footer.html', 'overall_header.html', 'simple_footer.html', 'simple_header.html', 'searchbox.html', 'jumpbox.html', ), 'forum' => array( 'viewforum_body.html', 'viewforum_subforum.html', ), 'topic' => array( 'viewtopic_attach_body.html', 'viewtopic_body.html', 'viewtopic_print.html', ), 'group' => array( 'gcp_body.html', 'gcp_pending_info.html', 'gcp_user_body.html', ), 'user' => array( 'ucp_agreement.html', 'ucp_footer.html', 'ucp_header.html', 'ucp_main.html', 'ucp_pm_body.html', 'ucp_pm_popup.html', 'ucp_pm_preview.html', 'ucp_pm_read.html', 'ucp_prefs.html', 'ucp_profile.html', 'ucp_register.html', 'ucp_remind.html', ), 'profile' => array( 'memberlist_body.html', 'memberlist_email.html', 'memberlist_im.html', 'memberlist_view.html', ), 'mod' => array( 'mcp_forum.html', 'mcp_foruminfo.html', 'mcp_front.html', 'mcp_header.html', 'mcp_jumpbox.html', 'mcp_move.html', 'mcp_post.html', 'mcp_queue.html', 'mcp_reports.html', 'mcp_topic.html', 'mcp_viewlogs.html', 'report_body.html', ), 'search' => array( 'search_body.html', 'search_results_posts.html', 'search_results_topics.html', ), 'posting' => array( 'posting_attach_body.html', 'posting_body.html', 'posting_poll_body.html', 'posting_preview.html', 'posting_smilies.html', 'posting_topic_review.html', ), 'login' => array( 'login_body.html', 'login_forum.html', ), 'custom' => array(), ); $tpldata = ''; if ($template_id) { $sql = 'SELECT * FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; $result = $db->sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_TEMPLATE']); } $db->sql_freeresult($result); $test_ary = array(); foreach ($tpllist as $category => $tpl_ary) { $test_ary = array_merge($test_ary, $tpl_ary); } $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); while ($file = readdir($dp)) { if (!strstr($file, 'bbcode.') && strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) { if (!in_array($file, $test_ary)) { $tpllist['custom'][] = $file; } } } closedir($dp); unset($matches); unset($test_ary); if ($tplname) { $fp = fopen($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $tplname, 'r');// . '.html' while (!feof($fp)) { $tpldata .= fread($fp, 4096); } @fclose($fp); preg_match_all('##', $tpldata, $included_tpls); $included_tpls = $included_tpls[1]; } } /* if (isset($_POST['tpl_download'])) { header("Content-Type: text/html; name=\"" . $tplname . ".html\""); header("Content-disposition: attachment; filename=" . $tplname . ".html"); echo $str; exit; } */ // Generate list of template options $tpl_options = ''; ksort($tpllist); foreach ($tpllist as $category => $tpl_ary) { if (sizeof($tpl_ary)) { sort($tpl_ary); $tpl_options .= ''; foreach ($tpl_ary as $tpl_file) { $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; $tpl_options .= ''; } } } $tplname_options = ''; $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); while ($file = readdir($dp)) { if (strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) { $tpl = substr($file, 0, strpos($file, '.')); $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; $tplname_options .= ''; } } closedir($dp); // adm_page_header($user->lang['EDIT_TEMPLATE']); ?>lang['EDIT_TEMPLATE_EXPLAIN']; ?>
lang['MANAGE_TEMPLATE']); ?>lang['MANAGE_TEMPLATE_EXPLAIN']; ?>
array( 'body', 'p', 'h1', 'h2', 'h3', '.tabletitle', '.cattitle', '.topictitle', '.topicauthor', '.topicdetails', '.postdetails', '.postbody', '.posthilit', '.postauthor', '.mainmenu', '.nav', '.genmed', '.gensmall', '.copyright', ), 'tables' => array( 'table', 'th', '.cat', '.catdiv', 'td', '.row1', '.row2', '.row3', '.spacer', 'hr', ), 'forms' => array( 'form', 'input', 'select', '.textarea', '.post', '.btnlite', '.btnmain', '.btnbbcode', ), 'bbcode' => array( '.b', '.u', '.i', '.color', '.size', '.code', '.quote', 'flash', '.syntaxbg', '.syntaxcomment', '.syntaxdefault', '.syntaxhtml', '.syntaxkeyword', '.syntaxstring', ), 'custom' => array(), ); // We categorise the elements which comprise the css class so that we set // any appropriate additional data, e.g. sizes require the scale type to be set, // images require the relevant image be pulled and selected in the dropdown, etc. $match_elements = array( 'colors' => array('background-color', 'color',), 'sizes' => array('font-size', 'line-height',), 'images' => array('background-image',), 'repeat' => array('background-repeat',), 'other' => array('font-weight', 'font-family', 'font-style', 'text-decoration',), ); // Used in an sprintf statement to generate appropriate output for rawcss mode $map_elements = array( 'colors' => '%s', 'sizes' => '%d%s', 'images' => 'url(\'./../%s\')', 'repeat' => '%s', 'other' => '%s', ); $s_hidden_fields = ''; // Do we want to edit an existing theme? if ($theme_id) { $sql = 'SELECT * FROM ' . STYLES_CSS_TABLE . " WHERE theme_id = $theme_id"; $result = $db->sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_THEME']); } $db->sql_freeresult($result); // Grab template data if (!($fp = fopen("{$phpbb_root_path}styles/themes/$theme_path/$theme_name.css", 'rb'))) { die("ERROR"); } $stylesheet = fread($fp, filesize("{$phpbb_root_path}styles/themes/$theme_path/$theme_name.css")); fclose($fp); // Pull out list of "custom" tags if (preg_match_all('#([a-z\.:]+?) {.*?}#si', $stylesheet, $matches)) { $test_ary = array(); foreach ($base_classes as $category => $class_ary) { $test_ary = array_merge($test_ary, $class_ary); } $matches = preg_replace('#^\.#', '', $matches[1]); foreach ($matches as $value) { if (!in_array($value, $test_ary)) { $base_classes['custom'][] = $value; } } unset($matches); unset($test_ary); } } // Do we have a class set? If so, we need to extract and set the relevant data if (!empty($class)) { // We must generate the relevant data ... what we need depends on whether // we are looking @ the rawcss or the simplified settings and whether we // have just selected a class. We must also cope with switching between // simple and rawcss mode $css_element = array(); if (!empty($_POST['rawcss']) && (!empty($_POST['hidecss']) || !empty($_POST['preview']) || !empty($_POST['update']))) { $css_element = preg_replace("#;[\r\n]*#s", "\n", stripslashes($_POST['rawcss'])); $css_element = explode("\n", $css_element); } else if (($showcss && !empty($_POST['showcss'])) || !empty($_POST['preview']) || !empty($_POST['update'])) { if (!empty($_POST['cssother'])) { $css_element = explode('; ', stripslashes($_POST['cssother'])); } foreach ($match_elements as $type => $match_ary) { foreach ($match_ary as $match) { $var = str_replace('-', '_', $match); if (!empty($_POST[$var])) { $css_element[] = str_replace('_', '-', $var) . ': ' . (($type == 'sizes') ? sprintf($map_elements[$type], stripslashes($_POST[$var]), $_POST[$var . '_units']) : sprintf($map_elements[$type], stripslashes($_POST[$var]))); } } } } else if (preg_match('#^' . $class . ' {(.*?)}#m', $stylesheet, $matches)) { $css_element = explode('; ', ltrim(substr($matches[1], 0, -2))); } // User wants to submit data ... if (!empty($_POST['update'])) { $updated_element = implode('; ', $css_element) . ';'; if (preg_match('#^' . $class . ' {(.*?)}#m', $stylesheet)) { $stylesheet = preg_replace('#^(' . $class . ' {).*?(})#m', '\1 ' . $updated_element . ' \2', $stylesheet); } else { $stylesheet .= ''; } if (!($fp = fopen($phpbb_root_path . 'styles/themes/' . $css_external, 'wb'))) { die("ERROR"); } $stylesheet = fwrite($fp, $stylesheet); fclose($fp); $error[] = $user->lang['THEME_UPDATED']; add_log('admin', 'LOG_EDIT_THEME', $theme_name); } // I guess really this needs some basic examples, pulled from subSilver // to demonstrate the default classes. Other, custom classes can just use // the div/span and some text? This is gonna get nasty :( if (!empty($_POST['preview'])) { $output = '%s'; ?>h1 |
h2 |
h3 |
mainmenu | ||
titles |
navlink |
th | ||
---|---|---|
cattitle / cat | catdiv | |
topictitle / row1 | topicdetails / row1 | |
row3 | ||
spacer | ||
postdetails / row2 | postbody / row1 posthilit |
gen | genmed | gensmall |
copyright phpBB |
postbody / bold italic underline | ||
|
||
|
||
|
lang['EDIT_THEME_EXPLAIN']; ?>
lang['SHOW_RAW_CSS_EXPLAIN']; ?>
lang['THEMES']); ?>lang['THEMES_EXPLAIN']; ?>
cache_root); while ($dir = readdir($dp)) { $template_dir = $phpbb_root_path . $this->cache_root . $dir; if (!is_file($template_dir) && !is_link($template_dir) && $dir != '.' && $dir != '..') { array_push($template_list, $dir); } } closedir($dp); } else { array_push($template_list, $template); } foreach ($template_list as $template) { $dp = opendir($phpbb_root_path . $this->cache_root . $template); while ($file = readdir($dp)) { unlink($phpbb_root_path . $this->cache_root . $file); } closedir($dp); } return; } function compile_cache_show($template) { global $phpbb_root_path; $template_cache = array(); $template_dir = $phpbb_root_path . $this->cache_root . $template; $dp = opendir($template_dir); while ($file = readdir($dp)) { if (preg_match('#\.html$#i', $file) && is_file($template_dir . '/' . $file)) { array_push($template_cache, $file); } } closedir($dp); return; } } // // FUNCTIONS // --------- ?>