Log in

View Full Version : extend Recent Login Code



sarahmx
02-08-2010, 11:58 AM
Hi..

I'm a php newbie...

this code below is to show recent login member in xoops cms

is there anyway to extend this code to show when actually did the user login..
example minutes/seconds/hours/days ago



$hours = 24;
$kira=0;
$time = ( intval( $hours ) > 0 ) ? time() - ( intval( $hours ) * 3600 ) : ( time() - 24*3600 );
global $xoopsDB;


echo "<table><tr>";
$sql = "SELECT distinct uid, uname, user_avatar, last_login FROM ".$xoopsDB->prefix("users")." WHERE level > 0 AND uid NOT IN (0) AND last_login >= '" . $time . "' ORDER BY last_login DESC";
$result = $xoopsDB->query($sql);

while (list($uid, $uname,$user_avatar,$poster,$last_login) = $xoopsDB->fetchRow($result) ) {
$kira++;
if ($user_avatar == 'blank.gif')
{
echo "<td style='padding:5px;text-align:center'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/blank_avatar.gif' title='".$uname."' border='0' alt='".$uname."' height='48' width='48'></a><br /><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'>".$uname."</a></td>";
}

else

{
echo "<td style='padding:5px;text-align:center'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/".$user_avatar."' title='".$uname."' border='0' alt='".$uname."' height='48' width='48'></a><br /><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'>".$uname."</a></td>";
}

if($kira == 4)

{

$count=0;

echo "</tr><tr>";

}}

echo "</tr></table>";