Snippet: Display members online

Tomno399

Quoteolder then xxx seconds will be deleted ... time range grows up then

Thank you Manuela, I got it and I understand now why there is shown a difference to the user statistic modul.

I always learn something new to but unfortunately I will never be a php programmer.

Tom

DarkViper

Quote from: Tomno399 on July 15, 2015, 08:56:27 AMBut why I cannot see a member who was logged in two days before when I ask the last seven days? Is this memory not asked or lost in the database?

The reason is the clean-up of the database.
i.e.: if you call the function with $seconds = 300 so all records older then 300 seconds will be deleted with that statement: $database->query("DELETE FROM $table WHERE timestamp < ".$timeout);
If you set $seconds = (60*60*24*7) // =7 days.. so you can see the records from (now - 300) to the future only. The time range grows up then till after 7 days you can see records from the whole last week.

Manuela
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Tomno399

thank you marmot!

I use wb283sp4, php 5.5

I have a question of understanding about the snippet: After a login I will be shown as the first member, after a second login with another username and another password, I will be shown as second member. I think it will be the same with a third and a fourth user login (not tested). So far so good the module works!

But why I cannot see a member who was logged in two days before when I ask the last seven days? Is this memory not asked or lost in the database?

Hmm I would like to get more and more understanding ...

regards tom

marmot

Hi,

Quote from: Tomno399 on July 14, 2015, 03:10:00 PM
MembersOnline (604800, 'Login in den letzten 7 Tagen', 'display_name', '0 users online', 0); does not really work. Is the time too long or?
works fine for me with wb282sp3. Of course the last parameter makes only sense with the include patch.
QuoteBy the way Marmot's download "include.zip" is demaged. Can anyone take an upload again?
find the file attached.

Tomno399

hmmm, my call

MembersOnline (604800, 'Login in den letzten 7 Tagen', 'display_name', '0 users online', 0);

does not really work. Is the time too long or?

By the way Marmot's download "include.zip" is demaged. Can anyone take an upload again?

thanks tom

DarkViper

#21
Quote from: Tomno399 on May 17, 2015, 12:21:30 PMOne Question: I miss the closing "?>" in the include.php above. Is it not necessary? I do not get any errors, but if it is working right I cant't check.

It's right to leave out the closing ?> at the end of a PHP file. See: Coding Style Guide / Common / Files or PSR-2 :: Coding Style Guide

Manuela
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Tomno399

@marmot

One Question: I miss the closing "?>" in the include.php above. Is it not necessary? I do not get any errors, but if it is working right I cant't check.

Thanks Tom

mava100

dear marmot you are my best helper ...  :-) all solved thanks you again!

marmot

Hi,

Quote from: MoSaG on August 13, 2013, 09:24:53 AM
Could you please post the original error that is displayed?
the reported notice says that $_SESSION['USER_ID'] is not set when user is not logged in. That's why the notice only occurs when showing the snippnet to guests.
Tried to fix this and indtroduce parameter $show_guests = 1 to also show how many guests are online in the attached file. Maybe you want to test and find somthing helpful for updating you snippnet.

regards

MoSaG

Could you please post the original error that is displayed?
And I also need the version of your WebsiteBaker installation too.

mava100

I have some error if no one is logged: notice error in line in include.php on line 45, 47, 49
It's minor problem but how I can eliminate from frontend page? I'm newbie sorry!
thanks in advance


iradj

Thank you. Everything works great.

MoSaG

#14
Quote from: iradj on August 30, 2010, 03:51:19 PM
Yes exactly what I mean.  URL is www.evgberg.de

can't reproduce it, but perhaps this helps to you:

at first try to clear caches and relogg, if this does'nt help, empty database table '..._mod_members_online', if this also has no effect try to change line 58 from:
$tpl->set_var(array("USERNAME" => $username));
to:
if ($username) { $tpl->set_var(array("USERNAME" => $username)); }

Hope some/one of this tips will help.

EDIT: perhaps the new 0.1.4 version will solve the problem, the snippet has stored users that are not logged in with id 0 so they are always on - this will be checked now and only id higher than 0 will be stored to the members_online table, in addition there is now a custom message available if no user is online, see the updated version in 1st message.

iradj

Quote from: MoSaG on August 30, 2010, 03:19:58 PM
Quote from: iradj on August 30, 2010, 01:39:40 PM
Thanks, it works. Can you write me why I always get one sized line.
Sorry don't understand, do you mean the blank line (only the bullet) under your name?
Perhaps you give me the link to your website so I can view it in action?

Yes exactly what I mean.  URL is www.evgberg.de

MoSaG

