<!-- #include file="bbsuser.asp" -->
<!-- #include file="../inc/conn.asp" -->
<!-- #include file="../inc/htmlencode2.asp"-->
<!--#include file="upload_5xsoft.inc"-->
<!-- #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")

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(upload.form("remenu"),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
'============================
 pid=upload.form("id")'主题id
 remenu=trim(upload.form("remenu"))
 if remenu="" then
		response.write "<center><BR><BR><h3>请输入回复内容！</h3></center>"
		response.end
 end if
 'remenu=htmlencode2(upload.form("remenu"))'回复内容
 remenu=upload.form("remenu")
'++++++++++++++++引用+++++++++++++++++++
if InStr(remenu,"[quote]")>0 then
'if InStr(remenu,"[quote]")>0 and request.cookies("bz")<>1 then
	wz = InStr(remenu,"[/quote]") - (InStr(remenu,"[quote]")+7)		'id位数
	plkey = Mid(remenu,InStr(remenu,"[quote]")+7,wz)				'求出引用ID关键字	
	keyLY2=Mid(remenu,InStr(remenu,"[quote]"),7+8+InStr(remenu,"[/quote]") - (InStr(remenu,"[quote]")+7))		'求出欲替换的字符串				  	
	set rs1=server.createobject("adodb.recordset")
	rs1.open "select top 1 * from bbsmenu where id="& plkey,conn,1,1
	keyxx="<font color=#568AC2>回复: "& rs1("user_id")&"</font>" '" ["& left(rs1("ip"),InStrRev(rs1("ip"),".")) &"*" &"] :</font>"
	keyLY="<table width=99% border=0 align=center cellpadding=4 cellspacing=1 bgcolor=#999999><tr><td bgcolor=#ffffee>"& keyxx &"<br>"& rs1("remenu") &"</td></tr></table>"  '取出欲引用内容即替换后内容
	rs1.close
	set rs1=nothing
	remenu=Replace(remenu,keyLY2,keyLY)
end if
'+++++++++++++++++++++++++++++++++++++++ 
 bbs_img_text = trim(upload.form("bbs_img_text"))'图片1文字说明
 img_url = trim(upload.form("img_url"))'图片连接地址
 img_url_text = trim(upload.form("img_url_text"))'图片2文字说明
 pollYN = upload.form("poll")
 
 if request.cookies("name")="" then
	rename=bbsuser
 else
	rename=request.cookies("name")
 end if
 '邮件
 if session("bbs_email")="" then
	remail=trim(upload.form("remail"))
 else
	remail=session("bbs_email")
 end if

'===========================图片信息
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 = 18  '//水印文字的大小。
           '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
remenu = htmlencode2(remenu)
remenu = dvhtmlcode(remenu)
remenu = ubbcode(remenu)
'==========================================================
sqk="select * from bbstitle where id="&pid&""
set rers=server.createobject("adodb.recordset")
rers.open sqk,conn,3,1
htmfilename=rers("htmfilename")
P_display=rers("P_display")
TitleID=rers("id")
retitle=rers("title")'取出主题贴主题
postuser=rers("name")'新加
user_id=rers("user_id")
rep=rers("rep")
postnum=rers("postnum")

BoardID_1=rers("BoardID_1")
BoardID_2=rers("BoardID_2")
menu=rers("menu")

indate=rers("dateh")
zhiye=rers("zhiye")
if rers("bbs_img")<>"" and rers("bbs_img_display")=1 then
YN="Y"
else
YN="N"
end if
if rers("img_url_display")=1 then
   img_url=rers("img_url")
else
   img_url=""
end if

rers.close
set rers=nothing
if P_display="0" then
   response.write "<script language='javascript'>"
   response.write "alert('该主题贴被禁止回贴！');"
   response.write "history.go(-1);"
   response.write "</script>"
   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")
'+++++++++++++++新版新加取出主题贴用户资料
 str="select * from clubuser where clubuser_name='"&postuser&"'"
 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
rs.close
set rs=nothing
 '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
touxian=touxianvalue(jingyuan)
jibie=jibievalue(jingyuan)
 call FTBBS_HTML_MB
 if pollYN="Y" then
 postmb=Application("FTBBSMB")(4,0)
 else
 postmb=Application("FTBBSMB")(1,0)
 end if
 repostmb=Application("FTBBSMB")(2,0)
 repostformmb=Application("FTBBSMB")(3,0)				  
'+++++++++++++++++++++
'加入跟贴
 set bbs=server.createobject("adodb.recordset")
 sql="select * from bbsmenu where (id is null)"
 bbs.open sql,conn,1,3
 bbs.addnew
 bbs("pid")=pid
 bbs("BoardID_1")=BoardID_1
 bbs("BoardID_2")=BoardID_2
 bbs("user_id")=request.cookies("bbsuser") '昵称
 bbs("rename")=rename'用户名
 bbs("remail")=remail'邮件
 'if request.cookies("bz")=1 then
 'bbs("remenu")=ubbcode(remenu) 'remenu
 'else
 bbs("remenu")=remenu
 'end if 
 bbs("retel")=retel
 bbs("reip")=ip
 reindate=now()
 bbs("dateh")=reindate
 bbs("kind")=0
 bbs("usertype")=usertype'用户类型 0:注册用户 1:过客

 if filesize>0 then
	bbs("bbs_img")=fname
	bbs("bbs_img_display")=1
	h="25"
 else
    bbs("bbs_img_display")=0
    h="122"
 end if
 bbs("bbs_img_text")=bbs_img_text
 bbs("img_url")=img_url
 bbs("img_url_text")=img_url_text
 'bbs("bbs_img_display")=0'上传图片显示标志，不显示
 bbs("img_url_display")=0
 bbs("deleted")=0
 bbs.update
 datetime=bbs("dateh") 
 bbs.update
 bbs.close
 set bbs=nothing
 'rst="select * from bbsmenu order by id desc"
 'set rt=conn.execute(rst)
 'reid=rt("id")
 'rt.close
'=============================主题回复+1,redate=getdate()
  strsql="update bbstitle set rep=rep+1,postnum=postnum+1,redate='"&reindate&"' where id="+pid
  conn.execute(strsql)
'=============================更新统计信息
'一级类别
strsql="update BBS_Cate set BBS_Cate_Reply=BBS_Cate_Reply+1 where BBS_Cate_ID='"&BoardID_1&"'"
conn.execute(strsql)

if BoardID_2<>"" then'二级类别
	strsql="update BBS_Cate set BBS_Cate_Reply=BBS_Cate_Reply+1 where BBS_Cate_ID='"&BoardID_2&"'"
	conn.execute(strsql)
end if
'++++++++++++++++++++++++++++++++++++++++
'加入用户资料
'if request.cookies("bz")<>1 then '版主不扣
rsql="update clubuser set jingyuan=jingyuan+5,tili=tili-10 where clubuser_name='"&request.cookies("name")&"'"
conn.execute(rsql)
'end if
'++++++++++++++++++++++++++++++++++++++++
pagenum=Application("FTBBSMB")(6,0) '20 '每页显示20条
'k=cus1("k")/pagenum
k=(rep+1)/pagenum

dim page

if int(k)=k and int(k)<>0 then
   page=k
else
   page=int(k)+1
end if

if page=1 then
tourl="../html/"&htmfilename
else
tourl="../html/"&replace(htmfilename,".htm","")&"_"&page&".htm"
end if
'++++++++++++++++++取出主题贴与回复表单的内容++++++++++++++++++++++++++++
     postmb=replace(replace(postmb,"$PostID$",TitleID),"$pagenav$",page)
	 postmb=replace(postmb,"$page$",page)
	 postmb=replace(postmb,"$TitleID$",TitleID)
	 postmb=replace(postmb,"$title$",retitle)
	 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$",user_id)
	 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$",postuser)
	 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$",img_url)
	 if pollYN="Y" then
	 postmb=replace(postmb,"$YNPOLL$","Y")
	 else
	 postmb=replace(postmb,"$YNPOLL$","N")
	 end if
	 'repostmb=rsr("repostmb")
	 repostformmb=replace(replace(repostformmb,"$PostID$",TitleID),"$pagenav$",page)
	 repostformmb=replace(repostformmb,"$TitleID$",TitleID)
	 repostformmb=replace(repostformmb,"$title$",retitle)
	 repostformmb=replace(repostformmb,"$upfiletype$",upfiletype)
	 repostformmb=replace(repostformmb,"$BoardID_1$",BoardID_1)
	 repostformmb=replace(repostformmb,"$BoardID_2$",BoardID_2)
	 repostformmb=replace(repostformmb,"$name$",postuser)
	 repostformmb=replace(repostformmb,"$htmfilename$",htmfilename)
	 if pollYN="Y" then
	 repostformmb=replace(repostformmb,"$pollY$","Y")
	 else
	 repostformmb=replace(repostformmb,"$pollY$","N")
	 end if

'新版加入生成静态页功能,循环取出回贴内容
strsql="select * from bbsmenu where pid="&pid&" and deleted=0 order by id asc"
set cus1=server.createobject("adodb.recordset")
cus1.open strsql,conn,3,1
If not(cus1.bof and cus1.eof) then
   cus1.pagesize=pagenum
   dbPageNum=cus1.PageCount
   If page>dbPageNum Then page=dbPageNum End If
   if page=0 then page=1 end if  '取得页号    
   cus1.AbsolutePage=page
   i=1

 While not cus1.eof and i<=pagenum
'++++++++++++++++++取出回复贴子的用户信息++++++++++++++++++++++
 str="select * from clubuser where clubuser_name='"&cus1("rename")&"'"
 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
rs.close
set rs=nothing

     reid=cus1("id")
     reuser=cus1("user_id")
	 reuser_id=cus1("rename")
     rebbs_img=cus1("bbs_img")
     remenu=cus1("remenu")
	 datetime=cus1("dateh")
	 postnum=postnum+1
     if cus1("bbs_img")<>"" and cus1("bbs_img_display")=1 then
        REYN="Y"
     else
        REYN="N"
     end if
     if cus1("img_url_display")=1 then
        reimg_url=cus1("img_url")
	 else
	    reimg_url=""
     end if
	 	 
     touxian=touxianvalue(jingyuan)
     jibie=jibievalue(jingyuan)
	 	 
	 remb=replace(repostmb,"$title$",retitle)
	 remb=replace(remb,"$img$",img)
	 remb=replace(remb,"$reuser$",reuser)
	 remb=replace(remb,"$touxian$",touxian)
	 remb=replace(remb,"$jibie$",jibie)
	 remb=replace(remb,"$tili$",tili)
	 remb=replace(remb,"$jingyuan$",jingyuan)
	 remb=replace(remb,"$reg_date$",clubuser_reg_date)
	 remb=replace(remb,"$TitleID$",TitleID)
	 remb=replace(remb,"$Titleid$",TitleID)
	 remb=replace(remb,"$htmfilename$",htmfilename)
	 remb=replace(remb,"$reuser_id$",reuser_id)
	 remb=replace(remb,"$remenu$",remenu)
	 remb=replace(remb,"$signname$",signname)
	 remb=replace(remb,"$reid$",reid)
	 remb=replace(remb,"$YN$",REYN)
	 remb=replace(remb,"$postnummb$",postnum)
	 remb=replace(remb,"$page$",page)
	 remb=replace(remb,"$name$",reuser_id)
	 remb=replace(remb,"$datetime$",datetime)
	 remb=replace(remb,"$img_url$",reimg_url)
	 if pollYN="Y" then
	 remb=replace(remb,"$YNPOLL$","Y")
	 else
	 remb=replace(remb,"$YNPOLL$","N")
	 end if
     i=i+1
     cus1.movenext
	 HtmlNLB=HtmlNLB+remb
 Wend
end if

cus1.close
conn.close
set conn=nothing

	 ALLHtmlNL=postmb&HtmlNLB&repostformmb
	 'response.write remb'HtmlNLB'ALLHtmNL
	 'response.end
	 myFile = Server.MapPath(tourl)
     Const ForReading = 1
     Const Forwriting = 2
     Const ForAppending = 8
	 Set fileStreamObj = CreateObject("Scripting.FileSystemObject")
     fileStreamObj.CreateTextFile(myFile)
     set textStream = fileStreamObj.OpenTextFile(myFile,ForWriting,False)
     textStream.Write(ALLHtmlNL)
     textStream.Close()
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
response.redirect tourl
%>

