<?php
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");

$id=$_GET["id"];
$f=$_GET["mode"];
$kind=$_GET["kind"];
if ($kind==1){
   $sql="update {$tablepre}bbstitle set sign=".$f." where id=".$id;
}
elseif ($kind==2){
   $sql="update {$tablepre}bbstitle set huati=".$f." where id=".$id;
}
elseif ($kind==3){
   $sql="update {$tablepre}bbstitle set showinhomepage=".$f." where id=".$id;
}
elseif ($kind==4){
   $sql="update {$tablepre}bbstitle set boardsign=".$f." where id=".$id;
}
elseif ($kind==5){
   $sql="select name,BoardID_1,BoardID_2 from {$tablepre}bbstitle where id=".$id;
   $rs=mysql_query($sql);
   $myrow = mysql_fetch_array($rs);
   $numrows = mysql_num_rows($rs);
   if ($f==1){
       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=".$id;
       $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"]."'");
	   }
   }
   else{
       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=".$id;
       $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"]."'");
	   }
   }
   $sql="update {$tablepre}bbstitle set deleted=".$f." where id=".$id;
}
mysql_query($sql);
include_once("makejs.php");
bbsad();
$db->close();
delcache("../cache/ftbbshome.txt");
delcache("../cache/default_list.txt");
header("Location:".$_SERVER["HTTP_REFERER"]);
?>
