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(); $safe_mode = (@ini_get('safe_mode') && @strtolower(ini_get('safe_mode')) == 'on') ? true : false; // 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 (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $style_name)) { $error[] = $user->lang['STYLE_ERR_NAME_CHARS']; } 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']; } $sql_where = ($action == 'add') ? "WHERE style_name = '" . $db->sql_escape($style_name) . "'" : "WHERE style_id <> $style_id AND style_name = '" . $db->sql_escape($style_name) . "'"; $sql = 'SELECT style_name FROM ' . STYLES_TABLE . " $sql_where"; $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); } $active_yes = ($style_active) ? ' checked="checked"' : ''; $active_no = (!$style_active) ? ' checked="checked"' : ''; $default_style_yes = ($style_id == $config['default_style']) ? ' checked="checked"' : ''; $default_style_no = ($style_id != $config['default_style']) ? ' checked="checked"' : ''; // Output the page adm_page_header($user->lang['EDIT_STYLE']); ?>

lang['EDIT_STYLE']; ?>

lang['EDIT_STYLE_EXPLAIN']; ?>

">
Edit Style
', $error); ?>
Style Name:
Style Copyright: ' . $style_copyright . '' : ''; ?>
Template set:
Theme set:
Imageset:
Default style: /> Yes   /> No
Active: /> Yes   /> No
  
lang['MANAGE_STYLE']); ?>

lang['MANAGE_STYLE']; ?>

lang['MANAGE_STYLE_EXPLAIN']; ?>

">sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $style_count[$row['user_style']] = $row['style_count']; } $db->sql_freeresult($result); $sql = 'SELECT style_id, style_name, style_active FROM ' . STYLES_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; $stylevis = (!$row['style_active']) ? 'activate' : 'deactivate'; ?> sql_freeresult($result); ?>
Style name Used by Options
">  ">lang['STYLE_' . strtoupper($stylevis)]; ?>   ">Delete   ">Export   Preview 
Create new style:
lang['EDIT_IMAGESET']); ?>
">
Parameter Value
Imageset name:
Copyright:
sql_query($sql); if (!extract($db->sql_fetchrow($result))) { trigger_error($user->lang['NO_IMAGESET']); } $db->sql_freeresult($result); $imglist = array( 'buttons' => array( 'btn_post', 'btn_post_pm', 'btn_reply', 'btn_reply_pm', 'btn_locked', 'btn_profile', 'btn_pm', 'btn_delete', 'btn_ip', 'btn_quote', 'btn_search', 'btn_edit', 'btn_report', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', 'btn_topic_watch', 'btn_topic_unwatch', ), 'icons' => array( 'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',), 'forums' => array( 'forum', 'forum_new', 'forum_locked', 'forum_link', 'sub_forum', 'sub_forum_new',), 'folders' => array( 'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',), 'polls' => array( 'poll_left', 'poll_center', 'poll_right',), 'custom' => array(), ); $test_ary = array(); foreach ($imglist as $category => $img_ary) { foreach ($img_ary as $img) { if (!empty($$img)) { $test_ary[] = preg_replace('#^"styles/imagesets/' . $imageset_path . '/(\{LANG\}/)?(.*?)".*$#', '\2', $$img); } } } $dp = @opendir($phpbb_root_path . 'styles/imagesets/' . $imageset_path); while ($file = readdir($dp)) { if (is_file($phpbb_root_path . 'styles/imagesets/' . $imageset_path . '/' . $file)) { if (!in_array($file, $test_ary)) { $imglist['custom'][] = $file; } } } closedir($dp); unset($matches); unset($test_ary); $imgwidth = (preg_match('#width="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; $imgheight = (preg_match('#height="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; } // Generate list of image options $img_options = ''; foreach ($imglist as $category => $img_ary) { $img_options .= ''; foreach ($img_ary as $img) { $selected = ($img == $imgname) ? ' selected="selected"' : ''; $img_options .= ''; } } // Grab list of potential images $imagesetlist = filelist($phpbb_root_path . 'styles/imagesets/' . $imageset_path); $imagesetlist_options = ''; foreach ($imagesetlist as $path => $img_ary) { foreach ($img_ary as $img) { $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; $imagesetlist_options .= ''; } } $imagesetlist_options = '' . $imagesetlist_options; unset($imagesetlist); adm_page_header($user->lang['EDIT_IMAGESET']); ?>

lang['EDIT_IMAGESET']; ?>

lang['EDIT_IMAGESET_EXPLAIN']; ?>

">
lang['SELECT_CLASS']; ?>:  
Preview
img_lang, $$imgname)) . ' vspace="5" />' : ''; ?>
Parameter Value
Image:
Dimensions:
Dimensions are optional, set to zero to ignore.
X
  
lang['MANAGE_IMAGESET']); ?>

lang['MANAGE_IMAGESET']; ?>

lang['MANAGE_IMAGESET_EXPLAIN']; ?>

">sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> sql_freeresult($result); ?>
Imageset name Options
">  ">Details   ">Delete   ">Export 
Create new 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', ), 'bbcode' => array( 'b', 'u', 'i', 'color', 'size', 'flash', 'img', 'url', 'email', 'code', 'quote', 'quote_username', 'listitem', 'olist', 'ulist'), 'custom' => array(), ); // Lights, Camera ... switch ($action) { case 'cache': $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); $cache_prefix = 'tpl_' . $template_path; // User wants to delete one or more files ... if ($_POST['update'] && !empty($_POST['delete'])) { foreach ($_POST['delete'] as $file) { $file = $phpbb_root_path . 'cache/' . $cache_prefix . '_' . $file . '.html.' . $phpEx; if (file_exists($file) && is_file($file)) { @unlink($file); } } add_log('admin', 'LOG_CLEAR_TPLCACHE', $template_name); trigger_error($user->lang['TEMPLATE_CACHE_CLEARED']); } // Someone wants to see the cached source ... so we'll highlight it, // add line numbers and indent it appropriately. This could be nasty // on larger source files ... if (!empty($_GET['source']) && file_exists($phpbb_root_path . 'cache/' . $cache_prefix . '_' . $_GET['source'] . '.html.' . $phpEx)) { adm_page_header($user->lang['TEMPLATE_CACHE']); ?>

', '', '','[', ']', '.'); $str_to = array('<?php '; $str_to[] = ''; $str_from[] = '<?php '; $str_to[] = ''; $str_from[] = '?>'; $str_to[] = ''; } $code = str_replace($str_from, $str_to, $code); $code = preg_replace('#^()\n?(.*?)\n?()$#is', '\1\2\3', $code); $code = explode("$marker", $code); ?> $line) { ?>
   $j) { $indent = substr($indent, 0, -6); $j++; } unset($code[$key]); ?>

lang['ERR_TPLCACHE_READ']); } $tplcache_ary = array(); while ($file = readdir($dp)) { if (is_file($phpbb_root_path . 'cache/' . $file) && strstr($file, $cache_prefix)) { $filename = preg_replace('#^' . $cache_prefix . '_(.*?)\.html\.' . $phpEx . '$#i', '\1', $file); $tplcache_ary[$filename]['cache'] = filemtime($phpbb_root_path . 'cache/' . $file); $tplcache_ary[$filename]['size'] = filesize($phpbb_root_path . 'cache/' . $file); $tplcache_ary[$filename]['src'] = filemtime($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $filename . '.html'); } } closedir($dp); // Output the page adm_page_header($user->lang['TEMPLATE_CACHE']); ?>

lang['TEMPLATE_CACHE']; ?>

lang['TEMPLATE_CACHE_EXPLAIN']; ?>

"> $times_ary) { $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?>
lang['CACHE_FILENAME']; ?> lang['CACHE_FILESIZE']; ?> lang['CACHE_CACHED']; ?> lang['CACHE_CREATED']; ?> lang['MARK']; ?>
" onclick="viewsource('');return false"> format_date($times_ary['cache']); ?> format_date($times_ary['src']); ?>
lang['NO_CACHED_TPL_FILES']; ?>
lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?>
sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_TEMPLATE']); } $db->sql_freeresult($result); } // Output the page adm_page_header($user->lang['EDIT_TEMPLATE']); ?>

lang['EDIT_TEMPLATE']; ?>

lang['EDIT_TEMPLATE_EXPLAIN']; ?>

" onsubmit="return csspreview()">
Parameter Value
Template name:
Copyright:
  
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]; } } // 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']; ?>

lang['EDIT_TEMPLATE_EXPLAIN']; ?>

">
lang['SELECT_TEMPLATE']; ?>:  
Columns:  Rows:  
Raw HTML
  
