UBB.Dev
Posted By: ericgtr Online Status - 06/25/2003 2:37 AM
Is there a mod that will show an Online or Offline status under a users avatar or username? I had a user ask me about this and did some digging here but didn't see anything but thouth I would ask.
Posted By: msula Re: Online Status - 06/25/2003 2:45 AM
Hmm.. come to think of it, I don't think I've seen a hack for this, at least not in recent times. I would be interested in something like this as well
Posted By: JoshPet Re: Online Status - 06/25/2003 3:32 AM
I've thought about it.

Nearest I can figure is you'd have to add a third table to the query where it grabs the posts and users - have it also query the online table and then join them.



Haven't had time to play with it to see if I can pull it off without stressing things.

A nice substituition is the who's online mod that displays the user's names at the top of the screen on every page.
Posted By: Gardener Re: Online Status - 06/25/2003 11:26 PM
Yeah, I just saw the same thing on fudforum and thought it would be a nice hack for threads.

One way to not increase the load would be to add a field to the users table that says if they are online or not. Might be a bit tricky to make it update users who are not online though. =]
Posted By: JoshPet Re: Online Status - 06/25/2003 11:27 PM
You might have to have the online function update it there as well. Which is another query on every page.

I dunno - maybe a join when it's displayed.
Posted By: Gardener Re: Online Status - 06/25/2003 11:31 PM
Adding an extra join or query on the most heavily used script isn't really a good idea... At least not for a function that doesn't give much extra information.

Maybe every time someone logs in all users online status would be updated? That script isn't run very often, but it should keep it fairly up to date. Also, the online page could do the same thing, so that it is possible to catch users who have left since the last login.
Posted By: JoshPet Re: Online Status - 06/25/2003 11:47 PM
I'm just not sure how you'd clear them out and change them to offline when they weren't online any more.

Actually now that I think about it - showflat and show threaded already query the online table - to show how many people are browsing this forum. Maybe those queries could be expanded to grab the user iids of who is online - then match them up. I haven't really looked at it. But maybe that could be expanded.
Posted By: Gardener Re: Online Status - 06/25/2003 11:56 PM
Well, it's just the same way as online.php does it, if online.php wouldn't show them on the list, there online bit shouldn't be set. The user id:s of the users online could be stored (they should be in w3t_Online), and then two update queries on the user table:

UPDATE w3t_Users SET U_Online = 0 WHERE U_Online = 1 AND U_Number NOT IN ( list_of_id:s )
UPDATE w3t_Users SET U_Online = 1 WHERE U_Number IN ( list_of_id:s )

But if showflat/showthreaded already reads the online table your idea should work.
Posted By: Catshadow Re: Online Status - 10/17/2003 12:48 AM
Please understand me a lot.
What must I change or add in showflat?
and where I must include
"UPDATE w3t_Users SET U_Online = 0 WHERE U_Online = 1 AND U_Number NOT IN ( list_of_id:s )
UPDATE w3t_Users SET U_Online = 1 WHERE U_Number IN ( list_of_id:s )"
Posted By: JoshPet Re: Online Status - 10/17/2003 12:52 AM
That was just a theory or discussion. So far there's been no efficient way to do this without having to add another JOIN to a heavily used script. Probably need some major script hacking to make this work.
Posted By: Gardener Re: Online Status - 10/17/2003 1:26 PM
Ignore my queries in this thread, they are unnecessary.

The w3t_Online table contains all the info we need already, we don't need to addy any fields to the database or do any update queries.

Everytime a page is loaded the Online-table get's updated with the latest stats for that user.

To get a list of all current online users (who was active in the last 10 minutes) you only need to do this:
Code
   $Outdated = $html -> get_date() - 600; <br />   $queryOnline = " <br />      SELECT t1.O_Username,t2.U_Visible,t2.U_Color,t2.U_Number <br />      FROM   {$threadspre}Online AS t1, <br />                                 {$threadspre}Users AS t2 <br />      WHERE  t1.O_Username = t2.U_Username <br />      AND    O_Last > $Outdated <br />      ORDER BY t1.O_Last DESC <br />   ";


Actually, the join isn't necessary, you only need the user id:s to be able to check against it to know if the online image should be lit or not next to each user.

Also, I think it would be possible to change the query that reads how many are browsing the current forum so that it also reads info about all who are online. I'll get working on that.
Posted By: Gardener Re: Online Status - 10/17/2003 2:42 PM
Scrap the query above as well. You can find a finished hack for this called Online Users in the Modifications forum.
Posted By: Catshadow Re: Online Status - 10/17/2003 3:26 PM
Thank you very-very math !!! this hack is very popular... on such forums as ikonboard invisionboard vbulletin... now it is on ubb.threads - That`s GOOD!!!
© UBB.Developers