<!--#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=0 then
  set cschat=nothing
  application.unlock
  response.end
end if

myname=cschat.myname
room_id=cschat.room_id
my_level=cint(cschat.getListvalue(Application( ConstStr & "_user_list"),myname,3))

votes=application( ConstStr & "_votes")
if (votes(0)<>0 and votes(1)=myname) then my_level=1

room_name=cschat.GetListValue(Application(ConstStr & "_room_list"), room_id, 0)
cschat.FilterStr = Application(ConstStr & "_saysfilterstr")
forwhat=left(cschat.trdb(request("forwhat")),40)

end_level=application( ConstStr & "_l_kick")-1

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

errText=""
if my_level=0 then
  errText="你还没有登录到聊天室！"
elseif my_level-application( ConstStr & "_l_modlevel")<0 then
  errText="你暂时还没有此高级管理权力！"
elseif forwhat="" then
  errText="不注明原因，你想乱来啊？"
else
  Set Conn=Server.CreateObject("ADODB.Connection")
  conn.open Application( ConstStr & "_connstr")
  selwho=request("selwho")
  new_level=cint(request("new_level"))
  set rs=conn.execute("SELECT * FROM user WHERE username='" & selwho & "'")
  if rs.eof or rs.bof then
    errText="查无此人：<font color=green>"&selwho&"</font>！"
  else
    towho_level=rs("user_level")
    selwho=rs("username")
    if (new_level-towho_level)=0 then
      errText="<font color=green>"&selwho&"</font>已经是"&new_level&"级用户了！"
    elseif new_level-1<0 or new_level-end_level>0 then
      errText="你不能把对方的级别修改到"&new_level&"级！"
    else
      errText="你成功地修改了<font color=green>"&selwho&"</font>的级别！"
      conn.Execute("UPDATE user SET user_level="&new_level&" WHERE username='"&selwho&"'")
      occ_env=room_name&">"&myname&">"&Request.ServerVariables("REMOTE_ADDR")&">"&selwho&">"&towho_level&" 级修改为 "&new_level&" 级>"&forwhat
      conn.Execute("INSERT INTO record (stype,occ_time,occ_env) VALUES (30,'"&now()&"','"&occ_env&">修改了%%的级别')")
      if instr(Application( ConstStr & "_user_list"),"<$"&selwho&"$>")<>0 then
        user_array=split(Application( ConstStr & "_user_list"),"<$"&selwho&"$>")
        user_array2=split(user_array(1),"$>")
        user_array2(3)=new_level
        if user_array2(8)-new_level<0 or towho_level-new_level>0 then user_array2(8)=new_level
        user_array(1)=join(user_array2,"$>")
        Application( ConstStr & "_user_list")=join(user_array,"<$"&selwho&"$>")
      end if
    end if
  end if
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
end if
set cschat=nothing
application.unlock
response.redirect("showerr.asp?errtext="&ErrText)
%>