📄 ad_announce.php
字号:
<?php
class ad_announce
{
var $base_url;
var $parser;
var $post;
var $new_annc;
function ad_announce( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
switch ( $IN['code'] )
{
case "add" :
$this->add_announcement_form( );
break;
case "doadd" :
$this->add_announcement( );
break;
case "edit" :
$this->edit_announcement_form( );
break;
case "doedit" :
$this->edit_announcement( );
break;
case "delete" :
$this->delete_announcement_form( );
break;
case "dodelete" :
$this->delete_announcement( );
break;
default :
$this->main_screen( );
break;
}
}
function main_screen( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
$ADMIN->page_title = "论坛公告管理";
$ADMIN->page_detail = "你可以在此管理你的论坛公告内容,只有管理员才能发布论坛公告。<br><b>注意:</b> 论坛公告主题为粗体表示公告不过期。";
$g_array = array( );
$SKIN->td_header[] = array( "论坛公告/论坛栏目名称", "50%" );
$SKIN->td_header[] = array( "选项", "50%" );
$ADMIN->html .= $SKIN->start_table( "论坛栏目公告" );
$announcements = array( );
$categories = array( );
$forums = array( );
$DB->query( "SELECT c.id, c.name from ibf_categories c where c.id > '0' order by c.position" );
while ( $cat = $DB->fetch_row( ) )
{
$categories[] = $cat;
}
$DB->query( "SELECT f.id, f.name, f.parent_id, f.subwrap, f.category, f.sub_can_post from ibf_forums f order by f.position" );
while ( $for = $DB->fetch_row( ) )
{
$forums[$for[category]][] = $for;
}
$DB->query( "SELECT * FROM ibf_announcements ORDER by a_start DESC" );
while ( $ann = $DB->fetch_row( ) )
{
$announcements[$ann[a_forum]][] = $ann;
}
$i = 0;
for ( ; $i < count( $categories ); ++$i )
{
$ADMIN->html .= $SKIN->add_td_row( array(
$categories[$i]['name'],
" "
), "catrow" );
$cat_id = $categories[$i][id];
$g = 0;
for ( ; $g < count( $forums[$cat_id] ); ++$g )
{
if ( 0 < $forums[$cat_id][$g][parent_id] )
{
$pretext = "----论坛分栏目:";
$css = "subforum";
$linkage = "<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
}
else if ( $forums[$cat_id][$g][subwrap] )
{
if ( $forums[$cat_id][$g][sub_can_post] )
{
$pretext = "--论坛分类:";
$css = "catrow2";
$linkage = "<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
}
else
{
$pretext = "<strong>--论坛子分类:</strong>";
$css = "subforum";
$linkage = "";
}
}
else
{
$pretext = "--论坛栏目:";
$css = "catrow2";
$linkage = "<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
}
$ADMIN->html .= $SKIN->add_td_row( array(
$pretext." ".$forums[$cat_id][$g]['name'],
$linkage
), $css );
$a = 0;
for ( ; $a < count( $announcements[$forums[$cat_id][$g]['id']] ); ++$a )
{
$ADMIN->html .= $SKIN->add_td_row( array(
( !$announcements[$forums[$cat_id][$g]['id']][$a][a_expire] ? "<b>" : "" )."------论坛公告:".$announcements[$forums[$cat_id][$g]['id']][$a][a_title].( !$announcements[$forums[$cat_id][$g]['id']][$a][a_expire] ? "</b>" : "" ),
"<center><a href='{$ADMIN->base_url}&act=announcement&code=edit&id=".$announcements[$forums[$cat_id][$g]['id']][$a][a_id]."'>编辑</a> <a href='{$ADMIN->base_url}&act=announcement&code=delete&id=".$announcements[$forums[$cat_id][$g]['id']][$a][a_id]."'>删除</a></center>"
) );
}
}
}
$ADMIN->html .= $SKIN->end_table( );
$SKIN->td_header[] = array( "论坛公告/论坛公告/论坛栏目名称", "50%" );
$SKIN->td_header[] = array(
"选项 -- (<a href='{$ADMIN->base_url}&act=announcement&code=add&id=global'>添加论坛全局公告</a>)",
"50%"
);
$ADMIN->html .= $SKIN->start_table( "论坛全局公告" );
$g = 0;
for ( ; $g < count( $announcements[0] ); ++$g )
{
$ADMIN->html .= $SKIN->add_td_row( array(
( !$announcements[0][$g]['a_expire'] ? "<b>" : "" )."论坛公告:".$announcements[0][$g]['a_title'].( !$announcements[0][$g]['a_expire'] ? "</b>" : "" ),
"<center><a href='{$ADMIN->base_url}&act=announcement&code=edit&id=".$announcements[0][$g][a_id]."'>编辑</a> <a href='{$ADMIN->base_url}&act=announcement&code=delete&id=".$announcements[0][$g][a_id]."'>删除</a></center>"
) );
}
$ADMIN->html .= $SKIN->end_table( );
$ADMIN->output( );
}
function add_announcement( )
{
$this->process( );
exit( );
}
function delete_announcement( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
global $HTTP_POST_VARS;
$id = $IN['id'];
if ( !is_numeric( $id ) )
{
$ADMIN->error( "无法找到指定的ID!" );
}
$DB->query( "DELETE FROM ibf_announcements WHERE a_id='".$id."'" );
$ADMIN->done_screen( "论坛公告已经删除", "论坛公告管理", "act=announcement" );
}
function delete_announcement_form( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
if ( $IN['id'] == "" )
{
$ADMIN->error( "无法读取论坛公告ID,请检查后再试" );
}
$ADMIN->page_title = "删除论坛公告";
$ADMIN->page_detail = "请在删除前确信选择了正确的论坛公告。";
$DB->query( "SELECT * FROM ibf_announcements WHERE a_id='".$IN['id']."'" );
$ann = $DB->fetch_row( );
$ADMIN->html .= $SKIN->start_form( array(
1 => array( "code", "dodelete" ),
2 => array( "act", "announcement" ),
3 => array(
"id",
$IN['id']
)
) );
$ADMIN->html .= $SKIN->start_table( "删除确认:".$ann['a_title'] );
$ADMIN->html .= $SKIN->end_form( "删除论坛公告" );
$ADMIN->html .= $SKIN->end_table( );
$ADMIN->output( );
}
function add_announcement_form( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
if ( $IN['id'] == "" )
{
$ADMIN->error( "无法找到论坛ID,请检查后再试" );
}
$global = 0;
if ( $IN['id'] != "global" )
{
$DB->query( "SELECT name,id FROM ibf_forums WHERE id='".$IN['id']."'" );
$cat = $DB->fetch_row( );
if ( !$cat['id'] )
{
$ADMIN->error( "无法找到论坛栏目ID,请检查后再试" );
}
}
else
{
$global = 1;
}
$ADMIN->page_title = "添加论坛公告";
$ADMIN->page_detail = "你可以在此添加论坛栏目公告或论坛全局公告。";
$ADMIN->html .= $SKIN->start_form( array(
1 => array( "code", "doadd" ),
2 => array( "act", "announcement" ),
3 => array(
"id",
$IN['id']
)
), "REPLIER" );
$SKIN->td_header[] = array( " ", "20%" );
$SKIN->td_header[] = array( " ", "80%" );
if ( $global )
{
$title = "论坛全局公告";
}
else
{
$title = "论坛栏目公告:".$cat[name];
}
$ADMIN->html .= $this->table_top( );
$ADMIN->html .= $SKIN->start_table( $title );
$ADMIN->html .= $this->topictitle_fields( array( ) );
$ADMIN->html .= $this->startend_fields( array(
"start_time" => $this->date_array( "" ),
"end_time" => $this->date_array( time( ) + 2592000 )
) );
$ADMIN->html .= $this->namefield( $MEMBER['name'] );
$smilies = $this->html_add_smilie_box( );
$ADMIN->html .= $this->postbox_buttons( array(
"sig_checked" => "checked",
"smilies_checked" => "checked",
"smilies" => $smilies
) );
$ADMIN->html .= $SKIN->end_form( "添加论坛公告" );
$ADMIN->html .= $SKIN->end_table( );
$ADMIN->output( );
}
function edit_announcement_form( )
{
global $IN;
global $root_path;
global $INFO;
global $DB;
global $SKIN;
global $ADMIN;
global $std;
global $MEMBER;
global $GROUP;
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( 1 );
if ( $IN['id'] == "" )
{
$ADMIN->error( "无法找到论坛栏目ID,请检查后再试" );
}
$DB->query( "SELECT a.*,m.name,m.id FROM ibf_announcements a, ibf_members m WHERE a.a_id='".$IN['id']."' AND m.id=a.a_mid" );
$ann = $DB->fetch_row( );
$global = $ann['a_forum'] ? "0" : "1";
if ( !$ann['a_id'] )
{
$ADMIN->error( "无法找到指定的公告内容" );
}
$ADMIN->page_title = "编辑论坛公告";
$ADMIN->page_detail = "你可以在此编辑一个栏目或全局公告";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -