43
hi imrtfan very nice
btw can you make a special block for the success last login history where we can exclude any user etc
i forgot where i got this but i use this in my site all this while
le="color: #000000"><?php echo "<div style='clear:both;'></div> "; function timeDifference($start,$end,$return='days') { //change times to Unix timestamp. //$start = strtotime($start); //$end = strtotime($end); //subtract dates //echo 'Start Timestamp: ' . $start . '<br/>End Timestamp: ' . $end . '<br/>'; $difference = max($end, $start) - min($end,$start); $time = NULL; //calculate time difference. switch($return) { case 'days': $days = floor($difference/86400); $difference = $difference % 86400; $time['days'] = $days; case 'hours': $hours = floor($difference/3600); $difference = $difference % 3600; $time['hours'] = $hours; case 'minutes': $minutes = floor($difference/60); $difference = $difference % 60; $time['minutes'] = $minutes; case 'seconds': $seconds = $difference; $time['seconds'] = $seconds; } $output = array(); if(is_array($time)) { $showSec = true; if(isset($time['hours']) && $time['hours'] > 0) { $output[] = $time['hours'] . ' Hour'; $showSec = false; } if(isset($time['minutes']) && $time['minutes'] > 0) { $output[] = $time['minutes'] . ' minutes'; $showSec = false; } if(isset($time['seconds']) && $showSec == true) { return $time['seconds'] . ' Second'; } return implode(', ',$output); } } $now = time(); $hours = 24; $count=0; $time = ( intval( $hours ) > 0 ) ? time() - ( intval( $hours ) * 3600 ) : ( time() - 24*3600 ); global $xoopsDB; $sql = "SELECT distinct uid, uname, user_avatar, last_login FROM ".$xoopsDB->prefix("users")." WHERE level > 0 AND uid NOT IN (1) AND uid NOT IN (76) AND last_login >= '" . $time . "' ORDER BY last_login DESC"; $result = $xoopsDB->query($sql); while (list($uid, $uname,$user_avatar,$last_login) = $xoopsDB->fetchRow($result) ) { //Put this variable in the echo statements where you would like them to show up. $sinceLastLogin = ' ' . timeDifference($last_login,$now,'hours') . ' ago'; $count++; if ($user_avatar == 'avatars/blank.gif') { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/avatars/blank.gif' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } else { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/".$user_avatar."' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } } echo "<div style='clear:both;'></div> ";