<!-- #include file="include/config.asp" -->
<!-- #include file="../common/HtmlEdit/Include/DeCode.asp"-->
<!-- #include file="../include/jk_put.asp" -->
<!-- #include file="include/main.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("index.asp")
end if
%>
<!-- #include file="include/fir.asp" -->
<!-- #include file="include/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,cdd,fir_tipid,tiptrue
iframe=true
chk_true=true
edit_true=true
is_topic=false
sql="select top 1 forum_id,topic,tcolor,tbb,username,tim,islock,istop,isgood,tipid 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)
fir_tipid=rs(9)
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()
if int(login_modep)=1 or int(login_modep)=2 or int(login_modep)=3 then tiptrue=1
'----------------------------中间 开始----------------------------

call forum_grade()
call forum_top(tit)
if forum_power_true(forumpower)<>true  and int(fir_islock)=1 then
  call forum_msg("您要编辑的贴子所属的主题已被锁定！",1)
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
    call forum_msg("您要编辑的主题或回贴不存在！",1)
  else
    username=rs("username")
    ntopic=rs("topic")
    tim=rs("tim")
	tcod=rs("cod")
    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
        call forum_msg("您要编辑的主题或回贴不是您发表的或您的权限不够！",1)
      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
        call forum_msg("您要回复的主题已发布 <font class=blue>"&topic_day&"</font> 天，本版设置主题在 <font class=blue>"&max_edit_day&"</font> 天后不可编辑！",1)
      end if
    end if
    if edit_true then
      if joekoe_cms.chk() then
        call forum_reply_chk()
      else
        call forum_reply_main()
      end if
    end if
  end if
  rs.close
end if
'----------------------------中间 结束----------------------------
call forum_end()
call web_end(0,0)

sub forum_reply_chk()
  dim tmp1,topic,icon,word,word_edit,found_err,nistop,nisgood,nislock,nsql,cod,mode,tipid
  nistop=fir_istop
  nisgood=fir_isgood
  nislock=fir_islock
  tipid=fir_tipid
 if forum_power_true(forumpower)=true then
    if trim(request.form("istop"))="yes" then nistop=1
    if	forum_super_true()=true and trim(request.form("istops"))="yes" then nistop=2
    if trim(request.form("isgood"))="yes" then nisgood=1
    if trim(request.form("islock"))="yes" then nislock=1
  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
  
     '图标
	'mode=""
    'if Instr(Lcase(word),".jpg") then mode="jpg"
	'if Instr(Lcase(word),".gif") then mode="gif"
'----------帖子类型图标---------------------------- 
  mode=session("mode")
  if mode="" then
   filetype=split(filetypes,",")
   for i=0 to ubound(filetype)
    'if Instr(Lcase(word),"."&filetype(i)) then
    if Instr(word,"."&filetype(i)&"[") or Instr(word,"."&filetype(i)&"<") then
    mode=filetype(i)
  exit for
  end if
  next
  end if  
'----------帖子类型图标----------------------------
	'特殊贴


  rs("topic")=topic
  rs("icon")=icon
  rs("cod")=cod_type()
  rs("word")=word
  

  if forum_power_true(forumpower)=true and trim(request.form("edit_info"))="yes" then 
  word_edit=""
  else
        word_edit=vbcrlf&vbcrlf&"<br><div align=right><font 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)&" 编辑过]</font></div>"
  end if
  rs("edited")=word_edit
  rs.update
  call upload_note(index_url,viewid)
  nsql="update bbs_topic set "
  if is_topic then
    nsql=nsql&"topic='"&topic&"',"
    if forum_super_true()=true 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

   if format_power(login_mode,3)>format_power("user",3) and isarray(dimforumtip) then
     tipid=joekoe_cms.code_form(request.form("tip_id"))
     nsql=nsql&"tipid="&tipid&"," 
   end if  
     nsql=nsql&"istop="&nistop&",isgood="&nisgood&",icon="&icon&",islock="&nislock&",mode='"&mode&"'  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
  
   tmp1=vbcrlf&"<tr><td class=bbs_td>"&tit&"</td></tr><tr class=bbs_tr><td height=220>" & _
             vbcrlf&"<table border=0 width=300  align=center>" & _
        	 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='view.asp?forum_id=" & forumid & "&view_id=" & viewid & "'>您所编辑的主题</a>" & _
        	 vbcrlf&"<tr><td>　　2、<a href='list.asp?forum_id=" & forumid & "'>返回 <b>" & forumname & "</b></a></td></tr>" & _
        	 vbcrlf&"<tr><td>　　3、<a href='index.asp'>返回论坛首页</a></td></tr>" & _
        	 vbcrlf&"<tr><td height=30>系统将在 "&dim_num(21)&" 秒钟后自动返回 您所编辑的主题 ……</td></tr>" & _
		 vbcrlf&"</table></td></tr><meta http-equiv='refresh' content='"&dim_num(21)&"; url=view.asp?view_id=" & viewid & "'>"
    call forum_bar_top(tit,tmp1,1)
  call val_chk_end_forum("f_edit_"&forumid)
end sub

sub forum_reply_main()
   response.write forum_main_head()
   call forum_write_frm_check()  
%>
<tr><td colspan=2 class=bbs_td><%response.write tit%></td></tr>
     <form name=frm_post 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=bbs_tr>
<td width='20%'>用户信息：</td>
<td width='80%'>&nbsp;<font class=blue><b><%response.write login_username%></b></font>
&nbsp;&nbsp;您现在有&nbsp;<font class=red><b><%response.write login_emoney%></b></font>&nbsp;<%response.write joekoe_cms.web_unit%>,
&nbsp;<font class=red><b><%response.write login_integral%></b></font>&nbsp;积分 
</tr>
<tr class=bbs_tre>
<td>贴子主题：</td>
<td>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><%response.write 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>
<%if tiptrue=1 and isarray(dimforumtip) then %>
<tr class=bbs_tr>
<td>所属专题：</td>
<td>
<%if tiptrue=1 then call forum_tip_select(fir_tipid,0)%>&nbsp;您可以为该主题选择一个对应专题</td>
</tr>
<%end if%>
<tr class=bbs_tr>
<td>当前心情：</td>
<td class=s><script language=javascript>post_icon(10,0,"icon");</script></td>
</tr>
<%if forum_power_true(forumpower)=true and is_topic then %>
<tr class=bg_tds>
<td>主题加色：</td>
<td class=s><input type=checkbox name=tbb value='yes'<%if fir_tbb then response.write " checked"%>>选择加粗功能后将扣取你<font class=red><%response.write etb%></font>分
    &nbsp;颜色：#&nbsp;<input type=text name=tcolor value='<%response.write fir_tcolor%>' size=8 maxlength=7><a href='javascript:;' onClick="javascript:slect_color('tcolor');"><img border=0 src="../common/html_edit/images/btn_fgcolor.gif" width=23 height=22 align=absmiddle alt='点击选取主题字体颜色'></a>&nbsp;&nbsp;请正确填写<font class=red_3>6</font>位颜色代码。</td>
</td>
</tr>
<%end if%>
<%response.write bbs_html_edit(1,"frm_post","jk_word","")%>
<tr class=bbs_tr>
<td class=s><script language=javascript>post_textarea_caption('贴子内容：',"<input type=checkbox name=d_isubb value='yes' checked>使用UBB标签<br><input type=checkbox name=d_issign value='yes' checked>显示个性签名<!--<%response.write web_frm_word%>-->");</script></td>
<td class=s><script language=javascript>post_textarea(0,12,'<%response.write format_remark_var(rs("word"),1)%>');</script></td>
</tr>
<tr class=bbs_tr>
<td>上传文件：</td>
<td class=bg><iframe frameborder=0 name=upload_frame width='98%' height=30 scrolling=no src='../common/upload.asp?uppath=forum&upname=&uptext=jk_word'></iframe></td>
</tr>
<tr class=bbs_tr>
<td>E M 贴图：</td>
<td><%response.write jk_em("frm_post","jk_word")%></td>
</tr>
</tr>
<%if forum_power_true(forumpower)=true then%>
<tr class=bg_td>
<td>高级选项：</td>
<td><input type=checkbox name=edit_info value='yes'>&nbsp;不显示编辑信息&nbsp; 
<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;锁定
</td>
</tr>
<% end if %>
<tr class=bbs_trb>
<td>发表新贴：</td>
<td height=40><input type=submit class=btn value='可以发表啦' onclick=""javascript:return check_post('edit');"">　&nbsp;<%response.write preview_b("frm_post","jk_word","预览回复")%>　&nbsp;<input type=reset class=btn value='清除重写'>　&nbsp;（按 Ctrl + Enter 可快速发表）</td>
</tr>
</form> 
<%
  response.write forum_main_end()
  call preview_form("frm_post","jk_word")
end sub
%>