[asp]統計在線人數情況
以前ASP版本的統計在線。因為是從以前的系統中提取出來的。使用的話要修改下。
?
If?Cbool(Application("MARKONLINE"))?=?True?Then?CheckOnline()
Function?CheckOnline()
????DIM?IP,rsPrv,Sql
????If?DBSTATE?=?False?Then?DbOpen()
????Set?rsPrv=Server.CreateObject("ADODB.Recordset")
????If?Session("UserName")?=?""?then
????????Sql="select?*?from?[Online]?where?SessionID='"&?Session.Sessionid?&"'"
????????rsPrv.Open?Sql,Conn,1,3
????????If?rsPrv.Eof?then
????????????rsPrv.AddNew
????????????rsPrv("SessionID")?=?Session.SessionID
????????????rsPrv("GroupChargeLv")?=?-1
????????????rsPrv("LastActTime")=Now()
????????????rsPrv("UserIP")?=?GetIP
????????????rsPrv("OnLineTime")?=?0
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????Else
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????????rsPrv("OnLineTime")?=?rsPrv("OnLineTime")?+?DateDiff("n",rsPrv("LastActTime"),Now())
????????????rsPrv("LastActTime")?=?Now()
????????End?If
????????rsPrv.Update
????????rsPrv.Close()
????????'response.Write?"notlogin"
????Else
????????'response.Write?"logined"
????????Sql="select?*?from?[Online]?where?UserName='"&?Session("UserName")?&"'"
????????rsPrv.Open?sql,Conn,1,3
????????If?rsPrv.Eof?then
????????????rsPrv.AddNew
????????????rsPrv("SessionID")?=?Session.SessionID
????????????rsPrv("UserName")?=?Session("UserName")
????????????rsPrv("GroupChargeLv")?=?Session("GroupChargeLv")
????????????rsPrv("LastActTime")?=?Now()
????????????rsPrv("OnLineTime")?=?0
????????????rsPrv("UserIP")=?GetIP
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????Else
????????????If?rsPrv("SessionID")?<>?Session.SessionID?And?Application("LoginSet")(1)?=?False?Then
????????????????Response.Write("<script>alert('該帳戶已在其他地方登陸,網站設置1個ID只能有1個登陸\n你可以稍候嘗試登陸。');location.href='LoginOut.asp'")
????????????????Response.End()
????????????End?If
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????????rsPrv("OnLineTime")?=?rsPrv("OnLineTime")?+?DateDiff("n",rsPrv("LastActTime"),Now())
????????????rsPrv("LastActTime")=Now()?
????????End?If
????????rsPrv.Update
????????rsPrv.Close()
????End?If
????
????If?DateDiff("s",Application("OnLineLastDelete"),Now())?>?Int(Application("DELETEONLINEDIFF"))?Then
????????Application.Lock()
????????????Application("OnLineLastDelete")?=?now
????????Application.UnLock()
????????Conn.ExeCute("delete?from?[Online]?where?datedIff('s',LastActTime,Now())>"&????Int(Application("CHECKONLINEDIFF")?&""))??'刪除x秒沒有活動的訪客
????End?If
????Set?rsPrv?=?Nothing
End?Function
Function?CheckOnline()
????DIM?IP,rsPrv,Sql
????If?DBSTATE?=?False?Then?DbOpen()
????Set?rsPrv=Server.CreateObject("ADODB.Recordset")
????If?Session("UserName")?=?""?then
????????Sql="select?*?from?[Online]?where?SessionID='"&?Session.Sessionid?&"'"
????????rsPrv.Open?Sql,Conn,1,3
????????If?rsPrv.Eof?then
????????????rsPrv.AddNew
????????????rsPrv("SessionID")?=?Session.SessionID
????????????rsPrv("GroupChargeLv")?=?-1
????????????rsPrv("LastActTime")=Now()
????????????rsPrv("UserIP")?=?GetIP
????????????rsPrv("OnLineTime")?=?0
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????Else
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????????rsPrv("OnLineTime")?=?rsPrv("OnLineTime")?+?DateDiff("n",rsPrv("LastActTime"),Now())
????????????rsPrv("LastActTime")?=?Now()
????????End?If
????????rsPrv.Update
????????rsPrv.Close()
????????'response.Write?"notlogin"
????Else
????????'response.Write?"logined"
????????Sql="select?*?from?[Online]?where?UserName='"&?Session("UserName")?&"'"
????????rsPrv.Open?sql,Conn,1,3
????????If?rsPrv.Eof?then
????????????rsPrv.AddNew
????????????rsPrv("SessionID")?=?Session.SessionID
????????????rsPrv("UserName")?=?Session("UserName")
????????????rsPrv("GroupChargeLv")?=?Session("GroupChargeLv")
????????????rsPrv("LastActTime")?=?Now()
????????????rsPrv("OnLineTime")?=?0
????????????rsPrv("UserIP")=?GetIP
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????Else
????????????If?rsPrv("SessionID")?<>?Session.SessionID?And?Application("LoginSet")(1)?=?False?Then
????????????????Response.Write("<script>alert('該帳戶已在其他地方登陸,網站設置1個ID只能有1個登陸\n你可以稍候嘗試登陸。');location.href='LoginOut.asp'")
????????????????Response.End()
????????????End?If
????????????rsPrv("UserWhere")?=?Request.ServerVariables("HTTP_REFERER")
????????????rsPrv("OnLineTime")?=?rsPrv("OnLineTime")?+?DateDiff("n",rsPrv("LastActTime"),Now())
????????????rsPrv("LastActTime")=Now()?
????????End?If
????????rsPrv.Update
????????rsPrv.Close()
????End?If
????
????If?DateDiff("s",Application("OnLineLastDelete"),Now())?>?Int(Application("DELETEONLINEDIFF"))?Then
????????Application.Lock()
????????????Application("OnLineLastDelete")?=?now
????????Application.UnLock()
????????Conn.ExeCute("delete?from?[Online]?where?datedIff('s',LastActTime,Now())>"&????Int(Application("CHECKONLINEDIFF")?&""))??'刪除x秒沒有活動的訪客
????End?If
????Set?rsPrv?=?Nothing
End?Function
?
posted on 2006-03-31 12:10 墮落的賣豬販 閱讀(...) 評論(...) 編輯 收藏