<?
include_once("../inc/config.php");
include_once("../inc/publicfun.php");
include_once("../inc/ftbbsdbclass.php");
include_once("../conn.php");
include_once("check_master.php");
include_once("check_admin_qs.php");

$op=$_POST["op"];
$idList=$_POST["checkbox1"];

switch ($op){
case "选择删除":
    for($i=0; $i<count($idList); $i++){
	   $sql="select name,BoardID_1,BoardID_2,htmfilename from {$tablepre}bbstitle where id=".$idList[$i];
       $rs=mysql_query($sql);
       $myrow = mysql_fetch_array($rs);
       $numrows = mysql_num_rows($rs);
	   if ($numrows!=0){
	   mysql_query("delete from {$tablepre}bbstitle where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic-1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic-1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
       mysql_query("update {$tablepre}clubuser set postnum=postnum-1 where clubuser_name='".$myrow["name"]."'");
	   }
	   $sql="select BoardID_1,BoardID_2 from {$tablepre}bbsmenu where pid=".$idList[$i];
       $rsx=mysql_query($sql);
       $myrowx = mysql_fetch_array($rsx);
       $numrowsx = mysql_num_rows($rsx);
	   if ($numrowsx!=0){
	   mysql_query("delete from {$tablepre}bbsmenu where pid='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_2"]."'");
	   }
	   //bbs_cate主题数与回贴数减少,同时对应的clubuser用户发贴数减少
    }
	break;
case "精彩话题":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set huati=1 where id='".$idList[$i]."'");
    }
	break;
case "推荐话题":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set sign=1 where id='".$idList[$i]."'");
    }
	break;
case "首页显示":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set showinhomepage=1 where id='".$idList[$i]."'");
    }
	break;
case "取消首页显示":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set showinhomepage=0 where id='".$idList[$i]."'");
    }
	break;
case "取消精彩话题":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set huati=0 where id='".$idList[$i]."'");
    }
	break;
case "取消推荐话题":
    for($i=0; $i<count($idList); $i++){
    mysql_query("update {$tablepre}bbstitle set sign=0 where id='".$idList[$i]."'");
    }
	break;
case "选择显示":
    for($i=0; $i<count($idList); $i++){
	   $sql="select name,BoardID_1,BoardID_2,htmfilename from {$tablepre}bbstitle where id=".$idList[$i];
       $rs=mysql_query($sql);
       $myrow = mysql_fetch_array($rs);
       $numrows = mysql_num_rows($rs);
	   if ($numrows!=0){
	   mysql_query("update {$tablepre}bbstitle set deleted=0 where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic+1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic+1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
       mysql_query("update {$tablepre}clubuser set postnum=postnum-1 where clubuser_name='".$myrow["name"]."'");
	   }
	   $sql="select BoardID_1,BoardID_2 from {$tablepre}bbsmenu where pid=".$idList[$i];
       $rsx=mysql_query($sql);
       $myrowx = mysql_fetch_array($rsx);
       $numrowsx = mysql_num_rows($rsx);
	   if ($numrowsx!=0){
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply+".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply+".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_2"]."'");
	   }
    }
	break;
case "选择隐藏":
    for($i=0; $i<count($idList); $i++){
	   $sql="select name,BoardID_1,BoardID_2,htmfilename from {$tablepre}bbstitle where id=".$idList[$i];
       $rs=mysql_query($sql);
       $myrow = mysql_fetch_array($rs);
       $numrows = mysql_num_rows($rs);
	   if ($numrows!=0){
	   mysql_query("update {$tablepre}bbstitle set deleted=1 where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic-1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Topic=BBS_Cate_Topic-1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
       mysql_query("update {$tablepre}clubuser set postnum=postnum-1 where clubuser_name='".$myrow["name"]."'");
	   }
	   $sql="select BoardID_1,BoardID_2 from {$tablepre}bbsmenu where pid=".$idList[$i];
       $rsx=mysql_query($sql);
       $myrowx = mysql_fetch_array($rsx);
       $numrowsx = mysql_num_rows($rsx);
	   if ($numrowsx!=0){
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-".$numrowsx." where BBS_Cate_ID='".$myrowx["BoardID_2"]."'");
	   }
    }
	break;
}
//bbsad
//default_listbbsad
$db->close(); 
delcache("../cache/ftbbshome.txt");
delcache("../cache/default_list.txt");
header("Location:".$_SERVER["HTTP_REFERER"]);
?>