Skip to content

$uid->isOnline(); #491

@liomj

Description

@liomj

Hi how do i get the online/offline status of a particular user in the new core ?
i tried this in my custom page..but its not working i got a half loading page

$result= $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("users")." ORDER BY name ASC") or die(mysql_error()); 
$uid=$row['uid'];
while($row = $xoopsDB->fetchArray($result))
{
$online_handler =&xoops_gethandler('online'); 
    mt_srand((double)microtime()*1000000); 
    // set gc probabillity to 10% for now.. 
    if (mt_rand(1, 100) < 11) { 
        $online_handler->gc(300); 
    } 
    if (is_object($xoopsUser)) { 
        $uid = $xoopsUser->getVar('uid'); 
        $uname = $xoopsUser->getVar('uname'); 
    } else { 
        $uid = 0; 
        $uname = ''; 
    } 
    if (is_object($xoopsModule)) { 
        $online_handler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $_SERVER['REMOTE_ADDR']); 
    } else { 
        $online_handler->write($uid, $uname, time(), 0, $_SERVER['REMOTE_ADDR']); 
    }

	if ($uid->isOnline()) 
            { 
                echo "<span style='color:#ee0000;font-weight:bold;'>Online</span>&nbsp;"; 
            } 
            else 
            { 
                echo "<span style='color:#000000;font-weight:bold;'>Offline</span>&nbsp;"; 
            }

}

last time it works
http://xoops.org/modules/newbb/viewtopic.php?post_id=321914#321914

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions