11
zyspec
Re: Module/block which displays how many users were online today
  • 2009/2/1 14:34

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


To display users names you just need to modify trabis' code slightly:
$member_handler =& xoops_gethandler('member'); 
$days 1
$time time() - (60 60 24 $days); 
$criteria = new Criteria('last_login'$time'>'); 
$users $member_handler->getUserList($criteria); 
$total count($users);
if ( 
is_array($users) && ($total >= ) ) 

  echo 
"Already ".$total." visitors today.Today's Visitors:"
  foreach(
$users as $user) {
    echo 
$user '';
  }

else 

  echo 
"No users today"
}


I think - this should work (provided I don't have a syntax error or some other stupid mistake :) )
Edited: Corrected isarray to be is_array

12
demian
Re: Module/block which displays how many users were online today
  • 2009/2/1 14:57

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


thanks zyspec..

blank page--i got this error

Call to undefined function isarray() in class\xoopsblock.php(147) : eval()'d code on line 7




13
hipoonios
Re: Module/block which displays how many users were online today
  • 2009/2/1 15:04

  • hipoonios

  • Friend of XOOPS

  • Posts: 298

  • Since: 2005/9/24


My site show blank page when added your code in a php block.
I love Xoops!

14
demian
Re: Module/block which displays how many users were online today
  • 2009/2/1 15:11

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


extra question

1. is it possible to exclude members by ID - Example i want to exclude my username (admin) listed in the list

2. what about avatar..can it be included ?

thanks..and sorry if this is too much


15
zyspec
Re: Module/block which displays how many users were online today
  • 2009/2/2 14:50

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Sorry, 'isarray' should be 'is_array' - fixed in previous example above (tested it on one of my test sites and it appears to work). Sorry again for the confusion.

16
demian
Re: Module/block which displays how many users were online today
  • 2009/2/2 22:55

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


thank you zyspec..yup it works


Quote:

1. is it possible to exclude members by ID - Example i want to exclude my username (admin) listed in the list

2. what about avatar..can it be included ?


anyone know on how to modified the code to show the above ?

17
burfodus
Re: Module/block which displays how many users were online today
  • 2009/2/3 6:12

  • burfodus

  • Just popping in

  • Posts: 94

  • Since: 2008/9/2 1


this code is great, thanks, however it does not account for people logged in previously returning to the site.

ie, me! - i added the block and was logged in as admin, but was not on the list, and i assume this will be the same result for most returning visitors.

i think possibly this is an error in XOOPS code more than the script, as when listing users by log in day, it shows admin hasnt logged in for weeks, when you have been on every day.

either way is there a fix for this?

sb..
XOOPS Version - XOOPS 2.3.2
PHP Version - 5.2.6
MySQL Version - 5.0.67-community
Server API Version - apache2handler
OS Version - WINNT

18
zyspec
Re: Module/block which displays how many users were online today
  • 2009/2/3 23:05

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


You should be able to exclude a member (by ID) by replacing the criteria clause above:
$criteria = new Criteria('last_login'$time'>');

with this code:
$exceptUser 1// User ID you want to exclude in results
$criteriaCompo = new CriteriaCompo();
$criteriaCompo->add(new Criteria('last_login'$time'>'));
$criteriaCompo->add(new Criteria('uid'$exceptUser'<>'));
$users $member_handler->getUserList($criteriaCompo);


It wouldn't be too hard to add an avatar to this too using the XoopsAvatar class but I don't have time right now - although for the right $ amount I would forgo sleep to get it done - I'd even test it before I published the code

19
hipoonios
Re: Module/block which displays how many users were online today
  • 2009/2/6 10:49

  • hipoonios

  • Friend of XOOPS

  • Posts: 298

  • Since: 2005/9/24


Thanks for the code zyspec. I also have a request. Is it possible to include time? I know a site having a block looking like this:

Last seen
Resized Image
I love Xoops!

20
demian
Re: Module/block which displays how many users were online today
  • 2009/2/6 12:00

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


hipo..you can try this

https://xoops.org/modules/repository/singlefile.php?cid=89&lid=1303

its an old module..don't know if its safe to use...

i just tried it..it works..but maybe need more some tweak to improve it
screenshot
Resized Image

hope someone can update this module

Login

Who's Online

381 user(s) are online (248 user(s) are browsing Support Forums)


Members: 0


Guests: 381


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits