chat.asp——主帧控制文件

发表于:2007-06-30来源:作者:点击数: 标签:
% Option Explicit const admin=admin const admpass=admin dim roomname,kicklist,onliuser,cha td ata,userdup,userid,noplace,username,i,chatpoin,password,admlevel username=trim(request.form(username)) password=request.form(password) roomname=ap
<%
Option Explicit
const admin="admin"
const admpass="admin"
dim roomname,kicklist,onliuser,chatdata,userdup,userid,noplace,username,i,chatpoin,password,admlevel
username=trim(request.form("username"))
password=request.form("password")
roomname=application("roomname")
kicklist=application("kicklist")
onliuser=application("onliuser")
chatdata=application("chatdata")
if username="系统" or username="所有人" or username="" then response.redirect "error.asp?mess=使用了非法的字符为名字或使用了系统保留的名名,请换一个再进"
if username=admin and password=admpass then
  admlevel=90
  session("admlevel")=9
  username="*"&username
else
  admlevel=0
  session("admlevel")=""
  if instr(kicklist,"‘’#"&username&"‘’")>0 then response.redirect "kickout.htm"
  if instr(kicklist,"‘’"&Request.ServerVariables("remote_addr")&"‘’")>0 then response.redirect "kickout.htm"
end if

userdup=false
for i=0 to 50
  if chatdata(i,0)=username then
    if chatdata(i,1)<>request.servervariables("remote_addr") then
      response.redirect "error.asp?mess=相同的聊天昵称已存在,请你用另一个昵称进入"
    else
      userdup=true
      userid=i
      chatdata(i,4)=admlevel
      exit for
    end if
  end if
next

if not userdup then
for i=0 to 50
  if chatdata(i,0)="" then
      userid=i
      chatdata(i,0)=username ‘’存用户名
      chatdata(i,1)=request.servervariables("remote_addr") ‘’存IP地址
      chatdata(i,3)=""   ‘’置耳语为空
      chatdata(i,4)=admlevel    ‘’置请勿打挠开关、MIDI开关
      chatdata(i,5)=""   ‘’置隐藏名单为空
      noplace=false
      session("userid")=i
      exit for
  end if
next
if not noplace then
   onliuser=onliuser&",‘’"&username&"‘’"  ‘’将用户加进名单列表
   for i=0 to 50
     chatdata(i,4)=(chatdata(i,4) mod 4)+4  ‘’通知其它用户刷新名单
   next
else
   response.redirect "error.asp?mess=聊天室已经满员!"
end if
else
   if instr(onliuser,",‘’"&username&"‘’")<1 then  onliuser=onliuser&",‘’"&username&"‘’"
   
   
end if
chatpoin=application("chatpoin")   ‘’保留5条历史记录
if chatdata(userid,2)>4 then
  chatdata(userid,2)=chatpoin-5
else
  chatdata(userid,2)=chatpoin-5+50
end if
application.lock
  application("chatdata")=chatdata
  application("onliuser")=onliuser
application.unlock
session("userip")=request.servervariables("remote_addr")
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><% =application("roomname") %></title>
<script Language=‘’JavaScript‘’ src="action.js"></script>
<script Language=‘’JavaScript1.2‘’>
var username="<% =username %>";
midisw=false;   //音乐开关
var list=new Array(‘’‘’);
var btitle = ‘’<html><head><title><% =application("roomname") %></title>\n<style type=\"text/css\">\n<!--\n.p9 {  font-size: 10.5pt; line-height: 19pt}\na:visited {  color: #0000FF; text-decoration: none}\na:link {  color: #0000FF; text-decoration: none}\na:hover {  color: #FF0000}\n-->\n</style></head><body bgcolor=ffffff>\n<center>欢迎光临<font color=red><% =application("roomname") %></font>,请文明聊天</center><br>\n<p class=\"p9\" align=\"left\">‘’
function cleanbody(){   //初始化谈话区
  with (b.document) {open();write(btitle);}
}

var autoscroll=true;
function scrollsays(){if (autoscroll) b.scroll(0,650000);}
    
var comm=new Array();
function cs(name)
{
var obj=i.document.inputform
obj.WHOTO.value=name;
obj.msg.focus();
return;
}

function writecomm()
{
  comm.sort();
  if (!b.document.title) cleanbody();  
  for(var i=0;i<comm.length;i++)
  {
    comm[i]=tstr(comm[i]);
    b.document.writeln(comm[i]+"<br>\n");
  }
  scrollsays();
}

function tstr(mstr)
{
  var tmpstr="";
  var tmpsay=""
  mstr=mstr.split(",");
  for (var i=6;i<mstr.length;i++) tmpsay=tmpsay+","+mstr[i];
  tmpsay=tmpsay.substring(1,tmpsay.length);
  if (!midisw) tmpsay=tmpsay.replace("<img","<img");
  if (username==mstr[3]) mstr[3]="<font color=red>["+mstr][3]+"]</font>"
  else mstr[3]="<a href=\"javascript:parent.cs(‘’"+mstr[3]+"‘’)\">"+mstr[3]+"</a>"
  if (username==mstr[1]) mstr[1]="<font color=red>["+mstr][1]+"]</font>"
  else mstr[1]="<a href=\"javascript:parent.cs(‘’"+mstr[1]+"‘’)\">"+mstr[1]+"</a>"
  tmpstr=tmpstr+"("+mstr[0]+")"+mstr[1]+"</a>"+action[mstr[2]].replace("#",mstr[3])+"<font color="+mstr[4]+">"+tmpsay+"</font>";
  if (mstr[5]=="1") tmpstr=tmpstr+"<font face=wingdings color=#ffceca> )</font>";
  return tmpstr+"</b>";
}
</script>
</head>
<frameset cols="*,160" border="0" framespacing="1" frameborder="true">
  <frameset  rows="*,100,0">
    <frame src="about:blank" name="b" noresize>
    <frame src="input.asp?user=<% =username %>" name="i" frameborder="yes" scrolling="no" noresize>
    <frame src="refresh.asp?user=<% =username %>" name="r">
  </frameset>
  <frame src="list.asp"  name="u" noresize>
</frameset>
</frameset>
<noframes><body onLoad="write()" bgcolor="#FFFFFF">
</body></noframes>
</html>

原文转自:http://www.ltesting.net