<!-- #Include File="Include/Config.asp" -->
<!-- #include file="Include/Con_bbs_Fir.asp" -->
<!-- #include file="Include/Con_bbs_Post.asp" -->
<%

'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

tit_fir=Cls.ChannelName
dim editid,fir_topic,fir_tcolor,fir_tbb,fir_username,fir_tim,fir_islock,fir_istop,fir_isgood,fir_bbs_data,username,ntopic,tim,chk_true,edit_true,is_topic,topic_day,max_edit_day,fir_SpecialID
chk_true=true
edit_true=true
is_topic=false
editid=Cls.code_id("eid")
call bbs_list_load()
Bbsid=dim_topic(0,0)
fir_topic=dim_topic(1,0)
fir_tcolor=dim_topic(17,0)
fir_tbb=dim_topic(18,0)
fir_username=dim_topic(15,0)
fir_tim=dim_topic(16,0)
fir_islock=dim_topic(4,0)
fir_istop=dim_topic(5,0)
fir_isgood=dim_topic(6,0)
fir_bbs_data=dim_topic(10,0)
fir_SpecialID=dim_topic(19,0)
ftit="编辑帖子"
call bbs_first()
call word_size_load()
call DoWebHead(2,1)
call bbs_load_power()
'----------------------------中间 开始----------------------------
topic_day=datediff("d",fir_tim,Cls.now_time)
max_edit_day=bbs_config(15)
call bbs_grade(0)
call bbs_top(0,"")
if is_super=false and int(fir_islock)=1 then
  call bbs_msg("您要编辑的贴子所属的主题已被锁定！")
else
  sql="select top 1 * from "&fir_bbs_data&" where reply_id="&viewid&" and id="&editid
  call Cls.exe_conn(rs,sql,3)
  if rs.eof then
    call bbs_msg("您要编辑的主题或回贴不存在！")
  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 is_super=false and cstr(login_username)<>cstr(username) then
      edit_true=false
      call bbs_msg("您要编辑的主题或回贴不是您发表的或您的权限不够！")
    end if
    if not is_super then
      if int(max_edit_day)>0 and int(topic_day)>int(max_edit_day) then
        edit_true=false
        call bbs_msg("您要回复的主题已发布 <font class=blue>"&topic_day&"</font> 天，本版设置主题在 <font class=blue>"&max_edit_day&"</font> 天后不可编辑！")
      end if
    end if
    if edit_true=true then
      if Cls.chk() then
        call bbs_reply_chk()
      else
        call bbs_reply_main()
      end if
    end if
  end if
  rs.close
