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

$layer=$_GET["layer"];
if ($layer=="0"){
	$layer_name="一级类别";
	$BBS_Cate_PID="0";
}
elseif ($layer=="1"){
	$layer_name="二级类别";
	$BBS_Cate_PID=$_GET["BBS_Cate_PID"];
	$BBS_Cate_Name=$_GET["BBS_Cate_Name"];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../css/xmwuye.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table width="99%" border="0" align="center" cellspacing="1" cellpadding="2" bgcolor="#cccccc">
  <form name="form1" method="post" action="Category_add.php">
    <TR> 
      <TD height="25" colspan="2"> 
        <div align="center"><B>论坛分类管理</B></div></TD>
    </TR>
    <tr bgcolor="#f3f3f3"> 
      <td height="25" colspan="2"> <div align="center"><b>[ 
          <?=$BBS_Cate_Name?>
          -]&nbsp; 
          <?=$layer_name?>
          </b></div></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="19%"><div align="right">
          <?=$layer_name?>
          名称：</div></td>
      <td width="81%"> <input type="text" name="BBS_Cate_Name" size="40"> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td><div align="right">
          <?=$layer_name?>
          版主：</div></td>
      <td> <input type="text" name="BBS_Cate_Manager_Name" size="40">
        多个版主用&quot;|&quot;分开 </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="right">论坛版主email：</td>
      <td> <input name="BBS_Cate_Manager_Email" type="text" size="40"> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="right">论坛版块说明：</td>
      <td> <textarea name="BBS_Cate_Note" cols="60" rows="8"></textarea>
        支持UBB代码 </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td><div align="right">论坛权限：</div></td>
      <td><input name="fangwenqs" type="radio" value="0" checked>
        所有用户都可以访问 
        <input type="radio" name="fangwenqs" value="1">
        只有注册用户才能访问<br> <input type="radio" name="fangwenqs" value="2">
        认证用户才可以访问 
        <input type="radio" name="fangwenqs" value="3">
        版主管理员才可以访问<br> <input type="radio" name="fangwenqs" value="4">
        版主管理员可发贴回贴其他用户只可回贴<br> <input type="radio" name="fangwenqs" value="5">
        版主管理员可发贴回贴其他用户只可看贴 </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="23"> <div align="right">树型状态：</div></td>
      <td> <input type="radio" name="tree" value="1" checked>
        默认展开 
        <input type="radio" name="tree" value="0">
        默认收缩</td>
    </tr>
    <? if ($layer==1){?>
    <tr bgcolor="#FFFFFF"> 
      <td> <div align="right">版块版规：</div></td>
      <td> <TEXTAREA rows=8 cols=60 name="menu"></textarea> 
      </td>
    </tr>
    <? }?>
    <tr bgcolor="#FFFFFF"> 
      <td height="25"></td>
      <td>
          <INPUT TYPE="hidden" name="BBS_Cate_PID" value="<?=$BBS_Cate_PID?>">
          <INPUT TYPE="hidden" name="layer" value="<?=$layer?>">
          <input type="submit" name="B1" value="添加类别" <? if (false===strrpos($_SESSION["admin_qs"],"1")){?>disabled<? }?>>
	  </td>
    </tr>
  </form>
</table>
  
<br>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#cccccc">
  <FORM METHOD=POST ACTION="index.php">
    <TR >
	  <TD height="25" align="right" bgcolor="#CCCCCC"><B>[ 
        <?=$BBS_Cate_Name?>-]</B>论坛名称：</TD>
	  <TD align="left" bgcolor="#CCCCCC"> 
    <INPUT TYPE="text" NAME="searchcontent">
	<INPUT TYPE="hidden" name="BBS_Cate_PID" value="<?=$BBS_Cate_PID?>">
	<INPUT TYPE="hidden" name="layer" value="<?=$layer?>">
	<INPUT TYPE="hidden" name="BBS_Cate_Name" value="<?=$BBS_Cate_Name?>">
	<INPUT TYPE="submit" value="搜索">
      </TD>
   </TR>
</FORM>
</TABlE>

<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#cccccc">
  <tr>
    <td height="25" bgcolor="#F9F9F9"> 
      <? if ($layer==0){?>
      <a href="../admin/main.php">管理首页</a>>>一级类别 
      <? }?>
      <? if ($layer==1){?>
      <a href="../admin/main.php">管理首页</a>>><A HREF="index.php?layer=0">一级类别</A> 
      >> 
      <?=$BBS_Cate_Name?>
      <? }?>
      (添加二级类别请点击下面一级类别<font color="#FF0000">编号</font>) </td>
  </tr>
</table>
<table width="99%" border="0" align="center" cellspacing="1" cellpadding="2" bgcolor="#f3f3f3">
  <tr bgcolor="#f3f3f3"> 
    <td width="10%" height="23"> 
      <div align="center"><b>编号</b></div></td>
    <td> 
      <div align="center"><b><?=$layer_name?></b></div></td>
    <td> 
      <div align="center"><b>主题数量</b></div></td>
    <td> 
      <div align="center"><b>回复数量</b></div></td>
    <td> 
      <div align="center"><b>版主</b></div></td>
    <td> 
      <div align="center"><b>版主Email</b></div></td>
    <td width="8%"> 
      <div align="center"><b>状态</b></div></td>
    <td width="8%"> 
      <div align="center"><b>修改</b></div></td>
    <td width="8%"> 
      <div align="center"><b>删除</b></div></td>
  </tr>
<?
$searchcontent=trim($_POST["searchcontent"]);
if ($searchcontent==""){
	$sql="select * from {$tablepre}bbs_cate where BBS_Cate_PID='".$BBS_Cate_PID."' order by BBS_ID asc";
}
else{
	$sql="select * from {$tablepre}bbs_cate where BBS_Cate_PID='".$BBS_Cate_PID."' and BBS_Cate_Name like '%".$searchcontent."%' order by BBS_ID asc";
}
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
if ($numrows!=0){
do {
?>
  <tr bgcolor="#FFFFFF" align=center> 
    <td> 
      <? if ($layer==0){?>
      <A HREF="index.php?layer=<?=($layer+1)?>&BBS_Cate_PID=<?=$myrow["BBS_Cate_ID"]?>&BBS_Cate_Name=<?=$myrow["BBS_Cate_Name"]?>"><FONT  COlOR="blue"><?=$myrow["BBS_Cate_ID"]?></FONT></A> 
      <? }else{?>
      <?=$myrow["BBS_Cate_ID"]?> 
      <? }?>
    </td>
    <td><?=$myrow["BBS_Cate_Name"]?></td>
    <td><?=$myrow["BBS_Cate_Topic"]?></td>
    <td><?=$myrow["BBS_Cate_Reply"]?></td>
    <td><?=$myrow["BBS_Cate_Manager_Name"]?></td>
    <td><?=$myrow["BBS_Cate_Manager_Email"]?></td>
    <td > 
      <? if ($myrow["deleted"]==0){?>
      <A HREF="status.php?BBS_ID=<?=$myrow["BBS_ID"]?>&Deleted=1"><FONT COlOR="red">已转正</FONT></A> 
      <? }else{?>
      <A HREF="status.php?BBS_ID=<?=$myrow["BBS_ID"]?>&Deleted=0"><FONT COlOR="green">未转正</FONT></A> 
      <? }?>
    </td>
    <FORM METHOD=POST ACTION="Category_mod.php">
      <td> <INPUT TYPE="hidden" name="BBS_Cate_ID" value="<?=$myrow["BBS_Cate_ID"]?>"> 
        <INPUT TYPE="hidden" name="layer" value="<?=$layer?>"> <INPUT TYPE="submit" name="修改" value="修改" <? if (false===strrpos($_SESSION["admin_qs"],"2")){?>disabled<? }?>> 
      </td>
    </FORM>
    <FORM METHOD=POST ACTION="Category_del.php" >
      <td> <INPUT TYPE="hidden" name="BBS_Cate_ID" value="<?=$myrow["BBS_Cate_ID"]?>"> 
        <INPUT TYPE="submit" name="删除" value="删除" onclick="return confirm('确实要删除吗？');" <? if (false===strrpos($_SESSION["admin_qs"],"3")){?>disabled<? }?>> 
      </td>
    </FORM>
  </tr>
<? }
while ($myrow = mysql_fetch_array($rs));
}
$db->close(); 
?>
</table>
<br>
</body>
</html>