Author |
Topic |
aecio
Junior Member
Brazil
120 Posts |
Posted - 07 December 2001 : 21:51:35
|
I propose a different approach to the Active Users Mod. In this mod, no database is used. Instead, since we are talking ASP here, I test how many active sessions on the server at any given moment. This is accomplished with two small modifications of two files:
First, add code to the Global.asa file in the root of your site, as such:
In the SUB Session_OnStart section, add:
Application.Lock Application("ActiveUsers") = Application("ActiveUsers") + 1 Application.Unlock
And on the SUB Session_OnEnd section, add:
Application.Lock Application("ActiveUsers") = Application("ActiveUsers") - 1 Application.Unlock
Second, modify the default.asp file and add a line to report the Active Users at the current moment. I inserted this code in line 800, right after this code:
Response.Write "</font>" & vbNewline & _ " </td>" & vbNewline & _ " </tr>" & vbNewline
Here is the code do insert:
'###### START OF ACTIVE USERS by Aecio Lemos ##### Response.Write " <tr>" & vbNewline & _ " <td bgcolor=""" & strForumCellColor & """ colspan=""" & sGetColspan(6,5) &_ """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & vbNewline Response.Write "*There is/are currently " & Application("ActiveUsers") & " user(s) online." Response.Write "</font>" & vbNewline & _ " </td>" & vbNewline & _ " </tr>" & vbNewline '##### END OF ACTIVE USERS by Aecio Lemos #####
That's it! Working example: http://www.xsaude.com.br/ and click on English. Check the stats on the All Forums page.
Cheers! |
|
Kenno
Average Member
Cambodia
846 Posts |
Posted - 07 December 2001 : 22:29:08
|
That works, but it lacks the feature that tell who those active users really are. For example, the one that we've had so far will tell the name of the members, or just guest.
In these days of computer viruses, asking if you may put your disk into someone's computer is the technological equivalent of unsafe sex. |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 07 December 2001 : 22:41:02
|
we've been using something similiar for quite awhile now on this site:
http://forum.snitz.com (near the top)
Right now it says:
Active Users: 28 Visits Today: 409 Highest Active Users: 770 |
|
|
aecio
Junior Member
Brazil
120 Posts |
Posted - 07 December 2001 : 22:43:52
|
Oh well,
As they say, Geniuses Think Alike! Hahahaha
Yes, it is a very simple alternative, but easy to use.
Cheers! |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 08 December 2001 : 00:39:55
|
quote:
That works, but it lacks the feature that tell who those active users really are. For example, the one that we've had so far will tell the name of the members, or just guest.
In these days of computer viruses, asking if you may put your disk into someone's computer is the technological equivalent of unsafe sex.
in sql, can we use a sql active session instead? then we know who are active. however, access do not support this and it won't show where they are.
|
|
|
bjlt
Senior Member
1144 Posts |
Posted - 08 December 2001 : 00:44:27
|
quote:
we've been using something similiar for quite awhile now on this site:
http://forum.snitz.com (near the top)
Right now it says:
Active Users: 28 Visits Today: 409 Highest Active Users: 770
then how do you get visits today and highest AU? I'm not good at asa file and like to follow the Snitz standard.
thanks.
|
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 08 December 2001 : 07:44:24
|
Here is the contents of the global.asa file:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart Application("ActiveUsers") = 0 Application("HighestToDate") = 0 Application("TodaysDate") = Date Application("VisitorsToday") = 0 End Sub Sub Session_OnStart Session.Timeout = 20 '## minutes Session("Start") = Now Application.Lock Application("ActiveUsers") = Application("ActiveUsers") + 1 if Application("ActiveUsers") > Application("HighestToDate") then Application("HighestToDate") = Application("HighestToDate") + 1 end if if Application("TodaysDate") = Date then Application("VisitorsToday") = Application("VisitorsToday") + 1 else Application("TodaysDate") = Date Application("VisitorsToday") = 1 end if Application.UnLock End Sub Sub Session_OnEnd ' Decrease the active visitors count when the session ends. Application.Lock Application("ActiveUsers") = Application("ActiveUsers") - 1 Application.UnLock End Sub </SCRIPT>
Here is what the code looks like that is on the front page of this forum:
<% '## BEGIN Active Users CODE Response.Write " <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>Active Users: " & Application("ActiveUsers") & " Visits Today: " & Application("VisitorsToday") & "</font><br>" & vbCrLf Response.Write " <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>Highest Active Users: " & Application("HighestToDate") & " " & "</font><br>" & vbCrLf '## END Active Users CODE %> |
|
|
aecio
Junior Member
Brazil
120 Posts |
Posted - 08 December 2001 : 15:03:03
|
Yeah, this is definitely better than what I have. In fact, just implemented it :0)
There is another version of this somewhere (I'll try to find it) that even tells which page the users are on.
Cheers! |
|
|
jenljl
Starting Member
21 Posts |
Posted - 09 December 2001 : 02:25:35
|
quote:
There is another version of this somewhere (I'll try to find it) that even tells which page the users are on.
If you happen to find that, could you post it here? I'm interested in getting it.
|
|
|
Ez4arab
Junior Member
479 Posts |
Posted - 09 December 2001 : 05:13:27
|
i made file of global.asa and i post the below code in the inc_top.asp
also i made global.asa [READ - WRITE - EXECUTE - DELETE] but the # is not shown
Arabic snit fourm http://aljish.com.sa/jforum |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 09 December 2001 : 05:26:39
|
The global.asa file needs to be in your root web directory. |
|
|
Ez4arab
Junior Member
479 Posts |
Posted - 09 December 2001 : 06:31:15
|
i have file forum where my files there do you mean i make file name it (root) the i will put the global.asa in this file
Arabic snit fourm http://aljish.com.sa/jforum |
|
|
aecio
Junior Member
Brazil
120 Posts |
Posted - 09 December 2001 : 11:05:19
|
Hi aljish,
The global.asa file must be in the root of your site. The root is the top level directory. For example, on my server, I have
C:\Inetpub\wwwroot\
and that is where my site is. When I type www.mysite.com it will show what is in the wwwroot folder. The forum is below this:
C:\Inetpub\wwwroot\forum\
The global.asa needs to be in the top level, in this case the
C:\Inetpub\wwwroot\
If you put it anywhere else, the system will not find it or use it.
Cheers! |
|
|
SimonT
Junior Member
United Kingdom
202 Posts |
Posted - 08 February 2002 : 19:20:54
|
At my host they keep restarting the server maybe 2 or 3 times a week in the morning I see my nice stats then later they are all lost is there any way to have these stats loged in a database or txt file ? as I want to see if I can get my active usrer count over the 38 active users I once had
SimonT
I so wish I could code in ASP.. |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 08 February 2002 : 19:32:10
|
You can use the same concept as in Mod USER Log to write it to text file. But will require fully enabled FSO on the server
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
Raichelle
Junior Member
370 Posts |
Posted - 09 February 2002 : 11:52:44
|
I already have something else on my global.asa file for my flash chat how can i include that code richard posted for both my flash chat to work and also that showing? this is the code i have on global.asa now
<SCRIPT LANGUAGE=VBScript RUNAT=Server> Sub Session_OnStart 'Set session variable for virtual-directory test Session("ChatInitialised")=True End Sub
Sub Session_OnEnd Dim vChatName, vChatUsers, vChatMoods, vUserCount Dim vRoomNo Dim m, n vRoomNo = Session("RoomNo") vChatName = "" & Session("ChatName") If vChatName <> "" Then Application.Lock vUserCount = CLng(Application("UserCount" & vRoomNo)) If vUserCount < 2 Then vChatUsers = "" vChatMoods = "" vUserCount = 0 Else vChatUsers = Application("ChatUsers" & vRoomNo) vChatMoods = Application("ChatMoods" & vRoomNo) For n = 0 To vUserCount - 1 If vChatUsers(n) = vChatName Then For m = n To vUserCount - 2 vChatUsers(m) = vChatUsers(m+1) vChatMoods(m) = vChatMoods(m+1) Next vUserCount = vUserCount - 1 Redim Preserve vChatUsers(vUserCount) Redim Preserve vChatMoods(vUserCount) Exit For End If Next End If Application("ChatUsers" & vRoomNo) = vChatUsers Application("ChatMoods" & vRoomNo) = vChatMoods Application("UserCount" & vRoomNo) = vUserCount AddLineToChat vRoomNo, "**" & vChatName & " has left (timed out)**" Session("ChatName") = "" If vUserCount = 0 Then Application("ChatLines" & vRoomNo) = "" Application("ChatLineCount" & vRoomNo) = 0 Application("ChatMaxLines" & vRoomNo) = 0 End If Application.Unlock End If End Sub
Sub AddLineToChat (ByVal vRoomNo, ByVal vNewLine)
Dim vCurrentLine, vChatLines, vMaxLines
vCurrentLine = Application("ChatLineCount" & vRoomNo) vChatLines = Application("ChatLines" & vRoomNo) vMaxLines = Application("ChatMaxLines" & vRoomNo) vCurrentLine = vCurrentLine + 1 If vCurrentLine > vMaxLines Then vMaxLines = vMaxLines + 500 If vCurrentLine = 1 Then Redim vChatLines(vMaxLines) Else Redim Preserve vChatLines(vMaxLines) End If Application("ChatMaxLines" & vRoomNo) = vMaxLines End If vChatLines(vCurrentLine - 1) = vNewLine Application("ChatLines" & vRoomNo) = vChatLines Application("ChatLineCount" & vRoomNo) = vCurrentLine End Sub </SCRIPT>
|
|
|
Topic |
|