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

if ($_POST["act"]=="y"){
   $boardid1=$_POST["boardid1"];
   $boardid2=$_POST["boardid2"];
   $boardid3=$_POST["boardid3"];
   $boardid4=$_POST["boardid4"];
   if (false===strrpos($boardid2,$boardid1) || false===strrpos($boardid4,$boardid3)){
      echo "<br><br><br><br><center>错误:一级类别与二级类别不对应</center>";
	  exit;
   }
   $strsql="update {$tablepre}bbstitle set BoardID_1='".$boardid3."',BoardID_2='".$boardid4."' where BoardID_1='".$boardid1."' and BoardID_2='".$boardid2."'";
   mysql_query($strsql);
   $strsql="update {$tablepre}bbsmenu set BoardID_1='".$boardid3."',BoardID_2='".$boardid4."' where BoardID_1='".$boardid1."' and BoardID_2='".$boardid2."'";
   mysql_query($strsql);
   $msg="类别转换成功!";
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$charset?>">
<LINK href="../css/xmwuye.css" type=text/css rel=stylesheet>
<TITLE>类别转换</TITLE>
<base target="right">
<style type="text/css">
<!--
body {
	background-color: #ffffff;
}
.STYLE1 {color: #FF0000}
-->
</style>
</HEAD>
<BODY topmargin="0">
<table width="98%" align="center">
  <tr><td height="35" valign="bottom"><div align="center"><strong>类别转换</strong></div></td>
</tr></table>

<table width="98%" align="center">
<tr><td width=90% >
<form action="" method="post" target="main">
        <p><b>请在下面选择需要转换的条件 (此操作主要是实现贴子的合并或转换功能)</b><br>
          <br>
          <br>
          (<span class="STYLE1">说明: 类别选择一定要相对应如:选择的二级类别一定要是在所选一级类别下的二级类别</span>)<br>
          <br>
          将
          <select name="boardid1">
<?
$sql="select BBS_Cate_Name,BBS_Cate_ID,BBS_Cate_PID,BBS_Cate_Qs,BBS_Cate_Note,BBS_Cate_Topic,BBS_Cate_Reply,BBS_Cate_Manager_Name from {$tablepre}bbs_cate where BBS_Cate_PID='0' order by totop asc";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
do{
?>
            <option value="<?=$row["BBS_Cate_ID"]?>"><?=$row["BBS_Cate_Name"]?></option>
<?
 }
while ($row = mysql_fetch_array($rs));
 ?>
          </select>
          的
          <select name="boardid2">
<?
$sql="select BBS_Cate_Name,BBS_Cate_ID,BBS_Cate_PID,BBS_Cate_Qs,BBS_Cate_Note,BBS_Cate_Topic,BBS_Cate_Reply,BBS_Cate_Manager_Name from {$tablepre}bbs_cate where BBS_Cate_PID<>'0' order by totop asc";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
do{
?>
            <option value="<?=$row["BBS_Cate_ID"]?>"><?=$row["BBS_Cate_Name"]?></option>
<?
 }
while ($row = mysql_fetch_array($rs));
?>
          </select>
          <label></label>
          转换到 
          <select name="boardid3">
<?
$sql="select BBS_Cate_Name,BBS_Cate_ID,BBS_Cate_PID,BBS_Cate_Qs,BBS_Cate_Note,BBS_Cate_Topic,BBS_Cate_Reply,BBS_Cate_Manager_Name from {$tablepre}bbs_cate where BBS_Cate_PID='0' order by totop asc";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
do{
?>
            <option value="<?=$row["BBS_Cate_ID"]?>"><?=$row["BBS_Cate_Name"]?></option>
<?
 }
while ($row = mysql_fetch_array($rs));
 ?>
          </select>
          的
          <select name="boardid4">
<?
$sql="select BBS_Cate_Name,BBS_Cate_ID,BBS_Cate_PID,BBS_Cate_Qs,BBS_Cate_Note,BBS_Cate_Topic,BBS_Cate_Reply,BBS_Cate_Manager_Name from {$tablepre}bbs_cate where BBS_Cate_PID<>'0' order by totop asc";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
do{
?>
            <option value="<?=$row["BBS_Cate_ID"]?>"><?=$row["BBS_Cate_Name"]?></option>
<?
 }
while ($row = mysql_fetch_array($rs));
?>
          </select> 
          <input name="act" type="hidden" id="act" value="y">
          <input type=submit value="开始转换" <? if (false===strrpos($_SESSION["admin_qs"],"2")){?>disabled<? }?>>
          <br>
        </p>
  </form>
</td>
</tr>
<tr><td>

</td></tr>
</table>
<table width="97%" height="60" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center"><font color=red><?=$msg?></font></div></td>
  </tr>
</table>
</body>
</html>