<!--#include file="../conn.asp" -->
<!-- #include file="check_master.asp" -->
<!-- #include file="../inc/ubbcode.asp"-->
<!-- #include file="../touxianfun.asp" -->
<%
int page
Const ForReading = 1
Const Forwriting = 2
Const ForAppending = 8

call FTBBS_HTML_MB
url=Application("FTBBSMB")(10,0)
upfiletype=Application("FTBBSMB")(12,0)
upfilesize=Application("FTBBSMB")(13,0)
htm_ext=Application("FTBBSMB")(32,0)
'+++++++++++++++++++++++++++++++++++++
'pollYN=request("poll")
fname=replace(trim(request("fname")),htm_ext,"")
if instr(fname,"_")<>0 then
myarray=split(fname,"_",-1,1)
pid=myarray(0)
page=myarray(1)
else
pid=fname
page=1
end if

xfn=pid&htm_ext
sqk="select * from bbstitle where htmfilename like '%"&xfn&"%'"
set rers=server.createobject("adodb.recordset")
rers.open sqk,conn,3,1
if rers.eof then
   rers.close
   response.write "<SCRIPT language=JavaScript>alert('你输入的文件名不存在或文件名错误！');"
   response.write "history.go(-1);"
   response.write "</script>"        
   response.end
end if
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")
fd=rers("flag") '活动贴标识
if fd=1 then pollYN="Y"
bbs_img=rers("bbs_img")
bbs_img_text=rers("bbs_img_text")

if rers("img_url_display")=1 then
   img_url=rers("img_url")
else
   img_url=""
end if
rers.close
set rers=nothing
'第一次没有生成页面时将重新更新生成
if htmfilename="" or isnull(htmfilename) then
   if Application("FTBBSMB")(7,0)="M" then
   htmfilename=year(indate)&month(indate)&"/"&TitleID&htm_ext
   else
   htmfilename=year(indate)&month(indate)&day(indate)&"/"&TitleID&htm_ext
   end if
   sqlstr="update bbstitle set htmfilename='"&htmfilename&"' where id="&TitleID
   conn.execute sqlstr
end if

'当静态页存放的文件夹不存时就创建文件夹
htmarray=split(htmfilename,"/")
myFolder = "../"&htmarray(0)
myFolder = Server.MapPath(myFolder)
Set fileStreamObj = CreateObject("Scripting.FileSystemObject")
If fileStreamObj.FolderExists(myFolder) = False Then
   fileStreamObj.CreateFolder (myFolder)
End If

filename = split(htmfilename,"/")(1)  
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
   clubuser_id=rs("clubuser_id")
   jingyuan=rs("jingyuan")
   tili=rs("tili")
   img=rs("userimg")
   clubuser_reg_date=formatdatetime(rs("clubuser_reg_date"),2)
   if rs("signname")<>"" then
   signname=ftbbsubbcode(rs("signname"))
   else
   signname="<a href=../moduserinfo.asp?postuser="&postuser&"><FONT color=#568ac2>个人签名档还未设置，请点击这里进行设置</font></a>"
   end if
   bz=rs("bbsmanager")
