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

require "bin/config.php";
require "bin/common.php";

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

$oBrd=new CBoard;
if(!$oBrd->load($bid)){errorview('error board id!');}

###### GENERATE INPUT FORM ######
if(!$zcodeallowed){$zbbstate="不";}

#--- Print header ---
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.=" >> 发表文章";
menu_bar($posText,'');

#--- Print script functions ---
print <<<EOT
<script>
function DoTitle(addTitle) { 
 var currentTitle = document.form.f_title.value; 
 revisedTitle = addTitle+currentTitle;
 document.form.f_title.value=revisedTitle; 
}

var msgMax="$maxpostsize";
function CheckLength(){
 msgLen=document.form.f_comment.value.length;
 if(msgMax !=0){msg="最大字符为 "+msgMax+ " 字节";}
 else{msg="";}
 alert(msg+"\\n您的内容已有 "+msgLen+" 字节");
}

function ValidateForm(){
 userLen=document.form.f_user.value.length;
 if(userLen<1){alert("请输入用户名称!");return false;}
 passLen=document.form.f_pass.value.length;
 if(passLen<1){alert("请输入用户密码!");return false;}
 titleLen=document.form.f_title.value.length;
 if(titleLen<2){alert("文章标题不能小于2个字符！");return false;}
 msgLen =document.form.f_comment.value.length;
 errors="";
 if(msgLen<2){errors="文章内容不能小于2个字符！";}
 if((msgMax!=0)&&(msgLen>msgMax)){
  errors="本论坛限制文章长度不得超过 "+msgMax+" 字节\\n目前您的文章字节: "+msgLen;
 }

 if(errors != ""){alert(errors);return false;}
 else{document.form.submit1.disabled = true;return true;}
}

function emoticon(theSmilie){
 document.form.f_comment.value += theSmilie + ' ';
 document.form.f_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>
EOT;

#--- Print form ---
$nopass=($sv_user) ? '------' : '';
print <<<EOT
<form method=post name=form onsubmit="return ValidateForm()" action=ztopic_new_s.php>
<input type=hidden name=bid value=$bid>
<TABLE width=630 cellSpacing=1 cellPadding=3 border=0 class=forumLine>
<TR><TD class=rowCaption colSpan=4>发表文章</TD></TR>
<TR>
 <TD width=129 class=row1>用户名称</TD>
 <TD width=190 class=row1>
  <INPUT class=plain maxLength=20 size=15 name=f_user value='$sv_user'></TD>
 <TD width=129 class=row1>您的密码</TD>
 <TD width=190 class=row1>
  <INPUT class=plain type=password size=15 name=f_pass value='$nopass'></TD>
</TR>
<TR>
 <TD width=129 class=row2>文章标题
  <SELECT onchange=DoTitle(this.options[this.selectedIndex].value)>
  <OPTION selected value="">&nbsp;类型</OPTION>
  <OPTION value=[原创]>[原创]</OPTION><OPTION value=[转帖]>[转帖]</OPTION>
  <OPTION value=[灌水]>[灌水]</OPTION><OPTION value=[讨论]>[讨论]</OPTION>
  <OPTION value=[求助]>[求助]</OPTION><OPTION value=[推荐]>[推荐]</OPTION>
  <OPTION value=[公告]>[公告]</OPTION><OPTION value=[注意]>[注意]</OPTION>
  <OPTION value=[贴图]>[贴图]</OPTION><OPTION value=[建议]>[建议]</OPTION>
  <OPTION value=[下载]>[下载]</OPTION><OPTION value=[分享]>[分享]</OPTION></SELECT></TD>
 <TD colspan=3 class=row2>
  <INPUT class=plain maxLength=50 size=59 name=f_title></TD>
</TR>
<TR>
 <TD vAlign=top width=129 class=row1>您的表情</TD>
 <TD colspan=3 class=row1>
<input type=radio name=f_emote value=1 checked><img src=$imgurl/1.gif>
<input type=radio name=f_emote value=2><img src=$imgurl/2.gif>
<input type=radio name=f_emote value=3><img src=$imgurl/3.gif>
<input type=radio name=f_emote value=4><img src=$imgurl/4.gif>
<input type=radio name=f_emote value=5><img src=$imgurl/5.gif>
<input type=radio name=f_emote value=6><img src=$imgurl/6.gif>
<input type=radio name=f_emote value=7><img src=$imgurl/7.gif>
<input type=radio name=f_emote value=8><img src=$imgurl/8.gif>
<input type=radio name=f_emote value=9><img src=$imgurl/9.gif>
<input type=radio name=f_emote value=10><img src=$imgurl/10.gif>
<input type=radio name=f_emote value=11><img src=$imgurl/11.gif>
<br><input type=radio name=f_emote value=12><img src=$imgurl/12.gif>
<input type=radio name=f_emote value=13><img src=$imgurl/13.gif>
<input type=radio name=f_emote value=14><img src=$imgurl/14.gif>
<input type=radio name=f_emote value=15><img src=$imgurl/15.gif>
<input type=radio name=f_emote value=16><img src=$imgurl/16.gif>
<input type=radio name=f_emote value=17><img src=$imgurl/17.gif>
<input type=radio name=f_emote value=18><img src=$imgurl/18.gif>
<input type=radio name=f_emote value=19><img src=$imgurl/19.gif>
<input type=radio name=f_emote value=20><img src=$imgurl/20.gif>
<input type=radio name=f_emote value=21><img src=$imgurl/21.gif>
<input type=radio name=f_emote value=22><img src=$imgurl/22.gif>
<br><input type=radio name=f_emote value=23><img src=$imgurl/23.gif>
<input type=radio name=f_emote value=24><img src=$imgurl/24.gif>
<input type=radio name=f_emote value=25><img src=$imgurl/25.gif>
<input type=radio name=f_emote value=26><img src=$imgurl/26.gif>
<input type=radio name=f_emote value=27><img src=$imgurl/27.gif>
<input type=radio name=f_emote value=28><img src=$imgurl/28.gif>
<input type=radio name=f_emote value=29><img src=$imgurl/29.gif>
<input type=radio name=f_emote value=30><img src=$imgurl/30.gif>
<input type=radio name=f_emote value=31><img src=$imgurl/31.gif>
<input type=radio name=f_emote value=32><img src=$imgurl/32.gif>
<input type=radio name=f_emote value=33><img src=$imgurl/33.gif>
 </TD>
</TR>
<TR>
 <TD vAlign=top width=129 class=row2>
 <TABLE cellSpacing=3 cellPadding=0 width=97 align=left border=0>
 <TR><TD vAlign=top>文章内容<BR>
  (<a href=javascript:CheckLength();>查看内容长度</a>)</TD></TR>
 <TR><TD vAlign=middle>
  <TABLE style="BORDER-RIGHT: 1px inset; BORDER-TOP: 1px inset; BORDER-LEFT: 1px inset; WIDTH: 125px; BORDER-BOTTOM: 1px inset" cellSpacing=1 cellPadding=3 border=0>
  <TR align=center>
<TD><A href=javascript:emoticon(':)')><IMG alt=笑脸 src=$imgurl/regular_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(':d')><IMG alt=开口笑脸 src=$imgurl/teeth_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(':o')><IMG alt="微笑说 O" src=$imgurl/omg_smile.gif border=0></A></TD></TR>
  <TR align=center>
<TD><A href=javascript:emoticon(':p')><IMG alt=微笑时伸出舌头 src=$imgurl/tounge_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(';)')><IMG alt=眨眼微笑 src=$imgurl/wink_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(':(')><IMG alt=苦笑 src=$imgurl/sad_smile.gif border=0></A></TD></TR>
  <TR align=center>
<TD><A href=javascript:emoticon(':s')><IMG alt=狡猾的微笑 src=$imgurl/confused_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(':|')><IMG alt=严肃的微笑 src=$imgurl/whatchutalkingabout_smile.gif border=0></A></TD>
<TD><A href=javascript:emoticon(':[')><IMG alt=可爱的笑 src=$imgurl/angel_smile.gif border=0></A></TD></TR>
  </TABLE></TD></TR>
 <TR><TD>
ZBB代码： ${zbbstate}允许<br>
贴图标签： ${zbbstate}允许<br>
表情字符转换： 允许
 </TD></TR></TABLE>
 </TD>
 <TD colspan=3 class=row2>
EOT;

#--- Print ZBB panel ---
if($zcodeallowed){
 print <<<EOT
<SCRIPT src=bin/zbbcode.js></SCRIPT>
<INPUT type=button title="加粗: [Alt] + b" style="FONT-WEIGHT: bold" accessKey=b onclick=ZBBCbold() value=" B " name=bold>
<INPUT type=button title="倾斜: [Alt] + i" style="FONT-STYLE: italic" accessKey=i onclick=ZBBCitalic() value=" I " name=italic>
<INPUT type=button title="下划线: [Alt] + u" style="TEXT-DECORATION: underline" accessKey=u onclick=ZBBCunder() value=" U " name=under>
<INPUT type=button title="超链接: [Alt] + h" style="COLOR: blue; TEXT-DECORATION: underline" accessKey=h onclick=ZBBCurl() value=" http:// ">
<INPUT type=button title="EMAIL: [Alt] + e" style="COLOR: blue; TEXT-DECORATION: underline" accessKey=e onclick=ZBBCemail() value="  @  ">
<INPUT type=button title="图片: [Alt] + p" accessKey=p onclick=ZBBCimage() value=" 图片 ">
<INPUT type=button title="引用: [Alt] + q" accessKey=q onclick=ZBBCquote() value=" 引用 " name=quote>
<INPUT type=button title="代码: [Alt] + c" accessKey=c onclick=ZBBCcode() value=" 代码 " name=code>
EOT;
}

#--- Print content & options ---
print <<<EOT
 <TEXTAREA class=plain name=f_comment rows=10 cols=60 onkeydown=presskey();></TEXTAREA></TD>
</TR>
<TR>
 <TD vAlign=top width=129 class=row1>选项</TD>
 <TD colspan=3 class=row1>
<input type=checkbox value=1 name=f_nocode> 禁止 <a href=bin/zbbcode.htm onclick="return popWin(this.href,600,400);">ZBB代码</a><br>
<input type=checkbox value=1 name=f_nosmile> 禁止 <a href=bin/zbbcode.htm#smilies onclick="return popWin(this.href,600,400);">表情字符</a><br>
<input type=checkbox value=1 name=f_lock> 不允许别人回复我的文章</TD>
</TR>
<TR>
 <TD align=center colSpan=4 class=row2>
<INPUT 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>
EOT;

page_footer();
exit;

?>