使用数据库判断在线名单以及在线人数
'*********使用数据库判断在线名单以及在线人数
'*********系统支持:asp+access,在windows2000+iis5上测试通过
'*********login.asp*********
<%@LANGUAGE="VBSCRIPT"%>
<%'ON ERROR RESUME NEXT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
.
.
.
'登录判断,略
.
.
'登录成功
session("Name")=rs("M_Name")
rs.Close
strSQL="Update B_MEMBER Set M_IsOnLine=yes,M_LastTime=now() Where M_Name='"+strName+"'"
rs.Open strSQL,myconn
response.redirect"xxx.asp"
SET RS=NOTHING
MYCONN.CLOSE
SET MYCONN=NOTHING
%>
'*********refresh.asp*******
<%@LANGUAGE="VBSCRIPT"%>
<%'ON ERROR RESUME NEXT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
<html>
<head>
<meta http-equiv="refresh" content="60,url=refresh.asp">
</head>
.
.
.
'设置5分钟未动作的id为offline,rers1为前面打开的连接,读取id。
set rers2=Server.CreateObject("ADODB.RECORDSET")
For ipage= 1 to onlinenum
if minute(now)-minute(rers1("M_LastTime"))>5 or minute(now)-minute(rers1("M_LastTime"))<0 then
reSQL="Update B_MEMBER Set M_IsOnLine=no Where M_ID="&rers1("M_ID")
rers2.Open reSQL,myconn
end if
rers1.MoveNext
if rers1.EOF then exit for
next
myconn.close
SET MYCONN=NOTHING
%>
'*************main.asp,主文件中判断关闭,防止直接关闭浏览器产生错误
<body ONUNLOAD="javascript:window.open ('close.asp', 'newwindow', 'height=20, width=20, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no')" >
'*************close.asp,同上**********
<%@LANGUAGE=VBSCRIPT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
<%ON ERROR RESUME NEXT
SET RSCLO=SERVER.CreateObject("ADODB.RECORDSET")
STRCLO="UPDATE B_MEMBER SET M_ISONLINE=NO,M_ATAREA='不在线' WHERE M_NAME='"&SESSION("NAME")&"'"
RSCLO.Open STRCLO,MYCONN
RSCLO.Close
MYCONN.CLOSE
SET RSCLOSE=NOTHING
SET MYCONN=NOTHING
Response.Write err.description
%>
<script language="JavaScript">
window.close();
</script>
基本就是这样。
'*********系统支持:asp+access,在windows2000+iis5上测试通过
'*********login.asp*********
<%@LANGUAGE="VBSCRIPT"%>
<%'ON ERROR RESUME NEXT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
.
.
.
'登录判断,略
.
.
'登录成功
session("Name")=rs("M_Name")
rs.Close
strSQL="Update B_MEMBER Set M_IsOnLine=yes,M_LastTime=now() Where M_Name='"+strName+"'"
rs.Open strSQL,myconn
response.redirect"xxx.asp"
SET RS=NOTHING
MYCONN.CLOSE
SET MYCONN=NOTHING
%>
'*********refresh.asp*******
<%@LANGUAGE="VBSCRIPT"%>
<%'ON ERROR RESUME NEXT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
<html>
<head>
<meta http-equiv="refresh" content="60,url=refresh.asp">
</head>
.
.
.
'设置5分钟未动作的id为offline,rers1为前面打开的连接,读取id。
set rers2=Server.CreateObject("ADODB.RECORDSET")
For ipage= 1 to onlinenum
if minute(now)-minute(rers1("M_LastTime"))>5 or minute(now)-minute(rers1("M_LastTime"))<0 then
reSQL="Update B_MEMBER Set M_IsOnLine=no Where M_ID="&rers1("M_ID")
rers2.Open reSQL,myconn
end if
rers1.MoveNext
if rers1.EOF then exit for
next
myconn.close
SET MYCONN=NOTHING
%>
'*************main.asp,主文件中判断关闭,防止直接关闭浏览器产生错误
<body ONUNLOAD="javascript:window.open ('close.asp', 'newwindow', 'height=20, width=20, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no')" >
'*************close.asp,同上**********
<%@LANGUAGE=VBSCRIPT%>
<!--#INCLUDE FILE="../FPDB/CONNECTION.ASP"-->
<%ON ERROR RESUME NEXT
SET RSCLO=SERVER.CreateObject("ADODB.RECORDSET")
STRCLO="UPDATE B_MEMBER SET M_ISONLINE=NO,M_ATAREA='不在线' WHERE M_NAME='"&SESSION("NAME")&"'"
RSCLO.Open STRCLO,MYCONN
RSCLO.Close
MYCONN.CLOSE
SET RSCLOSE=NOTHING
SET MYCONN=NOTHING
Response.Write err.description
%>
<script language="JavaScript">
window.close();
</script>
基本就是这样。
- 没有相关文章
- 没有评论