PDA

View Full Version : 24h Visitors' Statistics (members and guests)


Olsufr
02-12-2005, 10:00 PM
A very simple display of statistics of all visitors (members and guests) who have visited the forum last 24 hours.

It displays the statistics on Forum Home in the section of "Users online":

example: " Total users last 24h: 2692 (members : 741, guests : 1951) "

There is no additional SQL query.

----------------------------------

Installation (there is in attached file)

Step 1

In index.php

Find:

$show['loggedinusers'] = true;
}
else
{
$show['loggedinusers'] = false;
}


And insert this code before it:

// ############# Oleg Subel - 24h visitors' statistics ###############

$datecut24 = TIMENOW - 86400;
$numberregistered24 = 0;
$numberguest24 = 0;

$forumusers24 = $DB_site->query("
SELECT userid, lastactivity FROM " . TABLE_PREFIX . "session
WHERE lastactivity > $datecut24
");

$time24 = TIMENOW ;
while ($loggedin24 = $DB_site->fetch_array($forumusers24))
{
$userid24 = $loggedin24['userid'];
if (!$userid24)
{ // Guest
$numberguest24++;
}
else
{
$numberregistered24++;
}
if ($loggedin24['lastactivity'] < $time24)
{
$time24 = $loggedin24['lastactivity'];
}
}
$time24 = TIMENOW - $time24;
$time24 = floor($time24 / 3600) + (($time24 % 3600) ? 1 : 0);

$numbertotal24 = $numberregistered24 + $numberguest24;

// memory saving
unset($loggedin24);
$DB_site->free_result($forumusers24);
// ############# End of 24h visitors' statistics ###############


Step 2

In includes/cron/cleanup.php
and in includes/cron/cleanup2.php

Find:

$DB_site->query("
### Delete stale sessions ###
DELETE FROM " . TABLE_PREFIX . "session
WHERE lastactivity < " . intval(TIMENOW - $vboptions['cookietimeout'])
);

And replace with this code:

$DB_site->query("
### Delete stale sessions ###
DELETE FROM " . TABLE_PREFIX . "session
WHERE lastactivity < " . intval(TIMENOW - 86400)
); // modified by Oleg S.for 24h visitors' statistics


Step 3

Add new phrase

Phrase Type: GLOBAL
Varname: active_users_24h
Text: Total users last {1}h

Step 4

FORUMHOME template modification

Find:

<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>


and replace with:

<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
&nbsp;&nbsp;&nbsp;&nbsp;<phrase 1="$time24">$vbphrase[active_users_24h]</phrase>: $numbertotal24 (<phrase 1="$numberregistered24" 2="$numberguest24">$vbphrase[x_members_and_y_guests]</phrase>)
</td>


END

ericgtr
02-13-2005, 03:23 PM
Just so you know, i've already released one myself here https://vborg.vbsupport.ru/showthread.php?s=&threadid=72972 :)

ALcorn
02-13-2005, 03:29 PM
Just so you know, i've already released one myself here https://vborg.vbsupport.ru/showthread.php?s=&threadid=72972 :)
Your hack is about the number of newly registered users, not about the stats of registered users AND guests visited the forum in last 24 hours ;)

Olsufr
02-13-2005, 03:30 PM
ericgtr, my hack counts, shows members and guests statistics.
It is different.

ericgtr
02-13-2005, 03:31 PM
Your hack is about the number of newly registered users, not about the stats of registered users AND guests visited the forum in last 24 hours ;)
Right you are. I was checking this over and it's pretty slick, nice mod! :)

James T Brock
02-13-2005, 04:11 PM
Nice mod. I have the other one installed but I like the ability for this one to count guess users as well.

Harley77
02-14-2005, 03:06 PM
Having an issue, It only seems to show users from the last 1h. It reads on my forum home
Total users last 1h: 49 (34 members and 15 guests)

This number has been fluxuating up and down as time passes. Where do I need to look to fix this?

KanyeWest
02-14-2005, 05:44 PM
i likey i really likey i installed

update justinstalled took nomore than 6 minutes

KanyeWest
02-14-2005, 05:53 PM
Having an issue, It only seems to show users from the last 1h. It reads on my forum home
Total users last 1h: 49 (34 members and 15 guests)

