PDA

View Full Version : Users Online displayed on main page AND on individual forum indexes?


KuraFire
09-21-2001, 09:28 AM
How can I make it so that, at the top of each forum index (where you would see an announcement - right above there, for instance, OR all the way at the bottom, but pref. at the top) it shows all the users and the number of guests that are currently browsing a thread on THAT particular forum?

This is done in UBB right here:

http://www.fantasy-freak.com/cgi-bin/ubb/ultimatebb.cgi <- normal "Who's Online" at the top;

http://www.fantasy-freak.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=1 <- Who's Online at the top that applies to that forum ONLY!

I'm sorry if this has been hacked in the past already, I couldn't find it so I figured I'd just ask it.

Help greatly appreciated! ^_^

Inzagi
09-21-2001, 10:36 AM
I also would like to know wheater there is a hack like this.
I think it is very useful.

Inzagi
09-21-2001, 07:30 PM
bump

KuraFire
09-24-2001, 07:17 AM
and another bump... :/

KuraFire
09-25-2001, 11:22 AM
*bump*

More and more and more people are now requesting this hack on my board.. :/

Admin
09-25-2001, 12:26 PM
Basically you need to move the whole blcok of:
if ($displayloggedin and $permissions['canwhosonline']) {
$datecut=time()-$cookietimeout;
...
eval("\$loggedinusers = \"".gettemplate('forumhome_loggedinusers')."\";");
}
from index.php to somewhere in global.php.

Then you might be able to use $totalonline in any of your templates.

KuraFire
09-25-2001, 12:40 PM
If we put it in a thread, will it then also show all the people browsing THAT thread?

btw, thanks a lot for the hack! :up:
(edit: :up: is what I have on my board as the code for the Thumbs up smilie :))

* 1337Devil = happy ^_^

Admin
09-25-2001, 12:44 PM
No, it will always show the number of members (guest and members) that are right now somewhere on your board.

KuraFire
09-25-2001, 01:13 PM
ow..

can't it be done so that it shows the amount of members and guests one -that- particular forum?

(in case you haven't yet, check out the Fantasy Freak links, they show this exactly)

Neo
09-25-2001, 01:30 PM
umm i would like this hack but the code up there does not help me really.. i am new to this can you tell:cool:

KuraFire
09-25-2001, 01:36 PM
I think you'd want to wait on the improvement/more specific hack, too, Neogeniseva. And I'm sure that FF will be more than willing to specify how to do it.


For the current one, though, I can tell you how to implement it. Just copy that code, open up the global.php file, paste it somewhere in the middle. Myself, I placed it below the line "// ############# START SESSIONS ##############" and above this line:

// figure out the chosen style settings

Then upload global.php to your forum, and go to edit a template (forumdisplay is a good idea :)). Add in the line $totalonline somewhere in the template (anywhere) and it will show the "Who's Online" bit..

Neo
09-25-2001, 01:51 PM
thanks i will try it out

KuraFire
09-25-2001, 01:58 PM
no problem, remember that it as of yet DOESN'T show users online per specific forum, it just copies the "Who's Online" entries from Forumhome. :)

KuraFire
09-26-2001, 07:58 AM
*bump* in the hope FireFly notices that I would want it to show users on that particular forum, not global online users ^_^

Kodo
09-26-2001, 06:20 PM
I too would like to see this :D

Inzagi
09-26-2001, 10:00 PM
I am at least pretty sure, that it is possible to do with vB.
See the example:
http://www.boardy.de/forumdisplay.php3?forumid=11

KuraFire
09-27-2001, 06:21 AM
I suspected no less. But -how- ? :/

DarkReaper
09-27-2001, 11:00 AM
You have to make a modified function in online.php that calls itself to check for particular instances of where user[info] == browsingforum1 or something like that. That's a very rough idea of how to do it, but maybe it will help.

KuraFire
09-27-2001, 11:19 AM
Thanks :)

Perhaps not of much use to me (my hacking skillz = 0 :)) but any potential hacker who would make this hack now has a guideline (in case he/she needed it) :)

Admin
09-27-2001, 12:31 PM
$usershere=$DB_site->query("SELECT COUNT(*) FROM session WHERE location LIKE 'forumid=$forumid'");
That's basically it.

Add it to your forumdisplay.php file right before the dooutput, and use $usershere[count] to display the number.

The query is OK, but the whole thing isn't really tested right now.

KuraFire
09-27-2001, 12:40 PM
Uhm.. okay, I put that in the forumdisplay.php right at the end _before_ the dooutput line, but what it displays is this:

Resource id #19

And nothing else... Erm?

Admin
09-27-2001, 12:42 PM
LOL sorry about that, use this:
$usershere=$DB_site->query_first("SELECT COUNT(*) FROM session WHERE location LIKE 'forumid=$forumid'");

KuraFire
09-27-2001, 12:44 PM
Interesting. Now it says:



Array



and again, nothing else. :D

KuraFire
09-27-2001, 12:45 PM
Do I still have to put that stuff above in global.php as well? Cos last time I did that, I got an error (in global.php) whenever I wanted to load a page, so that didn't work :(

Admin
09-27-2001, 12:47 PM
Are you sure you're using $usershere[count] and not just $usershere ???

Admin
09-27-2001, 12:47 PM
Leave that thing along for a sec, I can't deal with both issues at the same time.

KuraFire
09-27-2001, 01:17 PM
Okay I put

$usershere[count]


in the template, but now nothing shows up. :/

Oh well, I'll hear about it once you have enough to etc. :)

Admin
09-27-2001, 01:22 PM
In forumdisplay.php
$usershere=$DB_site->query_first("SELECT COUNT(*) AS count FROM session WHERE location LIKE '%forumid=$forumid%'");

eval("dooutput(\"".gettemplate('forumdisplay')."\");");
Now use $usershere[count].

WORKS

Freddie Bingham
09-27-2001, 01:28 PM
Remember you are going to do a full table scan on the session table every time someone opens up forumdisplay.php, adding an index won't help you. Session resides in memory but it still takes cycles to do that and if you have 200 entries in session than you could have 100+ users doing this at the same time.

KuraFire
09-27-2001, 01:36 PM
FF: yup, it works, shows up # of people on that particular forum. Awesome, thanks! :up:


Freddie: so like, for a n00b like me, what does that mean? :D

Inzagi
09-27-2001, 03:14 PM
@FireFly
Do you also know a way it shows exactly which users are online like on the first forum page and not online the amount of users?

KuraFire
09-27-2001, 04:04 PM
Also, I noticed that this doesn't include people who are browsing a thread on forum X, it only shows the amount of people that are browsing the Forum X index. :(

We're a demanding sod, ain't we? ;)

Freddie Bingham
09-27-2001, 04:43 PM
It means watch your server load rise.

KuraFire
09-27-2001, 05:03 PM
Ah. Will it also increase bandwidth usage, or ONLY server load?

Inzagi
09-29-2001, 09:14 PM
*bump again*
still many questions open

ethank
10-01-2001, 03:45 PM
I was thinking of doing something with a heap table that kept track of people using something like map coordinates. Not too much server load, and it could work for the rest of the site.

And it would be much nicer than using the location field. You just have a lookup table that cross referenced the "coordinate" to its actual location, and each page would lookup who else has that coordinate to do a "who's on this page with you"

Still thinking this one through.

Ethan

Inzagi
10-04-2001, 09:05 AM
WOW,
sounds good!

Please let me now if you have achieved anythink !
Thank you!

KuraFire
10-04-2001, 09:46 AM
Indeed, that would be great. :)

ethank
10-05-2001, 03:16 AM
Starting this one tommorow. Still trying to figure out the best way to do it simply. Will keep you all posted.

Ethan

ethank
10-05-2001, 10:27 PM
Progress:

I put the heap table for location:

CREATE TABLE location (
userid smallint(5) unsigned NOT NULL default '0',
x char(255) default NULL,
y char(255) default NULL,
lastactivity int(10) unsigned NOT NULL default '0',
sessionhash char(32) NOT NULL default '',
KEY userid (userid)
) TYPE=HEAP;

Then I created a function called updateLocation(x,y)

I put that on all the pages and areas I wanted to track. Some of the info looks like this:


userid x y lastvisit
2861 newthread 86 1002323693
3430 showthread 9797 1002323781
3575 calendar 10 1002323641
3593 showthread 4250 1002323519


I haven't yet done the lookup for column X, and I'm still tweaking how this will work.

Some things I have planned for this include a map drawn using GD to see where people are clustered. Right now I added a feature "Users reading this thread" up.

Inzagi
10-08-2001, 08:23 AM
I am really looking forward this to be published !!
Will be a great hack I suppose !
Please keep on posting the progress you make,
it's just wonderful!

Inzagi
10-10-2001, 07:41 PM
Any news yet?

ethank
10-10-2001, 08:13 PM
Originally posted by Inzagi
Any news yet?

Still working on it. Its been busy this week with other things.

EThan