lang['MANAGE_TEMPLATE']); ?>

lang['MANAGE_TEMPLATE']; ?>

lang['MANAGE_TEMPLATE_EXPLAIN']; ?>

">sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> sql_freeresult($result); ?>
Template name Options
">  ">Cache   ">Details   ">Delete   ">Export   ">Preview 
Create new template:
sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_THEME']); } $db->sql_freeresult($result); $s_hidden_fields = ''; } else { if ($action == 'install' && !empty($_GET['name'])) { $theme_path = htmlspecialchars($_GET['name']); if (!file_exists("{$phpbb_root_path}styles/themes/$theme_path/theme.cfg")) { trigger_error($user->lang['NO_THEME']); } if (!($themecfg = file("{$phpbb_root_path}styles/themes/$theme_path/theme.cfg"))) { trigger_error($user->lang['NO_THEME']); } $theme_version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($themecfg[2])); $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); if ($theme_version != $phpbbversion) { $error[] = $user->lang['THEME_VERSION_DIFF']; } $theme_name = trim($themecfg[0]); $theme_copyright = trim($themecfg[1]); $s_hidden_fields = ''; } else { $theme_name = (!empty($_POST['theme_name'])) ? htmlspecialchars(stripslashes($_POST['theme_name'])) : ''; $theme_copyright = (!empty($_POST['theme_copyright'])) ? htmlspecialchars(stripslashes($_POST['theme_copyright'])) : ''; $css_storedb = (!empty($_POST['css_storedb'])) ? 1 : (($safe_mode) ? 1 : 0); $s_hidden_fields = (!empty($_POST['theme_basis'])) ? '' : ''; if (!empty($_POST['theme_path'])) { $s_hidden_fields .= ''; } } } // Do the update thang if (isset($_POST['update'])) { $sql_where = ($action == 'add' || $action == 'install') ? "WHERE theme_name = '" . $db->sql_escape($theme_name) . "'" : "WHERE theme_id <> $theme_id AND theme_name = '" . $db->sql_escape($theme_name) . "'"; $sql = 'SELECT theme_name FROM ' . STYLES_CSS_TABLE . " $sql_where"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $error[] = $user->lang['THEME_ERR_NAME_EXIST']; } $db->sql_freeresult($result); if (empty($theme_name)) { $error[] = $user->lang['THEME_ERR_STYLE_NAME']; } if (strlen($theme_name) > 30) { $error[] = $user->lang['THEME_ERR_NAME_LONG']; } if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $theme_name)) { $error[] = $user->lang['THEME_ERR_NAME_CHARS']; } if (strlen($theme_copyright) > 60) { $error[] = $user->lang['THEME_ERR_COPY_LONG']; } if (!sizeof($error)) { // Replace any chars which may cause us problems with _ $theme_path = ($action == 'add') ? str_replace(' ', '_', $theme_name) : htmlspecialchars($_POST['theme_path']); if ($action == 'add' && file_exists("{$phpbb_root_path}styles/themes/$theme_path")) { for ($i = 1; $i < 100; $i++) { if (!file_exists("$phpbb_root_path/styles/themes/{$theme_path}_{$i}")) { $theme_path .= "_$i"; break; } } } $css_storedb = 1; $css_data = ''; if ($action == 'install') { if (!is_writeable("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css")) { $css_data = implode('', file("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css")); } else { $css_storedb = 0; } } else if (!$safe_mode && is_writeable("{$phpbb_root_path}styles/themes") && $action == 'add') { umask(0); if (@mkdir("{$phpbb_root_path}styles/themes/$theme_path", 0777)) { $css_storedb = 0; @chmod("{$phpbb_root_path}styles/themes/$theme_path", 0777); } if (!empty($_POST['theme_basis']) && !$css_storedb) { $sql = 'SELECT theme_name, theme_path, css_storedb, css_data FROM ' . STYLES_CSS_TABLE . ' WHERE theme_id = ' . intval($_POST['theme_basis']); $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $css_data = ($row['css_storedb']) ? $row['css_data'] : implode('', file($phpbb_root_path . 'styles/themes/' . $row['theme_path'] . '/' . $row['theme_path'] . '.css')); if (!$css_storedb && ($fp = @fopen("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css", 'wb'))) { $css_storedb = (fwrite($fp, $css_data)) ? 0 : 1; if (!$css_storedb) { // Get a list of all files and folders in the basis themes folder $filelist = filelist($phpbb_root_path . 'styles/themes/' . $row['theme_path'], '', '*'); // Copy every file bar the original stylesheet foreach ($filelist as $path => $file_ary) { foreach ($file_ary as $file) { if ($file == $row['theme_path'] . '.css') { continue; } if (!file_exists("{$phpbb_root_path}styles/themes/$theme_path/$path")) { @mkdir("{$phpbb_root_path}styles/themes/$theme_path/$path"); } @copy("{$phpbb_root_path}styles/themes/" . $row['theme_path'] . "/$path/$file", "{$phpbb_root_path}styles/themes/$theme_path/$path/$file"); } } unset($filelist); } } else { $css_storedb = 1; } @fclose($fp); } $db->sql_freeresult($result); } } $sql_ary = array( 'theme_name' => $theme_name, ); if ($action == 'add' || $action == 'install') { $sql_ary = array_merge($sql_ary, array( 'theme_copyright' => $theme_copyright, 'theme_path' => $theme_path, 'css_storedb' => $css_storedb, 'css_data' => ($css_storedb) ? $css_data : '',) ); } $sql = ($action == 'add' || $action == 'install') ? 'INSERT INTO ' . STYLES_CSS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE theme_id = ' . $theme_id; $db->sql_query($sql); $message = ($action == 'add' || $action == 'install') ? (($css_storedb) ? 'THEME_DB_ADDED' : 'THEME_FS_ADDED') : 'THEME_DETAILS_UPDATE'; $log = ($action == 'add' || $action == 'install') ? (($css_storedb) ? 'LOG_ADD_THEME_DB' : 'LOG_ADD_THEME_FS') : 'LOG_EDIT_THEME_DETAILS'; add_log('admin', $log, $theme_name); trigger_error($user->lang[$message]); } } $css_storedb_no = (!$css_storedb) ? ' checked="checked"' : ''; $css_storedb_yes = ($css_storedb) ? ' checked="checked"' : ''; // Output the page adm_page_header($user->lang['EDIT_THEME']); ?>

