<!--#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
  response.redirect("showerr.asp")
  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))

Set Conn=Server.CreateObject("ADODB.Connection")
conn.open Application(ConstStr & "_connstr")
sql="SELECT * FROM user WHERE username='" & myname & "'"
set Rs=conn.Execute(sql)
if not (Rs.eof or Rs.bof) then
  add_exp_num=datediff("n",cschat.getListvalue(Application( ConstStr & "_user_list"),myname,11),now())
  exp_num=Rs("exp_num")+add_exp_num
  if my_level-10<0 and Application( ConstStr & "_autoupgrade")=1 and rs("auto_update")=1 then
    if exp_num-application(ConstStr & "_expupto"&( my_level+1 ))>0 then my_level=my_level+1
  end if
  if (Rs("user_level")-my_level)>0 then my_level=Rs("user_level")
  out_info=0
  out_time=now()
  conn.Execute("UPDATE user SET s_color="&request("sc")&",n_color="&request("mc")&",out_time='"&out_time&"',out_info="&out_info&",user_level="&my_level&",exp_num="&exp_num&",room_id=0 WHERE username='"&myname&"'")
  
  Application( ConstStr & "_room_list")=cschat.SetListValue(Application( ConstStr & "_room_list"), room_id, 10, add_exp_num, 2, 7, now(), 0)
  conn.Execute("UPDATE room SET room_time='"&now()&"',room_exp=room_exp+"&add_exp_num&" WHERE ID="&room_id)
end if

say_mess=split(application(ConstStr & "_exitchatshow"),"::")
say_mess(0)=say_mess(0) & "<\script>parent.dell(\'" & myname & "\')</\script>"

says = Application(ConstStr & "_says")
current = Application(ConstStr & "_current")
cschat.newsay myname,"´ó¼Ò",0,room_id,say_mess(0),say_mess(1),say_mess(2),-2,says,current
Application(ConstStr & "_says") = says
Application(ConstStr & "_current") = current

application(ConstStr & "_user_list")=cschat.DelList(application(ConstStr & "_user_list"), myname)

Application( ConstStr & "_room_list")=cschat.SetListValue(Application( ConstStr & "_room_list"), room_id, 12, myname, -1)

set cschat=nothing
rs.close
set rs=nothing
application.unlock
Session.Abandon
Session("Leave")="true"
conn.close
set conn=nothing
%><META content='text/html; charset=gb2312' http-equiv=content-type><meta HTTP-EQUIV='Pragma' CONTENT='no-cache'><script>window.close();</script>