📄 acp_styles.php
字号:
foreach ($var_ary as $var) { if (!isset($style_row[$var])) { $style_row[$var] = ''; } } $files = $data = array(); if ($mode == 'style') { $style_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['style_name'], $style_row['style_copyright'], $config['version']), $this->style_cfg); $style_cfg .= (!$inc_template) ? "\ntemplate = {$style_row['template_name']}" : ''; $style_cfg .= (!$inc_theme) ? "\ntheme = {$style_row['theme_name']}" : ''; $style_cfg .= (!$inc_imageset) ? "\nimageset = {$style_row['imageset_name']}" : ''; $data[] = array( 'src' => $style_cfg, 'prefix' => 'style.cfg' ); unset($style_cfg); } // Export template core code if ($mode == 'template' || $inc_template) { $template_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['template_name'], $style_row['template_copyright'], $config['version']), $this->template_cfg); $template_cfg .= "\nbbcode_bitfield = {$style_row['bbcode_bitfield']}"; $data[] = array( 'src' => $template_cfg, 'prefix' => 'template/template.cfg' ); // This is potentially nasty memory-wise ... if (!$style_row['template_storedb']) { $files[] = array( 'src' => "styles/{$style_row['template_path']}/template/", 'prefix-' => "styles/{$style_row['template_path']}/", 'prefix+' => false, 'exclude' => 'template.cfg' ); } else { $sql = 'SELECT template_filename, template_data FROM ' . STYLES_TEMPLATE_DATA_TABLE . " WHERE template_id = {$style_row['template_id']}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $data[] = array( 'src' => $row['template_data'], 'prefix' => 'template/' . $row['template_filename'] ); } $db->sql_freeresult($result); } unset($template_cfg); } // Export theme core code if ($mode == 'theme' || $inc_theme) { $theme_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['theme_name'], $style_row['theme_copyright'], $config['version']), $this->theme_cfg); // Read old cfg file $items = $cache->obtain_cfg_items($style_row); $items = $items['theme']; if (!isset($items['parse_css_file'])) { $items['parse_css_file'] = 'off'; } $theme_cfg = str_replace(array('{PARSE_CSS_FILE}'), array($items['parse_css_file']), $theme_cfg); $files[] = array( 'src' => "styles/{$style_row['theme_path']}/theme/", 'prefix-' => "styles/{$style_row['theme_path']}/", 'prefix+' => false, 'exclude' => ($style_row['theme_storedb']) ? 'stylesheet.css,theme.cfg' : 'theme.cfg' ); $data[] = array( 'src' => $theme_cfg, 'prefix' => 'theme/theme.cfg' ); if ($style_row['theme_storedb']) { $data[] = array( 'src' => $style_row['theme_data'], 'prefix' => 'theme/stylesheet.css' ); } unset($items, $theme_cfg); } // Export imageset core code if ($mode == 'imageset' || $inc_imageset) { $imageset_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['imageset_name'], $style_row['imageset_copyright'], $config['version']), $this->imageset_cfg); foreach ($this->imageset_keys as $topic => $key_array) { foreach ($key_array as $key) { $imageset_cfg .= "\nimg_" . $key . ' = ' . str_replace("styles/{$style_row['imageset_path']}/imageset/", '{PATH}', $style_row[$key]); } } $files[] = array( 'src' => "styles/{$style_row['imageset_path']}/imageset/", 'prefix-' => "styles/{$style_row['imageset_path']}/", 'prefix+' => false, 'exclude' => 'imageset.cfg' ); $data[] = array( 'src' => trim($imageset_cfg), 'prefix' => 'imageset/imageset.cfg' ); unset($imageset_cfg); } switch ($format) { case 'tar': $ext = '.tar'; $mimetype = 'x-tar'; $compress = 'compress_tar'; break; case 'zip': $ext = '.zip'; $mimetype = 'zip'; break; case 'tar.gz': $ext = '.tar.gz'; $mimetype = 'x-gzip'; break; case 'tar.bz2': $ext = '.tar.bz2'; $mimetype = 'x-bzip2'; break; default: $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; } if (!sizeof($error)) { include($phpbb_root_path . 'includes/functions_compress.' . $phpEx); if ($mode == 'style') { $path = preg_replace('#[^\w-]+#', '_', $style_row['style_name']); } else { $path = $style_row[$mode . '_path']; } if ($format == 'zip') { $compress = new compress_zip('w', $phpbb_root_path . "store/$path$ext"); } else { $compress = new compress_tar('w', $phpbb_root_path . "store/$path$ext", $ext); } if (sizeof($files)) { foreach ($files as $file_ary) { $compress->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); } } if (sizeof($data)) { foreach ($data as $data_ary) { $compress->add_data($data_ary['src'], $data_ary['prefix']); } } $compress->close(); add_log('admin', 'LOG_' . $l_prefix . '_EXPORT', $style_row[$mode . '_name']); if (!$store) { $compress->download($path); @unlink("{$phpbb_root_path}store/$path$ext"); exit; } trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path$ext") . adm_back_link($this->u_action)); } } $sql = "SELECT {$mode}_id, {$mode}_name FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " WHERE {$mode}_id = $style_id"; $result = $db->sql_query($sql); $style_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$style_row) { trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); } $this->page_title = $l_prefix . '_EXPORT'; $format_buttons = ''; foreach ($methods as $method) { $format_buttons .= '<input type="radio"' . ((!$format_buttons) ? ' id="format"' : '') . ' class="radio" value="' . $method . '" name="format"' . (($method == $format) ? ' checked="checked"' : '') . ' /> ' . $method . ' '; } $template->assign_vars(array( 'S_EXPORT' => true, 'S_ERROR_MSG' => (sizeof($error)) ? true : false, 'S_STYLE' => ($mode == 'style') ? true : false, 'L_TITLE' => $user->lang[$this->page_title], 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], 'L_NAME' => $user->lang[$l_prefix . '_NAME'], 'U_ACTION' => $this->u_action . '&action=export&id=' . $style_id, 'U_BACK' => $this->u_action, 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '', 'NAME' => $style_row[$mode . '_name'], 'FORMAT_BUTTONS' => $format_buttons) ); } /** * Display details */ function details($mode, $style_id) { global $template, $db, $config, $user, $safe_mode, $cache, $phpbb_root_path; $update = (isset($_POST['update'])) ? true : false; $l_type = strtoupper($mode); $error = array(); $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE); switch ($mode) { case 'style': $sql_from = STYLES_TABLE; break; case 'template': $sql_from = STYLES_TEMPLATE_TABLE; break; case 'theme': $sql_from = STYLES_THEME_TABLE; break; case 'imageset': $sql_from = STYLES_IMAGESET_TABLE; break; } $sql = "SELECT * FROM $sql_from WHERE {$mode}_id = $style_id"; $result = $db->sql_query($sql); $style_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$style_row) { trigger_error($user->lang['NO_' . $l_type] . adm_back_link($this->u_action), E_USER_WARNING); } $style_row['style_default'] = ($mode == 'style' && $config['default_style'] == $style_id) ? 1 : 0; if ($update) { $name = request_var('name', ''); $copyright = request_var('copyright', '', true); $template_id = request_var('template_id', 0); $theme_id = request_var('theme_id', 0); $imageset_id = request_var('imageset_id', 0); $style_active = request_var('style_active', 0); $style_default = request_var('style_default', 0); $store_db = request_var('store_db', 0); if ($mode == 'style' && (!$template_id || !$theme_id || !$imageset_id)) { $error[] = $user->lang['STYLE_ERR_NO_IDS']; } if ($mode == 'style' && $style_row['style_active'] && !$style_active && $config['default_style'] == $style_id) { $error[] = $user->lang['DEACTIVATE_DEFAULT']; } if (!$name) { $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; } if (!sizeof($error)) { // Check length settings if (utf8_strlen($name) > 30) { $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; } if (utf8_strlen($copyright) > 60) { $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; } } } if ($update && sizeof($error)) { $style_row = array_merge($style_row, array( 'template_id' => $template_id, 'theme_id' => $theme_id, 'imageset_id' => $imageset_id, 'style_active' => $style_active, $mode . '_storedb' => $store_db, $mode . '_name' => $name, $mode . '_copyright' => $copyright) ); } // User has submitted form and no errors have occurred if ($update && !sizeof($error)) { $sql_ary = array( $mode . '_name' => $name, $mode . '_copyright' => $copyright ); switch ($mode) { case 'style': $sql_ary += array( 'template_id' => $template_id, 'theme_id' => $theme_id, 'imageset_id' => $imageset_id, 'style_active' => $style_active, ); break; case 'imageset': break; case 'theme': if ($style_row['theme_storedb'] != $store_db) { $theme_data = ''; if (!$style_row['theme_storedb']) { $theme_data = $this->db_theme_data($style_row); } else if (!$store_db && !$safe_mode && is_writeable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css")) { $store_db = 1; $theme_data = $style_row['theme_data']; if ($fp = @fopen("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css", 'wb')) { $store_db = (@fwrite($fp, str_replace("styles/{$style_row['theme_path']}/theme/", './', $theme_data))) ? 0 : 1; } fclose($fp); } $sql_ary += array( 'theme_mtime' => ($store_db) ? filemtime("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css") : 0, 'theme_storedb' => $store_db, 'theme_data' => ($store_db) ? $theme_data : '', ); } break; case 'template': if ($style_row['template_storedb'] != $store_db) { if (!$store_db && !$safe_mode && is_writeable("{$phpbb_root_path}styles/{$style_row['template_path']}/template")) { $sql = 'SELECT * FROM ' . STYLES_TEMPLATE_DATA_TABLE . " WHERE template_id = $style_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!($fp = @fopen("{$phpbb_root_path}styles/{$style_row['template_path']}/template/" . $row['template_filename'], 'wb'))) { $store_db = 1; break; } fwrite($fp, $row['template_data']); fclose($fp); } $db->sql_freeresult($result); if (!$store_db) { $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . " WHERE te
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -