<!--#include file="../conn.asp"-->
<!-- #include file="../admin/check_master.asp" -->
<!--#include file="../admin/check_admin_qs.asp" -->
<!--#include file="../admin/dhfun.asp" -->
<%
   dim sql
   dim rs
   return_url=request.serverVariables("HTTP_REFERER")
   ptuser=request("ptuser")
   str="select id,BoardID_2,rep,htmfilename from bbstitle Where id="&request("id")
   set rs=server.createobject("adodb.recordset")
   rs.open str,conn,1,1

   id=rs("id")
   BoardID_2=rs("BoardID_2")
   rep=rs("rep")
   htmfilename=rs("htmfilename")
   call FTBBS_HTML_MB
   pagenum=Application("FTBBSMB")(6,0)
   htm_ext=Application("FTBBSMB")(32,0)
   k=rep/pagenum
   if int(k)=k and int(k)<>0 then
      page=k
   else
      page=int(k)+1
   end if

   if htmfilename="" or isnull(htmfilename) then
      response.write ""
   else
     htmarray=split(htmfilename,"/")
     For i=1 to page
	     if i=1 then
		    FiLePaTh = Server.MapPath("../")& htmfilename 
		 else
            FiLePaTh = Server.MapPath("../")& htmarray(0)&"/"&id&"_"&i&htm_ext
		 end if
            Set fso = CreateObject("Scripting.FileSystemObject")
			If fso.FileExists(FiLePaTh) = True Then
               fso.DeleteFile(FiLePaTh)
			end if
            Set fso = nothing 
	 Next 
   end if
   
   sql="delete from bbstitle where id="&request("id")
   conn.execute sql
   sql="delete from bbsmenu where pid="&request("id")
   conn.execute sql
   sql="update BBS_Cate set BBS_Cate_Topic=BBS_Cate_Topic-1 where BBS_Cate_ID='"&BoardID_2&"'"
   conn.execute sql
   sql="update clubuser set postnum=postnum-1 where postnum>0 and clubuser_name='"&ptuser&"'"
   conn.execute sql
   
   sql0="select * from ftbbs_upload where upload_htm='"&htmfilename&"'"
   set rs0=server.createobject("adodb.recordset")
   rs0.open sql0,conn,1,1
   if not rs0.eof then
      oldpicFile = "../"&rs0("upload_pic")
      mypicFile = Server.MapPath(oldpicFile)
      Set fso = CreateObject("Scripting.FileSystemObject")
        If fso.FileExists(mypicFile) = True Then
          fso.DeleteFile(mypicFile)
        end if
      Set fso = nothing
      sql="delete from ftbbs_upload where upload_htm='"&htmfilename&"'"
      conn.execute sql   
   end if
   default_listbbsad
   conn.close
   set conn=nothing
   
   if request("bbs_img")<>"" then
   '以下是删除图片文件
   mypicFile = "../"&htmarray(0)&"/" &request("bbs_img")
   mypicFile = Server.MapPath(mypicFile)
   Set fso = CreateObject("Scripting.FileSystemObject")
      If fso.FileExists(mypicFile) = True Then
         fso.DeleteFile(mypicFile)
      end if
   Set fso = nothing   
   end if
   response.redirect return_url
%>