This number has been fluxuating up and down as time passes. Where do I need to look to fix this?
i think i found problem

Step 3. ################################################## ################

Add new phrase

Phrase Type: GLOBAL
Varname: active_users_24h
Text: Total users last {1}h

it should be 24 but waht do i no im not a coder

Olsufr
02-14-2005, 08:41 PM
KanyeWest, the code is right.
My hack shows visitor's statistics and indicates real time for it.
For example, if there are sessions in your SESSIONS table in DB only for 1 hour,
this hack shows as you say: Total users last 1h: 49 (34 members and 15 guests)It is start only.

Later your statistics will be collected more and more hour by hour.
And after 24 hours hack will show statistics for 24 hours (no more).

i think i found problem

Step 3. ################################################## ################

Add new phrase

Phrase Type: GLOBAL
Varname: active_users_24h
Text: Total users last {1}h

it should be 24 but waht do i no im not a coderThere is no error.

JC
02-15-2005, 03:57 AM
Will someone please take a look at my site, for some reason it's only half working, viewed here www.707imports.com/vb3 - I don't get it. I've tried this like 10x's! :( I'd be willing to let someone login and fix it haha.

user : tester
pw : pwforpaul

JC
02-15-2005, 04:06 AM
I actually installed a different version of this hack and it worked, yay! Thanks anyways!

Rids
02-15-2005, 11:49 AM
Nice mod - thanks for sharing :)

yinyang
02-15-2005, 06:11 PM
Just so you know, i've already released one myself here https://vborg.vbsupport.ru/showthread.php?s=&threadid=72972 :)

your hack is not the same. yours shows who registered that day and the total number of members.

this hack shows who Visited in the last 24 hours. For example, yours doesn't pick up guests.

Elfo King
02-15-2005, 07:53 PM
Having an issue, It only seems to show users from the last 1h. It reads on my forum home
Total users last 1h: 49 (34 members and 15 guests)

This number has been fluxuating up and down as time passes. Where do I need to look to fix this?

same problem.....only guest e member for only 1 hour!
not for 24......solution ??

Olsufr
02-15-2005, 11:00 PM
Elfo King, there is the answer:
Your statistics must be collected.

the code is right.
My hack shows visitor's statistics and indicates real time for it.
For example, if there are sessions in your SESSIONS table in DB only for 1 hour,
this hack shows as you say:
Total users last 1h: 49 (34 members and 15 guests)
It is start only.

Later your statistics will be collected more and more hour by hour.
And after 24 hours hack will show statistics for 24 hours (no more).

Elfo King
02-16-2005, 04:59 PM
Ehm, sorry....
Another question:
Where i can change the statistics for collect more hours?
I need to change the value of the Hourly Cleanup #1 and/or Hourly Cleanup #2 ?

Thx :p

Rids
02-17-2005, 12:10 AM
I've had it installed for over 36 hours now and its still showing figures for 1h. In fact the figures seem to be all over the place:

Total users last 1h: 109 (94 members and 15 guests)

10 minutes later ...

Total users last 1h: 200 (181 members and 19 guests)

The actual number of active members that have been to the site all day is only 70 so where it is getting these figures from I have no idea. Could it be counting each and every visit by each member maybe?

neocorteqz
02-17-2005, 02:07 AM
I've had it installed for over 36 hours now and its stillshowing figures for 1h. In fact the figures seem to be all over theplace:

Total users last 1h: 109 (94 members and 15 guests)

10 minutes later ...

Total users last 1h: 200 (181 members and 19 guests)

The actual number of active members that have been to the site all dayis only 70 so where it is getting these figures from I have no idea.Could it be counting each and every visit by each member maybe?Including Revisits from members, At least i think, as there reallyisn't a way of counting without checking against IP address.

Olsufr
02-17-2005, 01:05 PM
Another question:
Where i can change the statistics for collect more hours?
I need to change the value of the Hourly Cleanup #1 and/or Hourly Cleanup #2 ?
Yes. To have statistics more than during 24 hours
you have to change this in my hack
(in includes/cron/cleanup.php
and includes/cron/cleanup2.php):
$DB_site->query("
### Delete stale sessions ###
DELETE FROM " . TABLE_PREFIX . "session
WHERE lastactivity < " . intval(TIMENOW - 86400)
); // modified by Oleg S.for 24h visitors' statistics

