Joomla Who’s Online Module Minor Hack for showing the Actual User Online

  • Share
  • Share

This hack is best suit for people that had already change the session lifetime. If you have ever tweak the session settings on the Global Settings, you will need to have this hack in order to display correct online user stats. For example if you had set your session lifetime to 90 minutes, your online user stats will be the frame within the 90 minutes. This is usually the case when we want to extend the time of login, but we will still want to have the real user online stats over maybe 10-20 minutes. So what should we do?

Step 1.

This code replaces the original helper.php code in the joomla /modules/mod_whoisonline folder. It works on my system – Joomla 1.5.X. We will need to change two part of the file in this tutorial. The first part are near line 28, and second part will be around 62.

Original Code

$query = 'SELECT guest, usertype, client_id' .
		' FROM #__session' .
		' WHERE client_id = 0';

Replace with the following code

$datenow = date("Y-m-d H:i:s");
$time_string = strtotime($datenow);
// Modified query below to only show members/users active in the last 10 minutes
$extra_time = 600; //example: 10 min x 60 sec
$online_time = ($time_string-$extra_time);

$query = "SELECT a.guest, a.usertype, a.client_id"
		."\n FROM #__session AS a"
		."\n WHERE a.client_id=0 AND a.time>'$online_time'";

Step 2.

Original Code

$query = 'SELECT DISTINCT a.username' .
		 ' FROM #__session AS a' .
		 ' WHERE client_id = 0' .
		 ' AND a.guest = 0';

Replace with the following code

$datenow = date("Y-m-d H:i:s");
$time_string = strtotime($datenow);
// Modified query below to only show members/users active in the last 10 minutes
$extra_time = 600; //10 min x 60 sec
$online_time = ($time_string-$extra_time);

// New Query below to only show members/users active in the last 10 minutes
$query = "SELECT DISTINCT a.username, a.userid, u.name"
		."\n FROM #__session AS a, #__users AS u"
		."\n WHERE (a.userid=u.id) AND (a.guest = 0) AND (NOT ( a.usertype is NULL OR a.usertype = '' )) AND a.time>'$online_time'"
		."\n ORDER BY ".(($ueConfig['name_format'] > 2) ? "a.username" : "u.name")." ASC";

Download


If you have problem with the code above, you can always download the source at here.
Joomla Who’s Online Module Minor Hack for showing the Actual User Online (977)

Be a link sponsor for this page now

[sponsorbox]


Related Posts Plugin for WordPress, Blogger...

I hope you have enjoyed this post, be sure to subscribe to my rss feed by click the subscribe button at the top.

Good Luck!

Be Sure to Subscribe to our feed or follow us on twitter to get the latest updates/patches
End of Article, Thanks for reading.
You can leave a response, or trackback from your own site.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

16 Responses to “Joomla Who’s Online Module Minor Hack for showing the Actual User Online

  1. Hi,

    You have a Great Blog, I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep it up.

    Jenny

  2. Issac Maez says:

    Thanks for the great post. I always like to bookmark webmaster or website related posts like this one.

  3. Cheers for the fantastic information – I enjoyed reading it! :)

  4. Simon Lowell says:

    This is an awesome blog! I really wish that someday I could have a page that is as well done as this..

  5. Angella Peon says:

    I’m surfing the Internet seeking for relevant info like in your blog. I’m impressed with the content. Thnx for the info, keep up the nice work. I’ll bookmark your place so I can find for updates afterwards

  6. Hi how are you i really liked this.

  7. Hey mate. I don’t follow many blogs, but yours is of thefew I follow.Have a nice day!

  8. iMp says:

    im looking for a fake guest online mod do u find any??please share with us
    thx

  9. Anyone knows where to find the real joomla module for "who's online"?

  10. xtianpjb says:

    how about guest online + ip address?

  11. djvorn says:

    thz Q very much

    u just great!!!!

  12. Meftasagor says:

    great stuff. Thanks a lot for your nice tutorial.

  13. svetoslav says:

    hm… got any ideas how to remove inactive guests after 10 mins?? like delete their sessions after 10 mins of inactivity or sth like this?

Leave a Reply