<!-- #include file="include/con_forum.asp" -->
<!-- #include file="include/jk_ubbtst.asp" -->
<%
call time_lock()
dim replyid
replyid=trim(request.querystring("reply_id"))
if not joekoe_cms.int_true(viewid) or not joekoe_cms.int_true(replyid) then
  call format_redirect("forum.asp")
end if
%>
<!-- #include file="include/con_forum_fir.asp" -->
<!-- #include file="include/con_forum_write.asp" -->
<%
dim fir_topic,fir_islock,rword,chk_true,quote
chk_true=true
rword=""
quote=trim(request.querystring("quote"))
sql="select top 1 forum_id,topic,islock from bbs_topic where id="&viewid
set rs=joekoe_cms.exec(sql,1)
if rs.eof then
  call web_error("forum_viewid")
end if
forumid=rs(0)
fir_topic=rs(1)
fir_islock=rs(2)
rs.close
ftit="回复主题"

call forum_first()
call web_head(2,1,h_var3,0,0)
call forum_readonly()
call forum_load(0,0,0,1)
'----------------------------中间 开始----------------------------
call forum_grade()
call forum_top(tit)
response.write vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>"
response.write vbcrlf&"<tr><td colspan=2 class=td0>&nbsp;"&img_skin(web_img_m)&"&nbsp;"&tit&"</td></tr>"

if int(fir_islock)=1 then
  response.write vbcrlf&"<tr><td colspan=2 align=center height=200 class=bg_td><font class=red>您要回复或引用的贴子所属的主题已被锁定！</font></td></tr>"
else
  if quote="yes" then
    sql="select top 1 bbs_data.username,bbs_data.word,bbs_data.tim,user_data.popedom from bbs_data,user_data where bbs_data.userid=user_data.id and bbs_data.reply_id="&viewid&" and bbs_data.id="&replyid
    call joekoe_cms.exec("",-1)
    rs.open sql,conn,1,3
    if rs.eof then
      rs.close
      response.write vbcrlf&"<tr><td colspan=2 align=center height=200 class=bg_td><font class=red>您要编辑的主题或回贴不存在！</font></td></tr>"
    else
      if joekoe_cms.popedom_p(rs("popedom"),42)=0 then
        rword="[quote][b]以下是引用 [u]"&rs("username")&"[/u] 在 [i]"&rs("tim")&"[/i] 的发言：[/b]"&vbcrlf&reubbtst(rs("word"))&vbcrlf&"[/quote]"
      end if
    end if
    rs.close
  end if
  if chk_true then
    if joekoe_cms.chk() then
      response.write vbcrlf&"<tr><td colspan=2 class=bg_td align=center height=200>"
      call forum_reply_chk()
      response.write vbcrlf&"</td></tr>"
    else
      call forum_reply_main()
    end if
  end if
end if

response.write vbcrlf&"</table>"
response.write vbcrlf&ukong
'----------------------------中间 结束----------------------------
call forum_end()
call web_end(0,0)

