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

$url=$_POST["url"];
$BBS_Cate_Name=trim($_POST["BBS_Cate_Name"]);
$BBS_Cate_Manager_Name=trim($_POST["BBS_Cate_Manager_Name"]);
$BBS_Cate_Manager_Email=trim($_POST["BBS_Cate_Manager_Email"]);
$BBS_Cate_Note=trim($_POST["BBS_Cate_Note"]);
$fangwenqs=trim($_POST["fangwenqs"]);
$treesign=trim($_POST["tree"]);
$menu=trim($_POST["menu"]);
$BBS_Cate_PID=$_POST["BBS_Cate_PID"];
$BBS_Cate_ID=$_POST["BBS_Cate_ID"];
$layer=$_POST["layer"];
$totop=$_POST["totop"];

if ($BBS_Cate_Name==""){
   echo "<BR><BR><center>请输入论坛名称！</center>";
   exit;
}

$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=adminmakecache('../cache/ftbbsmb.html',$query,$expire);
$treemb=$ftbbsmb[9];

if (strrpos($BBS_Cate_Manager_Name,"|")){
   $bzarr = explode("|",$BBS_Cate_Manager_Name);
   for($i=0; $i<count($bzarr); $i++){
       $sql="select clubuser_name from {$tablepre}clubuser where clubuser_name='".$bzarr[$i]."'";
       $rsbz=mysql_query($sql);
       $bzrow = mysql_fetch_array($rsbz);
       $bznumrows = mysql_num_rows($rsbz);
	   if ($bznumrows!=0){
       mysql_query("update {$tablepre}clubuser set bbsadmin=1 where clubuser_name='".$bzarr[$i]."'");
	   }
       else{
	   echo "<br><br><center>你所加入的版主中的用户名不存在！</center>";
	   exit;
	   }
   }
}
else{
  mysql_query("update {$tablepre}clubuser set bbsadmin=1 where clubuser_name='".$BBS_Cate_Manager_Name."'");
}

if ($totop!=""){
$sql="update {$tablepre}bbs_cate set BBS_Cate_Name='".$BBS_Cate_Name."',BBS_Cate_Manager_Name='".$BBS_Cate_Manager_Name."',BBS_Cate_Manager_Email='".$BBS_Cate_Manager_Email."',totop=".$totop.",BBS_Cate_Qs=".$fangwenqs.",treesign=".$treesign.",BBS_Cate_Note='".$BBS_Cate_Note."',BBS_Cate_Board='".$menu."' where BBS_Cate_ID='".$BBS_Cate_ID."'";
}
else{
$sql="update {$tablepre}bbs_cate set BBS_Cate_Name='".$BBS_Cate_Name."',BBS_Cate_Manager_Name='".$BBS_Cate_Manager_Name."',BBS_Cate_Manager_Email='".$BBS_Cate_Manager_Email."',BBS_Cate_Qs=".$fangwenqs.",treesign=".$treesign.",BBS_Cate_Note='".$BBS_Cate_Note."',BBS_Cate_Board='".$menu."' where BBS_Cate_ID='".$BBS_Cate_ID."'";
}
mysql_query($sql);

include_once("maketree.php");
include_once("makejs.php");
maketotree($treemb);
maketodh();
$db->close();
delcache("../cache/ftbbshome.txt");
delcache("../cache/default_list.txt");
header("Location:".$url);
?>