Sieu ho tro Homepage
Forum Home Forum Home > Information Technology > The programming language > Active Server Pages (ASP) VBScript
  New Posts New Posts RSS Feed - ?m s? ngu?i online
  FAQ FAQ  Forum Search   Events   Register Register  Login Login


?m s? ngu?i online

 Post Reply Post Reply
Author
Message
guest View Drop Down
Guest
Guest
Avatar

Joined: 16 November 2007
Location: Vietnam
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote guest Quote  Post ReplyReply Direct Link To This Post Topic: ?m s? ngu?i online
    Posted: 26 February 2008 at 15:32
<%
Sub LogActiveUser
            Dim strActiveUserList
            Dim intUserStart, intUserEnd
            Dim strUser
            Dim strDate

            strActiveUserList = Application("ActiveUserList")

        If Instr(1, strActiveUserList, Session.SessionID) > 0 Then
            Application.Lock
            intUserStart = Instr(1, strActiveUserList, Session.SessionID)
            intUserEnd = Instr(intUserStart, strActiveUserList, "|")
            strUser = Mid(strActiveUserList, intUserStart, intUserEnd - intUserStart)
            strActiveUserList = Replace(strActiveUserList, strUser, Session.SessionID & ":" & Now())
            Application("ActiveUserList") = strActiveUserList
            Application.UnLock
        Else
            Application.Lock
            Application("ActiveUsers") = CInt(Application("ActiveUsers")) + 1
            Application("ActiveUserList") = Application("ActiveUserList") & Session.SessionID & ":" & Now() & "|"
            Application.UnLock
        End If
End Sub
%>
<%
Sub ActiveUserCleanup
Dim ix
Dim intUsers
Dim strActiveUserList
Dim aActiveUsers
Dim intActiveUserCleanupTime
Dim intActiveUserTimeout

intActiveUserCleanupTime = 1 'In minutes, how often should the ActiveUserList be cleaned up.
intActiveUserTimeout = 20 'In minutes, how long before a User is considered Inactive and is deleted from ActiveUserList

If Application("ActiveUserList") = "" Then Exit Sub

If DateDiff("n", Application("ActiveUsersLastCleanup"), Now()) > intActiveUserCleanupTime Then

    Application.Lock
    Application("ActiveUsersLastCleanup") = Now()
    Application.Unlock

    intUsers = 0
    strActiveUserList = Application("ActiveUserList")
    strActiveUserList = Left(strActiveUserList, Len(strActiveUserList) - 1)

    aActiveUsers = Split(strActiveUserList, "|")

For ix = 0 To UBound(aActiveUsers)
    If DateDiff("n", Mid(aActiveUsers(ix), Instr(1, aActiveUsers(ix), ":") + 1, Len(aActiveUsers(ix))), Now()) > intActiveUserTimeout Then
        aActiveUsers(ix) = "XXXX"
    Else
        intUsers = intUsers + 1
    End If
Next

strActiveUserList = Join(aActiveUsers, "|") & "|"
strActiveUserList = Replace(strActiveUserList, "XXXX|", "")

    Application.Lock
    Application("ActiveUserList") = strActiveUserList
    Application("ActiveUsers") = intUsers
    Application.UnLock

End If

End Sub
%>
<%

Call LogActiveUser()
Call ActiveUserCleanup()

Response.Write "Hiện có: <font color=""#FF0000"">" & Application("ActiveUsers") & "</font> khách."

%>




Back to Top
Sponsored Links


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.

This page was generated in 0.156 seconds.
bao ky nam , Thuoc nam ky dieu
C?a thp ch?ng chy,cua thep chong chay,c?a ch?ng chy,cua chong chay,c?a nh?a abs,cua nhua abs,c?a abs,cua abs,cua thep van go,c?a thp vn g?,c?a thp an ton,cua thep an toan,c?a cu?n ch?ng chy,cua cuon chong chay,c?a g? ch?ng chy,cua go chong chay,c?a tru?t t? d?ng,cua truot tu dong,c?a knh ch?ng chy,cua kinh chong chay