<!-- #include file="include/con_forum.asp" -->
<%

call time_lock()
dim editid
editid=trim(request.querystring("edit_id"))
if not joekoe_cms.int_true(viewid) or not joekoe_cms.int_true(editid) 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_tcolor,fir_tbb,fir_username,fir_tim,fir_islock,fir_istop,fir_isgood,username,ntopic,tim,chk_true,edit_true,is_topic,topic_day,max_edit_day
chk_true=true
edit_true=true
is_topic=false
sql="select top 1 forum_id,topic,tcolor,tbb,username,tim,islock,istop,isgood 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_tcolor=rs(2)
fir_tbb=rs(3)
fir_username=rs(4)
fir_tim=rs(5)
fir_islock=rs(6)
fir_istop=rs(7)
fir_isgood=rs(8)
rs.close
ftit="编辑主题"

call forum_first()
'-----------------------不可编辑参数设置-------------------------------
topic_day=datediff("d",fir_tim,joekoe_cms.now_time)
if forum_config(19)>0 then
  max_edit_day=forum_config(19)
else
  max_edit_day=dim_num(34)
end if
'-----------------------不可编辑参数结束-------------------------------
call web_head(2,1,h_var3,0,0)
call forum_readonly()
call forum_load()
'----------------------------中间 开始----------------------------

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(login_modep)<>1 and 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
  sql="select top 1 * from bbs_data where reply_id="&viewid&" and id="&editid
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  if rs.eof then
    chk_true=false
    response.write vbcrlf&"<tr><td colspan=2 align=center height=200 class=bg_td><font class=red>您要编辑的主题或回贴不存在！</font></td></tr>"
  else
    username=rs("username")
    ntopic=rs("topic")
    tim=rs("tim")
    if cstr(username)=cstr(fir_username) and cstr(tim)=cstr(fir_tim) then is_topic=true
    if forum_power_true(forumpower)=false then
      if cstr(login_username)<>cstr(username) then
        edit_true=false
        response.write vbcrlf&"<tr><td colspan=2 align=center height=200 class=bg_td><font class=red>您要编辑的主题或回贴不是您发表的或您的权限不够！</font></td></tr>"
      end if
    end if
	if not forum_power_true(forumpower) then
      if int(max_edit_day)>0 and int(topic_day)>int(max_edit_day) then
        edit_true=false
        response.write vbcrlf&"<tr><td colspan=2 align=center height=200 class=bg_td><font class=red>您要编辑的主题或回帖已发布 <font class=blue>"&topic_day&"</font> 天，本版设置主题或回帖在 <font class=blue>"&max_edit_day&"</font> 天后不可编辑！</font></td></tr>"
      end if
    end if
    if edit_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
  rs.close
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,word_edit,found_err,nistop,nisgood,nislock,nsql
  nistop=fir_istop
  nisgood=fir_isgood
  nislock=fir_islock
  if int(login_modep)=1 then
    if trim(request.form("istop"))="yes" then
      nistop=1
    else
      nistop=0
    if trim(request.form("istops"))="yes" then
      nistop=2
    else
      nistop=0
    end if
    end if
    if trim(request.form("isgood"))="yes" then
      nisgood=1
    else
      nisgood=0
    end if
    if trim(request.form("islock"))="yes" then
      nislock=1
    else
      nislock=0
    end if
  end if
  word_edit=""
  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_edit_"&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 word_size_true(word)=false then
    found_err=found_err&"+贴子的 <font class=red>内容</font> 是必须要的，不能少于 "&min_word_size&" B或超过 "&max_word_size&" KB！<br>"
  end if
  if found_err<>"" then
    response.write found_error(found_err,320)
    exit sub
  end if
  
  if not(int(login_modep)=1 and trim(request.form("edit_info"))<>"yes") then
    word_edit=vbcrlf&vbcrlf&"[ALIGN=right][COLOR=#000066][本贴已被 "
    if cstr(login_username)=cstr(username) then
      word_edit=word_edit&"作者"
    else
      word_edit=word_edit&login_username
    end if
    word_edit=word_edit&" 于 "&joekoe_cms.time_type(joekoe_cms.now_time,2)&" 编辑过][/COLOR][/ALIGN]"
  end if
  
  rs("topic")=topic
  rs("icon")=icon
  rs("word")=word&word_edit
  rs.update
  call upload_note(index_url,viewid)
  nsql="update bbs_topic set "
  if is_topic then
    nsql=nsql&"topic='"&topic&"',"
    if int(login_modep)=1 then
      fir_tcolor=trim(request.form("tcolor"))
      if len(fir_tcolor)<>6 then fir_tcolor=""
      fir_tbb=0
      if trim(request.form("tbb"))="yes" then fir_tbb=1
      nsql=nsql&"tcolor='"&fir_tcolor&"',tbb="&fir_tbb&","
    end if
  end if
  nsql=nsql&"istop="&nistop&",isgood="&nisgood&",islock="&nislock&" where id="&viewid
  call joekoe_cms.exec(nsql,0)
  if cstr(nistop)<>cstr(fir_istop) then
    application.lock
    application(joekoe_cms.web_cookies&"_forum_istop_state_"&forumid)=empty
    application(joekoe_cms.web_cookies&"_forum_istops_state")=empty
    application.unlock
  end if
  
  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_forum("f_edit_"&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%>&edit_id=<%response.write editid%>' 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_edit_"&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 ntopic%>' size=60 maxlength=50><%response.write redx%>长度不能超过50</td>
  </tr>
  </table>
</td>
</tr>
<tr class=bg_td>
<td>当前心情：</td>
<td><%response.write jk_icon(rs("icon"))%></td>
</tr>
<%if int(login_modep)=1 and is_topic then%>
<tr class=bg_tds>
<td>主题加色：</td>
<td><input type=checkbox name=tc value='yes' class=bg_tds<%if fir_tcolor<>"" then response.write " checked"%>>&nbsp;&nbsp;颜色：#&nbsp;<input type=text name=tcolor value='<%response.write fir_tcolor%>' size=10 maxlength=7>&nbsp;&nbsp;<a href='javascript:;' onClick="javascript:slect_color('tcolor');"><img border=0 src="html_edit/images/btn_fgcolor.gif" width=23 height=22 align=absmiddle alt='点击选取主题字体颜色'></a>&nbsp;&nbsp;请正确填写<font class=red_3>6</font>位颜色代码。
&nbsp;&nbsp;&nbsp;主题加粗：<input type=checkbox name=tbb value='yes' class=bg_tds<%if fir_tbb then response.write " checked"%>>&nbsp;是否对本主题进行加粗。
</td>
</tr>
<%end if%>
<tr class=bg_td>
<td><%call frm_ubb_type("class=bg_td")%></td>
<td><%call frm_ubb("write_frm","jk_word","",1)%></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",max_word_size,"贴子内容")%><br><br><%response.write web_frm_word&"<br>长度<="&max_word_size&"KB"%></td></td></tr></table></td>
<td>
<table border=0><tr>
<td><textarea  name=jk_word rows=10 cols=90 alt='按 Ctrl+Enter 可直接发送' onkeydown="javascript:frm_quicksubmit();"><%response.write joekoe_cms.code_word(rs("word"))%></textarea></td>
<td width=5></td>
<td valign=bottom><%call textarea_resize("jk_word")%></td>
</tr></table>
</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>
<script language = "JavaScript">
<!--
var em_frm="write_frm"
var em_word="jk_word"
-->
</script>
<script language = "JavaScript" src = "style/magicface.Js"></script>
<% if int(login_modep)=1 then %>
<tr class=bg_td>
<td>高级选项：</td>
<td><input type=checkbox name=edit_info value='yes' class=bg_td checked>&nbsp;显示编辑信息&nbsp;
<% if is_topic then %>
<input type=checkbox name=istop value='yes' class=bg_td<%if int(fir_istop)=1 then response.write " checked"%>>&nbsp;固顶&nbsp;<input type=checkbox name=istops value='yes' class=bg_td<%if int(fir_istop)=2 then response.write " checked"%>>&nbsp;总固顶&nbsp;<input type=checkbox name=isgood value='yes' class=bg_td<%if int(fir_isgood)=1 then response.write " checked"%>>&nbsp;精华&nbsp;<input type=checkbox name=islock value='yes' class=bg_td<%if int(fir_islock)=1 then response.write " checked"%>>&nbsp;锁定
<% end if %>
</td>
</tr>
<% end if %>
<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

%>