PDA

View Full Version : [RELEASE vB2.0] Max Users History


Kier
Tue 13th Mar '01, 5:49pm
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.

snyx
Tue 13th Mar '01, 5:52pm
Looks like my bitching paied off for once! LOL!
Great hack man!

Overgrow
Tue 13th Mar '01, 6:13pm
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!

conan
Tue 13th Mar '01, 6:17pm
Great hack man as always!

Kier
Tue 13th Mar '01, 6:17pm
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 :)

Overgrow
Tue 13th Mar '01, 6:32pm
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

mrlister
Tue 13th Mar '01, 6:36pm
Kier. I don't know what we'd do without you

Shak
Tue 13th Mar '01, 6:51pm
Thanks

It works and was very simple to install.

SystemLogic
Tue 13th Mar '01, 7:05pm
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.

Freddie Bingham
Tue 13th Mar '01, 7:37pm
Something I had planned on adding to vb at one point but never got around to it..

Kier
Tue 13th Mar '01, 9:19pm
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

Freddie Bingham
Tue 13th Mar '01, 9:34pm
Originally posted by eva2000
cool - is beta 4 gonna have this in it ? No..

Dream
Tue 13th Mar '01, 9:55pm
sweet mod, thank you.

chrispadfield
Tue 13th Mar '01, 10:15pm
nice, took about 30 seconds to install ! your hacks rule :)

Kier
Tue 13th Mar '01, 10:26pm
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.

chrispadfield
Tue 13th Mar '01, 10:40pm
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.

chrispadfield
Tue 13th Mar '01, 10:45pm
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?

Me2Be
Tue 13th Mar '01, 11:16pm
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

Kier
Wed 14th Mar '01, 12:41am
New version available :)

Freddie Bingham
Wed 14th Mar '01, 12:47am
Interesting way of doing it..

Kier
Wed 14th Mar '01, 12:50am
Originally posted by freddie
Interesting way of doing it.. Well a boring way just wouldn't be fun would it? ;)

Chris Schreiber
Wed 14th Mar '01, 12:54am
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 :)

Dream
Wed 14th Mar '01, 1:09am
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.

Kier
Wed 14th Mar '01, 1:22am
Oops, you're right :)

I've altered the file with the new instructions.

leadZERO
Wed 14th Mar '01, 5:38am
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.

Kier
Wed 14th Mar '01, 9:05am
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.

Dream
Wed 14th Mar '01, 11:10am
if you download a style youll have to delete the MAXONLINERECORDS template first, or when you upload it youll have the old record.

Kier
Wed 14th Mar '01, 11:30am
No, you won't. MAXONLINERECORDS is stored in template set -1, so you can't download it.

Dream
Wed 14th Mar '01, 11:40am
ohhh ok thanks. and what about using another style in the board? will it save the right record?

veedee
Wed 14th Mar '01, 11:42am
am i the only person who cant do it ? :(

Kier
Wed 14th Mar '01, 12:07pm
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.

Kier
Wed 14th Mar '01, 7:59pm
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.

Stallion
Tue 20th Mar '01, 7:41pm
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...

auto
Mon 9th Apr '01, 8:22pm
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.

Wayne Luke
Mon 9th Apr '01, 11:19pm
This hack is no longer necessary as it is built into vBulletin 2.0 Beta 4 and higher.

JJR512
Fri 13th Apr '01, 1:50pm
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?

auto
Fri 13th Apr '01, 2:07pm
you have to revert to original templates, the ones that affect this.

per
Tue 17th Apr '01, 10:29am
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

Wayne Luke
Tue 17th Apr '01, 11:01am
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

Wayne Luke
Tue 17th Apr '01, 11:02am
This hack is no longer necessary as it is installed into 2.0 by default.