<!-- #include file="../inc/conn.asp" -->
<!-- #include file="../inc/htmlencode2.asp"-->
<!--#include file="upload_5xsoft.inc"-->
<!--include file="asptohtm.asp"-->
<!--#include file="../inc/ubbcode.asp"-->
<!-- #include file="touxianfun.asp" -->
<%
call FTBBS_CS
url=Application("FTBBS_CS_1")
upfiletype=Application("FTBBS_CS_2")
upfilesize=Application("FTBBS_CS_3")
picYN=Application("FTBBS_CS_4")
'+++++++++++++++++++++++++++++++++++++++++++++
dim upload,file,formName,formPath
set upload=new upload_5xSoft ''建立上传对象
ip=request.servervariables("remote_addr")'ip地址
'表单提交信息
BoardID_1 = upload.form("BoardID_1") 'BoardID_1
BoardID_2 = upload.form("BoardID_2") 'BoardID_2
if BoardID_1="" then
	response.write "<BR><BR><BR><center>对不起，请先选择主论坛类别！</center>"
	response.end
end if
'++++++++++++++++++++++++++++++++
call FTBBS_BZ_NAME(BoardID_1)
BBS_Cate_Name1=Application("BBS_Cate_Name1")
call FTBBS_BZ_NAME2(BoardID_1,BoardID_2)
BBS_Cate_Name2=Application("BBS_Cate_Name2")
BBS_Cate_Manager_Name=Application("BBS_Cate_Manager_Name")
'++++++++++++++++++++++++++++++++
title = trim(upload.form("title")) '主题
title=htmlencode2(title)
titlecolor = trim(upload.form("titlecolor"))
zhiye = trim(upload.form("zhiye"))
menu = trim(upload.form("menu"))
ticon = trim(upload.form("ticon"))
tel=trim(upload.form("tel"))
bbs_img_text = trim(upload.form("bbs_img_text"))
img_url = trim(upload.form("img_url"))
img_url_text = trim(upload.form("img_url_text"))

if menu="" then
	response.write "<SCRIPT language=JavaScript>alert('内容不能为空！');"
   	response.write "history.go(-1);"
    response.write "</script>"        
    response.end
end if

BBS_Return_Url = upload.form("BBS_Return_Url")'发布返回地址

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
		response.write "<center>对不起，你无权发表话题！</center>"
		response.end
	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
		response.write "<SCRIPT language=JavaScript>alert('对不起，内容中不能含有"&rs_arrest("content")&"关键字！');"
   	    response.write "history.go(-1);"
   		response.write "</script>"        
        response.end		
	end if
rs_arrest.movenext
loop
rs_arrest.close
set rs_arrest=nothing
'===========================图片信息
formPath="../html/upfile"'上传目录
'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file ''列出所有上传了的文件
	set file=upload.file(formName)'图片
	filesize=file.FileSize'图片大小

	if filesize>0 then
		if filesize>clng(upfilesize) then
		   response.write "<SCRIPT language=JavaScript>alert('你上传的图片太大,系统允许上传的图片大小限制在"&upfilesize&"字节以下！');"
   	       response.write "history.go(-1);"
   		   response.write "</script>"        
           response.end
		end if
		vfname = makefilename(now())
		'随机数
		Randomize
		Random=Int((1000 - 100 + 1) * Rnd + 100)'3位随机数
		vfname=vfname&"_"&Random'图片名称

		FileExt=GetExtendName(file.FileName)'图片类型
		if InStr(upfiletype,FileExt)<=0 then
		   response.write "<SCRIPT language=JavaScript>alert('只能上传"&replace(upfiletype,"|",",")&"类型的图片！');"
   	       response.write "history.go(-1);"
   		   response.write "</script>"        
           response.end
        end if

		fname = vfname & "." & GetExtendName(file.FileName)'图片名称
		file.SaveAs Server.mappath(formPath&fname)   ''保存文件
        '如果支持水印组件就加入图片水印功能
		'If IsObjInstalled("Persits.Jpeg") Then
           'Set Jpeg = Server.CreateObject("Persits.Jpeg")
		
           'Jpeg.Open Server.mappath(formPath&fname)
           'Jpeg.Canvas.Font.Size = 25  '//水印文字的大小。
           'Jpeg.Canvas.Font.ShadowColor = &H000000 '//水印文字的阴影色彩。
		
           'Jpeg.Canvas.Font.ShadowXoffset = 1  '//水印文字阴影向右偏移的像素值，输入负值则向左偏移。
        
		   'Jpeg.Canvas.Font.ShadowYoffset = 1  '//水印文字阴影向下偏移的像素值，输入负值则向右偏移。
		
           'Jpeg.Canvas.Font.Color = &HFFFFFF 'FF0000水印文字的颜色，&H后面输入色彩值
           'Jpeg.Canvas.Font.Family = "Courier New" '水印文字的字体名称(Arial)
           'Jpeg.Canvas.Font.Bold = True
           'Jpeg.Canvas.Print 10, 10, "http://www.xmfangzi.com"

           'Jpeg.Canvas.Pen.Color = &Hffffff '000000
           'Jpeg.Canvas.Pen.Width = 0
           'Jpeg.Canvas.Brush.Solid = False
           'Jpeg.Canvas.Bar 0, 0, Jpeg.Width, Jpeg.Height '水印文字的起始坐标（像素）

           'Jpeg.Save Server.mappath(formPath&fname)
		'end if
		'水印功能结束
	end if

