<?php
include_once("inc/config.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/publicfun.php");
include_once("conn.php");
include_once("ftbbs_nav.php");
include_once("checkuser.php");
include_once("bbsuser.php");

$username=get_cookie('username');
$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=makecache('ftbbsmb.html',$query,$expire);

$url=$ftbbsmb[10];
$upfiletype=$ftbbsmb[12];
$upfilesize=$ftbbsmb[13];
$getcodeoff=$ftbbsmb[30];
$htm_ext=$ftbbsmb[32];
$sitenav=$ftbbsmb[61];

$pid=intval(trim($_GET["id"]));
$postuser=trim($_GET["postuser"]);
$reid=intval(trim($_GET["reid"]));
$filename=$pid.$htm_ext;

$sql="select {$tablepre}bbs_cate.BBS_Cate_Name,{$tablepre}bbs_cate.BBS_Cate_Manager_Name,{$tablepre}bbs_cate.BBS_Cate_ID,{$tablepre}bbs_cate.BBS_Cate_PID from {$tablepre}bbs_cate,{$tablepre}bbstitle where {$tablepre}bbs_cate.BBS_Cate_ID = {$tablepre}bbstitle.BoardID_2 and {$tablepre}bbstitle.ID='".$pid."'";
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);

$myname=$myrow["BBS_Cate_Manager_Name"];
$bbsname=$myrow["BBS_Cate_Name"];
$BBS_Cate_ID=$myrow["BBS_Cate_ID"];
$BBS_Cate_PID=$myrow["BBS_Cate_PID"];
$admintobz=0;
$username=get_cookie('username');
if (strrpos($myname,"|")){
	$arr=explode("|",$myname);
    for($i=0; $i<count($arr); $i++){
	if ($arr[$i]==$username){
	   $admintobz=1;
	   }
    }
}
elseif($myname==$username){
    $admintobz=1;
} 

if ($reid!=""){
   $str="select * from {$tablepre}bbsmenu where id=".$reid;
   $rs=mysql_query($str);
   $row = mysql_fetch_array($rs);
   $remenu=$row["remenu"];
   $postuser=$row["user_id"];
   $str="select htmfilename from {$tablepre}bbstitle where id=".$pid;
   $rs=mysql_query($str);
   $row = mysql_fetch_array($rs);
   $htmfilename=$row["htmfilename"];
}
else{
   $str="select * from {$tablepre}bbstitle where id=".$pid;
   $rs=mysql_query($str);
   $row = mysql_fetch_array($rs);
   $title=$row["title"];
   $remenu=$row["menu"];
   $picture=$row["picture"];
   $zhiye=$row["zhiye"];
   $postuser=$row["name"];
   $titlecolor=$row["titlecolor"];
   $bbs_img=$row["bbs_img"];
   $bbs_img_display=$row["bbs_img_display"];
   $htmfilename=$row["htmfilename"];
}

