<!-- #include file="conn.asp" -->
<!-- #include file="bbsuser.asp" -->
<!-- #include file="inc/htmlencode2.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!-- #include file="touxianfun.asp" -->
<%
call FTBBS_HTML_MB
url=Application("FTBBSMB")(10,0)
upfiletype=Application("FTBBSMB")(12,0)
upfilesize=Application("FTBBSMB")(13,0)
getcodeoff=Application("FTBBSMB")(30,0)
ip=request.servervariables("remote_addr")
fd = request.form("fd")
BoardID_1 = request.form("BoardID_1")
BoardID_2 = request.form("BoardID_2")
returnurl="main.asp?layer_1="&BoardID_1&"&layer_2="&BoardID_2
refbhturl="fbht.asp?layer_1="&BoardID_1&"&layer_2="&BoardID_2
if request.cookies("payuser")=3 then
   call ftbbs_msg("你的用户名被管理员封锁,请联系管理员！",returnurl)
end if
if session(FTBBS&"LastPostTime")="" then
   session(FTBBS&"LastPostTime")=now()
else
   if datediff("s",session(FTBBS&"LastPostTime"),now())<=Application("FTBBSMB")(18,0) then
	  call ftbbs_msg("连续发帖间隔时间不能少于"&Application("FTBBSMB")(18,0)&"秒!",refbhturl)
   else
      session(FTBBS&"LastPostTime")=now()
   end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++
If getcodeoff=1 Then
   codestr = Trim(request.form("codestr"))
   codename = Trim(request.form("codename"))
   If CStr(Session("GetCode"&codename)) <> CStr(codestr) Then
   call ftbbs_msg("验证码错误，请重新输入！",refbhturl)
  end if
End If
'++++++++++++++++++++++++++++++++
call FTBBS_BZ_NAME(BoardID_1)
BBS_Cate_Name1=Application("BBS_Cate_Name1")
BBS_Cate_QS1=Application("BBS_Cate_QS1")
call FTBBS_BZ_NAME2(BoardID_1,BoardID_2)
BBS_Cate_Name2=Application("BBS_Cate_Name2")
BBS_Cate_Manager_Name=Application("BBS_Cate_Manager_Name")
BBS_Cate_QS2=Application("BBS_Cate_QS2")
'++++++++++++++++++++++++++++++++
title = trim(request.form("title")) '主题
title=htmlencode2(title)
title=Checkstr(title)
titlecolor = trim(request.form("titlecolor"))
zhiye = trim(request.form("zhiye"))
menu = Checkstr(trim(request.form("menu")))
ticon = trim(request.form("ticon"))
tel=trim(request.form("tel"))
bbs_img_text = trim(request.form("bbs_img_text"))
img_url = trim(request.form("img_url"))
img_url_text = trim(request.form("img_url_text"))
bbs_img = request.form("bbs_img")
bbs_img_display = request.form("bbs_img_display")

FileName = session("filename") 'trim(request.form("FileName"))
ftbbsuser=request.cookies("name")
if len(title)<=0 then
    call ftbbs_msg("标题不能为空!",refbhturl)
end if
if len(menu)<=0 then
    call ftbbs_msg("内容不能为空!",refbhturl)
end if

if request.cookies("bbsuser")="" then
	response.redirect "fbht.asp?layer_1="&BoardID_1&"&BoardID_2="&BoardID_2
end if
'阻止ip
Sql_arrest="select * from BBS_arrest where kind='IP' order by id asc"
set rs_arrest=server.createobject("adodb.recordset")
rs_arrest.open sql_arrest,conn,1,1
do while not rs_arrest.eof
	if rs_arrest("content")=ip then
	   call ftbbs_msg("对不起，你无权发表话题!",returnurl) 
	end if
rs_arrest.movenext
loop
rs_arrest.close
'阻止关键字
Sql_arrest="select * from BBS_arrest where kind='Keyword' order by id asc"
rs_arrest.open sql_arrest,conn,1,1
do while not rs_arrest.eof
	if (instr(menu,rs_arrest("content"))<>0 or instr(title,rs_arrest("content"))<>0) then
		title=replace(title,rs_arrest("content"),"*****")
		menu=replace(menu,rs_arrest("content"),"*****")		
	end if
