<!--#include file="inc_const.asp"-->
<%response.expires=0
Response.CacheControl = "Private"
application.lock

set cschat=server.createobject("ffcschat.cssbchat")
my_level=cschat.getLevel(Session,Application(ConstStr & "_user_list"),Application(ConstStr & "_room_list"))

application.unlock
if my_level=0 then
  set cschat=nothing
  response.redirect("showerr.asp")  
  response.end
end if
myname=cschat.myname
room_id=cschat.room_id

if my_level-application( ConstStr & "_superlevel")=0 then myname="管理员"

id=request("id")
if id="" or (not isnumeric(id)) then
else
  Set Conn=Server.CreateObject("ADODB.Connection") 
  conn.open Application( ConstStr & "_connstr")
  sql="SELECT * FROM guestbook WHERE id=" & id 
  set rs=conn.Execute(sql)
  if rs.eof or rs.bof then
    errText="你要删除的留言并不存在！"
  else
    flag=false
    if myname=rs("who") or (rs("secret")<>0 and myname=rs("towho")) then
      flag=true
    elseif my_level-application( ConstStr & "_l_delnote")>=0 then
      flag=true
      occ_env=cschat.GetListValue(Application(ConstStr & "_room_list"), room_id, 0)&">"&myname&">"&Request.ServerVariables("REMOTE_ADDR")&">"&id&">"&rs("who")&" 写给 "&rs("towho")&">标题："&rs("text_title")
      conn.Execute("INSERT INTO record (stype,occ_time,occ_env) VALUES (6,'"&now()&"','"&occ_env&">删除了ID为%%的留言')")
    end if
    if flag then 
      conn.Execute("DELETE FROM guestbook WHERE id="&id)
      errText="你成功删除了此条留言！"
    else
      errText="你无权删除此条留言！"
    end if
  end if
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
end if
set cschat=nothing
response.redirect("showerr.asp?errtext="&errtext)%>