Author |
Topic |
|
wii
Free ASP Hosts Moderator
Denmark
2632 Posts |
Posted - 22 January 2004 : 03:39:12
|
I use the below code to show active user count in my header, but could we fix it, so users donīt have to refresh before actually seeing the correct number?
I mean, if you visit the forum and there are 6 users online (according to the active user count in the default.asp page - which counts correctly), it will show only 5 at the top using the below code, after refreshing the page, it will show the correct number 6.
'### ACTIVE USER COUNT - OJM ADDED ### intTotalActiveMembers = 0 intTotalActiveGuests = 0 intTotalActiveUsers = 0
'## Ls3k - Before we can do anything we need to get rid of those slackers who have left ;) deleteInactiveUsers()
'## Ls3k - Get counts strSql = "SELECT COUNT(AU_IP) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID = -1" set rs = my_conn.execute (strSql) intTotalActiveGuests = rs("CNT") rs.close set rs = nothing
strSql = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID <> -1" set rs = my_conn.execute (strSql) intTotalActiveMembers = rs("CNT") rs.close set rs = nothing
intTotalActiveUsers = intTotalActiveMembers + intTotalActiveGuests '### ACTIVE USER COUNT - OJM ADDED ### |
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 22 January 2004 : 09:59:53
|
Is this code run before the ActiveUserTracker sub? If so, you have to change it so that the ActiveUserTracker sub is run before the code used to count the active users. |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
|
|
wii
Free ASP Hosts Moderator
Denmark
2632 Posts |
Posted - 22 January 2004 : 10:23:36
|
Ok, Havenīt thought of that approach. I will try this...
Btw, the problem with the count is in all forums I have seen so far that have this feature, so it may not be that simple to fix.
I have the above code at the top of my inc_header file, then further down I have the ActiveUserTracker sub. |
|
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 22 January 2004 : 10:48:31
|
I cannot say anything about that, but I have a similar feature on my site and it counts visitors accurately.
If you move the ActiveUserTracker sub so that it comes before the counting code (or moves the counting code after the ActiveUserTracker sub), it will count visitors correctly. It does on my website. |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
|
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
Posted - 02 April 2004 : 06:53:45
|
Just wondered how you would actually display the active users using this code, if that makes sense. Usually you'd have some formatting etc.........
Would like this feature myself, so your help would be appreciated! |
*If Knowledge is Power, and Power Corrupts, what hope is there for Mankind * |
|
|
masterao
Senior Member
Sweden
1678 Posts |
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
Posted - 02 April 2004 : 17:40:12
|
Oh yes, I do have Active Users Mod installed ~ I just thought that the code above would need to be 'called' in some way so that the active users online are displayed with formatting, etc.
Thanks for that though ~ I've managed to get it working myself, but my only problem is when I have the Members Online displayed in inc_header as well as the active users panel turned on on default.asp, Members names are shown twice in the panel. Don't suppose you'd know how to fix that would you? |
*If Knowledge is Power, and Power Corrupts, what hope is there for Mankind * |
|
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 02 April 2004 : 18:04:47
|
Oh, then it shouldn't be a problem.
If you post a link to a text-version of your inc_header.asp, I'll take a look at it. |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
Edited by - masterao on 02 April 2004 18:05:21 |
|
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 03 April 2004 : 04:57:21
|
The code that posted will only show the number of members and guests online, not the names of them. Your code will show the names, and as you are using the same variable-names here as in the AU panel, they will be doubled.
Depending on what you want to do, you have a couple of alternatives:
If you want to show online member names in the header, you must rename the variables used in inc_online_members.asp. The variables you need to change are intTotalActiveUsers, intActiveMembers, intActiveAnonMembers, and intActiveGuests.
If you only want to list the count of members online, use Wii's code above.
If you want to do something else, then you must explain what you want to display. |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
|
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
Posted - 03 April 2004 : 19:17:49
|
Hi masterao,
Well, I tried changing all occurences of those variables in inc_online_members.asp, but it ended up showing 'None' all the time. Would you be willing to show me specifically where to change them?
Here's my inc_online_members.asp - if you could point to the particular ones I need to change, that would be most helpful!
bolOverride = chkAUPermissions(strAUAnonOverride)
bolPanel = chkAUPermissions(strAUPAllow)
bolAUPage = chkAUPermissions(strAUAllow)
'## Ls3k - Before we can do anything we need to get rid of those slackers who have left ;)
deleteInactiveUsers()
'## Ls3k - Lest first deal with members logged in - for them we need to join with the members table.
intTotalActiveUsers = 0
intActiveMembers = 0
intActiveAnonMembers = 0
intActiveGuests = 0
strSql = "SELECT ME.MEMBER_ID, ME.M_NAME, ME.M_AUHIDE, ME.M_LEVEL " & _
"FROM " & strTablePrefix & "ACTIVE_USERS AU, " & strMemberTablePrefix & "MEMBERS ME " & _
"WHERE AU.MEMBER_ID = ME.MEMBER_ID"
set rsAM = my_conn.execute (strSql)
if rsAM.EOF or rsAM.BOF then
rsAM.close
set rsAM = nothing
else
do until rsAM.EOF
intTotalActiveUsers = intTotalActiveUsers + 1
if (rsAM("M_AUHIDE")="1" or isNull(rsAM("M_AUHIDE"))) or strAUAnon = 0 or bolOverride then
intActiveMembers = intActiveMembers + 1
if strActiveMemberList <> "" then
strActiveMemberList = strActiveMemberList & " | " & VBNewLine
end if
if strUseExtendedProfile then
strActiveMemberList = strActiveMemberList & "<a href=""pop_profile.asp?mode=display&id="& rsAM("MEMBER_ID") & """>"
else
strActiveMemberList = strActiveMemberList & "<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & rsAM("MEMBER_ID") & "')"">"
end if
strActiveMemberList = strActiveMemberList & "<font color=""" & strDefaultFontColor & """>"
if rsAM("M_LEVEL") = 2 then
strActiveMemberList = strActiveMemberList & "<font color=""" & strAUModColor & """>"
elseif rsAM("M_LEVEL") = 3 then
strActiveMemberList = strActiveMemberList & "<font color=""" & strAUAdminColor & """>"
end if
strActiveMemberList = strActiveMemberList & rsAM("M_NAME")
if rsAM("M_LEVEL") = 2 or rsAM("M_LEVEL") = 3 then
strActiveMemberList = strActiveMemberList & "</font>"
end if
strActiveMemberList = strActiveMemberList & "</font>"
strActiveMemberList = strActiveMemberList & "</a>"
else
intActiveAnonMembers = intActiveAnonMembers + 1
end if
rsAM.movenext
loop
rsAM.close
set rsAM = nothing
end if
'## Ls3k - Now lets count those peskey guests.
strSql = "SELECT COUNT(AU_IP) AS CNT FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID = -1"
set rs = my_conn.execute (strSql)
intActiveGuests = rs("CNT")
rs.close
set rs = nothing
intTotalActiveUsers = intTotalActiveUsers + intActiveGuests
response.write " <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & VBNewLine & _
" " & fLang(strLangMOD_Ls3kAU_00100) & ": "
if intActiveMembers > 0 then
response.write strActiveMemberList & VBNewLine
else
response.write fLang(strLangMod_Ls3kAU_00110) & VBNewLine
end if
%>
|
*If Knowledge is Power, and Power Corrupts, what hope is there for Mankind * |
|
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 04 April 2004 : 05:28:50
|
Im a little pressed with time at the moment (not at home right now), but when I get home later today I'll take a look. |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
|
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
Posted - 04 April 2004 : 06:39:51
|
Many thanks, masterao..... |
*If Knowledge is Power, and Power Corrupts, what hope is there for Mankind * |
|
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 05 April 2004 : 16:40:41
|
I've done the necessary changes, and this should work for you as it worked ok on my test-forum.
If I understood you correctly, you are only going to show members online with this code? The code you supplied also counts the guests, which isn't necessary in that case. I have removed the guest-counting code, but if you want to display the number of guests online as well, then let me know .
Get code here |
Jan =========== FR Portal Forums | Active Users 4.0.20 Mod |
|
|
Martha2Mary
Junior Member
New Zealand
250 Posts |
Posted - 05 April 2004 : 18:04:25
|
That is exactly what I wanted, Jan. Thank you very much for taking your time to do this for me |
*If Knowledge is Power, and Power Corrupts, what hope is there for Mankind * |
|
|
masterao
Senior Member
Sweden
1678 Posts |
|
|
Topic |
|