我自己写的聊天室源代码(七)
发表于:2007-06-30来源:作者:点击数:
标签:
*****************************聊天处理****************************** %‘’chatadmin.asp% %response.buffer = true% html head meta http-equiv=Content-Type content=text/html; charset=gb2312 title聊天处理/title meta name=GENERATOR content=Micros
*****************************聊天处理******************************
<%‘’chatadmin.asp%>
<%response.buffer = true%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>聊天处理</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Theme" content="none, default">
<meta name="Microsoft Border" content="none">
</head>
<%
dim sc_name,sc_pass,sc_pass1,sc_ip,sc_flag,sc_sex,sc_comin,sc_goout,sc_userflag,sc_bq(100),sc_a
clearcase/" target="_blank" >cction(100,2),sc_friend(100)
dim sc1_user1(30,8),sc1_point,sc1_message,sc1_usernum,sc1_user,sc1_userout,sc1_userout1(30,6)
application.lock
sc1_point = application("ap_point")
sc1_message = application("ap_message")
sc1_usernum = application("ap_usernum")
sc1_user = application("ap_user")
sc1_userout = application("ap_userout")
‘’用户在线检查
for i = 1 to 30
for j = 1 to 8
sc1_user1(i,j) = ""
next
for j = 1 to 6
sc1_userout1(i,j) = ""
next
next
sc1_ff = 0
j=0
sc1_time = now
for i = 1 to 30
if trim(sc1_user(i,1)) <> "" then
sc1_time1 = cdate(sc1_user(i,7))
if datediff("s",sc1_time1,sc1_time) < 61 then
j = j + 1
for k = 1 to 8
sc1_user1(j,k) = sc1_user(i,k)
next
else
‘’在线数量-1
sc1_usernum = sc1_usernum - 1
‘’配置离别用语
if sc1_point > 50 then
sc1_point = 1
end if
sc1_message(sc1_point,1) = sc1_user(i,1)
sc1_message(sc1_point,2) = "所有人"
sc1_message(sc1_point,3) = sc1_user(i,3)
sc1_message(sc1_point,4) = ""
sc1_message(sc1_point,5) = "8"
sc1_message(sc1_point,6) = "<font color=‘’#FF0000‘’>"
sc1_ttt = now
if hour(sc1_ttt) < 10 then
sc1_message(sc1_point,7) = "0" + cstr(hour(sc_ttt)) + ":"
else
sc1_message(sc1_point,7) = "" + cstr(hour(sc_ttt)) + ":"
end if
if minute(sc1_ttt) < 10 then
sc1_message(sc1_point,7) = sc1_message(sc1_point,7) + "0" + cstr(minute(sc_ttt)) + ":"
else
sc1_message(sc1_point,7) = sc1_message(sc1_point,7) + cstr(minute(sc_ttt)) + ":"
end if
if second(sc1_ttt) < 10 then
sc1_message(sc1_point,7) = sc1_message(sc1_point,7) + "0" + cstr(second(sc_ttt))
else
sc1_message(sc1_point,7) = sc1_message(sc1_point,7) + cstr(second(sc_ttt))
end if
sc_point = sc_point + 1
if sc_point > 50 then
sc_point = 1
end if
end if
end if
next
j = 0
for i = 1 to 30
if trim(sc1_userout(i,1)) <> "" then
sc1_time1 = cdate(sc1_userout(i,5))
if datediff("s",sc1_time1,sc1_time) < 1 then
j = j + 1
for k = 1 to 6
sc1_userout1(j,k) = sc1_userout(i,k)
next
end if
end if
next
‘’用户状态 4正常,0异常,1被踢,2被禁止说话,3禁止浏览
sc_ssss = 0
for i = 1 to 30
if trim(replace(trim(request.form("t1")),"<","<")) = trim(sc1_userout1(i,2)) then
if sc1_userout1(i,3) = "1" then
session("ss_nowflag") = 1
sc_ssss = 1
exit for
end if
if sc1_userout1(i,3) = "2" then
session("ss_nowflag") = 2
sc_ssss = 1
exit for
end if
if sc1_userout1(i,3) = "3" then
session("ss_nowflag") = 3
sc_ssss = 1
exit for
end if
end if
next
if sc_ssss = 0 then
session("ss_nowflag") = 4
end if
application("ap_point") = sc1_point
application("ap_message") = sc1_message
application("ap_usernum") = sc1_usernum
application("ap_user") = sc1_user1
application("ap_userout") = sc1_userout1
application.unlock
sc_ip = request.servervariables("remote_addr")
sc_name = replace(trim(request.form("t1")),"<","<")
sc_pass = trim(request.form("t3"))
set conn=server.createobject("adodb.connection")
conn.open "chat","chat","chat001"
‘’检查用户
sc_flag = 0
sc_
sql1 = "select user_password,user_flag,user_sex from user_info_table where user_name=‘’" + sc_name + "‘’"
set rs = conn.execute(sc_sql1)
if rs.eof then
sc_flag = 1
else
if rs(1) = 3 then
rs.close
conn.close
session("ss_nowwhat")="SORRY!你的账号已经被管理员封闭!!"
response.redirect "nochat.asp"
end if
sc_pass1 = trim(rs(0))
sc_userflag = trim(cstr(rs(1)))
sc_sex=trim(rs(2))
rs.close
end if
‘’口令检查
if sc_flag = 0 then
if sc_pass <> sc_pass1 then
sc_flag = 2
end if
end if
‘’机器/用户是否已经进入检查
if sc_flag = 0 then
dim sc_userall
sc_userall = application("ap_user")
for i = 1 to 30
if sc_userall(i,1) = sc_name then
sc_flag = 3
end if
if sc_userall(i,4) = sc_ip then
sc_flag = 4
end if
next
end if
if sc_flag = 0 then
sc_nn = application("ap_usernum")
if sc_nn >=30 then
sc_flag = 5
end if
end if
select case sc_flag
case 0
‘’通过检查允许登录
sc_sql2 = "select * from user_hello_table where user_name=‘’" + sc_name + "‘’"
set rs = conn.execute(sc_sql2)
sc_comin = rs(1)
sc_goout = rs(2)
rs.close
application.lock
‘’读取系统信息
dim sc_user,sc_message,sc_userout,sc_usernum,sc_point
sc_user = application("ap_user")
sc_message = application("ap_message")
sc_userout = application("ap_userout")
sc_point = application("ap_point")
sc_usernum = application("ap_usernum")
if sc_point > 50 then
sc_point = 1
end if
‘’配置聊天内容
sc_message(sc_point,1) = sc_name ‘’源
sc_message(sc_point,2) = "所有人" ‘’目的
sc_message(sc_point,3) = sc_comin ‘’进入语
sc_message(sc_point,4) = "" ‘’表情
sc_message(sc_point,5) = "7"
sc_message(sc_point,6) = "<font color=‘’#000000‘’>"
sc_ttt = now
if hour(sc_ttt) < 10 then
sc_message(sc_point,7) = "0" + cstr(hour(sc_ttt)) + ":"
else
sc_message(sc_point,7) = "" + cstr(hour(sc_ttt)) + ":"
end if
if minute(sc_ttt) < 10 then
sc_message(sc_point,7) = sc_message(sc_point,7) + "0" + cstr(minute(sc_ttt)) + ":"
else
sc_message(sc_point,7) = sc_message(sc_point,7) + cstr(minute(sc_ttt)) + ":"
end if
if second(sc_ttt) < 10 then
sc_message(sc_point,7) = sc_message(sc_point,7) + "0" + cstr(second(sc_ttt))
else
sc_message(sc_point,7) = sc_message(sc_point,7) + cstr(second(sc_ttt))
end if
sc_point = sc_point + 1
if sc_point > 50 then
sc_point = 1
end if
application("ap_point") = sc_point
application("ap_message") = sc_message
‘’配置登录用户
sc_usernum = sc_usernum + 1
sc_userall(sc_usernum,1) = sc_name ‘’用户名
sc_userall(sc_usernum,2) = sc_comin ‘’进入语
sc_userall(sc_usernum,3) = sc_goout ‘’退出语
sc_userall(sc_usernum,4) = sc_ip
sc_userall(sc_usernum,5) = sc_userflag
sc_userall(sc_usernum,6) = request.form("r1")
sc_userall(sc_usernum,7) = cstr(now)
sc_userall(sc_usernum,8) = sc_sex
application("ap_user") = sc_userall
application("ap_usernum") = sc_usernum
application.unlock
‘’配置session
sc_sql3 = "select user_bq from user_bq_table where user_name=‘’所有人‘’ or user_name=‘’" + sc_name + "‘’"
sc_sql4 = "select acction_name,user_acction from user_acction_table where user_name=‘’所有人‘’ or user_name=‘’" + sc_name + "‘’"
sc_sql5 = "select user_friend from user_friend_table where user_name=‘’" + sc_name + "‘’"
set rs=conn.execute(sc_sql3)
for i = 1 to 100
sc_bq(i) = ""
sc_acction(i,1) = ""
sc_acction(i,2) = ""
sc_friend(i) = ""
next
sc_i = 0
do while not rs.eof
sc_i = sc_i + 1
sc_bq(sc_i) = rs(0)
rs.movenext
loop
rs.close
set rs=conn.execute(sc_sql4)
sc_i = 0
do while not rs.eof
sc_i = sc_i + 1
sc_acction(sc_i,1) = rs(0)
sc_acction(sc_i,2) = rs(1)
rs.movenext
loop
rs.close
set rs=conn.execute(sc_sql5)
sc_i = 0
do while not rs.eof
sc_i = sc_i + 1
sc_friend(sc_i) = trim(rs(0))
rs.movenext
loop
rs.close
‘’读取内容位置
if sc_point -2 < 1 then
session("ss_oldpoint") = sc_point +48
else
session("ss_oldpoint") = sc_point - 2
end if
‘’保存在线人数
session("ss_usernum") = sc_usernum
‘’当前聊天状态
session("ss_nowflag") = 1
‘’表情数组
session("ss_bq") = sc_bq
‘’动作数组
session("ss_acction") = sc_acction
‘’朋友数组
session("ss_friend") = sc_friend
‘’错误信息
session("ss_nowwhat") = "正常登录"
‘’用户姓名
session("ss_name") = sc_name
‘’用户权限
session("ss_userflag") = sc_userflag
‘’默认颜色
session("ss_color") = "#000000"
‘’悄悄话
session("ss_qq") = "4"
‘’对象
session("ss_who") = "所有人"
‘’会话过期时间
session.timeout = 30
response.redirect "chat.asp"
case 1
‘’用户不存在
session("ss_nowwhat")="Hi!用户名好像不存在耶!!"
response.redirect "nochat.asp"
case 2
‘’口令不正确
session("ss_nowwhat")="你好像敲错了!!口令错误!!"
response.redirect "nochat.asp"
case 3
‘’用户已经进入
session("ss_nowwhat")="你想干什么?该用户已经进入聊天室!!"
response.redirect "nochat.asp"
case 4
‘’机器已经进入
session("ss_nowwhat")="你想干什么?该机器已经进入聊天室!!"
response.redirect "nochat.asp"
case 5
‘’人满为患
session("ss_nowwhat")="SORRY!聊天室人满为患,过一会进入好吗?"
response.redirect "nochat.asp"
end select
%>
<body>
<p><%
ss=session("ss_friend")
response.write(ss(1))%> </p>
</body>
<%conn.close%>
</html>
****************************初始化参数******************************
<%‘’clearall.asp%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>初始化参数</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Theme" content="none, default">
<meta name="Microsoft Border" content="none">
</head>
<%
dim sc_user(30,8) ‘’登录用户数组
‘’1.用户名 2.进入语 3.退出语 4.IP 5.权限 6.图片 7.刷新时间 8.性别
‘’权限:0系统管理员,1普通管理员,2普通用户
dim sc_message(50,7) ‘’聊天内容数组
‘’1.源 2.目的 3.动作/内容 4.表情 5.标志位 6字体颜色 7时间
‘’标志位:1踢人,2禁止说话,3禁止浏览,4公开话,5悄悄话,6动作,7进入,8退出
dim sc_userout(30,6) ‘’被管理的特殊用户
‘’1.源 2.目的 3.动作类型 4.开始时间 5.结束时间 6.时长
‘’动作类型:1踢人,2禁止说话,3禁止浏览
dim i,j
for i = 1 to 30
for j =1 to 6
sc_user(i,j) = ""
sc_userout(i,j) = ""
next
sc_user(i,7) = ""
sc_user(i,8) = ""
next
for i = 1 to 50
for j =1 to 6
sc_message(i,j) = ""
next
next
application.lock
‘’用户数组
application("ap_user") = sc_user
‘’被管理用户
application("ap_userout") = sc_userout
‘’聊天信息
application("ap_message") = sc_message
‘’用户数量
application("ap_usernum") = 0
‘’最新语句位置
application("ap_point") = 1
application.unlock
%>
<body>
</body>
</html>
***************************用户权限修改*****************************
<%‘’userflag.asp%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户权限修改</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Theme" content="none, default">
<meta name="Microsoft Border" content="none">
</head>
<body>
<%
dim sc_user,sc_user1(30)
application.lock
sc_user = application("ap_user")
application.unlock
for i = 1 to 30
sc_user1(i) = sc_user(i,1)
next
if request.form("b1") = "确定" then
set conn=server.createobject("adodb.connection")
conn.open "chat","chat","chat001"
sql = "update user_info_table set user_flag=" + request.form("d2") + " where user_name=‘’" + trim(request.form("d1")) + "‘’"
set rs=conn.execute(sql)
conn.close
end if
%>
<form method="POST" action="userflag.asp">
<p>将<select name="D1" size="1">
<%
for i = 1 to 30
if trim(sc_user1(i)) <> "" then
%> <option value="<%response.write(trim(sc_user1(i)))%>"><%response.write(trim(sc_user1(i)))%></option>
<%
end if
next%> </select>的权限改为<select name="D2" size="1">
<option value="0">超级用户</option>
<option value="1">普通管理员</option>
<option selected value="2">普通用户</option>
<option value="3">封闭账号</option>
</select><input type="submit" value="确定" name="B1"><input type="reset" value="取消"
name="B2"></p>
</form>
</body>
</html>
原文转自:http://www.ltesting.net