📄 ad_templates.php
字号:
while ( $row = $DB->fetch_row( $aq ) )
{
$text = $this->convert_tags( $row['section_content'] );
$output .= "<!--IBF_START_FUNC|{$row['func_name']}|{$row['func_data']}-->\n\n";
$output .= $text."\n";
$output .= "<!--IBF_END_FUNC|{$row['func_name']}-->\n\n";
}
$output .= "\n<!--IBF_GROUP_END:{$IN['group']}-->\n";
if ( $return == 0 )
{
$DB->query( "SELECT skname FROM ibf_tmpl_names WHERE skid='".$IN['setid']."'" );
$set = $DB->fetch_row( );
$name = str_replace( " ", "_", $set['skname'] );
@header( "Content-type: unknown/unknown" );
@header( "Content-Disposition: attachment; filename={$name}.{$IN['group']}.html" );
print $output;
exit( );
}
else
{
return $output;
}
}
function show_cats( )
{
global $IN;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
if ( $IN['id'] == "" )
{
$ADMIN->error( "你必须指定一个存在的论坛模板文件ID,请返回后重试!" );
}
$DB->query( "SELECT * from ibf_tmpl_names WHERE skid='".$IN['id']."'" );
if ( !( $row = $DB->fetch_row( ) ) )
{
$ADMIN->error( "无法在数据库中找到相关的数据信息" );
}
require( "./sources/Admin/skin_info.php" );
if ( $row['author'] && $row['email'] )
{
$author = "<br><br>论坛模板文件:<b>'{$row['skname']}'</b> 的作者是:<a href='mailto:{$row['email']}' target='_blank'>{$row['author']}</a>";
}
else if ( $row['author'] )
{
$author = "<br><br>论坛模板文件:<b>'{$row['skname']}'</b> 的作者是:{$row['author']}";
}
if ( $row['url'] )
{
$url = " (网站:<a href='{$row['url']}' target='_blank'>{$row['url']}</a>)";
}
$ADMIN->page_detail = "请在下面选择你需要编辑的选项。<br><br><b>下载</b> - 允许你下载所有文件的 HTML 文件格式到你的本地电脑进行编辑。<br><b>上传</b> - 允许你上传所有文件的 HTML 文件格式覆盖论坛模板文件。{$author} {$url}";
$ADMIN->page_title = "编辑论坛模板文件";
$ADMIN->html .= $SKIN->js_checkdelete( );
$all_cats = $DB->query( "select group_name, set_id, suid, count(group_name) as number_secs, group_name FROM ibf_skin_templates WHERE set_id='".$IN['id']."' group by group_name" );
$SKIN->td_header[] = array( "主题界面分类名称", "40%" );
$SKIN->td_header[] = array( "查看选项", "20%" );
$SKIN->td_header[] = array( "管理选项", "30%" );
$SKIN->td_header[] = array( "# 数据", "10%" );
$ADMIN->html .= "<script language='javascript'>\n\t\t\t\t\t\t function pop_win(theUrl) {\n\t\t\t\t\t\t \t\n\t\t\t\t\t\t \twindow.open('{$SKIN->base_url}&'+theUrl,'Preview','width=400,height=450,resizable=yes,scrollbars=yes');\n\t\t\t\t\t\t }\n\t\t\t\t\t\t </script>";
$ADMIN->html .= $SKIN->start_table( "论坛模板文件:".$row['skname'] );
while ( $group = $DB->fetch_row( $all_cats ) )
{
$name = "<b>".$group['group_name']."</b>";
$desc = "";
$expand = "展开编辑";
$eid = $group['suid'];
$exp_content = "";
if ( isset( $skin_names[$group['group_name']] ) )
{
$name = "<b>".$skin_names[$group['group_name']][0]."</b>";
$desc = "<br><span id='description'>".$skin_names[$group['group_name']][1]."</span>";
}
else
{
$name .= " (非默认论坛模板文件)";
$desc = "<br>这个文件不是默认的论坛标准安装模板文件,并且没有任何相关叙述内容。";
}
if ( $IN['expand'] == $group['suid'] )
{
$expand = "Collapse";
$eid = "";
$new_q = $DB->query( "SELECT func_name, LENGTH(section_content) as sec_length, suid FROM ibf_skin_templates WHERE set_id='{$IN['id']}' AND group_name='{$group['group_name']}'" );
if ( $DB->get_num_rows( $new_q ) )
{
$exp_content .= $SKIN->add_td_basic( "<a name='anc{$group['suid']}'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <table cellspacing='1' cellpadding='5' width='100%' align='center' bgcolor='#333333'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td align='left' id='catrow2'><a style='font-weight:bold;font-size:12px;color:#000033' href='{$SKIN->base_url}&act=templ&code=edit&id={$IN['id']}&expand=' title='全部展开' alt='全部展开'>{$name}</a></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td colspan='3' bgcolor='#FFFFFF'> </td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td width='30%' id='catrow2'></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td width='20%' id='catrow2' align='center'># Characters</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td width='20%' id='catrow2'align='center'>编辑</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <td width='30%' id='catrow2'align='center'>预览选项</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t <!--CONTENT--></table>", "left", "tdrow2" );
$temp = "";
$sec_arry = array( );
while ( $i = $DB->fetch_row( $new_q ) )
{
$sec_arry[$i['suid']] = $i;
$sec_arry[$i['suid']]['easy_name'] = $i['func_name'];
if ( $bit_names[$group['group_name']][$i['func_name']] != "" )
{
$sec_arry[$i['suid']]['easy_name'] = $bit_names[$group['group_name']][$i['func_name']];
}
}
usort( $sec_arry, array( "ad_settings", "perly_word_sort" ) );
foreach ( $sec_arry as $id => $sec )
{
$sec['easy_name'] = preg_replace( "/^(\\d+)\\:\\s+?/", "", $sec['easy_name'] );
$temp .= "\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t <td width='40%' id='tdrow1'><b>{$sec['easy_name']}</b></td>\n\t\t\t\t\t\t\t\t\t <td width='10%' id='tdrow1' align='center'>{$sec['sec_length']}</td>\n\t\t\t\t\t\t\t\t\t <td width='10%' id='tdrow1' align='center'><a href='{$SKIN->base_url}&act=templ&code=edit_bit&suid={$sec['suid']}&expand={$group['suid']}'>编辑</a></td>\n\t\t\t\t\t\t\t\t\t <td width='40%' id='tdrow1' align='center' nowrap>(<a href='javascript:pop_win(\"act=rtempl&code=preview&suid={$sec['suid']}&type=html\")'>HTML</a> | <a href='javascript:pop_win(\"act=rtempl&code=preview&suid={$sec['suid']}&type=text\")'>文本</a> | <a href='javascript:pop_win(\"act=rtempl&code=preview&suid={$sec['suid']}&type=css\")'>CSS模式</a>)</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t";
}
$exp_content = str_replace( "<!--CONTENT-->", $temp, $exp_content );
$desc = "";
}
}
else
{
$ADMIN->html .= $SKIN->add_td_row( array(
"<span style='font-weight:bold;font-size:12px;color:#000033'><a href='{$SKIN->base_url}&act=templ&code=edit&id={$IN['id']}&expand={$eid}&#anc{$eid}'>".$name."</a></span>".$desc,
"<center><a href='{$SKIN->base_url}&act=templ&code=edit&id={$IN['id']}&expand={$eid}'>{$expand}</a></center>",
"<center><a href='{$SKIN->base_url}&act=templ&code=download&setid={$group['set_id']}&group={$group['group_name']}' title='下载 HTML 文件至本地编辑'>下载</a> | <a href='{$SKIN->base_url}&act=templ&code=upload&setid={$group['set_id']}&group={$group['group_name']}' title='上传 HTML 文件后进行覆盖'>上传</a></center>",
"<center>".$group['number_secs']."</center>"
) );
}
$ADMIN->html .= $exp_content;
}
$ADMIN->html .= $SKIN->end_table( );
$ADMIN->nav[] = array( "act=templ", "论坛模板管理首页" );
$ADMIN->nav[] = array(
"",
"管理论坛模板文件:\"".$row['skname']."\""
);
$ADMIN->output( );
}
function perly_word_sort( $a, $b )
{
$nat_a = intval( $a['easy_name'] );
$nat_b = intval( $b['easy_name'] );
if ( strlen( $nat_a ) < 2 )
{
$nat_a = "0".$nat_a;
}
if ( strlen( $nat_b ) < 2 )
{
$nat_b = "0".$nat_b;
}
return strcmp( $nat_a, $nat_b );
}
function edit_info( )
{
global $IN;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
global $HTTP_POST_VARS;
if ( $IN['id'] == "" )
{
$ADMIN->error( "你必须指定一个存在的论坛模板文件ID,请返回后重试!" );
}
$DB->query( "SELECT * from ibf_tmpl_names WHERE skid='".$IN['id']."'" );
if ( !( $row = $DB->fetch_row( ) ) )
{
$ADMIN->error( "无法在数据库中找到相关的数据信息" );
}
$final['skname'] = stripslashes( $HTTP_POST_VARS['skname'] );
if ( isset( $HTTP_POST_VARS['author'] ) )
{
$final['author'] = str_replace( ",", "", stripslashes( $HTTP_POST_VARS['author'] ) );
$final['email'] = str_replace( ",", "", stripslashes( $HTTP_POST_VARS['email'] ) );
$final['url'] = str_replace( ",", "", stripslashes( $HTTP_POST_VARS['url'] ) );
}
$db_string = $DB->compile_db_update_string( $final );
$DB->query( "UPDATE ibf_tmpl_names SET {$db_string} WHERE skid='".$IN['id']."'" );
$ADMIN->done_screen( "论坛模板文件已经更新", "论坛模板管理", "act=templ" );
}
function do_edit( )
{
global $IN;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
global $HTTP_POST_VARS;
$text = stripslashes( $HTTP_POST_VARS['template'] );
if ( $IN['suid'] == "" )
{
$ADMIN->error( "你必须指定一个存在的论坛模板文件ID,请返回后重试!" );
}
$DB->query( "SELECT * FROM ibf_skin_templates WHERE suid='".$IN['suid']."'" );
if ( !( $template = $DB->fetch_row( ) ) )
{
$ADMIN->error( "你必须指定一个存在的论坛模板文件ID,请返回后重试!" );
}
$real_name = $template['group_name'];
$DB->query( "SELECT * from ibf_tmpl_names WHERE skid='".$template['set_id']."'" );
if ( !( $row = $DB->fetch_row( ) ) )
{
$ADMIN->error( "无法在数据库中找到相关的数据信息" );
}
$phpskin = ROOT_PATH."Skin/s".$template['set_id']."/".$real_name.".php";
if ( $INFO['safe_mode_skins'] != 1 )
{
if ( SAFE_MODE_ON == 1 )
{
$ADMIN->error( "监测到安全模式功能,你需要修改启用论坛设置[安全模式主题],你可以在[论坛变量设置]里进行设置。" );
}
if ( !is_writeable( $phpskin ) )
{
$ADMIN->error( "无法写入目录 '{$phpskin}',请检查目录属性(CHMOD 777)。" );
}
}
if ( $text == "" )
{
$ADMIN->error( "你不能删除这个论坛模板文件" );
}
$text = preg_replace( "/</", "<", $text );
$text = preg_replace( "/>/", ">", $text );
$text = preg_replace( "/&/", "&", $text );
$text = str_replace( "\\n", "\\\\\\n", $text );
$text = preg_replace( "/\r/", "", $text );
$text = $this->unconvert_tags( $text );
$string = $DB->compile_db_update_string( array(
"section_content" => $text
) );
$DB->query( "UPDATE ibf_skin_templates SET {$string} WHERE suid='".$IN['suid']."'" );
$final = "<?php\n\n"."class {$real_name} {\n\n";
if ( $INFO['safe_mode_skins'] != 1 )
{
if ( SAFE_MODE_ON == 1 )
{
$ADMIN->error( "监测到安全模式功能,你需要修改启用论坛设置[安全模式主题],你可以在[论坛变量设置]里进行设置。" );
}
$DB->query( "SELECT * FROM ibf_skin_templates WHERE group_name='{$real_name}' AND set_id='{$template['set_id']}'" );
while ( $data = $DB->fetch_row( ) )
{
$final .= "\n\nfunction {$data['func_name']}({$data['func_data']}) {\n"."global \$ibforums;\n"."return <<<EOF\n";
$final .= $data['section_content'];
$final .= "\nEOF;\n}\n";
}
$final .= "\n\n}\n?>";
if ( $fh = fopen( "{$phpskin}", "w" ) )
{
fwrite( $fh, $final, strlen( $final ) );
fclose( $fh );
}
else
{
$ADMIN->error( "无法保存信息到 {$phpskin} ,请检查权限是否正确(CHMOD 777)。" );
}
}
$ADMIN->done_screen( "模板文件已经更新", "管理论坛模板文件:{$row['skname']}", "act=templ&code=edit&id={$template['set_id']}" );
}
function tools( )
{
global $IN;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
global $HTTP_POST_VARS;
if ( $IN['id'] == "" )
{
$ADMIN->error( "你必须选择一个合法的主题界面文件以执行这个操作" );
}
if ( $IN['tool'] == "tmpl" )
{
$this->tools_build_tmpl( );
}
else
{
$this->tools_rebuildphp( );
}
}
function tools_build_tmpl( )
{
global $IN;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
global $HTTP_POST_VARS;
$insert = 1;
$skin_dir = ROOT_PATH."Skin/s".$IN['id'];
$errors = array( );
$flag = 0;
if ( !file_exists( $skin_dir ) )
{
$ADMIN->error( "这个模板文件必须在安全模式下使用,不需要为模板文件运行此工具。" );
}
if ( !is_readable( $skin_dir ) )
{
$ADMIN->error( "无法写入文件到: '{$skin_dir}' ,请检查目录属性(CHMOD 777)." );
}
if ( is_dir( $skin_dir ) )
{
if ( $handle = opendir( $skin_dir ) )
{
while ( ( $filename = readdir( $handle ) ) !== false )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -