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 { $action = ''; if (isset($_POST['add'])) { $action = 'add'; } else if (isset($_POST['preview'])) { $action = 'preview'; } } $error = array(); $safe_mode = (@ini_get('safe_mode') && @strtolower(ini_get('safe_mode')) == 'on') ? true : false; // Generate list of archive types inc. regexp | match $archive_types = $archive_preg = ''; foreach (array('zip' => 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2') as $type => $module) { if ($module && !extension_loaded($module)) { break; } $archive_types .= (($archive_types != '') ? ', ' : '') . ".$type"; $archive_preg .= (($archive_preg != '') ? '|' : '') . '\.' . preg_quote($type); } // 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': if ($style_id) { $sql = 'SELECT s.style_id, s.style_name, s.style_copyright, t.template_id, t.template_name, t.template_path, t.template_copyright, c.theme_id, c.theme_name, c.theme_path, c.theme_copyright, c.css_storedb, c.css_data, i.* FROM ' . STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . " i WHERE s.style_id = $style_id AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; $result = $db->sql_query($sql); if (!($row = ($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_STYLE']); } $db->sql_freeresult($result); $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'css_storedb', 'css_data', 'imageset_id', 'imageset_name', 'imageset_path', 'imageset_copyright'); foreach ($var_ary as $var) { $$var = (!empty($row[$var])) ? $row[$var] : ''; unset($row[$var]); } $style_cfg = addslashes($style_name) . "\n"; $style_cfg .= addslashes($style_copyright) . "\n"; $style_cfg .= addslashes($config['version']) . "\n"; $template_cfg = addslashes($template_name) . "\n"; $template_cfg .= addslashes($template_copyright) . "\n"; $template_cfg .= addslashes($config['version']) . "\n"; $theme_cfg = addslashes($theme_name) . "\n"; $theme_cfg .= addslashes($theme_copyright) . "\n"; $theme_cfg .= addslashes($config['version']) . "\n"; $imageset_cfg = addslashes($imageset_name) . "\n"; $imageset_cfg .= addslashes($imageset_copyright) . "\n"; $imageset_cfg .= addslashes($config['version']) . "\n"; foreach (array_keys($row) as $key) { $imageset_cfg .= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $row[$key]) . "\n"; unset($row[$key]); } $files = array( array( 'src' => "styles/$template_path/template/", 'prefix-' => "styles/$template_path/", 'prefix+' => false, 'exclude' => 'template.cfg'), array( 'src' => "styles/$theme_path/theme/", 'prefix-' => "styles/$theme_path/", 'prefix+' => false, 'exclude' => ($css_storedb) ? 'stylesheet.cfg,theme.cfg' : 'theme.cfg' ), array( 'src' => "styles/$imageset_path/imageset/", 'prefix-' => "styles/$imageset_path/", 'prefix+' => false, 'exclude' => 'imageset.cfg' ), ); $data = array( array( 'src' => trim($style_cfg), 'prefix' => 'style.cfg' ), array( 'src' => trim($theme_cfg), 'prefix' => 'theme/theme.cfg' ), array( 'src' => trim($template_cfg), 'prefix' => 'template/template.cfg' ), array( 'src' => trim($imageset_cfg), 'prefix' => 'imageset/imageset.cfg' ), ); if ($css_storedb) { $data += array( array( 'src' => $css_data, 'prefix' => 'theme/stylesheet.css' ), ); } unset($css_data); unset($style_cfg); unset($theme_cfg); unset($template_cfg); unset($imageset_cfg); export('style', $style_id, $style_name, str_replace(' ', '_', $style_name), $files, $data); } break; case 'add': case 'edit': case 'install': if (isset($_POST['update'])) { if ($action == 'install') { $style_path = htmlspecialchars($_POST['style_path']); if (!($cfg = file("{$phpbb_root_path}styles/$style_path/style.cfg"))) { trigger_error($user->lang['NO_STYLE']); } $style_name = trim($cfg[0]); $style_copyright = trim($cfg[1]); // Imageset if (!($cfg = file("{$phpbb_root_path}styles/$style_path/imageset/imageset.cfg"))) { trigger_error($user->lang['NO_IMAGESET']); } $imageset_name = trim($cfg[0]); $imageset_copyright = trim($cfg[1]); $sql = 'SELECT imageset_id, imageset_name FROM ' . STYLES_IMAGE_TABLE . " WHERE imageset_name = '" . $db->sql_escape($imageset_name) . "'"; $result = $db->sql_query($sql); // If an entry already exists we need not install this one if (!($row = $db->sql_fetchrow($result))) { if (empty($imageset_name)) { $error[] = $user->lang['IMAGESET_ERR_STYLE_NAME']; } if (strlen($imageset_name) > 30) { $error[] = $user->lang['IMAGESET_ERR_NAME_LONG']; } if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $imageset_name)) { $error[] = $user->lang['IMAGESET_ERR_NAME_CHARS']; } if (strlen($imageset_copyright) > 60) { $error[] = $user->lang['IMAGESET_ERR_COPY_LONG']; } if (!sizeof($error)) { $sql_img_ary = array(); for ($i = 3; $i < sizeof($cfg); $i++) { $tmp = explode('||', $cfg[$i]); $sql_img_ary[$tmp[0]] = str_replace('{PATH}', "styles/$style_path/imageset/", trim($tmp[1])); } $sql_ary = array( 'imageset_name' => $imageset_name, 'imageset_copyright' => $imageset_copyright, 'imageset_path' => str_replace(' ', '_', $style_path), ); $sql_ary += $sql_img_ary; $sql = 'INSERT INTO ' . STYLES_IMAGE_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $imageset_id = $db->sql_nextid(); add_log('admin', 'LOG_ADD_IMAGESET', $imageset_name); } } else { $imageset_id = $row['imageset_id']; } $db->sql_freeresult($result); unset($cfg); // Theme if (!($cfg = file("{$phpbb_root_path}styles/$style_path/theme/theme.cfg"))) { trigger_error($user->lang['NO_THEME']); } $theme_name = trim($cfg[0]); $theme_copyright = trim($cfg[1]); $sql = 'SELECT theme_id, theme_name FROM ' . STYLES_CSS_TABLE . " WHERE theme_name = '" . $db->sql_escape($theme_name) . "'"; $result = $db->sql_query($sql); // If an entry already exists we need not install this one if (!($row = $db->sql_fetchrow($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)) { $css_storedb = 0; $css_data = ''; if (!is_writeable("{$phpbb_root_path}styles/$style_path/theme/stylesheet.css")) { $css_data = implode('', file("{$phpbb_root_path}styles/$style_path/theme/stylesheet.css")); $css_storedb = 1; } $sql_ary = array( 'theme_name' => $theme_name, 'theme_copyright' => $theme_copyright, 'theme_path' => str_replace(' ', '_', $style_path), 'css_storedb' => $css_storedb, 'css_data' => $css_data, ); $sql = 'INSERT INTO ' . STYLES_CSS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $theme_id = $db->sql_nextid(); $log = ($css_storedb) ? 'LOG_ADD_THEME_DB' : 'LOG_ADD_THEME_FS'; add_log('admin', $log, $theme_name); } } else { $theme_id = $row['theme_id']; } $db->sql_freeresult($result); unset($cfg); // Template if (!($cfg = file("{$phpbb_root_path}styles/$style_path/template/template.cfg"))) { trigger_error($user->lang['NO_TEMPLATE']); } $template_name = trim($cfg[0]); $template_copyright = trim($cfg[1]); $sql = 'SELECT template_id, template_name FROM ' . STYLES_TPL_TABLE . " WHERE template_name = '" . $db->sql_escape($template_name) . "'"; $result = $db->sql_query($sql); // If an entry already exists we need not install this one if (!($row = $db->sql_fetchrow($result))) { if (empty($template_name)) { $error[] = $user->lang['TPL_ERR_STYLE_NAME']; } if (strlen($template_name) > 30) { $error[] = $user->lang['TPL_ERR_NAME_LONG']; } if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $template_name)) { $error[] = $user->lang['TPL_ERR_NAME_CHARS']; } if (strlen($template_copyright) > 60) { $error[] = $user->lang['TPL_ERR_COPY_LONG']; } if (!sizeof($error)) { $sql_ary = array( 'template_name' => $template_name, 'template_copyright' => $template_copyright, 'template_path' => str_replace(' ', '_', $style_path), ); $sql = 'INSERT INTO ' . STYLES_TPL_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $template_id = $db->sql_nextid(); $log = 'LOG_ADD_TPL_FS'; add_log('admin', $log, $template_name); } } else { $template_id = $row['template_id']; } $db->sql_freeresult($result); unset($cfg); } else { $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; $style_copyright = (isset($_POST['style_copyright'])) ? stripslashes(htmlspecialchars($_POST['style_copyright'])) : ''; $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; } $style_active = (!empty($_POST['style_active'])) ? 1 : 0; $style_default = (!empty($_POST['default_style'])) ? 1 : 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' || $action == 'install') ? "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' || $action == 'install') ? '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); if ($action == 'add' || $action == 'install') { $style_id = $db->sql_nextid(); } if ($style_default) { set_config('default_style', $style_id); } $log = ($action == 'add' || $action == 'install') ? 'LOG_ADD_STYLE' : 'LOG_EDIT_STYLE'; add_log('admin', $log, $style_name); $message = ($action == 'add' || $action == 'install') ? '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))) { trigger_error($user->lang['NO_STYLE']); } $db->sql_freeresult($result); $style_default = ($config['default_style'] == $style_id) ? 1 : 0; } else { if ($action == 'install' && !empty($_GET['name'])) { $style_path = htmlspecialchars($_GET['name']); if (!file_exists("{$phpbb_root_path}styles/$style_path/style.cfg")) { trigger_error($user->lang['NO_STYLE']); } if (!($cfg = file("{$phpbb_root_path}styles/$style_path/style.cfg"))) { trigger_error($user->lang['NO_STYLE']); } $style_version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($cfg[2])); $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); if ($style_version != $phpbbversion) { $error[] = $user->lang['STYLE_VERSION_DIFF']; } $style_name = trim($cfg[0]); $style_copyright = trim($cfg[1]); if (!($cfg = file("{$phpbb_root_path}styles/$style_path/imageset/imageset.cfg"))) { trigger_error($user->lang['NO_IMAGESET']); } $imageset_name = trim($cfg[0]); unset($cfg); if (!($cfg = file("{$phpbb_root_path}styles/$style_path/theme/theme.cfg"))) { trigger_error($user->lang['NO_THEME']); } $theme_name = trim($cfg[0]); unset($cfg); if (!($cfg = file("{$phpbb_root_path}styles/$style_path/template/template.cfg"))) { trigger_error($user->lang['NO_TEMPLATE']); } $template_name = trim($cfg[0]); unset($cfg); $style_active = 1; $s_hidden_fields = ''; } else { $style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : ''; $style_copyright = ''; $style_active = 1; $template_id = $theme_id = $imageset_id = $style_default = 0; } } } if ($action != 'install') { $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"' : ''; $style_default_yes = ($style_default) ? ' checked="checked"' : ''; $style_default_no = (!$style_default) ? ' 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: $template_name" : ''; ?>
Theme set: $theme_name" : ''; ?>
Imageset: $imageset_name" : ''; ?>
Active: /> Yes   /> No
Make default style: /> 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); $installed = array(); $basis_options = ''; while ($row = $db->sql_fetchrow($result)) { $installed[] = strtolower($row['style_name']); $basis_options .= ''; $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; $stylevis = (!$row['style_active']) ? 'activate' : 'deactivate'; ?> sql_freeresult($result); ?> $cfg) { ?>
Style name Used by Options
Installed styles
">  ">lang['STYLE_' . strtoupper($stylevis)]; ?>   ">Delete   ">Export   Preview 
Uninstalled styles
">Install
No uninstalled themes detected
Create new style:
sql_query($sql); if (!($row = ($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_IMAGESET']); } $db->sql_freeresult($result); $imageset_name = $row['imageset_name']; $imageset_path = $row['imageset_path']; $imageset_copyright = $row['imageset_copyright']; unset($row['imageset_name']); unset($row['imageset_path']); unset($row['imageset_copyright']); unset($row['imageset_id']); $cfg = addslashes($imageset_name) . "\n"; $cfg .= addslashes($imageset_copyright) . "\n"; $cfg .= addslashes($config['version']) . "\n"; foreach (array_keys($row) as $key) { $cfg.= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $row[$key]) . "\n"; unset($row[$key]); } $files = array(array('src' => "styles/$imageset_path/imageset/", 'prefix-' => "styles/$imageset_path/", 'prefix+' => false, 'exclude' => 'imageset.cfg')); $data = array(array('src' => trim($cfg), 'prefix' => "imageset/imageset.cfg")); export('imageset', $imageset_id, $imageset_name, $imageset_path, $files, $data); } break; case 'delete': if ($imageset_id) { $sql = 'SELECT imageset_id, imageset_name, imageset_path FROM ' . STYLES_IMAGE_TABLE . " WHERE imageset_id = $imageset_id"; $result = $db->sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_IMAGESET']); } $db->sql_freeresult($result); remove('imageset', $imageset_id, $imageset_name, $imageset_path); } break; case 'add': case 'details': case 'install': details('imageset', $mode, $action, $imageset_id); exit; break; case 'edit': $imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($imgname) : ''; if ($imageset_id) { $sql = 'SELECT * FROM ' . STYLES_IMAGE_TABLE . " WHERE imageset_id = $imageset_id"; $result = $db->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
  
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(), ); // Lights, Camera ... switch ($action) { case 'preview': break; case 'refresh': if ($template_id) { $sql = 'SELECT template_path, template_storedb 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); if ($template_storedb && file_exists("{$phpbb_root_path}styles/$template_path/template/")) { $filelist = array('/' => array()); $sql = 'SELECT template_filename, template_mtime FROM ' . STYLES_TPLDATA_TABLE . " WHERE template_id = $template_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (@filemtime("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename']) > $row['template_mtime']) { $filelist['/'][] = $row['template_filename']; } } $db->sql_freeresult($result); store_templates('update', $template_id, $template_path, $filelist); unset($filelist); } } break; case 'delete': if ($template_id) { $sql = 'SELECT template_id, template_name, template_path, template_storedb 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); if ($template_storedb) { $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " WHERE template_id = $template_id"; $db->sql_query($sql); } remove('template', $template_id, $template_name, $template_path, $template_storedb); } break; case 'export': 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); $cfg = addslashes($template_name) . "\n"; $cfg .= addslashes($template_copyright) . "\n"; $cfg .= addslashes($config['version']) . "\n"; $cfg .= addslashes($bbcode_bitfield) . "\n"; if ($template_storedb) { // TODO // eek } else { $files = array(array('src' => "styles/$template_path/template/", 'prefix-' => "styles/$template_path/", 'prefix+' => false, 'exclude' => 'template.cfg')); $data = array(array('src' => trim($cfg), 'prefix' => 'template/template.cfg')); } export('template', $template_id, $template_name, $template_path, $files, $data); } break; case 'cache': $source = (!empty($_GET['source'])) ? htmlspecialchars($_GET['source']) : ''; $file_ary = (!empty($_POST['delete'])) ? array_map('htmlspecialchars', $_POST['delete']) : ''; $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'] && $file_ary) { foreach ($file_ary as $file) { $file = "{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx"; if (file_exists($file) && is_file($file)) { @unlink($file); } } unset($file_ary); 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 ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_$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]); ?>

sql_query($sql); $filemtime = array(); while ($row = $db->sql_fetchrow($result)) { $filemtime[$row['template_filename']] = $row['template_mtime']; } $db->sql_freeresult($result); } // Open the cache directory and grab a list of the relevant cached templates. // We also grab some other details such as when the compiled template was // created, when the original template was modified and the cached filesize if (!($dp = @opendir("{$phpbb_root_path}cache"))) { trigger_error($user->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'] = (!$template_storedb) ? filemtime("{$phpbb_root_path}styles/$template_path/template/$filename.html") : $filemtime[$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_MODIFIED']; ?> 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); // User wants to submit data ... if (!empty($_POST['update'])) { // Where is the template stored? if (!$template_storedb && is_writeable("{$phpbb_root_path}styles/$template_path/template/$tplname")) { // Grab template data if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'wb'))) { trigger_error($user->lang['NO_TEMPLATE']); } $stylesheet = fwrite($fp, stripslashes($stylesheet)); fclose($fp); } else { $db->sql_transaction('begin'); if (!$template_storedb) { // We change the path to one relative to the root rather than the theme folder $sql = 'UPDATE ' . STYLES_TPL_TABLE . ' SET template_storedb = 1 WHERE template_id = ' . $template_id; $db->sql_query($sql); $filelist = filelist("{$phpbb_root_path}styles/$template_path/template"); $filelist = array('/template' => $filelist['']); store_templates('insert', $template_id, $template_path, $filelist); } $sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . " SET template_data = '" . $db->sql_escape($tpldata) . "', template_mtime = " . time() . " WHERE template_id = $template_id AND template_filename = '" . $db->sql_escape($tplname) . "'"; $db->sql_query($sql); $db->sql_transaction('commit'); } @unlink("{$phpbb_root_path}cache/tpl_{$template_name}_$tplname.$phpEx"); $error[] = $user->lang['TEMPLATE_UPDATED']; add_log('admin', 'LOG_EDIT_TEMPLATE', $template_name); } $test_ary = array(); foreach ($tpllist as $category => $tpl_ary) { $test_ary = array_merge($test_ary, $tpl_ary); } if (!$template_storedb) { $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); while ($file = readdir($dp)) { if (!strstr($file, 'bbcode.') && strstr($file, '.html') && !in_array($file, $test_ary) && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) { $tpllist['custom'][] = $file; } } closedir($dp); unset($matches); unset($test_ary); if ($tplname && !$tpldata) { if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'r'))) { trigger_error($user->lang['NO_TEMPLATE']); } $tpldata = fread($fp, filesize("{$phpbb_root_path}styles/$template_path/template/$tplname")); fclose($fp); } } else { $sql = 'SELECT * FROM ' . STYLES_TPLDATA_TABLE . " WHERE template_id = $template_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!strstr($row['template_filename'], 'bbcode.') && !in_array($row['template_filename'], $test_ary)) { $tpllist['custom'][] = $row['template_filename']; } if ($row['template_filename'] == $tplname && !$tpldata) { $tpldata = $row['template_data']; } } $db->sql_freeresult($result); } // List of included templates if ($tplname) { preg_match_all('##', $tpldata, $included_tpls); $included_tpls = $included_tpls[1]; } } unset($test_ary); // Generate list of template options $tpl_options = ''; ksort($tpllist); foreach ($tpllist as $category => $tpl_ary) { sort($tpl_ary); $tpl_options .= ''; foreach ($tpl_ary as $tpl_file) { $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; $tpl_options .= ''; } } // Output page adm_page_header($user->lang['EDIT_TEMPLATE']); ?>

lang['EDIT_TEMPLATE']; ?>

lang['EDIT_TEMPLATE_EXPLAIN']; ?>

">
lang['SELECT_TEMPLATE']; ?>:  
Columns:  Rows:  
Raw HTML
  
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 (!$theme_storedb) { if (!($fp = fopen("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css", 'rb'))) { trigger_error($user->lang['NO_THEME']); } $stylesheet = fread($fp, filesize("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")); fclose($fp); } else { $stylesheet = &$theme_data; } // 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 += $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); } // Where is the CSS stored? if (!$storedb && is_writeable("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.css")) { // Grab template data if (!($fp = fopen("{$phpbb_root_path}styles/$theme_path/theme/stylesheet.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( 'theme_storedb' => 1, 'theme_data' => str_replace('./', "styles/$theme_path/theme/", $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($theme_path, $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/$theme_path/theme"); $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:
  
sql_query($sql); if (!(extract($db->sql_fetchrow($result)))) { trigger_error($user->lang['NO_THEME']); } $db->sql_freeresult($result); remove('theme', $theme_id, $theme_name, $theme_path, $theme_storedb); } break; case 'export': 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); $cfg = addslashes($theme_name) . "\n"; $cfg .= addslashes($theme_copyright) . "\n"; $cfg .= addslashes($config['version']) . "\n"; if ($css_storedb) { $files = array(array('src' => "styles/$theme_path/theme/", 'prefix-' => "styles/$theme_path/", 'prefix+' => false, 'exclude' => "$theme_path.css,theme.cfg")); $data = array(array('src' => $css_data, 'prefix' => "theme/$theme_path.css"), array('src' => trim($cfg), 'prefix' => "theme/theme.cfg")); } else { $files = array(array('src' => "styles/$theme_path/theme/", 'prefix-' => "styles/$theme_path/", 'prefix+' => false, 'exclude' => "theme.cfg")); $data = array(array('src' => trim($cfg), 'prefix' => "theme/theme.cfg")); } unset($css_data); export('theme', $theme_id, $theme_name, $theme_path, $files, $data); } break; } // Front page front('theme', array('details', 'refresh', 'export', 'delete', 'preview')); break; } exit; // --------- // FUNCTIONS // function front($type, $options) { global $phpbb_root_path, $phpEx, $SID, $config, $db, $user, $mode; switch ($type) { case 'template': $table = STYLES_TPL_TABLE; break; case 'theme': $table = STYLES_CSS_TABLE; break; case 'imageset': $table = STYLES_IMAGE_TABLE; break; } $l_prefix = strtoupper($type); // Output list of themes adm_page_header($user->lang[$l_prefix . 'S']); ?>

lang[$l_prefix . 'S']; ?>

lang[$l_prefix . 'S_EXPLAIN']; ?>

">sql_query($sql); $installed = array(); $basis_options = ''; while ($row = $db->sql_fetchrow($result)) { $installed[] = $row[$type . '_name']; $basis_options .= ''; $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> sql_freeresult($result); ?> $cfg) { $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?>
Theme name Options
Installed themes
">  ">lang[strtoupper($option)]; ?> 
Uninstalled themes
">Install
No uninstalled themes detected
Create new theme:
$id ORDER BY {$type}_id"; $result = $db->sql_query($sql); $options = ''; if (!($row = $db->sql_fetchrow($result))) { trigger_error($user->lang['ONLY_' . $l_prefix]); } do { $options .= ''; } while ($row = $db->sql_fetchrow($result)); if (isset($_POST['update'])) { $sql = "DELETE FROM $table WHERE {$type}_id = $id"; $db->sql_query($sql); $sql = "UPDATE $table SET {$type}_id = " . intval($_POST['newid']) . " WHERE {$type}_id = $id"; $db->sql_query($sql); $onfs = 0; if (!empty($_POST['deletefs']) && is_writeable("{$phpbb_root_path}styles/$path/{$type}")) { $filelist = filelist("{$phpbb_root_path}styles/$path/{$type}", '', '*'); krsort($filelist); foreach ($filelist as $subpath => $file_ary) { $subpath = "{$phpbb_root_path}styles/$path/{$type}$subpath"; foreach ($file_ary as $file) { /* if (!@unlink("$subpath/$file")) { $onfs = 1; }*/ } /* if (!@rmdir($subpath)) { $onfs = 1; }*/ } } else { $onfs = (file_exists("{$phpbb_root_path}styles/$path/{$type}") && !is_writeable("{$phpbb_root_path}styles/$path/{$type}")) ? 1 : 0; } add_log('admin', 'LOG_DELETE_' . $l_prefix, $name); $message = ($onfs) ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED'; trigger_error($user->lang[$message]); } // Output list of themes adm_page_header($user->lang['DELETE_' . $l_prefix]); ?>

lang['DELETE_' . $l_prefix]; ?>

lang['DELETE_' . $l_prefix . '_EXPLAIN']; ?>

">
lang['DELETE_' . $l_prefix]; ?>
lang[$l_prefix . '_NAME']; ?>:
Delete from filesystem: lang['YES']; ?>   lang['NO']; ?>
Update XXXXXX to:
Select XXXXXX to replace this one if used by styles.
  
sql_query($sql); if (!($row = $db->sql_fetchrow($result))) { trigger_error($user->lang['NO_' . $l_type]); } $db->sql_freeresult($result); $name = (!empty($row[$type . '_name'])) ? $row[$type . '_name'] : ''; $copyright = (!empty($row[$type . '_copyright'])) ? $row[$type . '_copyright'] : ''; $path = (!empty($row[$type . '_path'])) ? $row[$l_type . '_path'] : ''; $storedb = (!empty($row[$type . '_storedb'])) ? $type[$type . '_storedb'] : ''; $data = (!empty($row[$type . '_data'])) ? $row[$type . '_data'] : ''; unset($row); $s_hidden_fields = ''; } else if ($action == 'install' && empty($_POST['update'])) { if (empty($_GET['name'])) { trigger_error($user->lang[$l_type . '_ERR_NO_NAME']); } $path = trim(htmlspecialchars($_GET['name'])); if (!file_exists("{$phpbb_root_path}styles/$path/$type/$type.cfg")) { trigger_error($user->lang['NO_' . $l_type]); } if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) { trigger_error($user->lang['NO_' . $l_type]); } $name = trim($cfg[0]); $copyright = trim($ecfg[1]); $version = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', trim($cfg[2])); $phpbbversion = preg_replace('#^2\.([0-9]+?)\.([0-9]+?).*?$#', '\1.\2', $config['version']); if ($version != $phpbbversion) { $error[] = $user->lang[$l_type . '_VERSION_DIFF']; } $s_hidden_fields = ''; } else { $name = (!empty($_POST['name'])) ? htmlspecialchars(stripslashes($_POST['name'])) : ''; $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars(stripslashes($_POST['copyright'])) : ''; $storedb = (!empty($_POST['storedb'])) ? 1 : (($safe_mode) ? 1 : 0); $basis = (!empty($_POST['basis'])) ? intval($_POST['basis']) : false; $path = (!empty($_POST['path'])) ? htmlspecialchars(stripslashes($_POST['path'])) : ''; $s_hidden_fields = (!empty($_POST['basis'])) ? '' : ''; if ($path) { $s_hidden_fields .= ''; } } } // Do the update thang if (isset($_POST['update'])) { if (!$safe_mode && $action == 'add' && is_writeable("{$phpbb_root_path}styles") && (!empty($_FILES['upload_file']['name']) || !empty($_POST['import_file']))) { if (!empty($_FILES['upload_file']['name'])) { $realname = htmlspecialchars($_FILES['upload_file']['name']); $filename = htmlspecialchars($_FILES['upload_file']['tmp_name']); if (!is_uploaded_file($filename)) { trigger_error("$filename was not uploaded"); } } else { $realname = htmlspecialchars($_POST['import_file']); $filename = "{$phpbb_root_path}store/$realname"; } if (!preg_match('#(' . $archive_preg . ')$#i', $realname, $match)) { $error[] = sprintf($user->lang['UPLOAD_WRONG_TYPE'], $archive_types); } $path = preg_replace('#^(.*?)' . preg_quote($match[0]) . '$#', '\1', $realname); // Attempt to extract the files to a temporary directory in store $tmp_path = $phpbb_root_path . 'store/tmp_' . substr(uniqid(''), 0, 10) . '/'; if (!@mkdir($tmp_path)) { trigger_error("Cannot create $tmp_path"); } include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); switch ($match[0]) { case '.zip': $zip = new compress_zip('r', $filename); break; default: $zip = new compress_tar('r', $filename, $match[0]); } $zip->extract($tmp_path); $zip->close(); $filelist = filelist($tmp_path, '', '*'); if (!in_array($type . '.cfg', $filelist['/' . $type])) { trigger_error($user->lang[$l_type . '_ERR_NOT_' . $l_type]); } $cfg = file("$tmp_path$type/$type.cfg"); if ($name == '') { $name = trim($cfg[0]); } $copyright = trim($cfg[1]); $version = trim($cfg[2]); unset($cfg); } else if ($action == 'install') { $path = (!empty($_POST['path'])) ? htmlspecialchars($_POST['path']) : ''; if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/$type.cfg"))) { trigger_error($user->lang['NO_' . $l_type]); } $name = (!empty($_POST['name'])) ? htmlspecialchars($_POST['name']) : trim($cfg[0]); $storedb = (!empty($_POST['storedb'])) ? 1 : 0; $copyright = trim($cfg[1]); $version = trim($cfg[2]); unset($cfg); } else { $name = (!empty($_POST['name'])) ? htmlspecialchars($_POST['name']) : ''; $copyright = (!empty($_POST['copyright'])) ? htmlspecialchars($_POST['copyright']) : ''; $storedb = (!empty($_POST['storedb'])) ? 1 : 0; } $sql_where = ($action == 'add' || $action == 'install') ? "WHERE {$type}_name = '" . $db->sql_escape($name) . "'" : "WHERE {$type}_id <> $id AND {$type}_name = '" . $db->sql_escape($name) . "'"; $sql = "SELECT {$type}_name FROM $table $sql_where"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; } $db->sql_freeresult($result); unset($row); if (empty($name)) { $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; } if (strlen($name) > 30) { $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; } if (!preg_match('#^[a-z0-9_\-\+\. ]+$#i', $name)) { $error[] = $user->lang[$l_type . '_ERR_NAME_CHARS']; } if (strlen($copyright) > 60) { $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; } if (!sizeof($error)) { $css_data = ''; if ($action == 'install') { switch ($type) { case 'theme': if (!is_writeable("{$phpbb_root_path}styles/$path/$type/stylesheet.css")) { $storedb = 1; if (!($css_data = implode('', file("{$phpbb_root_path}styles/$path/$type/stylesheet.css")))) { trigger_error($user->lang['NO_THEME']); } } break; case 'template': $filelist = filelist("{$phpbb_root_path}styles/$path/$type", '', 'html'); foreach ($filelist as $pathfile => $file_ary) { foreach ($file_ary as $file) { if (!is_writeable("{$phpbb_root_path}styles/$path/$type$pathfile/$file")) { $storedb = 1; break; } } } break; case 'imageset': if (!($cfg = file("{$phpbb_root_path}styles/$path/$type/imageset.cfg"))) { trigger_error($user->lang['NO_IMAGESET']); } for ($i = 3; $i < sizeof($cfg); $i++) { $tmp = explode('||', $cfg[$i]); $sql_img_ary[$tmp[0]] = str_replace('{PATH}', "styles/$path/$type/", trim($tmp[1])); } unset($cfg); break; } } if ($action == 'add' && !$safe_mode && is_writeable("{$phpbb_root_path}styles")) { if (file_exists("{$phpbb_root_path}styles/$path/$type/")) { for ($i = 1; $i < 100; $i++) { if (!file_exists("$phpbb_root_path/styles/{$path}_{$i}/$type/")) { $path .= "_$i"; break; } } } umask(0); if (@mkdir("{$phpbb_root_path}styles/$path", 0777)) { @chmod("{$phpbb_root_path}styles/$path", 0777); } if (@mkdir("{$phpbb_root_path}styles/$path/$type", 0777)) { if (!@chmod("{$phpbb_root_path}styles/$path/$type", 0777)) { $storedb = 1; } } if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) { // TODO // mkdir, rmdir and rename error catching ksort($filelist); foreach ($filelist as $filepath => $file_ary) { if ($path && !file_exists("{$phpbb_root_path}styles/$path$filepath")) { @mkdir("{$phpbb_root_path}styles/$path$filepath", 0777); } foreach ($file_ary as $file) { @rename("$tmp_path$filepath/$file", "{$phpbb_root_path}styles/$path$filepath/$file"); } if ($filepath && file_exists("$tmp_path$filepath")) { @rmdir("$tmp_path$filepath"); } } @rmdir("$tmp_path/$type"); @rmdir($tmp_path); } else if ($basis && !$storedb && !$safe_mode) { switch ($type) { case 'theme': $sql = "SELECT theme_name, theme_path, theme_storedb, css_data FROM $table WHERE theme_id = $basis"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $css_data = ($row['storedb']) ? $row['css_data'] : implode('', file($phpbb_root_path . 'styles/' . $row['theme_path'] . "/$type/stylesheet.css")); if (!$storedb && ($fp = @fopen("{$phpbb_root_path}styles/$path/$type/stylesheet.css", 'wb'))) { $storedb = (@fwrite($fp, $css_data)) ? 0 : 1; if (!$storedb) { unset($css_data); // Get a list of all files and folders in the basis themes folder $filelist = filelist($phpbb_root_path . 'styles/' . $row['theme_path'] . '/' . $type, '', '*'); // Copy every file bar the original stylesheet foreach ($filelist as $filepath => $file_ary) { foreach ($file_ary as $file) { if ($file == 'stylesheet.css') { continue; } if (!file_exists("{$phpbb_root_path}styles/$path/$type/$filepath")) { @mkdir("{$phpbb_root_path}styles/$path/$type/$filepath"); } @copy("{$phpbb_root_path}styles/" . $row['theme_path'] . "/$type/$filepath/$file", "{$phpbb_root_path}styles/$path/$type/$filepath/$file"); } } unset($filelist); } } else { $storedb = 1; } @fclose($fp); } $db->sql_freeresult($result); break; case 'template': $sql = "SELECT theme_name, theme_path, theme_storedb, css_data FROM $table WHERE theme_id = $basis"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $error = $user->lang['NO_TEMPLATE']; break; } if (!is_writeable("{$phpbb_root_path}styles/$path/$type")) { $storedb = 1; } if ($row['template_storedb']) { } break; case 'imageset': $sql = "SELECT imageset_name, imageset_path FROM $table WHERE imageset_id = $basis"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { // Get a list of all files and folders $filelist = filelist("{$phpbb_root_path}styles/" . $row['imageset_path'] . '/imageset/', '', '*'); // Copy every file foreach ($filelist as $pathfile => $file_ary) { foreach ($file_ary as $file) { if (!file_exists("{$phpbb_root_path}styles/$path/$type/$pathfile")) { @mkdir("{$phpbb_root_path}styles/$path/$type/$pathfile"); } @copy("{$phpbb_root_path}styles/" . $row['imageset_path'] . "/$type$pathfile/$file", "{$phpbb_root_path}styles/$path/$type$pathfile/$file"); } } unset($filelist); } $db->sql_freeresult($result); break; } } } // Build relevant array ... we need to do this in bits depending on the // action and type $sql_ary = array( $type . '_name' => $name, ); if ($action == 'add' || $action == 'install') { $sql_ary += array( $type . '_copyright'=> $copyright, $type . '_path' => $path, ); switch ($type) { case 'theme': $sql_ary += array( $type . '_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, $type . '_storedb' => $storedb, $type . '_data' => ($storedb) ? $css_data : '', ); break; case 'template': $sql_ary += array( $type . '_storedb' => $storedb, ); break; } } if ($action == 'details' && $mode != 'imagesets') { $sql = "SELECT {$type}_path, {$type}_storedb" . (($type == 'theme') ? ', theme_data' : '') . " FROM $table WHERE {$type}_id = $id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row[$type . '_storedb'] != $storedb) { $path = $row[$type . '_path']; switch ($type) { case 'theme': $css_data = implode('', file("{$phpbb_root_path}styles/$path/$type/stylesheet.css")); if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$path/theme/stylesheet.css")) { $storedb = 1; if ($fp = @fopen("{$phpbb_root_path}styles/$path/$type/stylesheet.css", 'wb')) { $storedb = (@fwrite($fp, str_replace("styles/$path/theme/", './', $css_data))) ? 0 : 1; } fclose($fp); } $css_data = str_replace('./', "styles/$path/theme/", $css_data); $sql_ary += array( $type . '_mtime' => ($storedb) ? filemtime("{$phpbb_root_path}styles/$path/$type/stylesheet.css") : 0, $type . '_storedb' => $storedb, $type . '_data' => ($storedb) ? $css_data : '', ); break; case 'template': $filelist = filelist("{$phpbb_root_path}styles/$path/template", '', 'html'); if (!$storedb && !$safe_mode && is_writeable("{$phpbb_root_path}styles/$path/template")) { $sql = 'SELECT * FROM ' . STYLES_TPLDATA_TABLE . " WHERE template_id = $id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!($fp = fopen("{$phpbb_root_path}styles/$path/template/" . $row['template_filename'], 'wb'))) { $storedb = 1; break; } if (!fwrite($fp, $row['template_data'])) { $storedb = 1; break; } fclose($fp); } $db->sql_freeresult($result); if (!$storedb) { $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " WHERE template_id = $id"; $db->sql_query($sql); } } $sql_ary += array( $type . '_storedb' => $storedb, ); break; } } } $db->sql_transaction('begin'); $sql = ($action == 'add' || $action == 'install') ? "INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary) : "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE {$type}_id = $id"; $db->sql_query($sql); if ($type == 'template' && $storedb) { $filelist = array('/template' => $filelist['']); if (!$id) { $id = $db->sql_nextid(); } store_templates('insert', $id, $path, $filelist); } $db->sql_transaction('commit'); $message = ($action == 'add' || $action == 'install') ? (($storedb) ? $l_prefix . '_DB_ADDED' : $l_prefix . '_FS_ADDED') : $l_prefix . '_DETAILS_UPDATE'; $log = ($action == 'add' || $action == 'install') ? (($storedb) ? 'LOG_ADD_' . $l_prefix . '_DB' : 'LOG_ADD_' . $l_prefix . '_FS') : 'LOG_EDIT_' . $l_prefix . '_DETAILS'; add_log('admin', $log, $_name); trigger_error($user->lang[$message]); } // If we were uploading or importing and an error occured we delete // the temporary files if (!empty($_FILES['upload_file']) || !empty($_POST['import_file'])) { // TODO // mkdir, rmdir and rename error catching ksort($filelist); foreach ($filelist as $filepath => $file_ary) { foreach ($file_ary as $file) { @unlink("$tmp_path$filepath/$file"); } if ($filepath && file_exists("$tmp_path$filepath")) { @rmdir("$tmp_path$filepath"); } } @rmdir("$tmp_path/$type"); @rmdir($tmp_path); } } $storedb_no = (!$storedb) ? ' checked="checked"' : ''; $storedb_yes = ($storedb) ? ' checked="checked"' : ''; // Output the page adm_page_header($user->lang[$l_prefix . '_' . $l_type]); ?>

lang[$l_prefix . '_' . $l_type]; ?>

lang[$l_prefix . '_' . $l_type . '_EXPLAIN']; ?>

">$file"; } } closedir($dp); $store_options = '' . $store_options; $sql = "SELECT {$type}_id, {$type}_name FROM $table"; $result = $db->sql_query($sql); $basis_options = ''; while ($row = $db->sql_fetchrow($result)) { $selected = (!empty($_POST['basis']) && $_POST['basis'] == $row[$type . '_id']) ? ' selected="selected"' : ''; $basis_options .= ''; } $db->sql_freeresult($result); ?>
lang[$l_prefix . '_' . $l_type]; ?>
', $error); ?>
lang[$l_type . '_NAME']; ?>:
lang['COPYRIGHT']; ?>: ' : "$copyright"; ?>
lang[$l_type . '_LOCATION']; ?>:
lang[$l_type . '_LOCATION_EXPLAIN']; ?>
/> Filesystem   />Database
lang[$l_type . '_BASIS']; ?>
lang[$l_type . '_EXISTING_BASIS']; ?>:
lang[$l_type . '_UPLOAD_BASIS']; ?>:
lang['ALLOWED_FILETYPES']; ?>:
lang[$l_type . '_IMPORT_BASIS']; ?>:
  
$file_ary) { foreach ($file_ary as $file) { if (!($fp = fopen("{$phpbb_root_path}styles/$path$pathfile/$file", 'r'))) { trigger_error("Could not open {$phpbb_root_path}styles/$path/$pathfile/$file"); } $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$path$pathfile/$file")); fclose($fp); if (preg_match_all('##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' => $id, 'template_filename' => $file, 'template_included' => (!empty($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', 'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile/$file"), 'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile/$file")), ); $sql = ($mode == 'insert') ? 'INSERT INTO ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TPLDATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) . " WHERE template_id = $id AND template_filename = '" . $db->sql_escape($file) . "'"; $db->sql_query($sql); } } } function export($type, $id, $name, $path, &$files, &$data) { global $phpbb_root_path, $phpEx, $SID, $config, $user, $mode, $action; include($phpbb_root_path . 'includes/functions_compress.'.$phpEx); $l_prefix = strtoupper($type); if (isset($_POST['update'])) { 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: $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; } if (!sizeof($error)) { if (!($zip = new $compress('w', "{$phpbb_root_path}store/$path.$ext"))) { trigger_error($user->lang['STORE_UNWRITEABLE']); } if ($files) { foreach ($files as $file_ary) { $zip->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); } } if ($data) { foreach ($data as $data_ary) { $zip->add_data($data_ary['src'], $data_ary['prefix']); } } $zip->close(); add_log('admin', 'LOG_EXPORT_' . $l_prefix, $name); if (empty($_POST['store'])) { header('Pragma: no-cache'); header("Content-Type: application/$mimetype; name=\"$path.$ext\""); header("Content-disposition: attachment; filename=$path.$ext"); $fp = fopen("{$phpbb_root_path}store/$path.$ext", 'rb'); while ($buffer = fread($fp, 1024)) { echo $buffer; } fclose($fp); @unlink("{$phpbb_root_path}store/{$type}_$path.$ext"); exit; } trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext")); } } // Output list of themes adm_page_header($user->lang[$l_prefix . '_EXPORT']); ?>

lang[$l_prefix . '_EXPORT']; ?>

lang[$l_prefix . '_EXPORT_EXPLAIN']; ?>

">
lang[$l_prefix . '_EXPORT']; ?>
', $error); ?>
lang[$l_prefix . '_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 . '  '; } ?>
  

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";