[asp]統計線上人數情況

來源:互聯網
上載者:User

以前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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.