rs_arrest.movenext
loop
rs_arrest.close
set rs_arrest=nothing

'if request.cookies("bz")<>1 then
 rsql="update clubuser set jingyuan=jingyuan+10,tili=tili-10,postnum=postnum+1 where tili>0 and clubuser_name='"&ftbbsuser&"'"
 conn.execute(rsql)
'end if 

menu=htmlencode2(menu) '新增
menu=ftHTMLCode(menu)

menu=RegExReplace(menu,"\b(script)\b"," $1 ")
menu=RegExReplace(menu,"\b(iframe)\b"," $1 ")
menu=ubbcode(menu)
'+++++++++++++++++++++++++++++++++++++++++++++++
 if Application("FTBBSMB")(7,0)="M" then
 inFolder=year(date())&month(date())
 else
 inFolder=year(date())&month(date())&day(date())
 end if
 indate=now()
 htmfilename=inFolder&"/"&FileName
 sql="select * from bbstitle where (id is null)"
 set rsr=server.createobject("adodb.recordset")
 rsr.open sql,conn,1,3
 rsr.addnew
 rsr("name")=ftbbsuser
 rsr("user_id")=ftbbsuser
 rsr("BoardID_1")=BoardID_1
 rsr("BoardID_2")=BoardID_2
 rsr("title")=title
 rsr("zhiye")=zhiye
 rsr("menu")=menu
 rsr("tel")=tel
 rsr("ip")=ip
 rsr("dateh")=indate
 rsr("hit")=0
 rsr("rep")=0
 rsr("redate")=indate
 if bbs_img_display<>"" then
 rsr("bbs_img")=bbs_img
 rsr("bbs_img_display")=bbs_img_display
 end if
 rsr("bbs_img_text")=bbs_img_text
 rsr("img_url")=img_url
 rsr("img_url_text")=img_url_text
 rsr("img_url_display")=0
 rsr("picture")=ticon
 rsr("htmfilename")=htmfilename
 rsr("titlecolor")=titlecolor
 if fd="Y" then
 rsr("flag")=2
 end if
rsr.update
rsr.close
set rsr=nothing

'========================更新统计信息
'一级类别
strsql="update BBS_Cate set BBS_Cate_Topic=BBS_Cate_Topic+1 where BBS_Cate_ID='"&BoardID_1&"'"
conn.execute(strsql)

if BoardID_2<>"" then'二级类别
	strsql="update BBS_Cate set BBS_Cate_Topic=BBS_Cate_Topic+1 where BBS_Cate_ID='"&BoardID_2&"'"
	conn.execute(strsql)
end if

'内容写入个人博客中
if request.Form("addblog")="Y" then
   userip=request.servervariables("remote_addr")
   sql="select * from ftblog_type where blogtype='默认分类' and userid="&request.cookies("clubuser_id")&" and blogphoto=0 order by id desc"
   set rs=server.createobject("adodb.recordset")
   rs.open sql,conn,1,3
   if rs.eof then
   rs.addnew
   rs("userid")=request.cookies("clubuser_id")
   rs("blogtype")="默认分类"
   rs("blogphoto")=0
   rs("qs")=0
   rs("userip")=userip
   rs.update
   rs.close
   set rs=nothing
   end if
   rs=conn.execute("select top 1 id from ftblog_type where userid="&request.cookies("clubuser_id")&" and blogtype='默认分类' order by id desc")
   blogtypeid=rs("id")
   str="insert into ftblog(blogtitle,blogcontent,blogtypeid,blogqs,writedate,xinqin,userip,userid,plqs) values('"&title&"','"&menu&"','"&blogtypeid&"',0,'"&indate&"','一般','"&userip&"',"&request.cookies("clubuser_id")&",0)"
   conn.execute(str)
   str="update ftblog_type set totalnum=totalnum+1 where id="&blogtypeid&" and userid="&request.cookies("clubuser_id")&""
   conn.execute(str)
end if
closedb
if returnurl<>"" then
response.redirect returnurl
else
response.redirect "main.asp"
end if
%>