lang['EDIT_THEME']; ?>

lang['EDIT_THEME_EXPLAIN']; ?>

" onsubmit="return csspreview()">
Parameter Value
', $error); ?>
Theme name:
Copyright: ' : "$theme_copyright"; ?>
Store location:
Location of stylesheet, images are always stored on the filesystem.
/> Filesystem   />Database
  
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); // Where is the CSS stored? if ($css_storedb) { $stylesheet = &$css_data; } else { if (!($fp = fopen("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css", 'rb'))) { trigger_error($user->lang['NO_THEME']); } $stylesheet = fread($fp, filesize("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.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 .= ''; } // Where is the CSS stored? if (is_writeable("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css") && !$css_storedb) { // Grab template data if (!($fp = fopen("{$phpbb_root_path}styles/themes/$theme_path/$theme_path.css", 'wb'))) { trigger_error($user->lang['NO_THEME']); } $stylesheet = fwrite($fp, $stylesheet); fclose($fp); } else { // We change the path to one relative to the root rather than the theme // folder $sql_ary = array( 'css_storedb' => 1, 'css_data' => str_replace('./', 'styles/themes/', $stylesheet), ); $sql = 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE theme_id = ' . $theme_id; $db->sql_query($sql); } $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'])) { // Temp, just to get this out of the way theme_preview($stylesheet, $class, $css_element); exit; } // Here we pull out the appropriate class entry then proceed to pull it apart, // setting appropriate variables to their respective values. We only match // certain css elements, the rest are "hidden" and can be accessed by exposing // the raw css if (!$showcss) { foreach ($match_elements as $type => $match_ary) { foreach ($match_ary as $match) { $var = str_replace('-', '_', $match); $$var = ''; if (sizeof($css_element)) { foreach ($css_element as $key => $element) { if (preg_match('#^' . preg_quote($match, '#') . ': (.*?)$#', $element, $matches)) { switch ($type) { case 'sizes': if (preg_match('#(.*?)(px|%|em|pt)#', $matches[1], $matches)) { ${$var . '_units'} = trim($matches[2]); } $$var = trim($matches[1]); break; case 'images': if (preg_match('#url\(\'(.*?)\'\)#', $matches[1], $matches)) { $$var = trim($matches[1]); $$var = str_replace('./', $theme_name . '/', $$var); } break; default: $$var = trim($matches[1]); } // Remove this element from array unset($css_element[$key]); break; } } } } } // Any remaining elements must be custom data so we save that // in a hidden field if (sizeof($css_element)) { $s_hidden_fields .= ''; } } } // End of class element variable setting // Generate list of class options $class_options = ''; foreach ($base_classes as $category => $class_ary) { $class_options .= ''; foreach ($class_ary as $class_name) { $selected = ($class_name == $class) ? ' selected="selected"' : ''; $class_options .= ''; } } // Grab list of potential images for class backgrounds $imglist = filelist("{$phpbb_root_path}styles/themes/$theme_path"); $bg_imglist = ''; foreach ($imglist as $path => $img_ary) { foreach ($img_ary as $img) { $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; $bg_imglist .= ''; } } $bg_imglist = '' . $bg_imglist; unset($imglist); // Output the page adm_page_header($user->lang['EDIT_THEME']); ?>

