Helpful Information
 
 
Category: vBulletin.org Forum
[RELEASE vB2.0] Max Users History

v2 - Updated to use no extra queries :D

Okay, seeing as people asked for this, here it is. It's very, very simple in its operation.

It just keeps a record of the most number of visitors at any one time, and displays it on the main forums page. The time/date format will obey the system you specified in the control panel, including timezone offsets.

http://kier.3dfrontier.com/vbhacks/maxonline.gif

Installation is very simple. Simply download the attachment to this message, unzip it and upload install_maxonline.php to your forums/admin folder, then open that page in a web browser and carefully follow the instructions it will give you.

The script will only call an extra query if the number of online users is greater than that the previous record. The records are stored in a new template called 'MAXONLINERECORDS', which is automatically installed for you with the supplied script.

The install script has an upgrade option that will clean up the mess left by the original version...

You can see it working online at snyx' forum here (http://www.form-kaos.com/forum/)

Extraordinarily Important Info
When you upgrade your board to a new version of vBulletin, you must modify the install script that you run like this:

Find $DB_site->query("DELETE FROM template WHERE templatesetid=-1 AND title<>'options'"); and replace it with $DB_site->query("DELETE FROM template WHERE templatesetid=-1 AND title<>'options' AND title<>'MAXONLINERECORDS'"); If you do not do this, your records will be destroyed when you upgrade.

Looks like my +++++ing paied off for once! LOL!
Great hack man!

thbththt Mine already worked on 2.0 two hours ago you just had to go put in a fancy install routine and screenshot :)


btw, I dig your who posted hack!

Great hack man as always!

Sorry, when I put this together you hadn't said whether yours worked in 2.0 or not...

Ah well, now there's a choice of two :)

When I posted I didn't even know if it worked in 1.x or not :) Sometimes I hack blindly at work. That's OK, I see how it works now.. if you put an install routine and a screenshot on your hack you get 5-stars eh?

heheh :P take care

Kier. I don't know what we'd do without you

Thanks

It works and was very simple to install.

Awesome hack, you've been on a roll Kier!

It's been installed here (http://www.systemlogic.net/boards) if anybody wants to see more example sites.

Something I had planned on adding to vb at one point but never got around to it..

cool - is beta 4 gonna have this in it ?

where does the max users retrieve the figure from ? and will upgrading to beta 4 etc be okay ?

The hack creates a new table with a single entry that is queried when you load index.php. It compared the value in the table with the $totalonline variable, and if $totalonline is larger than the value in the table, the table is updated.

- the above info is now incorrect -

To upgrade your board, you must modify the upgrade script as shown above, and modify the new index.php

Originally posted by eva2000
cool - is beta 4 gonna have this in it ? No..

sweet mod, thank you.

Originally posted by Kier
The hack creates a new table with a single entry that is queried when you load index.php. It compared the value in the table with the $totalonline variable, and if $totalonline is larger than the value in the table, the table is updated.

Upgrading to beta 4 will be fine, just modify index.php again after the upgrade. thanks :D

nice, took about 30 seconds to install ! your hacks rule :)

Stop downloading this one for a little while.

I've devised a way to do this without an extra query on index.php... give me 20 mins and i'll post the new version.

Kier i have been wondering how hard an average would be. Ok i am going to write my thoughts on how to do this as it is a stat i would love.

First, it is only going to work on a site relativly busy, ie with a hit on forumhome every few minutes or so.

So:

i) person hits forumhome (after installing hack).

it records:
i) number of users online
ii) that this is the 1st reporting
iii) the time reported
iv) the average online.

now it needs a couple of times for this to work so lets say we have this:

users: 10, 15, 23, 23, 8
id: 1, 2, 3, 4, 5
minutes (clearly the difference in times): 5, 2, 5, 2 (obviously we can't count the last one)
so to do average we do:

(10x5 + 2x15 + 5x23 + 2x23) / 4

which gives the average.

So any ideas on how this could be done. I would think what you want is a running total that an average can still be generated from but it is too late for me to think of a way to do that.

thinking...

say you kept a running count of total minutes and also the average so at any point you can say:

43,343 minutes of statstics with the current average online as 8.4 users.

Now, if you have the next stat of 3 minutes at 20 users then you can do:

((43,343 x 8.4) + (3 x 20) )/ 43,346

and that should give you back the new average and new total, so the process just continues. Make any sense? server intensive? would require two queries me thinks for every loading of forumhome, once to get the stat and second to update it. Wondering if it would perhaps be better to have a cron script run every 5 minutes say that does the updating and then just pull the results (which you might be able to do without another query if you can on your first bit) and that does it?

Originally posted by Kier
Stop downloading this one for a little while.

I've devised a way to do this without an extra query on index.php... give me 20 mins and i'll post the new version. Cool - let us know when you are ready! This is pretty sweet :D

New version available :)

Interesting way of doing it..

Originally posted by freddie
Interesting way of doing it.. Well a boring way just wouldn't be fun would it? ;)

Great hack..... and I like the way you cache the value inside of a template in the new version, that's a great way to avoid the overhead of another query :)

thanks

the instructions of the upgrade said to change this code

"$checkmax = $DB_site->query_first("...etc"

for this one

"$maxrecords = explode(" ", $templatecache...etc"

in forumhome_loggedinusers template. thats index.php... detail. thanks again.

Oops, you're right :)

I've altered the file with the new instructions.

installed the new version and it was painless to do :)

i really have to put my head in my php/mysql books so i can start to contribute :D

Really you don't even need the books...

I found that even after I bought a PHP book I still use the online manuals more often then the book.

Originally posted by leadZERO
I found that even after I bought a PHP book I still use the online manuals more often then the book. Very true. In fact, I taught myself the basics of PHP by hacking the nuts off a copy of vBLite.

if you download a style youll have to delete the MAXONLINERECORDS template first, or when you upload it youll have the old record.

No, you won't. MAXONLINERECORDS is stored in template set -1, so you can't download it.

ohhh ok thanks. and what about using another style in the board? will it save the right record?

am i the only person who cant do it ? :(

The template is called from templatesetid -1, which is not affected by custom styles. It will work regardless of which style you or your users choose.

Please read the Extraordinarily Important Info which I have just posted in the first post of this thread... if you don't, your records will be destroyed when you upgrade to a new version of vBulletin.

Little tip for optimization, if you want to include it on a later version...

UPDATE template SET template="$totalonline ".time()." WHERE title='MAXONLINERECORDS' AND SUBSTR(template, 0, INSTR(template, '0')-1) < '$totalonline'

And you can remove MAXONLINERECORDS from the cache. Actually, the string functions might slow it down even more, oh well...

Well, guess what everyone.

I forgot to add the code to the upgrade script when upgrading from b3 to b4....:o

Its ok I lost the records, but now it show the max # as the current number..... what do i do?
sorry for being so dumb.

This hack is no longer necessary as it is built into vBulletin 2.0 Beta 4 and higher.

Originally posted by wluke
This hack is no longer necessary as it is built into vBulletin 2.0 Beta 4 and higher.

I installed this hack on Beta 3. Then I upgraded from Beta 3 to Beta 5. Now where this hack used to be, all I see is this:

Currently Active Users:
There are currently 4 member(s) and 0 guest(s) on the boards.
Our record is Array users, at .

So how to I get the built-in version to work now?

you have to revert to original templates, the ones that affect this.

I tried to install the hack in our BB. But I received the following message...

Fatal error: Call to undefined function: cpheader() in /disk2s6/data/www/www.vapochill.com/forum/admin/install_maxonline.php on line 4

Hardware: Sun Enterprise 250
OS: Solaris 8
Webserver: Apache 1.3.14 / PHP 4.0.3pl1
vBulletin: 1.1.4

What am I doing wrong?

/Per

Originally posted by per
I tried to install the hack in our BB. But I received the following message...

Fatal error: Call to undefined function: cpheader() in /disk2s6/data/www/www.vapochill.com/forum/admin/install_maxonline.php on line 4

Hardware: Sun Enterprise 250
OS: Solaris 8
Webserver: Apache 1.3.14 / PHP 4.0.3pl1
vBulletin: 1.1.4

What am I doing wrong?

/Per

Using the wrong version of vBulletin. Upgrade to 2.0

This hack is no longer necessary as it is installed into 2.0 by default.










privacy (GDPR)