<!--#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"))

if my_level-application( ConstStr & "_l_delroom")<0 then
  set cschat=nothing
  response.redirect("showerr.asp?errtext=你想撤房子，可惜力气不够！！")
  application.unlock
  response.end
end if

room_id=cschat.room_id
myname=cschat.myname

room_name=cschat.getListvalue(Application( ConstStr & "_room_list"),room_id,0)

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

errText=""
cschat.FilterStr=application(ConstStr & "_saysfilterstr")
selroomid=cschat.trdb(request("selroomid"))

if selroomid="" or instr(Application( ConstStr & "_room_list"),"<$"&selroomid&"$>")<4 then
  errText="你要删除的房间并不存在或不能被删除!"
else
  sel_room_name=cschat.getListvalue(Application( ConstStr & "_room_list"),selroomid,0)
  user_list=trim(cschat.getListvalue(Application( ConstStr & "_room_list"),selroomid,12))
  if request("cmdYes")="撤房" then
    forwhat=left(cschat.trdb(request("forwhat")),40)
    if forwhat="" then
      errText="不注明原因，你想乱来啊？"
    else
      Set Conn=Server.CreateObject("ADODB.Connection")
      conn.open Application( ConstStr & "_connstr")

      occ_env=room_name&">"&myname&">"&Request.ServerVariables("REMOTE_ADDR")&">"&sel_room_name&"> >"&forwhat
      conn.Execute("INSERT INTO record (stype,occ_time,occ_env) VALUES (15,'"&now()&"','"&occ_env&">删除了房间%%')")

      application(ConstStr & "_room_list")=cschat.DelList(application(ConstStr & "_room_list"),selroomid)

      r_array=split(Application( ConstStr & "_room_list"),"$>")
      to_room_id=mid(r_array(0),3)

      add_say_mess=""
      if user_list<>"" then
        user_list_array=split(user_list," ")
        for j=0 to UBound(user_list_array)
          if user_list_array(j)<>"" and instr(Application( ConstStr & "_user_list"),"<$"&user_list_array(j)&"$>")<>0 then
            user_array=split(Application( ConstStr & "_user_list"),"<$"&user_list_array(j)&"$>")
            user_array2=split(user_array(1),"$>")
            user_array2(4)=to_room_id
            user_array(1)=join(user_array2,"$>")
            Application( ConstStr & "_user_list")=join(user_array,"<$"&user_list_array(j)&"$>")
            add_say_mess=add_say_mess&"parent.addl(\'" & user_list_array(j) & "\'," & user_array2(2) & ",\'" & user_array2(6) & "\',\'" & user_array2(12) & "\');"
          end if
        next
        Application( ConstStr & "_room_list")=cschat.SetListValue(Application( ConstStr & "_room_list"), to_room_id, 12, user_list, 1)
        user_list="'" & replace(user_list," ","','") & "'"
        conn.Execute("UPDATE user SET room_id=" & to_room_id & " WHERE username in ("& user_list &")")
      end if

      say_mess=split(application( ConstStr & "_delroomshow"),"::")
      say_mess(0)=replace(say_mess(0),"$F",forwhat)
      say_mess(0)=say_mess(0)&"<\script>if (parent.roomname==\'"&sel_room_name&"\') window.open(\'init.asp\',\'refresh\')</\script>"
      says = Application(ConstStr & "_says")
      current = Application(ConstStr & "_current")
      cschat.newsay myname,sel_room_name,0,-2,say_mess(0),say_mess(1),say_mess(2),-3,says,current

      if add_say_mess<>"" then
        add_say_mess="<\script>"&add_say_mess&"</\script>"
        cschat.newsay "大家","",0,to_room_id,add_say_mess,"","",-5,says,current
      end  if
      
      Application(ConstStr & "_says") = says
      Application(ConstStr & "_current") = current

      conn.execute("delete from room where ID="&selroomid)
      errText="你成功地撤掉了房子『<font color=green>"&sel_room_name&"</font>』!"
      conn.close
      set conn=nothing
    end if
  else%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="chat.css">
<script>function x(y,z){document.write("<option value=\""+y+"\">"+z+"</option>")}</script>
<body style="background-color:EAF2FF;color:112233;scrollbar-Base-Color: #b0d8ff;SCROLLBAR-DARKSHADOW-COLOR:#b0d8ff;SCROLLBAR-arrow-COLOR:#336699;SCROLLBAR-TRACK-COLOR: EAF2FF;SCROLLBAR-3DLIGHT-COLOR: #b0d8ff;SCROLLBAR-SHADOW-COLOR: #336699;SCROLLBAR-HIGHLIGHT-COLOR: #b0d8ff;">
  <table height=100% width=100%><tr><td align=center valign=center >
  <table width=380 align=center cellspacing=0 cellpadding=0 border=1 BORDERCOLORLIGHT=#000000 BORDERCOLORDARK=#ffffff>
   <tr><td class=navy1>你想撤消房间<font color=red>〖<%=sel_room_name%>〗</font>，请输入理由！</td>
  <form action=cutroom.asp method=post>
  <input name=selroomid type=hidden value="<%=selroomid%>">
  <tr><td height=70><select name=list style="background-color:3399FF;color:FFFFFF"
    onchange="javascript:document.forms[0].forwhat.value=document.forms[0].list.value;document.forms[0].forwhat.focus();">
    <script>x("","撤房");x("房间名字不雅","名字");x("故意建房间捣乱","捣乱");</script></select>　
    <input name=forwhat type=text maxlength=40  size=40 value='房间名字不雅'>
  <br><br><input class=navy1 type=submit name=cmdYes value="撤房">
    <input class=navy1 type=button name=cmdCancel value=放弃 onClick="javascript:window.close()">
    </td></tr></form></table></td></tr></table></form></body>
  <%end if
end if
set cschat=nothing
if errText<>"" then response.redirect("showerr.asp?errtext="&errText)
application.unlock%>




