to this:
$DB_site->query("
### Delete stale sessions ###
DELETE FROM " . TABLE_PREFIX . "session
WHERE lastactivity < " . intval(TIMENOW - 1*24*60*60)
); // modified by Oleg S.for 24h visitors' statistics where instead of 1 you can write another number (number of days of statistics)




and in index.php instead of this (lines of hack):

// ############# Oleg Subel - 24h visitors' statistics ###############

$datecut24 = TIMENOW - 86400;

write:
// ############# Oleg Subel - 24h visitors' statistics ###############

$datecut24 = TIMENOW - 1*24*60*60;where instead of 1 you can write another number (number of days of statistics)

kall
02-18-2005, 02:48 AM
Yup, same here.

http://forums.nzboards.com

I think I saw 2 hours once, but that was it.

*edit* Ahh, I was a moron.

You have to edit both of the /includes/cron/ files (as per the instructions), or it doesn't work.

TTG
02-22-2005, 08:14 PM
Tried this hack .. idea is good but every time a member comes back to the main page the stats jump up in number = to the number of members / guests viewing main page.

Every main page refresh adds the number of existing viewers to the exisiting total.

Omega Prime
02-23-2005, 12:55 PM
Guess this didn't work out...

I added this hack, but like most peple here, I noticed how the member stats kept rising whenever anyone (whether it was someone who visited just now or 10min ago) would add to the stats. After removing it from forumhome (since I was gonna see about working with it later) and adjusting the clock on the server, it shows over 2000 members online! It caused the CPU to max out to 100%, to the point where I had to close the forum and delete the sessions. It seems things are up and running again, but now it shows "Most users ever online was 2142, Today at 09:21 AM.", as well as showing members who are online when they shouldn't be online (within showthread) =/

Olsufr
02-23-2005, 10:59 PM
TTG, it is using standard (for vB3) online system. I didn't change anyone here.

whelck
03-16-2005, 01:25 AM
Whatever this is doing isn't right. It says in the past 7 hours I've had 4974 members and 576 guests. I don't even have that many registered members.

*uninstalls*

xtreme-mobile
03-18-2005, 06:55 PM
am i doing something wrong?

mine just shows like this.... (see screen shot

it just shows amount of threads and thats about it

Neutral Singh
03-19-2005, 01:13 AM
Thank You, I was looking for this modification for a long long time !! :)

KanyeWest
03-19-2005, 05:10 AM
this hack i still use today from first realease its awseom

Total users last 24h: 542 (345 members and 197 guests)

www.idenonfire.com/forums/ still usin proudly

Neutral Singh
04-14-2005, 01:17 PM
Activity during last 24 hour(s): 891 (74 members and 817 guests and [ARG:3 UNDEFINED] spiders)

Ever since i installed that hack to show web spiders on who is online... the above error is bold is showing up. I think in the following code another query about the spiders has to added... Olsufr, it would be wonderful if you could provide the code for adding the count for spiders too... best regards.


// ############# Oleg Subel - 24h visitors' statistics ###############

$datecut24 = TIMENOW - 86400;
$numberregistered24 = 0;
$numberguest24 = 0;

$forumusers24 = $DB_site->query("
SELECT userid, lastactivity FROM " . TABLE_PREFIX . "session
WHERE lastactivity > $datecut24
");

$time24 = TIMENOW ;
while ($loggedin24 = $DB_site->fetch_array($forumusers24))
{
$userid24 = $loggedin24['userid'];
if (!$userid24)
{ // Guest
$numberguest24++;
}
else
{
$numberregistered24++;
}
if ($loggedin24['lastactivity'] < $time24)
{
$time24 = $loggedin24['lastactivity'];
}
}
$time24 = TIMENOW - $time24;
$time24 = floor($time24 / 3600) + (($time24 % 3600) ? 1 : 0);

$numbertotal24 = $numberregistered24 + $numberguest24;

// memory saving
unset($loggedin24);
$DB_site->free_result($forumusers24);
// ############# End of 24h visitors' statistics ###############

eva01_
04-14-2005, 01:29 PM
to get rid of that bold error you have to check your file changes again and make sure you did the template changes as well

bmroyer
04-27-2005, 08:19 AM
Step 3. ################################################## ################

Add new phrase

Phrase Type: GLOBAL
Varname: active_users_24h
Text: Total users last {1}h

Where do I do that at? which file?

ALcorn
04-27-2005, 08:23 AM
Where do I do that at? which file?
Do it in phrase manager in your Admin Control Panel

bmroyer
04-27-2005, 08:33 AM
thanks much

bmroyer
04-27-2005, 11:09 PM
I just had a database error, I didn't think it was caused by this mod until now. My site just came back up, and I noticed that the users within 24 hours reset and is now at 1 hour.

Here is the error i got:

<html><head><title> Database Error</title><style type="text/css"><!--.error { font: 11px tahoma, verdana, arial, sans-serif; }--></style></head><body></table></td></tr></table></form><blockquote><p class="error">&nbsp;</p><p class="error"><b>There seems to have been a slight problem with the database.</b><br />Please try again by pressing the <a href="javascript:window.location=window.location;">refresh</a> button in your browser.</p><p class="error">An E-Mail has been dispatched to our <a href="mailto:bmroyer@gmail.com">Technical Staff</a>, who you can also contact if the problem persists.</p><p class="error">We apologise for any inconvenience.</p></blockquote><!--Database error in vBulletin :Link-ID == false, connect failedmysql error: mysql error number: 0Date: Wednesday 27th of April 2005 04:27:45 PMScript: http://www.unknownwriters.net/index.phpReferer: IP Address: 68.83.38.219 --></body></html>

ALcorn
04-28-2005, 07:51 AM
I just had a database error, I didn't think it was caused by this mod until now. My site just came back up, and I noticed that the users within 24 hours reset and is now at 1 hour.This error is not related to this mod, but I have also noticed that the 24H Visitors stats are reset when the database is out, so let's say "it's by design". :)

bmroyer
04-28-2005, 12:34 PM
This error is not related to this mod, but I have also noticed that the 24H Visitors stats are reset when the database is out, so let's say "it's by design". :)

so then what is the problem? I had the old vbadvanced, and deleted the cms index, then replaced with the new version of the cms index..would that be why?

ALcorn
04-28-2005, 01:15 PM
so then what is the problem? I had the old vbadvanced, and deleted the cms index, then replaced with the new version of the cms index..would that be why?
Again, your problem is related to the connectivity to your MySQL database and not to this mod, so we could't help you in this topic. Sorry.

arob42
05-05-2005, 08:07 PM
Can this hack be modified to report unique visits by members and guests? If not, any pointers before I go in and attempt the modification myself? Sure appreciate your help. Thanks.

--Robert

DesiFlavour
01-06-2006, 12:15 AM
The instructions on the initial post by the author and the ones in the attached text file are different, which ones am i suppose to follow? I've followed the ones from the attached file only and the mod doesn't seem right... figures its showing simply cannot be accurate.

Help please? :(

photongbic
03-29-2006, 11:23 AM
Will this work with vB 3.5.4?

jerx
05-10-2006, 05:40 PM
I don' t think it works with 3.5.4. Is anyone able to port this hack to 3.5.4? I am especially interested in the guest count.

MikeLR
09-15-2006, 08:43 PM
Is there allready a version for 3.6.x? I'm interested in the counting of the guests. :)

wezoo
10-27-2006, 10:18 AM
i would like to count guests too !!!!

|Jordan|
01-20-2007, 05:36 PM
I'm having some problems with this hack.

It displays the statistics fine, but it doesnt reset after 24 hours. It just shows 24hours and the numbers keep going up. I did all the file edits/uploads.

Mysticales
02-18-2007, 03:52 AM
Hrm I wonder.. you see we had this on 3.0 and I know we got it working on 3.5.4 as well.. even external JS showing on html.. but issues is this.. if you get flooded with users.. it made your forums crawl to a stop. (2000+ users that is) which show up as a guest on forums..

Anyone have any new word on this? Seems the way we have it isnt caching anymore like it used to... Im willing to work with anyone who KNOWS javascript, external stats posting and understand how this loads.. which case we could work together to make it not only cache the data it gets.. but works right on external displaying.

Realbigsource
03-02-2008, 05:39 PM
Do you guys have any mod like this that I can just upload with product manager, I dont want to mess with these code and mess up my forum.?