if (get_cookie('bz')==1 || $admintobz==1 || $username==$postuser){		
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language=javascript src="inc/cookies.js"></script>
<script>
var stylecook = getCookie("STYLESHOW");
var style;
var strstyle;
if(stylecook=="")
{
 stylecook=1;
}
else
{
 stylecook++;
}
style="main0"+stylecook+".css";
strstyle="<link href=\"css/"+style+"\"  rel=\"stylesheet\" type=\"text/css\"> ";
document.write(strstyle);
</script>
<script language="javascript">
<!--
    function changetitle(txt){
	   var currentTitle = document.myform.title.value;
       if (txt.charAt(1)==" "){
           txt1=txt.substr(2);
           document.myform.title.value=txt1+currentTitle;}
      else{
	       document.myform.title.value=txt+currentTitle;}
    }
//-->
</script>
<body leftmargin="0" topmargin="2">
<?
include_once("pbhead.php");
?>
<table width="99%" border=0 align="center" cellpadding=2 cellspacing=1 class="maintbbg">
  <tbody>
   <tr> 
      <td height="25" class="f12bg" align="left">&nbsp;<?=$userinfo?></td>
   </tr>
   <tr>
    <td height="26" class="maintbtr3">&nbsp;<a href="default.php">论坛首页</a> &gt;&gt; 编辑贴子</td>
  </tr>
  </tbody>
</table>
<table cellspacing=0 cellpadding=0 width="99%" align=center border=0>
  <tbody>
    <tr> 
      <td height=8></td>
    </tr>
  </tbody>
</table>
<table width="99%" border="0" cellspacing="1" cellpadding="1" align="center" class="listborder">
  <TR class="f12bg"> 
    <TD height="26" colspan="2"> <div align="center"><b>论 坛 话 题 编 辑</b></div></TD>
  </TR>
<form name="myform" method="POST" action="editpostact.php" onsubmit="<? if ($reid==""){?>return CheckForm(this);<?}else{?>return CheckReForm(this);<? }?>" style="MARGIN-BOTTOM: 0px"> 
 <script LANGUAGE="javascript">
<!--
var onecount;
onecount=0;
var j;
  
subcat = new Array();
<?
$strsql="select BBS_Cate_ID,BBS_Cate_PID,BBS_Cate_Name,Initial from {$tablepre}bbs_cate where BBS_Cate_PID<>'0' and deleted=0  order by totop asc";
$rs=mysql_query($strsql);
$row = mysql_fetch_array($rs);
$rsnum= mysql_num_rows($rs);
$j=0;
do {
?>
subcat[<?=$j?>] = new Array("<?=$row[2]?>","<?=$row[1]?>","<?=$row[0]?>");
<?
$j++;
}
while ($row = mysql_fetch_array($rs))
?>

onecount=<?=$j?>;

function changelocation(locationid)
    {
    document.myform.BoardID_2.length = 0; 

    var locationid=locationid;
    var i;
    document.myform.BoardID_2.options[0] = new Option('==请选择==','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
            document.myform.BoardID_2.options[document.myform.BoardID_2.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    

//-->
</script>
<? if ($reid==""){?>
     <TR class="maintbtr3"> 
      <TD width="14%" class="loopborder1"> 
        <div align="right">主论坛：</div>
      </TD>
      <TD width="86%" class="loopborder1"> 
        <SELECT NAME="BoardID_1" onChange="changelocation(document.myform.BoardID_1.options[document.myform.BoardID_1.selectedIndex].value)">    
<?
$str="select BBS_Cate_ID,BBS_Cate_Name from {$tablepre}bbs_cate Where BBS_Cate_PID='0' and deleted=0 order by BBS_ID asc";
$rs=mysql_query($str);
$row = mysql_fetch_array($rs);
do {
?>
          <option value="<?=$row["BBS_Cate_ID"]?>" <? if ($row["BBS_Cate_ID"]==$BBS_Cate_PID){ ?>selected<? }?>><?=$row["BBS_Cate_Name"]?></option>
<?
 }
while ($row = mysql_fetch_array($rs))
?>
        </SELECT>
      </TD>
    </TR>
    <TR> 
      <TD width="14%" height="25" class="loopborder1"> 
        <div align="right">分论坛：</div>
      </TD>
      <TD width="86%" height="25" class="loopborder1">
        <SELECT NAME="BoardID_2">
		  <option value="<?=$BBS_Cate_ID?>" selected><?=$bbsname?></option>
        </SELECT>
      </TD>
    </TR>
    <TR> 
      <TD width="14%" height="25" class="loopborder1"> 
        <div align="right">主　题：</div>
      </TD>
      <TD width="86%" height="25" class="loopborder1">
	    <? if ($reid==""){?>
	    <select name="zhiye" id="zhiye" style="width:60px" onChange="changetitle(document.myform.zhiye.options[document.myform.zhiye.selectedIndex].text)">
          <option value="1" <? if ($zhiye==1 || $zhiye==0){ ?>selected<? }?>>[原创]</option>
          <option value="2" <? if ($zhiye==2){?>selected <? }?>>[转载]</option>
		  <option value="3" <? if ($zhiye==3){?>selected<? }?>>[灌水]</option>
		  <option value="4" <? if ($zhiye==4){?>selected<? }?>>[讨论]</option>
		  <option value="5" <? if ($zhiye==5){?>selected<? }?>>[求助]</option>
		  <option value="6" <? if ($zhiye==6){?>selected<? }?>>[推荐]</option>
		  <option value="7" <? if ($zhiye==7){?>selected<? }?>>[公告]</option>
		  <option value="8" <? if ($zhiye==8){?>selected<? }?>>[贴图]</option>
		  <option value="9" <? if ($zhiye==9){?>selected<? }?>>[建议]</option>
		  <option value="10" <? if ($zhiye==10){?>selected<? }?>>[下载]</option>
        </select>
	    <?}?>
        <input name="title" type="text" value="<?=$title?>" size="55" id="title">
		<?if (get_cookie('bz')==1 || get_cookie('bbsadmin')==1){?>
        <SELECT name=titlecolor>
		  <option style="background-color:#ffffff;color: #000000" value="">标题颜色</option>
          <option style="background-color:#FF0000;color: #FF0000" value="#FF0000" <? if ($titlecolor=="#FF0000"){?> selected<? }?>>#FF0000</option>
          <option style="background-color:#BC8F8F;color: #BC8F8F" value="#BC8F8F" <? if ($titlecolor=="#BC8F8F"){?> selected<? }?>>#BC8F8F</option>
          <option style="background-color:#4169E1;color: #4169E1" value="#4169E1" <? if ($titlecolor=="#4169E1"){?> selected<? }?>>#4169E1</option>
          <option style="background-color:#8B4513;color: #8B4513" value="#8B4513" <? if ($titlecolor=="#8B4513"){?> selected<? }?>>#8B4513</option>
          <option style="background-color:#FA8072;color: #FA8072" value="#FA8072" <? if ($titlecolor=="#FA8072"){?> selected<? }?>>#FA8072</option>
          <option style="background-color:#F4A460;color: #F4A460" value="#F4A460" <? if ($titlecolor=="#F4A460"){?> selected<? }?>>#F4A460</option>
          <option style="background-color:#2E8B57;color: #2E8B57" value="#2E8B57" <? if ($titlecolor=="#2E8B57"){?> selected<? }?>>#2E8B57</option>
          <option style="background-color:#A0522D;color: #A0522D" value="#A0522D" <? if ($titlecolor=="#A0522D"){?> selected<? }?>>#A0522D</option>
          <option style="background-color:#C0C0C0;color: #C0C0C0" value="#C0C0C0" <? if ($titlecolor=="#C0C0C0"){?> selected<? }?>>#C0C0C0</option>
          <option style="background-color:#87CEEB;color: #87CEEB" value="#87CEEB" <? if ($titlecolor=="#87CEEB"){?> selected<? }?>>#87CEEB</option>
          <option style="background-color:#6A5ACD;color: #6A5ACD" value="#6A5ACD" <? if ($titlecolor=="#6A5ACD"){?> selected<? }?>>#6A5ACD</option>
          <option style="background-color:#708090;color: #708090" value="#708090" <? if ($titlecolor=="#708090"){?> selected<? }?>>#708090</option>
          <option style="background-color:#4682B4;color: #4682B4" value="#4682B4" <? if ($titlecolor=="#4682B4"){?> selected<? }?>>#4682B4</option>
          <option style="background-color:#D2B48C;color: #D2B48C" value="#D2B48C" <? if ($titlecolor=="#D2B48C"){?> selected<? }?>>#D2B48C</option>
          <option style="background-color:#008080;color: #008080" value="#008080" <? if ($titlecolor=="#008080"){?> selected<? }?>>#008080</option>
          <option style="background-color:#D8BFD8;color: #D8BFD8" value="#D8BFD8" <? if ($titlecolor=="#D8BFD8"){?> selected<? }?>>#D8BFD8</option>
          <option style="background-color:#FF6347;color: #FF6347" value="#FF6347" <? if ($titlecolor=="#FF6347"){?> selected<? }?>>#FF6347</option>
          <option style="background-color:#40E0D0;color: #40E0D0" value="#40E0D0" <? if ($titlecolor=="#40E0D0"){?> selected<? }?>>#40E0D0</option>
          <option style="background-color:#EE82EE;color: #EE82EE" value="#EE82EE" <? if ($titlecolor=="#EE82EE"){?> selected<? }?>>#EE82EE</option>
          <option style="background-color:#F5DEB3;color: #F5DEB3" value="#F5DEB3" <? if ($titlecolor=="#F5DEB3"){?> selected<? }?>>#F5DEB3</option>
          <option style="background-color:#435454;color: #435454" value="#435454" <? if ($titlecolor=="#435454"){?> selected<? }?>>#435454</option>
          <option style="background-color:#9ACD32;color: #9ACD32" value="#9ACD32" <? if ($titlecolor=="#9ACD32"){?> selected<? }?>>#9ACD32</option>
        </SELECT> 
        <? }?>
      </TD>
    </TR>
<? }?>
    <TR class="maintbtr3"> 
      <TD class="loopborder1"> 
        <div align="right">内　容：</div>
      </TD>
      <TD height=300>
<TEXTAREA type="hidden" rows=1 cols=1 name="menu" style="position:absolute;left:0;visibility:hidden;"><?=$remenu?></textarea>
<script type="text/javascript" src="fteditor/editor.js"></script> 
<script type="text/javascript">
var editor = new FtEditor("editor");
editor.hiddenName = "menu";
editor.editorWidth = "100%";
editor.editorHeight = "300px";
editor.show();
</script>
	  </TD>
    </TR>
    <TR> 
      <TD width="16%" height="25" class="loopborder1"> 
        <div align="right">上传附件：</div>
      </TD>
      <TD width="84%" height="28" class="loopborder1">
      <IFRAME name=mqs marginWidth=0 marginHeight=0 src="FtbbsUpFile.php?filename=<?=$htmfilename?>" frameBorder=0 width=100% scrolling=no height=25></IFRAME>
      </TD>
    </TR>
	<? if ($reid==""){?>
    <TR>
      <TD width="14%" height="25" class="loopborder1"> 
        <div align="right">发布状态：</div>
      </TD>
      <TD width="86%" height="25" class="loopborder1">
        <input type=radio name=ticon value=0.gif <? if ($picture=="0.gif"){?>checked<? }?>>
        <img src=images/0.gif width=19 height=19 > 
        <input type=radio name=ticon value=29.gif <? if ($picture=="29.gif"){?>checked<? }?>>
        <img src=images/29.gif width=19 height=19> 
        <input type=radio name=ticon value=30.gif <? if ($picture=="30.gif"){?>checked<? }?>>
        <img src=images/30.gif width=19 height=19> 
        <input type=radio name=ticon value=31.gif <? if ($picture=="31.gif"){?>checked<? }?>> 
		<img src=images/31.gif width=19 height=19> 
        <input type=radio name=ticon value=34.gif <? if ($picture=="34.gif"){?>checked<? }?>>
        <img src=images/34.gif width=19 height=19> 
        <input type=radio name=ticon value=36.gif <? if ($picture=="36.gif"){?>checked<? }?>>
        <img src=images/36.gif width=19 height=19> 
        <input type=radio name=ticon value=37.gif <? if ($picture=="37.gif"){?>checked<? }?>>
        <img src=images/37.gif width=19 height=19> 
        <input type=radio name=ticon value=38.gif <? if ($picture=="38.gif"){?>checked<? }?>>
        <img src=images/38.gif width=19 height=19> 
        <input type=radio name=ticon value=39.gif <? if ($picture=="39.gif"){?>checked<? }?>> 
		<img src=images/39.gif width=19 height=19> 
        <input type=radio name=ticon value=40.gif <? if ($picture=="40.gif"){?>checked<? }?>>
        <img src=images/40.gif width=19 height=19> 
        <input type=radio name=ticon value=41.gif <? if ($picture=="41.gif"){?>checked<? }?>>
        <img src=images/41.gif width=19 height=19> 
        <input type=radio name=ticon value=42.gif <? if ($picture=="42.gif"){?>checked<? }?>>
        <img src=images/42.gif width=19 height=19> 
        <input type=radio name=ticon value=43.gif <? if ($picture=="43.gif"){?>checked<? }?>>
        <img src=images/43.gif width=19 height=19>
      </TD>
    </TR>
	<? }?>
	<? if ($getcodeoff==1){?>
    <TR> 
      <TD width="16%" height="25" class="loopborder1"> 
        <div align="right">验 证 码：</div>
      </TD>
      <TD width="84%" height="25" class="loopborder1"><input name=codestr id=codestr type=text size=10 maxlength=4>
	  <img src="getyzm.php" alt="看不清楚请点击刷新验证码" class="simg" style="cursor : pointer;" onclick="this.src='getyzm.php';" align="absmiddle">
      </TD>
    </TR>
	<? }?>
    <TR class="maintbtr3"> 
      <TD height="35" colspan=2 align=center>
	    <input type="hidden" name="postuser" value="<?=$postuser?>"> 
        <input type="hidden" name="id" value="<?=$pid?>">
		<input type="hidden" name="reid" value="<?=$reid?>">
		<input type="hidden" name="reurl" value="<?=$_SERVER["HTTP_REFERER"]?>">
        <input name="bbs_img_display" type="hidden" id="bbs_img_display" value="<?=$bbs_img_display?>">
        <input name="bbs_img" type="hidden" id="bbs_img" value="<?=$bbs_img?>">
		<input name="CurrentMode" type="hidden" id="CurrentMode">
		<input type="submit" value="修改话题" name="submit1" style="height:25px;">
      </TD>
    </TR>
	</form>
  </TABLE>
<?
mysql_free_result($rs);
$db->close(); 
include_once("inc/bbstail.php");
?>
</body>
</html>
<?
}else{
   //mysql_query("update bbstitle set bbstop=0 where id='".$id."'");
   echo "<script language='javascript'>history.go(-1);</script>";
   exit;
}
?>