在线情况维护程序-趁NB论坛重新开发,先拿东西过来,别一会又关了

时间:2004年06月17日 00:38  标签: 原创技术 在线维护 asp

[原创]在线情况维护程序
\'====================================================================
\'=                   Copyright (c) 2003,NB联盟                      =
\'=                      All rights reserved.                        =
\'=------------------------------------------------------------------=
\'=                     文件名称:Online.asp                         =
\'=                     摘    要:在线情况维护文件                   =
\'=------------------------------------------------------------------=
\'=                     最后更新:eason007                           =
\'=                     最后日期:2004-03-31                         =
\'====================================================================
Option Explicit
Response.Buffer=True

Const TimeOver=20
Dim Conn
Dim Rs,SQL
Dim UserId,SessionId,IP
Dim Tag,Key

Set Rs=server.CreateObject("adodb.recordSet")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = "&Server.MapPath("Online.mdb")

Randomize Timer
Key = "NB" & (1+int(Rnd*1000000000))

Response.Cookies("Key").Path=""            \'this set cookies\'path
Response.Cookies("Key").Expires = DateAdd("n",TimeOver,Now())

Tag=0
UserId=12
\'UserId=Request.Cookies ("UserId")
If UserId="" Then UserId=0                \' 0=Guest
If Request.Cookies ("Key")="" Then
 Response.Cookies("Key")=Key
 SessionId=key
Else
 SessionId=Request.Cookies ("Key")
End If
If Request.ServerVariables("HTTP_X_ForWARDED_For")="" Then
    IP= Request.ServerVariables("REMOTE_ADDR")
Else
    IP=Request.ServerVariables("HTTP_X_ForWARDED_For")
End If

\'清理在线记录
\'....

SQL="select UserId,SessionId,IP from Online where IP=\'"&IP&"\' and UserId="&UserId&" and SessionId=\'"&SessionId&"\'"
Set Rs=Conn.Execute(SQL)
If Rs.EOF And Rs.BOF Then
    SQL="select UserId from Online where IP=\'"&IP&"\'"
    Set Rs=Conn.Execute(SQL)
    If Rs.EOF and Rs.BOF Then Tag=Tag+1
    SQL="select UserId from Online where UserId="&UserId
    Set Rs=Conn.Execute(SQL)
    If Rs.EOF and Rs.BOF Then Tag=Tag+3
    SQL="select UserId from Online where SessionId=\'"&SessionId&"\'"
    Set Rs=Conn.Execute(SQL)
    If Rs.EOF and Rs.BOF Then Tag=Tag+5
   
    Select Case Tag
    Case 0
        If UserId<>0 Then SQL="update online set ltime=\'"&now()&"\',SessionId=\'"&SessionId&"\',IP=\'"&IP&"\' where UserId="&UserId
    Case 1
        SQL="update online set IP=\'"&IP&"\' where UserId="&user&" and SessionId=\'"&SessionId&"\'"
    Case 3
        If UserId=0 Then
            SQL="insert into online (UserId,IP,SessionId) values ("&UserId&",\'"&IP&"\',\'"&SessionId&"\')"
        Else
            SQL="update online set UserId="&UserId&" where SessionId=\'"&SessionId&"\' and IP=\'"&IP&"\'"
        End If
    Case 5
        If UserId=0 Then
            SQL="insert into online (UserId,IP,SessionId) values ("&UserId&",\'"&IP&"\',\'"&SessionId&"\')"
        Else
            SQL="update online set SessionId=\'"&SessionId&"\',IP=\'"&IP&"\' where UserId="&UserId
        End If
    Case 4
        SQL="update online set IP=\'"&IP&"\',UserId="&UserId&" where SessionId="&SessionId
    Case 6
        If UserId=0 Then
            SQL="insert into online (UserId,IP,SessionId) values ("&UserId&",\'"&IP&"\',\'"&SessionId&"\')"
        Else
            SQL="update online set SessionId=\'"&SessionId&"\',IP=\'"&IP&"\' where UserId="&UserId
        End If
    Case 8
        SQL="insert into online (UserId,IP,SessionId) values ("&UserId&",\'"&IP&"\',\'"&SessionId&"\')"
    Case 9
        SQL="insert into online (UserId,IP,SessionId) values ("&UserId&",\'"&IP&"\',\'"&SessionId&"\')"   
    End Select
   
Else
    SQL="update online set ltime=\'"&now()&"\' where IP=\'"&IP&"\' and UserId="&UserId&" and SessionId=\'"&SessionId&"\'"
End If
\'Response.Write SQL&"

"
Conn.Execute(SQL)

SQL="select UserId,IP,SessionId from online"
Set Rs=Conn.Execute(SQL)
Do While Not rs.eof
    Response.Write rs(0)&"---->"
    Response.Write rs(1)&"---->"
    Response.Write rs(2)&"---->
"
    rs.movenext
Loop

相关文章:
0条评论(Comments) 订阅该Blog下的评论RSS
本文还没有评论,来给楼主说几句吧...
发表评论
正在加载...
搜索更多
文章导读
最新评论
我的豆瓣秀
RSS订阅
抓虾
Rojo
google reader
netvibes
my yahoo
newsgator
bloglines
鲜果
哪吒
有道
QQ邮箱
九点