<?php
#------------------------------------------------------#
#               本程序为zChain.net提供                 #
#                zChain论坛(ZBB)v2.00                  #
#------------------------------------------------------#
# INPUT: $bid,$tid,$sv_user

require_once('bin/config.php');
require_once('bin/common.php');
require_once('bin/zbbcodec.php');

require_once('core/class_forum_base.php');
CForumBase::setFileBase("$filepath");
require_once('core/base_memo_file.php');
require_once('core/class_board.php');
require_once('core/class_topic.php');

#--- Prepare topic data ---
$oBrd=new CBoard;
if(!$oBrd->load($bid)){errorview("error board!");}
$oTpc=new CTopic;
if(!$oTpc->load($bid,$tid)){errorview("error topic!");}
if($sv_user != $oTpc->user){errorview("对不起，您没有此项操作的权限！");}

zbbdecode(&$oTpc->body);

#--- Print edit form ---
page_header('编辑文章');
print "<CENTER>";
$posText="您当前位置：";
if($ck_root){$posText.="<a href=viewblist.php>$commname</a> >>";}
$posText.="<a href=viewboard.php?bid=$bid>$oBrd->name</a>";
$posText.=" >> $oTpc->title >> 编辑文章";
menu_bar($posText);

print <<<EOT
<SCRIPT>
var MessageMax="$maxpostsize";
var Override="";
function ValidateForm() {
titlesLength=document.form.titles.value.length;
if (titlesLength <2) {alert("文章标题不能小于2个字符！");return false;}
MessageLength  = document.form.comment.value.length;
errors = "";
if (MessageLength < 2) {
errors = "文章内容不能小于2个字符！";
}
if (MessageMax !=0) {
if (MessageLength > MessageMax) {
errors = "本论坛限制文章长度不得超过 " + MessageMax + " 字节\\n目前您的文章字节: " + MessageLength;
}
}
if (errors != "" && Override == "") {
alert(errors);
return false;
} else {
document.form.submit1.disabled = true;
return true;
}
}
function emoticon(theSmilie) {
document.form.comment.value += theSmilie + ' ';
document.form.comment.focus();
}
var i=0;
function presskey(eventobject){if(event.ctrlKey && window.event.keyCode==13){i++;if (i>1) {alert('帖子正在发出，请耐心等待！');return false;}this.document.form.submit();}}
</SCRIPT>
<FORM METHOD=POST action=ztopic_edit_s.php name=form onsubmit="return ValidateForm()">
<input type=hidden name=bid value=$bid>
<input type=hidden name=tid value=$tid>
<TABLE cellSpacing=1 cellPadding=5 border=0 width=600 class="forumLine">
<TR><TD colSpan=2 class="rowCaption">编辑文章</TD></TR>
<TR>
 <TD class="row1" width=100>文章标题</TD>
 <TD class="row1">
  <INPUT onmouseover=this.focus() maxLength=50 size=59 name=f_title value="$oTpc->title" class="plain">
 </TD>
</TR>
<TR>
 <TD vAlign=top class="row1" width=100>文章内容</TD>
 <TD class="row1">
  <TEXTAREA name=f_comment rows=10 cols=60 onkeydown=presskey(); class="plain">$oTpc->body</TEXTAREA>
 </TD>
</TR>
<TR>
 <TD vAlign=top width=100 class="row1" height=30>选项</TD>
 <TD class="row1">
  <input type=checkbox value=1 name=f_nocode>
  禁止 <a href=bin/zbbcode.htm onclick="popWin(this.href,500,300);">ZBB代码</a><br>
  <input type=checkbox value=1 name=f_nosmile>
  禁止 <a href=bin/zbbcode.htm#smilies onclick="popWin(this.href,500,300);">表情字符</a><br>
  <input type=checkbox value=1 name=f_lock>
  不允许别人回复我的文章
 </TD>
</TR>
<TR>
 <TD class="row2" colspan="2" align="center"> 
  <INPUT tabIndex=4 type=submit value=" 确 定 " name=submit1>&nbsp;
  <INPUT type=reset value=" 重 写 ">
 </TD>
</TR>
</TABLE>
</FORM>
<a href=javascript:history.back();><IMG src=$imgurl/back.gif border=0></a>
</CENTER>
EOT;

page_footer();

?>