lang['EDIT_THEME']; ?>

lang['EDIT_THEME_EXPLAIN']; ?>

Note

lang['SHOW_RAW_CSS_EXPLAIN']; ?>

" onsubmit="return csspreview()">
lang['SELECT_CLASS']; ?>:  
'; } ?> '; } ?>
Raw CSS
' . implode('
', $error) . '
Parameter Value
' . implode('
', $error) . '
Background
Color:
This is a hex-triplet of the form RRGGBB
Web-safe Colour Swatch
 
Image:
Repeat background:
Foreground
Color:
This is a hex-triplet of the form RRGGBB
Web-safe Colour Swatch
 
Font:
You can specify multiple fonts seperated by commas
Size:
Bold: /> lang['YES']; ?>   /> lang['NO']; ?>   /> lang['UNSET']; ?>
Italic: /> lang['YES']; ?>   /> lang['NO']; ?>   /> lang['UNSET']; ?>
Underline: /> lang['YES']; ?>   /> lang['NO']; ?>   /> lang['UNSET']; ?>
Line spacing:
      lang['HIDE_RAW_CSS'] . '" />' : ''; echo $s_hidden_fields; ?>

Custom Class

You can add additional classes to this theme if you wish. You must provide the actual CSS class name below, it must be the same as that you have or will use in your template. Please remember that class names may contain only alphanumeric characters, periods (.), colons (:) and number/hash/pound (#). The new class will be added to the Custom Class category in the select box above.

Add Custom Class
CSS class name:
  
' . $theme_id . ' ORDER BY theme_id'; $result = $db->sql_query($sql); $theme_options = ''; while ($row = $db->sql_fetchrow($result)) { $theme_options .= ''; } if ($theme_options == '') { trigger_error($user->lang['ONLY_THEME']); } $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); if (isset($_POST['update'])) { $sql = 'DELETE FROM ' . STYLES_CSS_TABLE . ' WHERE theme_id = ' . $theme_id; $db->sql_query($sql); $sql = 'UPDATE ' . STYLES_TABLE . ' SET theme_id = ' . intval($_POST['newtheme']) . ' WHERE theme_id = ' . $theme_id; $db->sql_query($sql); $onfs = 0; if (!empty($_POST['deletefs']) && is_writeable("{$phpbb_root_path}styles/themes/$theme_path")) { $filelist = filelist("{$phpbb_root_path}styles/themes/$theme_path", '', '*'); krsort($filelist); foreach ($filelist as $path => $img_ary) { $path = "{$phpbb_root_path}styles/themes/$theme_path$path"; foreach ($img_ary as $img) { if (!@unlink("$path/$img")) { $onfs = 1; } } if (!@rmdir($path)) { $onfs = 1; } } } else { $onfs = (file_exists("{$phpbb_root_path}styles/themes/$theme_path") && !is_writeable("{$phpbb_root_path}styles/themes/$theme_path")) ? 1 : 0; } add_log('admin', 'LOG_DELETE_THEME', $theme_name); $message = ($onfs) ? 'THEME_DELETED_FS' : 'THEME_DELETED'; trigger_error($user->lang[$message]); } // Output list of themes adm_page_header($user->lang['DELETE_THEME']); ?>

lang['DELETE_THEME']; ?>

lang['DELETE_THEME_EXPLAIN']; ?>

">
lang['DELETE_THEME']; ?>
lang['THEME_NAME']; ?>:
Delete from filesystem: lang['YES']; ?>   lang['NO']; ?>
Update styles to:
Select theme to replace this one if used by styles.
  
sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_THEME']); } $db->sql_freeresult($result); if (isset($_POST['update'])) { $theme_config = addslashes($theme_name) . "\n"; $theme_config .= addslashes($theme_copyright) . "\n"; $theme_config .= addslashes($config['version']) . "\n"; switch ($_POST['format']) { case 'tar': $ext = 'tar'; $mimetype = 'x-tar'; $compress = 'compress_tar'; break; case 'zip': if (!extension_loaded('zlib')) { trigger_error($user->lang['NO_SUPPORT_ZIP']); } $ext = 'zip'; $mimetype = 'zip'; $compress = 'compress_zip'; break; case 'tar.gz': if (!extension_loaded('zlib')) { trigger_error($user->lang['NO_SUPPORT_GZ']); } $ext = 'tar.gz'; $mimetype = 'x-gzip'; $compress = 'compress_tar'; break; case 'tar.bz2': if (!extension_loaded('bz2')) { trigger_error($user->lang['NO_SUPPORT_BZ2']); } $ext = 'tar.bz2'; $mimetype = 'x-bzip2'; $compress = 'compress_tar'; break; default: trigger_error($user->lang['NO_SUPPORT_ARCHIVE']); } if (!($zip = new $compress('w', "{$phpbb_root_path}store/theme_$theme_path.$ext"))) { trigger_error($user->lang['STORE_UNWRITEABLE']); } // If we have the css in the DB we'll use that in preference to the one on the // filesystem. We will also create an appropriate cfg file if ($css_storedb) { $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', "$theme_path.css,theme.cfg"); $zip->add_data($css_data, "$theme_path/$theme_path.css"); } else { $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', 'theme.cfg'); } $zip->add_data($theme_config, "$theme_path/theme.cfg"); $zip->close(); unset($theme_config); unset($css_data); if (empty($_POST['store'])) { header('Pragma: no-cache'); header("Content-Type: application/$mimetype; name=\"theme_$theme_path.$ext\""); header("Content-disposition: attachment; filename=theme_$theme_path.$ext"); echo implode('', file("{$phpbb_root_path}store/theme_$theme_path.$ext")); @unlink("{$phpbb_root_path}store/theme_$theme_path.$ext"); exit; } add_log('admin', 'LOG_EXPORT_THEME', $theme_name); trigger_error(sprintf($user->lang['THEME_EXPORTED'], "store/theme_$theme_path.$ext")); } // Output list of themes adm_page_header($user->lang['THEMES_EXPORT']); ?>

lang['THEMES_EXPORT']; ?>

lang['THEMES_EXPORT_EXPLAIN']; ?>

">
lang['THEMES_EXPORT']; ?>
lang['THEME_NAME']; ?>:
lang['DOWNLOAD_STORE']; ?>:
lang['DOWNLOAD_STORE_EXPLAIN']; ?>
Store   Download
lang['ARCHIVE_FORMAT']; ?>: 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2'); foreach ($compress_types as $type => $module) { if ($module && !extension_loaded($module)) { break; } echo ' .' . $type . '  '; } ?>
  
lang['THEMES']); ?>

lang['THEMES']; ?>

lang['THEMES_EXPLAIN']; ?>

">sql_query($sql); $installed_themes = array(); $basis_options = ''; while ($row = $db->sql_fetchrow($result)) { $installed_themes[] = $row['theme_path']; $basis_options .= ''; $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> sql_freeresult($result); ?> $themecfg) { ?>
Theme name Options
Installed themes
' . $row['theme_name'] . ''; ?>  ">Details   ">Delete   ">Export   ">Preview 
Uninstalled themes
">Install
No uninstalled themes detected
Create new theme: using
%s
'; ?>

h1

h2

h3

mainmenu
 
titles
th
cattitle / cat catdiv
topictitle / row1 topicauthor / row2 topicdetails / row1
row3
spacer
postdetails / row2 postbody / row1 posthilit


gen genmed gensmall
copyright phpBB




postbody / bold italic underline
A_N_Other wrote:
quote
Code:
10 Print "hello"
20 Goto 10
PHP:
// syntaxcomment
?>
<HTML>
<?php
echo $this = "HELLO";