Firefox PHP

<b>[code] Who's Online</b>

Posted by <b>Vulpes</b> 
Re: [code] Who's Online
August 20, 2002 08:16PM
Thanks Sab :)

I saw that you mentioned the "edit post" bug in another topic.
Hopefully vulpes will see one :)
Checked and working on Dev-3.4
October 15, 2002 06:19PM

let me just ask you a little question:

Whos online, is checked for IP adresses ? i mean, the number of diferent IP adresses is the number of people online ?
I´m asking that, because sometimes i have lots of people in my forum with the same IP (i.e. students loging from a University, companies, etc).

Is there any way to check whos online from usernames ?

best regards ! great hack man !

Vip Money

Re: Checked and working on Dev-3.4
October 16, 2002 01:32AM
yes, the ip has to be unique. It is not needed to be, find a variable you want (like username) and stick it in instead of ip, you dont even have to change anything, pretty much, just input needs to be changed.

Re: [code] Who's Online
October 23, 2002 06:31PM
Don't know what I have done but I followed Curious Cat's advice, made a couple of cosmetic changes, and for some reason which ever browser I am in shows ONLY that person as being logged in. In otherwords, it never shows any other person(s) and/or guest(s) being logged it.

Other wise looks/works good.

Any advice? Note, I am maybe at best and "advanced" newbie with PHP. I understand conceptually but not as well from a practic standpoint.

Thanks for your help all.

- Brian
Re: [code] Who's Online
November 02, 2002 02:38PM
I created one based on the userid, because if you base it on the username (or $author for that matter) a user changes his/her name, he/she'll show up twice in the list.

Re: [code] Who's Online
February 19, 2003 09:53PM
"shows ONLY that person as being logged in. In otherwords, it never shows any other person(s) and/or guest(s) being logged it."

I also got the same results. I installed this honestly minutes ago and haven't looked too deeply into it just yet - unfortunately no one else has posted the answer for me already ;)

GHXC
alright, alright, i see how it is
February 20, 2003 12:41AM
my problem was simply two computers w/ the same IP (coming from the same company) that were of course replacing themselves. I suppose I would've figured that out if I had read ALL the posts a bit better!

:)

GHXC
Re: [code] Who's Online
February 20, 2003 02:39AM
Hello,

In the script "Who' S Online" which functions very well at home
I do not have the function which I see on this forum, I am explained:

When the name of the person is shown, one can click above to have his profile, how to establish this link?

Thank you :)
hah, i'm with you on this one too
February 20, 2003 09:36PM
For me, my name will show up when I'm on the board without a link UNLESS I am logged in. When I log in my name is linked to my profile.

Looking over the code, this makes sense. It is written so the "who's online" feature will work for users that post without logins and therefore have no profiles to link to. If you are you are not logged onto the board, it still picks up your name from the cookie, but it has no way of knowing whether or not you have an account. I might throw in a few lines so it includes the userid in the cookie, but right now I got some other things going on. If I change it up, I'll be sure to post my modifications here.

GHXC
Anonymous User
Re: [code] Who's Online
February 25, 2003 11:01PM
I don't like this mod.

Re: hah, i'm with you on this one too
March 13, 2003 04:06PM
how can I display the current users name just like at the top of this page?

eg:
Welcome, "User"
(With it linking to the persons profile too)

im kinda lost :(

any help?

::Gonzo::



Post Edited (03-13-03 09:08)
Re: [code] Who's Online
April 09, 2003 06:50AM
is there any simple way to enable linking to user's profiles from within whoisonline.php ?
Anonymous User
Re: [code] Who's Online
April 25, 2003 01:28PM
Great MOD,

Great install document, curious_cat. Perhaphs you should add a comment on STEP 2 like.

STEP 2.
Using phpmyadmin ran the following:

CREATE TABLE whosonline (
ip char(15) NOT NULL default '',
ts timestamp(14) NOT NULL,
username char(255) NOT NULL default '',
forum char(250) NOT NULL default '',
PRIMARY KEY (ip),
KEY ts (ts),
KEY forum (forum)
) TYPE=MyISAM;

INSERT INTO whosonline VALUES ('record', 20011118030340, '1', 'Whatever');

If you don´t use phpmyadmin, make this:

* Connect to mysql server
host# mysql -h <host> -u root -p

* Select the correct database
mysql> USE <your_database_name_for_Phorum>

* Crate the new table for MOD whosonline
CREATE TABLE whosonline (
ip char(15) NOT NULL default '',
ts timestamp(14) NOT NULL,
username char(255) NOT NULL default '',
forum char(250) NOT NULL default '',
PRIMARY KEY (ip),
KEY ts (ts),
KEY forum (forum)
) TYPE=MyISAM;

* Insert a record
INSERT INTO whosonline VALUES ('record', 20011118030340, '1', 'Whatever');

Working fine on my Forum.

Regards,

Jesús
Portuguese MArio
Re: &lt;b&gt;[code] Who's Online&lt;/b&gt;
January 06, 2004 11:45PM
Does it works on 3.4.6 ?
yep does it work with 3.4.6 ???
Yes it works with Phorùm 3.4.6.......Very good job !!!!!!!
Re: <b>[code] Who's Online</b>
January 27, 2004 05:56PM
Does it works with Mysql 4.0.17 ?

Thanks.



Post Edited (01-27-04 10:56)
Anonymous User
Re: &lt;b&gt;[code] Who's Online&lt;/b&gt;
January 27, 2004 09:18PM
why should it not?
mysql4.0 is just an upgrade to 3.23.x, so this should run smoothly.

I checked this out and for my taste this is a bit too lenghty way to archive something quite small so i made one myself.

First you need to make a changes to your forums_auth table (forums might be different in your setup but _auth will stand)

i did this by using mysql commandline utility.

ALTER TABLE forums_auth ADD seen int(15) not nulld default 0

If you are using myadmin or similar, you just enter one field (int(15)) more into the forums_auth table.

Next, we need to update this lastseen field *each* time user is either logged on OR is downloading a page. Best and obvious way is ofcourse to include this functionality in the header.php. In top of the header.php is following code:

if ( !defined( "_COMMON_PHP" ) ) return;

Just *after* but before closing ?> tag, add following code snippet:

$SQL = "UPDATE ".$PHORUM['auth_table']." SET seen=".time()." WHERE id=".$phorum_user['id'];
if ( ($phorum_user['id'])>0 ){
$q2 = new query($DB);
$q2 -> query($DB,$SQL);
}

Ok, when this is done, we have working Last Seen field in our database.

My site design is pretty much stock phorum and i didnt really put effort into integrating the data into the layout so i went the easy way: I will put the output of online users into footer.php

So, somewhere in your footer.php, put following code:

$sql = "select id,name,username,seen FROM ".$PHORUM['auth_table']." WHERE seen>=(unix_timestamp()-900)";
$q->query($DB,$sql);
while ($myrow=$q->getrow()) {
$id= $myrow['id'];
$name= $myrow['name'];
printf('<a href="profile.php?id=%s" class="onlinelist">%s|</a>',$id,$name);
}


So, basicly now we have an output from a script that prints *logged in* users who have been loading a page in last 15 minutes. If you want to change this value, change the number 900. Which is seconds, 15*60 == 900.

And remember, all code allways has to be inside <?PHP and ?> tags

You can see this "mod" running live on phorum 3.4.6 (It should work also in older versions) at [www.fi-reggae.com]
Okay, but wat is the best way to put it in the header ? I've got some problems with that
Sorry, you do not have permission to post/reply in this forum.