end if
'----------------------------中间 结束----------------------------
call bbs_end()
call DoWebEnd()
sub bbs_reply_chk()
  dim tmp1,topic,icon,word,word_edit,found_err,nistop,nisgood,nislock,nsql,nfiletype
  if is_super=true and is_topic=true then
    nistop=0
    nisgood=0
    nislock=0
  else
    nistop=fir_istop
    nisgood=fir_isgood
    nislock=fir_islock
  end if
  if is_super=true then
    if Cls.code_form("istop")="yes" then nistop=1
    if Cls.code_form("istopz")="yes" then nistop=2
    if Cls.code_form("istops")="yes" then nistop=3
    if Cls.code_form("isgood")="yes" then nisgood=1
    if Cls.code_form("islock")="yes" then nislock=1
  end if
  word_edit=""
  topic=Cls.code_form("topic")
  icon=Cls.Code_Int("icon",0)
  word=Cls.Code_Remark("AsaiMHword")
  nfiletype=Get_Remark_FileType(word)
  fir_SpecialID=Cls.Code_Int("SpecialID",0)
  found_err=""
  if Not Cls.CodeIsTrue() and int(bbs_config(16))=1 then
    found_err=found_err&"+您输入的 <font class=red>验 证 码</font> 为空或有错误，请勿非法提交！<br>"
  end if
  if is_topic=true and topic="" 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> 是必须要的，不能少于"&word_size_min&"或超过"&word_size_max&"KB！<br>"
  end if
  if found_err="" then
    if not Cls.Put_Space("post_tim",Format_Mid_Num(18)) then
      found_err=found_err&"+论坛重复发贴间隔不得超过 <font class=red>"&Format_Mid_Num(18)&"</font> 秒钟！请勿重复发贴。<br>"
    end if
  end if
  if found_err<>"" then
    call bbs_msg(found_err) 'Response.Write found_error(found_err,320)
    exit sub
  end if
  if not(is_super=true and Cls.code_form("edit_info")<>"yes") then
	word_edit=word_edit&"本贴已被 "
    if cstr(login_username)=cstr(username) then
      word_edit=word_edit&"作者"
    else
      word_edit=word_edit&login_username
    end if
    word_edit=word_edit&" 于 "&Cls.time_type(Cls.now_time,2)&" 编辑过"
	if request.Form("codeMode")=0 then 
	      word_edit=vbcrlf&vbcrlf&"[align=right][color=#000066]"&word_edit&"[/color][/align]"
	else
	      word_edit=vbcrlf&vbcrlf&"<p style=""float:right;color:#000066"">"&word_edit&"</p>"
	 end if
  end if
  rs("topic")=topic
  rs("icon")=icon
  rs("word")=word&word_edit
  rs("Cod")=request.Form("codeMode")
  rs.update
  'call Cls.upload_note(Index_Url,viewid)
  nsql="update AsaiMHBbsTopic set "
  if is_topic=true then
    nsql=nsql&"topic='"&topic&"',icon="&icon&",filetype='"&nfiletype&"',SpecialID="&fir_SpecialID&","
    if is_super=true then
      fir_tcolor=Cls.code_form("tcolor")
      if len(fir_tcolor)<>6 then fir_tcolor=""
      fir_tbb=0
      if Cls.code_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 Cls.exec(nsql,0)
  if is_topic=true and (int(nistop)>0 or int(fir_istop)>0) then
    if int(nistop)=1 or int(fir_istop)=1 then
      call Cls.cache_del("bbs_istop_"&Bbsid)
    end if
    if int(nistop)=2 or int(fir_istop)=2 then
      call Cls.cache_del("bbs_istopz_"&zid)
    end if
    if int(nistop)=3 or int(fir_istop)=3 then
      call Cls.cache_del("bbs_istops")
    end if
  end if
  Call Cls.Cache_Del("web_menu")
  Call Cls.Cache_Del("Web_Info")
  Call Cls.Cache_Del("bbs_class")
  call bbs_post_chk()
