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

myname=cschat.myname
cschat.ConstStr=ConstStr

Set Conn=Server.CreateObject("ADODB.Connection")
conn.open Application( ConstStr & "_connstr")
Connstr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+server.mappath("db/global.asa")+";DefaultDir='';DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=15;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
Application(ConstStr & "_connstr") = ConnStr

if request("op")="init" then
  occ_env="系统>"&myname&">"&Request.ServerVariables("REMOTE_ADDR")&">聊天室> >此处只做记录"
  conn.Execute("INSERT INTO record (stype,occ_time,occ_env) VALUES (56,'"&now()&"','"&occ_env&">初始化了%%系统')")
  errtext="聊天室被重新初始化，所有的用户和发言被清除！"
  conn.close
  set conn=nothing
  cschat.InitGlobal(application)
elseif request("op")="pre" then
  occ_env="系统>"&myname&">"&Request.ServerVariables("REMOTE_ADDR")&">聊天室> >此处只做记录"
  conn.Execute("INSERT INTO record (stype,occ_time,occ_env) VALUES (55,'"&now()&"','"&occ_env&">修正了%%系统')")
  errtext="根据数据库设置修正了聊天室数据！"
  conn.close
  set conn=nothing
  cschat.preglobal_1 application
  
  MaxTalk = cint(Application(ConstStr & "_maxtalk"))
  dim newsays
  redim newsays(MaxTalk,5)
  for i=0 to MaxTalk
    newsays(i,0)=0
  next

  says=application( ConstStr & "_says")
  current=application( ConstStr & "_current")

  talk_num=ubound(says)
  if talk_num>MaxTalk then talk_num=MaxTalk
  
  for i=talk_num to 0 step -1
    for j=0 to 5
      newsays(i,j)=says(current,j)
    next
    current=current-1
    if current<0 then current=ubound(says)
  next

  application( ConstStr & "_says")=newsays
  application( ConstStr & "_current")=MaxTalk
  
    dim Ianswers(7)
    Ianswers(0)=0
    Ianswers(5)=now()
    Application( ConstStr & "_answers")=Ianswers
    Set qConn=Server.CreateObject("ADODB.Connection")
    qconn.open "DBQ="+server.mappath("questions.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
    set qrs=qconn.execute("select count(*) as qc from questlib")
    Application( ConstStr & "_quest_num")=qrs("qc")
    qrs.close
    qconn.close
    set qconn=nothing
    set qrs=nothing
end if
application.unlock
response.redirect("showerr.asp?errtext="&errText)
%>
