<!-- #include file="bbsuser.asp" -->
<!-- #include file="../inc/conn.asp" -->
<%
 DIM myFile
 Const ForReading = 1
 Const Forwriting = 2
 Const ForAppending = 8
 htmfilename=Request.QueryString("File")
 page=Request.QueryString("page")
 if page=1 then
   FileName=htmfilename
 else
   FileName=replace(htmfilename,".htm","")&"_"&page&".htm"  
 end if
 myarray=split(FileName,"/",-1,1)
 Post=Request.QueryString("Postnum")
 pid=Request.QueryString("id")
 postuser=Request.QueryString("postuser")
 reid=Request.QueryString("reid")

 myFile = Server.MapPath("../html"&"/"&FileName)

 SET fileStreamObj = CreateObject("Scripting.FileSystemObject")
 if fileStreamObj.FileExists(myFile)=false then
  myarray(1)=""
 end if
  
 if myarray(1)<>"" and request.cookies("bz")=1 and postuser<>"" then
   str="delete from bbsmenu where id="&reid
   conn.execute(str)
   
   SET textStream = fileStreamObj.OpenTextFile(myFile,ForReading,False)
   while not textStream.AtEndOfStream
    FileNl=FileNl+textStream.ReadLine()
   wend
   textStream.Close()
   set fileStreamObj=nothing
   EndPost="<!--End"&Post&"-->"
   i=Instr(1,Filenl,"<!--Begin"&Post&"-->")
   j=Instr(1,Filenl,EndPost)
   Left_NL=left(FileNl,i-1)
   Right_NL=right(FileNl,len(FileNl)-(j+len(EndPost)-1))

   SET fileStreamObj = CreateObject("Scripting.FileSystemObject")
   SET textStream = fileStreamObj.OpenTextFile(myFile,ForWriting,False)
   textStream.Write(left_nl+right_nl)
   textStream.Close()
   set fileStreamObj=nothing
   'response.write left_nl+right_nl
   'response.End()
   
   strsql="update bbstitle set rep=rep-1 where id="+pid
   conn.execute(strsql)
   Response.Redirect "../html"&"/"&FileName
 else
   response.write "<script language='javascript'>"
   response.write "alert('你的权限太低，无法使用此功能！');"
   response.write "history.go(-1);"
   response.write "</script>"
   response.end   
 end if
%>