<?
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 BoardID_1,BoardID_2 from {$tablepre}bbsmenu 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}bbsmenu where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
	   mysql_query("update {$tablepre}bbstitle set rep=rep-1,postnum=postnum-1 where ID='".$myrow["pid"]."'");
	   }
    }
	break;
case "选择显示":
    for($i=0; $i<count($idList); $i++){
	   $sql="select BoardID_1,BoardID_2 from {$tablepre}bbsmenu 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}bbsmenu set deleted=0 where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply+1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply+1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
	   mysql_query("update {$tablepre}bbstitle set rep=rep+1,postnum=postnum+1 where ID='".$myrow["pid"]."'");
	   }
    }
	break;
case "选择隐藏":
    for($i=0; $i<count($idList); $i++){
	   $sql="select BoardID_1,BoardID_2 from {$tablepre}bbsmenu 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}bbsmenu set deleted=1 where id='".$idList[$i]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-1 where BBS_Cate_ID='".$myrow["BoardID_1"]."'");
	   mysql_query("update {$tablepre}bbs_cate set BBS_Cate_Reply=BBS_Cate_Reply-1 where BBS_Cate_ID='".$myrow["BoardID_2"]."'");
	   mysql_query("update {$tablepre}bbstitle set rep=rep-1,postnum=postnum-1 where ID='".$myrow["pid"]."'");
	   }
    }
	break;
}
$db->close(); 
header("Location:".$_SERVER["HTTP_REFERER"]);
?>