sub forum_reply_chk()
  dim topic,icon,word,found_err
  topic=joekoe_cms.code_form(request.form("topic"))
  icon=form_icon()
  word=request.form("jk_word")
  found_err=""
  if not post_tim() then
    found_err=found_err&"+对不起，回帖的间隔时间为 <font class=red>"&int(dim_num(28))&"</font> 秒！<br>"
  end if
  if login_mode="" then
    found_err=found_err&"+<font class=red>您还没有注册或登陆本站！因此不能发表主题。</font><br>"
  end if
  if val_chk("f_reply_"&forumid)=false then
    found_err=found_err&"+您输入的 <font class=red>验 证 码</font> 为空或有错误，请勿非法提交！<br>"
  end if
  if len(topic)>50 then
    found_err=found_err&"+贴子的 <font class=red>主题</font> 长度不能超过50个字符！<br>"
  end if
  if var_null(word)="" or len(word)>word_size*1024 then
    found_err=found_err&"+贴子的 <font class=red>内容</font> 是必须要的，且大小不能超过"&word_size&"KB！<br>"
  end if
  if found_err<>"" then
    response.write found_error(found_err,320)
    exit sub
  end if
  
  sql="select * from bbs_data where id is null"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  rs.addnew
  rs("forum_id")=forumid
  rs("reply_id")=viewid
  rs("username")=login_username
  rs("userid")=login_id
  rs("topic")=topic
  rs("icon")=icon
  rs("word")=word
  rs("tim")=joekoe_cms.now_time
  rs("ip")=user_ip
  rs("sys")=user_sys
  rs.update
  rs.close
  sql="update bbs_topic set re_counter=re_counter+1,re_username='"&login_username&"',re_tim='"&joekoe_cms.now_time&"' where id="&viewid
  call joekoe_cms.exec(sql,0)
  sql="update bbs_forum set forum_new_num=forum_new_num+1,forum_data_num=forum_data_num+1 where forum_id in ("&forumparent&")"
  call joekoe_cms.exec(sql,0)
  sql="update bbs_forum set forum_new_info='"&login_username&"|"&joekoe_cms.now_time&"|"&viewid&"|"&fir_topic&"' where forum_id="&forumid
  call joekoe_cms.exec(sql,0)
  sql="update user_data set bbs_counter=bbs_counter+1,integral=integral+"&dim_num(10)&" where id="&login_id
  call joekoe_cms.exec(sql,0)
  sql="update configs set num_data=num_data+1,num_new=num_new+1 where id=1"
  call joekoe_cms.exec(sql,0)

  call upload_note(index_url,viewid)
  
  application.lock
  application(joekoe_cms.web_cookies&"_configs_num_data")=application(joekoe_cms.web_cookies&"_configs_num_data")+1
  application(joekoe_cms.web_cookies&"_configs_new_num")=application(joekoe_cms.web_cookies&"_configs_new_num")+1
  application.unlock
  
  response.write vbcrlf&"<table border=0 width=300>" & _
        	 vbcrlf&"<tr><td align=center height=30><font class=red>"&tit&"成功！谢谢您的发贴。</font></td></tr>" & _
        	 vbcrlf&"<tr><td height=30>您现在可以选择以下操作：</td></tr>" & _
        	 vbcrlf&"<tr><td>　　1、<a href='forum_view.asp?forum_id=" & forumid & "&view_id=" & viewid & "'>您所回复的主题</a>" & _
        	 vbcrlf&"<tr><td>　　2、<a href='forum_list.asp?forum_id=" & forumid & "'>返回 <b>" & forumname & "</b></a></td></tr>" & _
        	 vbcrlf&"<tr><td>　　3、<a href='forum.asp'>返回论坛首页</a></td></tr>" & _
        	 vbcrlf&"<tr><td height=30>系统将在 "&dim_num(21)&" 秒钟后自动返回 <b>" & forumname & "</b> ……</td></tr>" & _
		 vbcrlf&"</table><meta http-equiv='refresh' content='"&dim_num(21)&"; url=forum_list.asp?forum_id=" & forumid & "'>"
  call val_chk_end("f_reply_"&forumid)
end sub

sub forum_reply_main()
  call forum_write_frm_check()
%>
<form name=write_frm action='?forum_id=<%response.write forumid%>&view_id=<%response.write viewid%>&reply_id=<%response.write replyid%>&quote=<%response.write quote%>' method=post onsubmit="javascript:frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<%response.write val_code_num("f_reply_"&forumid,1)%>
<tr class=bg_td>
<td width='20%'>用户信息：</td>
<td width='80%'>用户名：<input type=username name=username value='<%response.write login_username%>' size=18 maxlength=20>&nbsp;&nbsp;
密码：<input type=password name=password value='<%response.write login_password%>' size=18 maxlength=20>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font class=gray>[ <a href='user_main.asp'>用户中心</a> ]&nbsp;&nbsp;&nbsp;&nbsp;[ <a href='login.asp?action=logout'>退出登陆</a> ]</font></td>
</tr>
<tr class=bg_tds>
<td>贴子主题：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><%call frm_topic("write_frm","topic")%></td>
  <td>&nbsp;<input type=text name=topic value='回复：<%response.write fir_topic%>' size=60 maxlength=50><%response.write redx%>长度不能超过50</td>
  </tr>
  </table>
</td>
</tr>
<tr class=bg_td>
<td>当前心情：</td>
<td><%response.write jk_icon(0)%></td>
</tr>
<tr class=bg_td>
<td><%call frm_ubb_type("class=bg_td")%></td>
<td><%call frm_ubb("write_frm","jk_word","")%></td>
</tr>
<tr class=bg_tds>
<td valign=top><table border=0><tr><td class=htd>贴子内容：<br><br><%call frm_word_size("write_frm","jk_word",word_size,"贴子内容")%><br><br><%response.write web_frm_word&"<br>长度<="&max_word&"KB"%></td></td></tr></table></td>
<td><textarea name=jk_word rows=12 cols=93 alt='按 Ctrl+Enter 可直接发送' onkeydown="javascript:frm_quicksubmit();"><%response.write joekoe_cms.code_word(rword)%></textarea></td>
</tr>
<tr class=bg_td>
<td>上传文件：</td>
<td class=bg><iframe frameborder=0 name=upload_frame width='98%' height=30 scrolling=no src='upload.asp?uppath=forum&upname=&uptext=jk_word'></iframe></td>
</tr>
<tr class=bg_td>
<td>E M 贴图：</td>
<td>&nbsp;<%response.write jk_em("write_frm","jk_word")%></td>
</tr>
<tr class=bg_tds>
<td>发表新贴：</td>
<td height=40><input type=submit value='可以发表啦' onclick="javascript:return write_frm_check(0);">　&nbsp;<%response.write preview_b("write_frm","jk_word","预览回复")%>　&nbsp;<input type=reset value='清除重写'>　&nbsp;（按 Ctrl + Enter 可快速发表）</td>
</tr>
</form>
<%
  call preview_form("write_frm","jk_word")
end sub
%>