Quote from: Stefek on August 30, 2010, 01:43:42 PM
this is a very nice snippet.

Quote from: Stefek on August 30, 2010, 01:43:42 PM
I suggest to use another parameter to have a choice between username || display_name, like:

I've added this.

Quote from: Stefek on August 30, 2010, 01:43:42 PM
BTW, there is another Snippet from User Ruud E. which creates a list of visitors who are not logged in.

Yes I know, my snippet based on Ruuds snippet - after I understand how Ruuds snippet worked, I have to remove many lines and code nearly from scratch, because his way is completly different.

Quote from: Stefek on August 30, 2010, 01:43:42 PM
Maybe it was a good idea to merge both, or extend this one to have a list of logged in users and a Number print of those not logged in?

I don't know if I can just (legaly) copy Ruuds code to my snippet ... but you are right, it is a good idea to show not logged in users too ... I'll think about it, how to solve this.

MoSaG

Quote from: iradj on August 30, 2010, 01:39:40 PM
Thanks, it works. Can you write me why I always get one sized line.
Sorry don't understand, do you mean the blank line (only the bullet) under your name?
Perhaps you give me the link to your website so I can view it in action?

Stefek

Hello,

this is a very nice snippet.

I suggest to use another parameter to have a choice between username || display_name, like:

MembersOnline ($seconds = 300, $headline = 'Active users in last 5 min', $show='username');
Makes more sense to me than a hardcoded solution.

BTW, there is another Snippet from User Ruud E. which creates a list of visitors who are not logged in.
Maybe it was a good idea to merge both, or extend this one to have a list of logged in users and a Number print of those not logged in?

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

iradj

Thanks, it works. Can you write me why I always get one sized line.

[gelöscht durch Administrator]

MoSaG

#8
Quote from: iradj on August 30, 2010, 12:07:22 PM
I want to show display_name and not user name. What should I do?

Hi,
if you want to show display_name instead of username change line 56 in include.php from
   $username = $database->get_one("SELECT username FROM ".TABLE_PREFIX."users WHERE user_id = '".$row['user_id']."'");
to
   $username = $database->get_one("SELECT display_name FROM ".TABLE_PREFIX."users WHERE user_id = '".$row['user_id']."'");

Have not tested, but should work ... tested, it works and thanks for this, because it makes more sense to display the display_name than the username! I'll change this on the snippet soon.

iradj

Hi,
I want to show display_name and not user name. What should I do?

BR Iradj

MoSaG

Quote from: crnogorac081 on August 27, 2010, 10:24:14 PM
Perhaps more precise would be: "Active users in last 5 min: <list>"
Quote from: crnogorac081 on August 27, 2010, 10:24:14 PM
And, regarding timeout, since this is a function, you can easily increase the timeout:

added support for a custom timeout and a custom headline. Perhaps I update it later to a multilanguage version ...

crnogorac081

#5
For example if you are hanging on forum, and you dont surf, you are still displayed as online.. :)

It is not my intention to increase/decrease timeout , just to point that even when you are loged in & not surfing, you are still online, but idle :)

Perhaps more precise would be: "Active users in last 5 min: <list>"

And, regarding timeout, since this is a function, you can easily increase the timeout:

function MembersOnline ($custom_timeout) {

global $database;
$timestamp = time();
if ($custom_timeout = null) { $my_timeout = "300"; } else { $my_timeout = $custom_timeout;}
$timeout = $timestamp - $custom_timeout;
....
the rest of code stays as is
}
example:
<?php MembersOnline(600); ?> => timeout 10 min
<?php MembersOnline(); ?>       => timeout 5 min



cheers

Edit: by the way I am not a pro-coder myself, and I am still learning..   so dont be afraid and keep your head up :) :)
Web developer

MoSaG

#4
5 Minutes is the default timeout, if you are idle 6 mins you will be kicked off the list. The next time you surf on a page (and still be logged in to the system), you're status will be updated to online again. I think, that's ok, no realtime updates at the moment ...
Do you think an option "show me always on, as long as I am not logged off" makes sense? (this could be one of the possible additions, a user may change the online status, the timeout, or "I want to be invisible" ;) )
On line 21 in inlcude.php you can set a higher timeout limit. Perhaps I learn in a few days how I get an admintool to run, where you can enter the timeout. Meanwhile you have to change it by hand in the snippet. Thanks for testing!

crnogorac081

Hi,

I did a quick review of your code..

What happens if I am online, but idle for 6 min ? I want be displayed..right :)
Web developer

crnogorac081

hi,

welcome to wb community :) the snippet sounds great, i am looking forward to test it

cheers
Web developer