next
'==========================================================
if request.cookies("bz")<>1 then
 rsql="update clubuser set jingyuan=jingyuan+10,tili=tili-10 where clubuser_name='"&request.cookies("name")&"'"
 conn.execute(rsql)
end if 
 str="select * from clubuser where clubuser_name='"&request.cookies("name")&"'"
 set rs=server.createobject("adodb.recordset")
 rs.open str,conn,3,1
'加入用户资料
if not rs.eof then
   jingyuan=rs("jingyuan")
   tili=rs("tili")
   img=rs("userimg")
   clubuser_reg_date=formatdatetime(rs("clubuser_reg_date"),2)
   if rs("signname")<>"" then
   signname=rs("signname")
   else
   signname="<a href=../../bbs/moduserinfo.asp?postuser="&request.cookies("name")&"><FONT color=#568ac2>个人签名档还未设置，请点击这里进行设置</font></a>"
   end if   
   'signname=rs("signname")
   bz=rs("bbsmanager")
else
   jingyuan=0
   tili=100
   img="cache5.gif"
   signname="<a href=../../bbs/moduserinfo.asp?postuser="&request.cookies("name")&"><FONT color=#568ac2>个人签名档还未设置，请点击这里进行设置</font></a>"
   bz=0			     
end if
'++++++++++++++++++++++++++++++++++++++
touxian=touxianvalue(jingyuan)
jibie=jibievalue(jingyuan)
'++++++++++++++++++++++++++++++++++++++
menu=htmlencode2(menu) '新增
menu=dvHTMLCode(menu)

'if bz=1 then
menu=ubbcode(menu)
'end if

'+++++++++++++++++++++++++++++++++++++++++++++++
 sql="select * from bbstitle where (id is null)"
 set rsr=server.createobject("adodb.recordset")
 rsr.open sql,conn,1,3
 rsr.addnew
 rsr("name")=rs("clubuser_name")
 rsr("user_id")=rs("clubuser_nickname")
 rsr("BoardID_1")=BoardID_1
 rsr("BoardID_2")=BoardID_2
 rsr("mail")=rs("clubuser_email")
 rsr("title")=title
 rsr("zhiye")=zhiye
 rsr("menu")=menu
 rsr("tel")=tel
 rsr("ip")=ip
 rsr("dateh")=now()'发表时间
 rsr("hit")=0
 rsr("rep")=0
 rsr("redate")=now()
 if filesize>0 then
	rsr("bbs_img")=fname
	rsr("bbs_img_display")=1
	YN="Y"
 else
    rsr("bbs_img_display")=0
    YN="N"
 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("titlecolor")=titlecolor
rsr.update
rsr.close
set rsr=nothing
 
 sql="select top 1 id,dateh from bbstitle order by id desc"
 set rsr=server.createobject("adodb.recordset")
 rsr.open sql,conn,1,3
 indate=rsr("dateh")
 TitleID=rsr("id")
 inFolder=year(date())&month(date())&day(date())
 htmfilename=inFolder&"/"&TitleID&".htm"
 rsr.close
 set rsr=nothing
 
