<!--#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
  application.unlock
  set cschat=nothing
  response.redirect("showerr.asp")  
  response.end
end if
myname=cschat.myname
'last_say_time=cschat.getListvalue(Application( ConstStr & "_user_list"),myname,5)


Set Conn=Server.CreateObject("ADODB.Connection")
conn.open Application( ConstStr & "_connstr")

set rs=conn.execute("SELECT friends FROM user WHERE username='" & myname & "'")
if rs.eof or rs.bof then response.end
friends=trim(rs("friends"))

if request("B1")="提交" then
  secret=1
  errStr=""
  set rs=conn.execute("SELECT count(*) as out_all FROM calls WHERE who='" & myname & "'")
  if rs("out_all")>50 then
    errstr="你的发件箱已经满了，不能发送新的消息，请整理发件箱！"
  else
    cschat.FilterStr = Application(ConstStr & "_saysfilterstr")
    callwho=cschat.trdb(request("callwho"))
    callmess=left(cschat.trdb(request("callmess")),100)
    if callwho="" or callmess="" then
      errstr="呼叫对象和呼叫信息不能为空！"
    elseif callwho="大家" then
      secret=0
      if my_level-application( ConstStr & "_superlevel")<>0 then errstr="你不能给所有的人发出呼叫！"
    else
      sql="SELECT * FROM user WHERE username='" & callwho & "'"
      Set Rs=conn.Execute(sql)
      if rs.eof or rs.bof then errstr="你呼叫的用户"&callwho&"还没有注册！"
      set rs=conn.execute("SELECT count(*) as out_all FROM calls WHERE towho='" & callwho & "'")
      if rs("out_all")>50 then errstr=callwho&"的收件箱已经满了，不能接收新的消息！"
    end if
  end if
  if errstr="" then
    conn.execute("insert into calls (who,towho,callmess,calltime,read) values ('"&myname&"','"&callwho&"','"&callmess&"','"&now()&"',0)")
    if instr(Application( ConstStr & "_user_list"),"<$"&callwho&"$>")=0 and callwho<>"大家" then
      errStr="你成功地发出了呼叫信息！但"&callwho&"暂时不在线！"
    else
      says = Application(ConstStr & "_says")
      current = Application(ConstStr & "_current")
      cschat.newsay callwho,callwho,secret,-2,"<\script>window.open(\'getcall.asp\',\'\',\'width=500,height=300,scrollbars=1\');</\script>","#","#",-5,says,current
      Application(ConstStr & "_says") = says
      Application(ConstStr & "_current") = current
      errStr="你成功地发出了呼叫信息！"
    end if
  end if
  response.redirect("showerr.asp?errtext="&errStr)
else
  onlinestr=""
  if request("towho")="" then
   all_user_array=split(Application( ConstStr & "_user_list"),"$><$")
   for i=0 to UBound(all_user_array) step 2
    all_user_array2=split(all_user_array(i),"$>")
    username=replace(all_user_array2(0),"<$","")
    if username<>myname then
      onlinestr=onlinestr&" "&username
    end if
   next
   onlinestr=trim(onlinestr)
  end if%>
<head><META content="text/html; charset=gb2312" http-equiv=content-type><meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
<link rel="stylesheet" type="text/css" href="chat.css"><style>p{margin-left:10px;margin-right:20px;margin-top:5px;margin-bottom:0px}</style></head>
<script>var hh=1;
function check() {if (hh==1) {hh=0;return true}else return false;}</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;" leftmargin=3 topmargin=20 >
  <table width=400 align=center cellspacing=0 cellpadding=0 border=1 BORDERCOLORLIGHT=#000000 BORDERCOLORDARK=#ffffff>
  <tr><td class=navy1 colspan=2><font color=navy>向聊友发送呼叫信息</font></td></tr>
  <form action="overroom.asp" method="post" onsubmit='return check()'>
  <tr><td style="text-align:left" colspan=2 nowrap height=100 >
   <p>对象：<input name=callwho type=text size=10 maxlength=10 value=<%=request("towho")%> >
   <select name=friends onchange="document.forms[0].callwho.value=this.value;this.options[0].selected=true;document.forms[0].callmess.focus();"><option value="">好友名单</option><script>var fn="<%=friends%>".split(" ");
   for (i=0;i<fn.length;i++) if (fn[i]!='') document.write('<option value="'+fn[i]+'">'+fn[i]+'</option>')</script></select>
   <select name=onlinestr onchange="document.forms[0].callwho.value=this.value;this.options[0].selected=true;document.forms[0].callmess.focus();"><option value="">在线名单</option><script>var gn="<%=onlinestr%>".split(" ");
   for (i=0;i<gn.length;i++) if (gn[i]!='') document.write('<option value="'+gn[i]+'">'+gn[i]+'</option>')</script></select>
   </p><p>内容：<input type=text name=callmess value="" size=50 maxlength="200">
   </p><p><center><input class=navy1 type="submit" name="B1" value="提交">
   <input class=navy1 type="reset" name="B2" value="重置">
   <input class=navy1 type=button name="B3" value="放弃" onclick="javascript:parent.window.close();return false"></center>
   </td></tr></form></table><br><center>[<a href='getcall.asp?stype=inbox'>收件箱</a>] [<a href='getcall.asp?stype=outbox'>发件箱</a>] [<a href='javascript:history.go(-1)'>后退</a>]</center>
<%end if
set cschat=nothing
application.unlock
rs.close
set rs=nothing
conn.close
set conn=nothing%>