end sub
sub bbs_reply_main()
  Response.write bbs_post_head(0,rs("cod"))
  dim tmp1,topictruetype
  if is_topic=true then
  topictruetype = 1
  else
  topictruetype = 0
  end if
 tmp1=vbcrlf&"<form name=frm_post action='?fid="&Bbsid&"&id="&viewid&"&eid="&editid&"' method=post  onsubmit=""javascript:frm_submitonce(this);""><input type=hidden name=chk value='yes'><input type=hidden name=upid value=''><tr class=bbs_tr><td width='120'>用户信息：</td><td>&nbsp;<b>"&format_user_name(login_username,0,0)&"</b>&nbsp;&nbsp;您现在有&nbsp;<font class=red><b>"&login_emoney&" </b></font>"&Cls.Web_Unit&",&nbsp;<font class=red><b>"&login_integral&"</b></font>&nbsp;积分,&nbsp;<font class=red><b>"&login_strength&"</b></font>&nbsp;点体力,&nbsp;<font class=red><b>"&login_expression&"</b></font>点经验&nbsp;<font class=Gys>[<a href='"&Cls.Web_Dir&"user/Index.asp'>用户中心</a>]&nbsp;</font></td></tr>" & _
	  vbcrlf& bbs_GetCode() & _
      vbcrlf&"<tr class=tre><td>贴子主题：</td><td><table border=0 cellspacing=5 cellpadding=1><tr><td>"&frm_topic("frm_post","topic")&"</td><td>&nbsp;<input type=text class=txt name=topic value='"&Cls.Code_Html(ntopic,1,0)&"' size=60 maxlength=50>"&redx&"长度不能超过50</td></tr></table></td></tr>" & _
      vbcrlf& Special_InitSelect(fir_SpecialID) & _
      vbcrlf&"<tr class=bbs_tr><td>当前心情：</td><td>"&LoadIcon(rs("icon"))&"</td></tr>"
      if is_super=true and is_topic=true then
      tmp1=tmp1&vbcrlf&"<tr class=bbs_tr><td>主题特效：</td><td><input type=checkbox name=tbb value='yes' "
	  if fir_tbb then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;使用加粗功能&nbsp;&nbsp;&nbsp;使用加色功能&nbsp;"&bbs_color_fk("tcolor",fir_tcolor)&"</td></tr>"
      end if
      tmp1=tmp1&vbcrlf&"<tr class=bbs_tr><td valign=top>贴子内容：<br><br>[<a href='javascript:;'  onclick=""post_check_length('frm_post','AsaiMHWord',"&word_size_max&")"">字数检查</a>]</td><td>"&LoadUBBEditor("4_"&topictruetype,"frm_post","AsaiMHWord",ReplaceEdit(rs("word"),1),"default","100%",250)&"</td></tr><tr class=bbs_tr><td>上传文件：</td><td class=bg><iframe id=UploadFiles width='98%' height=30 frameborder=0 scrolling=no src='"&Cls.Web_Dir&"Include/upload.asp?ID="&ChannelIDs&"&Type=0&Obj=AsaiMHword'></iframe></td></tr>"
      if is_super=true then
      tmp1=tmp1&vbcrlf&"<tr class=tr><td>高级选项：</td><td><input type=checkbox name=edit_info value='yes'  checked>&nbsp;显示编辑信息&nbsp;"
      if is_topic=true then
      tmp1=tmp1&vbcrlf&"<input type=checkbox name=istop value='yes' "
      if int(fir_istop)=1 then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;固顶&nbsp;"
      if int(login_modep)=1 or int(login_modep)=2 then
      tmp1=tmp1&"<input type=checkbox name=istopz value='yes' "
      if int(fir_istop)=2 then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;区固顶&nbsp;"
      tmp1=tmp1&"<input type=checkbox name=istops value='yes' "
      if int(fir_istop)=3 then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;总固顶&nbsp;"
      end if
      tmp1=tmp1&"<input type=checkbox name=isgood value='yes' "
      if int(fir_isgood)=1 then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;精华&nbsp;<input type=checkbox name=islock value='yes' "
      if int(fir_islock)=1 then tmp1=tmp1&" checked"
      tmp1=tmp1&">&nbsp;锁定"
    end if
    tmp1=tmp1&vbcrlf&"</td></tr>"
  end if
  tmp1=tmp1&vbcrlf&bbs_post_end(topictruetype)
  Cls.LoadTemplate(4)
  Cls.ReadPage "post"
  Cls.HtmlRcod "title",tit
  Cls.HtmlRcod "BbsGrade",bbs_grade(0)
  Cls.HtmlRcod "BbsTopBar",bbs_top(0,"")
  Cls.HtmlRcod "body",tmp1
  Cls.OutPage
end sub
function ReplaceEdit(str,scod)
  Dim strer,re
  strer = str
  Set re=new RegExp
  re.IgnoreCase=True
  re.Global=True
  if scod=0 then
     re.Pattern="\[align=right\]\[color\=\#000066\]本贴已被(.|\n)*\[\/align\]"
  else
     re.Pattern="<p style=""float:right;color:#000066"">本贴已被(.|\n)*</p>"
  end if
  strer=re.Replace(strer,"")
  strer=server.HTMLEncode(strer)
  set re = nothing
 ReplaceEdit = strer
end function
%>