strsql="update bbstitle set htmfilename='"&htmfilename&"' where id="&TitleID&""
conn.execute(strsql)
'========================更新统计信息
'一级类别
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

   myFolder = "../html/" & inFolder
   myFolder = Server.MapPath(myFolder)

   Set fileStreamObj = CreateObject("Scripting.FileSystemObject")
   If fileStreamObj.FolderExists(myFolder) = False Then
    fileStreamObj.CreateFolder (myFolder)
   End If
'+++++++++++++++++++++++++++++
 page=1
 call FTBBS_HTML_MB
     postmb=replace(replace(Application("FTBBSMB")(1,0),"$PostID$",TitleID),"$pagenav$",page)
	 postmb=replace(postmb,"$page$",1)
	 postmb=replace(postmb,"$TitleID$",TitleID)
	 postmb=replace(postmb,"$title$",title)
	 postmb=replace(postmb,"$BoardID_1$",BoardID_1)
	 postmb=replace(postmb,"$BoardID_2$",BoardID_2)
	 postmb=replace(postmb,"$BBS_Cate_Name1$",BBS_Cate_Name1)
	 postmb=replace(postmb,"$BBS_Cate_Name2$",BBS_Cate_Name2)
	 postmb=replace(postmb,"$BBS_Cate_Manager_Name$",BBS_Cate_Manager_Name)
	 postmb=replace(postmb,"$user_id$",request.cookies("bbsuser"))
	 postmb=replace(postmb,"$touxian$",touxian)
	 postmb=replace(postmb,"$jibie$",jibie)
	 postmb=replace(postmb,"$tili$",tili)
	 postmb=replace(postmb,"$jingyuan$",jingyuan)
	 postmb=replace(postmb,"$clubuser_reg_date$",clubuser_reg_date)
	 postmb=replace(postmb,"$name$",request.cookies("name"))
	 postmb=replace(postmb,"$menu$",menu)
	 postmb=replace(postmb,"$htmfilename$",htmfilename)
	 postmb=replace(postmb,"$url$",url)
	 postmb=replace(postmb,"$zhiye$",zhiye)
	 postmb=replace(postmb,"$signname$",signname)
	 postmb=replace(postmb,"$img$",img)
	 postmb=replace(postmb,"$date$",indate)
	 postmb=replace(postmb,"$YN$",YN)
	 postmb=replace(postmb,"$img_url$","")
	 if pollYN="Y" then
	 postmb=replace(postmb,"$YNPOLL$","Y")
	 else
	 postmb=replace(postmb,"$YNPOLL$","N")
	 end if

	 repostformmb=replace(replace(Application("FTBBSMB")(3,0),"$PostID$",TitleID),"$pagenav$",page)
	 repostformmb=replace(repostformmb,"$TitleID$",TitleID)
	 repostformmb=replace(repostformmb,"$title$",title)
	 repostformmb=replace(repostformmb,"$upfiletype$",upfiletype)
	 repostformmb=replace(repostformmb,"$BoardID_1$",BoardID_1)
	 repostformmb=replace(repostformmb,"$BoardID_2$",BoardID_2)
	 repostformmb=replace(repostformmb,"$name$",request.cookies("name"))
	 repostformmb=replace(repostformmb,"$htmfilename$",htmfilename)

	 HtmlNLA=postmb&repostformmb
	 htmfilename="../html/"&inFolder&"/"&TitleID&".htm"
	 myFile = Server.MapPath(htmfilename)

     Const ForReading = 1
     Const Forwriting = 2
     Const ForAppending = 8
     fileStreamObj.CreateTextFile(myFile)
     set textStream = fileStreamObj.OpenTextFile(myFile,ForWriting,False)
     textStream.Write(HtmlNLA)
     textStream.Close()
'++++++++++++++++++++++++++++
'关闭记录集与数据库
rs.close
set rs=nothing
conn.close
'response.redirect "../html/"&htmfilename
response.redirect "../bbs/main.asp"
%>