<!-- #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
const num_special=5
dim etc,etb,etcb,vote_n,isvote,now_bbs_data
isvote=Cls.code_query("isvote")
ftit="发表主题"
if isvote="yes" then
  ftit="发表投票"
end if
now_bbs_data=Split(Cls.Web_BbsData,"|")(0)
call bbs_first()
call word_size_load()
call DoWebHead(2,1)
call bbs_load_power()
'----------------------------中间 开始----------------------------
call bbs_grade(0)
call bbs_top(0,"")
vote_n=bbs_config(12)
if bbs_is_readonly()=false then
  call bbs_msg("本论坛已设置为不可发贴模式！")
else
  etc=bbs_config(9)
  etb=bbs_config(10)
  if Cls.chk() then
    call bbs_write_chk()
  else
    call bbs_write_main()
  end if
end if
'----------------------------中间 结束----------------------------
call bbs_end()
call DoWebEnd()
sub bbs_write_chk()
  dim tmp1,num_plus,num_strength,num_expression,orderid,topic,icon,word,tc,tcolor,tbb,is_vote,v_type,v_day,v_name,v_num,v_dim,v_dim_num,integral_del,cb_var,found_err,nistop,nisgood,nislock,t_filetype,t_SpecialID
  num_plus=bbs_config(7)
  num_strength=bbs_config(24)
  num_expression=bbs_config(26)
  nistop=0
  nisgood=0
  nislock=0
  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
  integral_del=0
  cb_var=""
  topic=Cls.code_form("topic")
  icon=Cls.Code_Int("icon",0)
  t_SpecialID=Cls.Code_Int("SpecialID",0)
  t_filetype=""
  word=Cls.Code_Remark("AsaiMHword")
  'tc=Cls.code_form("tc")
  tcolor=Cls.code_form("tcolor")
  tbb=0
  is_vote=0
  found_err=""
  dim tmp_s_emoney,tmp_s_integral,tmp_s_strength,tmp_s_expression,tmp_s_bbs_counter,tmp_s_online,tmp_t_special_data,t_special_data,t_isspecial,t_special_num,t_special_remark
    t_special_remark=""
    t_isspecial=int(request.form("t_isspecial"))
    if t_isspecial>num_special or t_isspecial<0 then t_isspecial=0
    if t_isspecial>0 then
      tmp_s_emoney=int(request.form("s_emoney"))
      tmp_s_integral=int(request.form("s_integral"))
      tmp_s_strength=int(request.form("s_strength"))
      tmp_s_expression=int(request.form("s_expression"))
      tmp_s_bbs_counter=int(request.form("s_bbs_counter"))
      tmp_s_online=int(request.form("s_online"))
      tmp_t_special_data=request.form("t_special_data")
      t_special_remark=request.form("t_special_remark")
      if t_special_data<>"" then
        dim tmpdimdata
        tmpdimdata=split(t_special_data,",")
        t_special_data=""
        for i=0 to ubound(tmpdimdata)
          if ChkName(tmpdimdata(i)) then
            if t_special_data="" then
              t_special_data=tmpdimdata(i)
            else
              t_special_data=t_special_data&","&tmpdimdata(i)
            end if
          end if
        next
        erase tmpdimdata
      end if
      select case int(t_isspecial)
      case 1,2
        if tmp_s_emoney<=0 and tmp_s_integral<=0 and tmp_s_strength<=0 and tmp_s_expression<=0 and tmp_s_bbs_counter<=0 and tmp_s_online<=0 then
 	    found_err=found_err&"+特殊贴的 <font class=red>分值</font> 至少要有一项为有效分值！<br />"
        else
          t_special_num="0,"&tmp_s_emoney&","&tmp_s_integral&","&tmp_s_strength&","&tmp_s_expression&","&tmp_s_bbs_counter&","&tmp_s_online&",0"
        end if
      case 3
        t_special_num="0,0,0,0,0,0,0,0"
      case 4
        t_special_num="0,0,0,0,0,0,0,0"
        if tmp_t_special_data="" then
 	      found_err=found_err&"+指定用户特殊贴的 <font class=red>权限用户</font> 不能为空！<br />"
	    else
	      tmp_t_special_data=request.form("t_special_data")
	    end if
      end select
      if t_special_remark="" then
	      found_err=found_err&"+特殊贴 <font class=red>说明</font> 不能为空！<br />"
	  end if
     end if
  if Not Cls.CodeIsTrue() and int(bbs_config(16))=1 then
    found_err=found_err&"+您输入的 <font class=red>验 证 码</font> 为空或有错误，请勿非法提交！<br />"
  end if
  if Cint(login_strength)<Cint(num_strength) then
    found_err=found_err&"+您的 <font class=red>体力</font> 不够发贴了,要多多在线增加体力哦！<br />"
  end if
  if topic="" or 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 tcolor<>"" then
    if len(tcolor)<>6 then
      found_err=found_err&"+请输入正确的 <font class=red>颜色代码</font> ！（请正确填写<font class=red2>6</font>位颜色代码）<br />"
    end if
    cb_var="加色"
    integral_del=etc
  else
    tcolor=""
  end if
  if Cls.code_form("tbb")="yes" then
    tbb=1
    integral_del=integral_del+etb
    cb_var=cb_var&"加粗"
  end if
  if int(login_integral)<int(integral_del) then
    found_err=found_err&"+发布"&cb_var&"主题要扣<font class=red>"&integral_del&"</font>分，您的积分不足（只有<font class=red>"&login_integral&"</font>分）！<br />"
  end if
  if isvote="yes" then
    is_vote=1
    v_type=0
    if Cls.code_form("v_type")="more" then
      v_type=1
    end if
    v_day=Cls.code_form("v_day")
    if not isnumeric(v_day) then
      v_day=0
    end if
    if int(v_day)>365 then
      v_day=0
    end if
    v_name=Cls.code_form("v_name")
    v_name=replace(v_name,"'","")
    v_name=replace(v_name,"|","")
    if v_name="" then
      found_err=found_err&"+请输入投票的项目，不能为空或超过<font class=red>"&vote_n&"</font>项！<br />"
    else
      v_dim=split(v_name,vbcrlf)
      v_name=""
      v_num=""
      v_dim_num=0
      for i=0 to ubound(v_dim)
        if int(v_dim_num)>(vote_n-1) then exit for
        if v_dim(i)<>"" then
          if v_name="" then
            v_name=v_dim(i)
            v_num="0"
          else
            v_name=v_name&"|"&v_dim(i)
            v_num=v_num&"|0"
          end if
          v_dim_num=v_dim_num+1
        end if
      next
      if int(v_dim_num)<2 then
        found_err=found_err&"+请输入投票的项目至少不能低于两项！<br />"
      end if
    end if
  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
  t_filetype=Get_Remark_FileType(word)
  orderid=Cls.Max_ID("AsaiMHBbsTopic","order_id","bbs_id="&Bbsid)
  orderid=orderid+1
  sql="insert into AsaiMHBbsTopic (order_id,bbs_id,username,userid,topic,tcolor,tbb,icon,counter,tim,re_username,re_counter,re_tim,istop,islock,isgood,isvote,vote_num,tip_num,is_html,form_id,bbs_data,t_special_num,t_special_data,t_isspecial,t_special_remark,filetype,SpecialID) " & _
      "values ("&orderid&","&Bbsid&",'"&login_username&"',"&login_id&",'"&topic&"','"&tcolor&"',"&tbb&",'"&icon&"',0,'"&Cls.now_time&"','"&login_username&"',0,'"&Cls.now_time&"',"&nistop&","&nislock&","&nisgood&","&is_vote&",0,0,0,0,'"&now_bbs_data&"','"&t_special_num&"','"&tmp_t_special_data&"','"&t_isspecial&"','"&t_special_remark&"','"&t_filetype&"',"&t_SpecialID&")"
  call Cls.exec(sql,0)
  viewid=first_id("AsaiMHBbsTopic","id")
  if isvote="yes" then
    sql="insert into AsaiMHBbsVote (reply_id,v_name,v_num,v_type,v_tim,v_day,v_username) " & _
	"values ("&viewid&",'"&v_name&"','"&v_num&"',"&v_type&",'"&Cls.now_time&"',"&v_day&",'')"
    call Cls.exec(sql,0)
  end if
  sql="select * from "&now_bbs_data&" where id is null"
  call Cls.exe_conn(rs,sql,3)
  rs.addnew
  rs("bbs_id")=Bbsid
  rs("reply_id")=viewid
  rs("username")=login_username
  rs("userid")=login_id
  rs("topic")=topic
  rs("icon")=icon
  rs("word")=word
  rs("tim")=Cls.now_time
  rs("ip")=Cls.ip_sys(0)
  rs("sys")=Cls.ip_sys(1)
  rs("is_topic")=1
  rs("is_shield")=0
  rs("Cod")=request.Form("codeMode")
  rs.update
  rs.close
  sql="update AsaiMHUserData set bbs_counter=bbs_counter+1,strength=strength-"&num_strength&",expression=expression+"&num_expression&",integral=integral+"&num_plus&"-"&integral_del&" where id="&login_id
  call Cls.exec(sql,0)
  sql="update AsaiMHConfigs set num_new=num_new+1 where id=1"
  call Cls.exec(sql,0)
  sql="update AsaiMHBbsClass set bbs_new_num=bbs_new_num+1,bbs_topic_num=bbs_topic_num+1,bbs_data_num=bbs_data_num+1 where bbs_id in ("&bbs_data(7)&")"
  call Cls.exec(sql,0)
  sql="update AsaiMHBbsClass set bbs_new_info='"&login_username&"|"&Cls.now_time&"|"&viewid&"|"&topic&"' where bbs_id="&Bbsid
  call Cls.exec(sql,0)
  call Cls.exec("update AsaiMHChannel set ChannelCount=ChannelCount+1,ChannelHits=ChannelHits+1 Where ChannelIDs=4",0)
  'call upload_note(Index_Url,viewid)
  'call Cls.cache_set("configs_num_new",Cls.cache_get("configs_num_new")+1)
  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_write_main()
  dim tmp1
   tmp1=bbs_post_head(1,0)&vbcrlf&"<form name=frm_post action='?fid="&Bbsid&"&isvote="&isvote&"' method=post onsubmit=""javascript:frm_submitonce(this);""><input type=hidden name=chk value='yes' ><input type=hidden name=upid value=''>" & _
        vbcrlf&"<tr class=bbs_tr><td width='20%'>用户信息：</td><td width='80%'>&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=bbs_tre><td>贴子主题：</td><td><table border=0 cellspacing=0 cellpadding=0><tr><td>"&frm_topic("frm_post","topic")&"</td><td>&nbsp;<input type=text class=txt name=topic size=50 maxlength=50>"&redx&"长度不能超过50&nbsp;</td></tr></table></td></tr>" & _
        vbcrlf& Special_InitSelect("t_SpecialID") & _
        vbcrlf&"<tr class=bbs_tr><td>当前心情：</td><td>"&LoadIcon(0)&"</td></tr>" & _
        vbcrlf&"<tr class=bbs_tr><td>主题特效：</td><td><input type=checkbox name=tbb value='yes'>&nbsp;使用加粗功能后将扣取你<font class=red>"&etb&"</font>分&nbsp;&nbsp;&nbsp;使用加色功能后将扣取你<font class=red>"&etc&"</font>分&nbsp;"&bbs_color_fk("tcolor"," ")&"</td></tr>"
    if isvote="yes" then
       tmp1=tmp1&vbcrlf&"<tr  class=bbs_tre><td>投票选项：</td><td><input type=radio name=v_type value='only' s checked>&nbsp;单选&nbsp;<input type=radio name=v_type value='more' s>&nbsp;多选&nbsp;&nbsp;&nbsp;过期时间：<select name=v_day size=1><option value='0'>永不过期</option><option value='1'>一天</option><option value='7'>一周</option><option value='30'>一个月</option><option value='365'>一年</option></select></td></tr><tr class=bbs_tre><td class=htd>1、每行作为一个选项；<br />2、至少不能低于两项；<br />3、最多有 <font class=red>"&vote_n&"</font> 个选项；<br />4、超过的将自动作废；<br />5、一经发布不得修改；</td><td><textarea name=v_name rows=7 cols=90 class=textarea></textarea></td></td></tr>"
    end if
       tmp1=tmp1&vbcrlf&"<tr  class=bbs_tr><td valign=top>贴子内容：<br /><br />[<a href='javascript:;'  onclick=""post_check_length2("&word_size_max&")"">字数检查</a>]<br /><br /><br /><br /><b>特殊内容：</b><br /><li>购买贴："&Change_Special(bbs_config(19))&"<br /><li>可见贴："&Change_Special(bbs_config(20))&"<br /><li>回复贴："&Change_Special(bbs_config(21))&"<br /><li>指定贴："&Change_Special(bbs_config(22))&"</td><td>"&LoadNewEditor("frm_post","AsaiMHword","")&"</td></tr>" & _
       vbcrlf&"<script language=""Javascript"" src="""&Cls.Web_Dir&"Style/trans_ubb.js""></script>" & _
       vbcrlf&"<tr class=bbs_tr><td>轻松论坛贴图：</td>" & _
       vbcrlf&"<td class=bg><IFRAME id=""rtf"" style=""WIDTH: 0px; HEIGHT: 0px"" marginWidth=""0"" marginHeight=""0"" src=""about:blank"" scrolling=""no""></IFRAME><INPUT onclick=""editorFrame.writeEditorContents(document.getElementById('AsaiMHword').value += trans())"" type=""button"" class=""btn"" value=""转换剪切板超文本数据""></td></tr>" & _
       vbcrlf&"<script language=""Javascript"">" & _
       vbcrlf&"rtf.document.designMode=""On"";" & _
       vbcrlf&"</script>" & _
	   vbcrlf&"<tr  class=bbs_tr>" & _
       vbcrlf&"<td>上传文件：</td>" & _
       vbcrlf&"<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>" & _
       vbcrlf&"</tr>" & _
	   vbcrlf&"<tr  class=bbs_tre>" & _
	   vbcrlf&"<td class=s>特 殊 贴：</td>" & _
	   vbcrlf&"<td class=s>" & _
	   vbcrlf&"<table border=0 cellspacing=0 cellpadding=0 width='100%'>" & _
	   vbcrlf&"<tr><td>请选择特殊贴类型：<select name=t_isspecial size=1 onchange=""javascript:change_special(this.options[this.selectedIndex].value);"">" & _
	   vbcrlf&"<option value='0' selected>不使用特殊贴</option>"
  if bbs_config(19)=1 then tmp1=tmp1&vbcrlf&"<option value='1'>&nbsp;购买贴&nbsp;</option>"
  if bbs_config(20)=1 then tmp1=tmp1&vbcrlf&"<option value='2'>&nbsp;可见贴&nbsp;</option>"
  if bbs_config(21)=1 then tmp1=tmp1&vbcrlf&"<option value='3'>&nbsp;回复贴&nbsp;</option>"
  if bbs_config(22)=1 then tmp1=tmp1&vbcrlf&"<option value='4'>&nbsp;指定贴&nbsp;</option>"
	tmp1=tmp1&vbcrlf&"</select> <font class=red>发布特殊贴后将不可随意修改，请注意填写！</font></td></tr>" & _
  	   vbcrlf&"<tr style=""display:none;"" id=div_special><td>" & _
       vbcrlf&"<table border=0 cellspacing=0 cellpadding=0 width='100%'>" & _
       vbcrlf&"<tr><td height=5></td></tr>" & _
       vbcrlf&"<tr><td id=div_special2></td></tr>" & _
       vbcrlf&"</table></td></tr></table></td></tr>" & _
       vbcrlf&"<tr class=bbs_tr style=""display:none;"" id=div_special_remark><td valign=top>特殊贴说明：<br /><br />当用户没有权限阅读此帖子时显示的提示信息，此信息将替代帖子正文。反则此信息不显示。</td><td><textarea name=t_special_remark rows=6 cols=90 class=textarea></textarea></td></tr>"
  if is_super=true then
    tmp1=tmp1&vbcrlf&"<tr class=tr>" & _
       vbcrlf&"<td>高级选项：</td>" & _
       vbcrlf&"<td><input type=checkbox name=istop value='yes' >&nbsp;固顶&nbsp;"
    if int(login_modep)=1 or int(login_modep)=2 then
      tmp1=tmp1&"<input type=checkbox name=istopz value='yes' >&nbsp;区固顶&nbsp;" & _
       vbcrlf&"<input type=checkbox name=istops value='yes' >&nbsp;总固顶&nbsp;"
    end if
    tmp1=tmp1&"<input type=checkbox name=isgood value='yes' >&nbsp;精华&nbsp;<input type=checkbox name=islock value='yes' >&nbsp;锁定</td>" & _
       vbcrlf&"</tr>"
  end if
  tmp1=tmp1&vbcrlf&bbs_post_end(1)
  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 Change_Special(pi)
  If int(pi)=1 Then
    Change_Special="<font class=red>可用</font>"
  Else
    Change_Special="不可用"
  End If
End Function
%>