else
   jingyuan=0
   tili=100
   img="cache5.gif"
   signname="<a href=../moduserinfo.asp?postuser="&postuser&"><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 page=1 then
        tourl="../"&htmfilename
     else
        tourl=replace("../"&htmfilename,htm_ext,"")&"_"&page&htm_ext
     end if
	 if fd=1 then
        postmb=Application("FTBBSMB")(4,0)
     else
        postmb=Application("FTBBSMB")(1,0)
     end if
     if pollYN="Y" then
        postmb=Application("FTBBSMB")(4,0)
     else
        postmb=Application("FTBBSMB")(1,0)
     end if	
 	 if Application("FTBBSMB")(8,0)=1 then
	 home="default_list.asp"
	 mainbbscate="main.asp"
	 bbsfbht="fbht.asp"
	 bbspoll="bbspoll.asp"
	 end if	  
     '++++++++++++++++++取出主题贴与回复表单的内容++++++++++++++++++++++++++++
     postmb=replace(replace(postmb,"$PostID$",TitleID),"$pagenav$",page)
	 postmb=replace(postmb,"$page$",page)
	 
     postmb=replace(postmb,"$home$",home)
	 postmb=replace(postmb,"$main$",mainbbscate)
	 postmb=replace(postmb,"$fbht$",bbsfbht)
	 postmb=replace(postmb,"$bbspoll$",bbspoll)
	 
	 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,"$userid$",clubuser_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)
	 if fd=2 then
	 postmb=replace(postmb,"$upfile$","<SCRIPT src=../bmform.asp?titleid="&TitleID&"></SCRIPT>")
	 else
	 postmb=replace(postmb,"$upfile$","")
	 end if
	 postmb=replace(postmb,"$img_url$",img_url)
	 postmb=replace(postmb,"$upfile$","")
	 
	 if pollYN="Y" then
	 postmb=replace(postmb,"$YNPOLL$","Y")
	 else
	 postmb=replace(postmb,"$YNPOLL$","N")
	 end if
	 
     repostformmb=Application("FTBBSMB")(3,0)
	 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)
	 repostformmb=replace(repostformmb,"$filename$",filename)
	 
	 if pollYN="Y" then
	 repostformmb=replace(repostformmb,"$pollY$","Y")
	 else
	 repostformmb=replace(repostformmb,"$pollY$","N")
	 end if

'新版加入生成静态页功能,循环取出回贴内容
     if rep>0 then
        strsql="select * from bbsmenu where pid="&TitleID&" 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
          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
		    clubuser_id=rs("clubuser_id")
            jingyuan=rs("jingyuan")
            tili=rs("tili")
            img=rs("userimg")
            clubuser_reg_date=formatdatetime(rs("clubuser_reg_date"),2)
            if rs("signname")<>"" then
            signname=ftbbsubbcode(rs("signname"))
            else
            signname="<a href=../moduserinfo.asp?postuser="&cus1("rename")&"><FONT color=#568ac2>个人签名档还未设置，请点击这里进行设置</font></a>"
            end if
            bz=rs("bbsmanager")
          else
            jingyuan=0
            tili=100
            img="cache5.gif"
            signname="<a href=../moduserinfo.asp?postuser="&cus1("rename")&"><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
		  bbs_img_text=cus1("bbs_img_text")

          if cus1("img_url_display")=1 then
             reimg_url=cus1("img_url")
	      else
	         reimg_url=""
          end if
	 	 
          touxian=touxianvalue(jingyuan)
          jibie=jibievalue(jingyuan)
		  
	 	  repostmb=Application("FTBBSMB")(2,0)
	      remb=replace(Application("FTBBSMB")(2,0),"$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,"$userid$",clubuser_id)
	      remb=replace(remb,"$remenu$",remenu)
	      remb=replace(remb,"$signname$",signname)
	      remb=replace(remb,"$reid$",reid)
	      remb=replace(remb,"$YN$",REYN)
	 	  'if REYN="Y" then '新增直接取图片
	 	  'remb=replace(remb,"$reupfile$","<IMG src=../../html/"&htmarray(0)&"/"&rebbs_img&" resize=1 class=c03 vspace=5><br>"&bbs_img_text)
	 	  'else
	 	  remb=replace(remb,"$reupfile$","")
	 	  'end if
	      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
		  j=j-1
        loop
      end if
	  cus1.close
    end if

	 ALLHtmlNL=postmb&HtmlNLB&repostformmb
	 myFile = Server.MapPath(tourl)
	 Set fileStreamObj = CreateObject("Scripting.FileSystemObject")
     fileStreamObj.CreateTextFile(myFile)
     set textStream = fileStreamObj.OpenTextFile(myFile,ForWriting,False)
     textStream.Write(ALLHtmlNL)
     textStream.Close()
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    conn.close
    set conn=nothing
    response.write "<SCRIPT language=JavaScript>alert('重新生成贴子完成！');"
   	response.write "window.location.href='admintohtm.asp';"
   	response.write "</script>"        
    response.end
%>