PDA

View Full Version : Logged in users optimization (1.0.1)


fury
12-27-2002, 10:00 PM
Note to users who have installed Xenon's Optimizing Forumhome v2.0 located here (http://www.vbulletin.org/hacks/index.php?s=&action=showhack&hackid=823) need not install this hack. Furthermore, should you wish to install that hack later on after installing this one, you will need to either uninstall it, or forego the section instructing you to modify the logged in users code.

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

This simple hack modifies the Logged in users list on the forumhome, reducing queries by one. This is done by knocking off the extra query for guest counting and instead changing the way the while loop that is used for the logged in users list works.

In other words, less queries = win. :)

Versions of vBulletin: 2.2.x
Tested on: 2.2.9
Modifications: File only (no database or template modifications)

Example: http://www.otcentral.com/forum/index.php
Except for the showing of one less query on the query count, you can see that the result is truly unnoticeable. Logged in users operates the same exact way as it does before the hack is made.

Although there's not much that can go wrong with this hack, support will be provided in this thread and by email. Preferrably thread in case someone else runs across the same problem. :)

Update: 12/29/2002 - 0:11

Version 1.0.1 released - Counter was still counting duplicate sessions but not displaying them.

JulianD
12-28-2002, 09:34 PM
nice hack. I'm going to test it on my local server :D

Xenon
12-28-2002, 09:39 PM
looks nice, but i think it could be buggy, because you've thrown out the DISTINCT selection, which wasn't there without reason i think ;).

But we'll see, it's a beta, maybe everything works correct and the distinct was just a devs paranoia ;)

fury
12-28-2002, 10:17 PM
DISTINCT is there to make sure no sessions get repeated in the logged in user list. I took that out because no matter how many guests would be there, it would only show up with the first. In its place I put a username token check to make sure the list doesn't already have the user in it.

NuclioN
12-29-2002, 12:42 AM
The number of users online on the index is after this mod not the same as the detaild list when you look at the locations and ip. On the index there were 20 and on the detailed list 13! So it looks there is a problem.

fury
12-29-2002, 02:48 AM
It seems to work fine on my board. Have you applied any other hacks that affect the logged in users part of your forumhome? Can I get a link to the board you installed it on?

fury
12-29-2002, 03:13 AM
Nevermind. I see the problem. The check which prevents duplicate sessions from showing is put outside of the registered user counter. The file is fixed, if you already installed this hack here is the code to move:

if (!substr_count($activeusers_bare,"|||".$username."|||")) {
REPLACE it with this
if (!substr_count($activeusers_bare,"|||".$loggedin['username']."|||")) {

and Move this just BELOW this line:
} else {
and ABOVE this line:
$numberregistered++;

Dean C
12-29-2002, 12:03 PM
Wow so we've found another way the vb dev's could reduce queries?

- miSt

fury
12-29-2002, 12:22 PM
Not quite yet

It appears for some mods and admins the dupe sessions are still counted and displayed.

Edit: I know what I did wrong. Thank god this is only a beta hack, i would've been dead after the first bug :D

Find this text (note: it's not its own line, there is text after it)

$activeusers_bare .= $username

Change it to this:

$activeusers_bare .= $loggedin['username']

Make sure there's still the . "|||"; after it.

Fixed the text file with the change, but didn't bother updating the version number. :D

fury
12-29-2002, 12:26 PM
Surely the vB devs would've thought of this for vB3, I think Kier said vB3's index.php is down to 8 queries... That's not bad considering all the info on it (number of users browsing each forum, last post title, etc)

fury
12-29-2002, 03:41 PM
LOL. I implemented the fix locally and fixed the text file here, but forgot to upload the damn thing to my site! http://www.otcentral.com/images/smilies/retard.gif

Lanigironu
12-29-2002, 06:32 PM
So is this working fine?

fury
12-29-2002, 06:34 PM
As far as I can tell, it's good now, really does function like the old currently active users list on the outside like it said originally :D

But still, to be on the safe side, keep a backup of your current index.php so you can revert in case something goes wrong. But I don't see why anything would, there are no template or DB modifications to do.

Lanigironu
12-29-2002, 06:37 PM
Ok, I'll try it out.

fury
12-29-2002, 06:38 PM
I'll be watching this thread :) Post if you notice any problems.

Lanigironu
12-29-2002, 06:45 PM
I don't think my queries dropped.

fury
12-29-2002, 06:47 PM
Do you have microstats installed, or $debug=1; in your config file to confirm this?

Try refreshing (when your session times out, a query is used to create another one, and then it goes back down one query)

Kars10
12-29-2002, 07:26 PM
Thanks Fury!!
It saves me one query!!
Works like a charm. :)

fury
12-29-2002, 07:28 PM
fury ;)

No problem, glad it works for you :D

Lanigironu
12-29-2002, 11:15 PM
I have Microstats installed, and my queries jumped from 35 to 38. I think I might've used the wrong file though. I think I used an index.php that didn't have the caching in it, so the queries rose because of it.

fury
12-29-2002, 11:22 PM
Woopsies. :o

Lanigironu
12-30-2002, 02:54 AM
Nope, I checked it. I used a slightly older index.php from when I first started playing around with the caching hack. I got it back to what it used to be, and it's back to 35. I didn't lose any queries with this hack.

nuno
12-30-2002, 03:09 AM
Nice job @fury, thanks :)

fury
12-30-2002, 01:40 PM
That can't be possible, if you did it right. My hack completely removes a $DB_site->query line related to the logged in users list. Would you feel comfortable sending me your index.php file at dennis@xibase.com so I can check it out?

Thanks, nuno :)

Chris M
12-30-2002, 05:43 PM
Looks good;)

Satan

fury
01-01-2003, 01:30 PM
I believe this hack's ready to come out of beta ;)

Should I just create a new thread or do I ask this one to be moved or what?

(heh, this is my first time ever releasing a hack on vb.org)

Kars10
01-01-2003, 04:03 PM
I think you can start a new Thread in Full Releases.
Put a link to this thread... ;)

Xenon
01-01-2003, 06:00 PM
depends on you :)
if you want i can move the thread to full releases, or you can just close the thread and create a new one in full releases.

just say what you prefer :)

blackice912
01-01-2003, 10:39 PM
Heck yeah, down by one query!

nuno
01-02-2003, 12:13 AM
@Xenon, me votes move :)

Xenon
01-02-2003, 01:54 PM
ok, i moved it, hope it's ok so :)

nuno
01-02-2003, 03:16 PM
thumbs up for Xenon :)

fury
01-02-2003, 06:28 PM
Thanks a bunch, Xenon :)

https://vborg.vbsupport.ru/

Xenon
01-02-2003, 06:37 PM
you're welcome :)

BlackDeath
01-03-2003, 04:48 AM
i think i will install this regardless but let me tell u the main reason why i think i like this hack. i have some users that like to piss me off when they don't agree w/ what is been done on the site. they use this script that creates multiple duplicate sessions from the same IP and it lags the server to a point that the site becomes inaccessible. will this prevent that from happening or just prevent it from displaying it??? my question is, does this hack block out multiple sessions from someone w/ the same IP?

fury
01-03-2003, 12:34 PM
No, it doesn't, it just doesn't count or show the duplicate sessions in the registered user list. Someone who has some experience hacking sessions.php could probably do something like that fairly easily though. The only way I know how adds an extra query to every page.

BlackDeath
01-03-2003, 11:51 PM
Originally posted by fury
No, it doesn't, it just doesn't count or show the duplicate sessions in the registered user list. Someone who has some experience hacking sessions.php could probably do something like that fairly easily though. The only way I know how adds an extra query to every page.

well i'd sure appreciate it if someone would make that hack for me. these people can cause the board to be inaccessible on a whim.

Aaron1
01-18-2003, 12:40 PM
It worked great with my 2.2.7 VB, aswell in combination with the Optimize Forumhome hack! 20 queries!

Alien
04-28-2003, 07:16 AM
So if I install this, and the optimize forumhome hacks both, neither do the exact same thing and become redundant eh? :)

-Jason

fury
04-28-2003, 11:04 AM
Unless I'm mistaken, the forumhome hack does not incorporate this feature; thus it will not be redundant to install them both.

Xenon
04-28-2003, 03:31 PM
fury, unfortunately you're wrong here.

version 2 of my forumhome optimization hack also incorparates this feature, because i rewrote the online users because of another problem i had.

that way it will be redundant, or even not possible, because the original query isn't there anymore..

fury
04-29-2003, 12:02 AM
OK, thanks for the correction. :)

Makes this thread kinda useless huh? :D

Xenon
04-29-2003, 04:13 PM
hmm, if anyone just wants to install that and no more optimizations, then he can use this (ok, i don't know why ;))

but as your thread was before the new version of mine, i'll let it up to you.

if you want to let it be here, it will.
if you want it removed, just tell me, i'll do for ya ;)

fury
04-29-2003, 04:18 PM
I think I'll edit the original post with the explanation and a link to the forumhome optimization hack, in case people who have already installed that happen upon this thread. ;)

Xenon
04-29-2003, 04:39 PM
okidokie :)

Alien
04-29-2003, 11:15 PM
Thanks for the help you two! :D

-Jason