<!-- #include file="bbsuser.asp" -->
<!-- #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")
'+++++++++++++++++++++++++++++++++++
 set upload=new upload_5xSoft '建立上传对象
 
 FileName = upload.form("FileName")
 pid = upload.form("id")
 postuser = upload.form("postuser")
 reid = upload.form("reid")
 BoardID_1 = upload.form("BoardID_1")
 BoardID_2 = upload.form("BoardID_2")
 title = upload.form("title")
 title = htmlencode2(title)
 titlecolor=upload.form("titlecolor")
 zhiye = upload.form("zhiye")
 ticon = upload.form("ticon")
 menu = upload.form("menu")
 bbs_img_text = trim(upload.form("bbs_img_text"))
 page = upload.form("page")
 ps = upload.form("ps")
 pollYN = upload.form("pollYN")
 'pic = upload.form("pic")改成自动从库中读取
 
 if menu="" then
	response.write "<SCRIPT language=JavaScript>alert('回复内容中不能为空！');"
   	response.write "history.go(-1);"
   	response.write "</script>"        
    response.end 
 end if

set rs_arrest=server.createobject("adodb.recordset")  
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

formPath="../html/upfile"'上传目录
sql="select top 1 BBS_Cate.BBS_Cate_Manager_Name from BBS_Cate,bbstitle where BBS_Cate.BBS_Cate_ID = bbstitle.BoardID_2 and bbstitle.id="&pid
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
myname=rs("BBS_Cate_Manager_Name")
admintobz=0
if InStr(myname,"|")>0 then
   myname=split(myname,"|",-1,1)
   for i=0 to UBound(myname)
     if InStr(myname(i),request.cookies("name"))>0 then
	    admintobz=1
	 end if
   next
end if

if FileName<>"" and (request.cookies("bz")=1 or postuser=request.cookies("name") or admintobz=1) then
  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)   ''保存文件
	 end if
   next

menu=htmlencode2(menu) '新增
menu=dvHTMLCode(menu)
menu=ubbcode(menu)

   if reid="" then
   sql="select * from bbstitle where id="&pid
   else
   sql="select * from bbsmenu where id="&reid
   end if

   set rsr=server.createobject("adodb.recordset")
   rsr.open sql,conn,1,3
   if reid="" then
      if postuser<>request.cookies("name") then
	  'if postuser=request.cookies("name") then
      rsr("BoardID_1")=BoardID_1
      rsr("BoardID_2")=BoardID_2
	  end if
      rsr("title")=title	  
      rsr("menu")=menu
      rsr("picture")=ticon
	  rsr("zhiye")=zhiye
	  rsr("titlecolor")=titlecolor
   else 
      rsr("remenu")=menu
   end if
   
   if filesize>0 then
	  rsr("bbs_img")=fname
      rsr("bbs_img_text")=bbs_img_text
	  YN="Y"
      if pickind(4)="N" then
      rsr("bbs_img_display")=1
      else
      rsr("bbs_img_display")=0
      end if
   end if
	  '以下是贴子是否修改过的标识与内容
	  rsr("img_url")="[此贴子已经被"&request.cookies("bbsuser")&"于"&now()&"编辑过]"
	  rsr("img_url_display") = 1
   
  rsr.update
  rsr.close
  set rsr=nothing

sql0="select * from bbstitle where id="&pid
set rs0=server.createobject("adodb.recordset")
rs0.open sql0,conn,1,1

  htmfilename=rs0("htmfilename")
  indate=rs0("dateh")
  postnum=rs0("rep")
  bbstitlemenu=rs0("menu")
  img_url=rs0("img_url")
  postuser=rs0("name")
  
  if reid<>"" then
     BoardID_1 = rs0("BoardID_1")
     BoardID_2 = rs0("BoardID_2")
	 title = rs0("title")
  end if
  if BoardID_1="" or BoardID_2="" then
     BoardID_1 = rs0("BoardID_1")
     BoardID_2 = rs0("BoardID_2")
  end if 
  
  if rs0("bbs_img")<>"" and rs0("bbs_img_display")=1 then
     YN="Y"
  else
     YN="N"
  end if
rs0.close  
  
  if reid="" and postuser<>request.cookies("name") then
  sqlstr="update bbsmenu set BoardID_1='"&BoardID_1&"',BoardID_2='"&BoardID_2&"' where pid="&pid
  conn.execute sqlstr
  end if

'+++++++++++++++++++++++++++++++++
if BoardID_1<>"" and BoardID_2<>"" then
   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")
end if
'+++++++++++++++新版新加取出主题贴用户资料
 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
   user_id=rs("clubuser_nickname")
   img=rs("userimg")
   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)
'以下是取出模板信息
 TitleID=pid
 retitle=title
 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)
'从上页获取page的参数值
if page="1" then
   xfilename=htmfilename
else
   xfilename=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,"$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$",bbstitlemenu)
	 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)
	 '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
pagenum=Application("FTBBSMB")(6,0)
If not(cus1.bof and cus1.eof) then
   '新加分页代码
   cus1.pagesize=pagenum
   if (page-cus1.PageCount) > 0 then
      page=cus1.pagecount
   elseif page = "" or page < 1 then
     page = 1
   end if
   '新加结束
   cus1.AbsolutePage=page
   '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   j=cus1.recordcount
   j=j-(page-1)*pagenum
   '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   i=0
 do while not cus1.eof and i<pagenum
 '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,"$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,"$postnummb$",i+1)
	 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
   j=j-1
loop
 'Wend
end if

cus1.close
conn.close
set conn=nothing

	 ALLHtmlNL=postmb&HtmlNLB&repostformmb
	 myFile = Server.MapPath("../html/"&xfilename)
     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()
'----------------------------------------
end if
response.redirect "../html/"&xfilename	
%>