79
good.
As i wrote in the last post the current defined task for last_login field in XOOPS CORE is keeping last visit of the user.(so last login is a confusing name !!!)
I know a couple of modules will provide you such a block for showing last visits.
I simplified your code to this:
echo "<div style='clear:both;'></div> ";
$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 = ' ' . class_exists("XoopsLocal") ? XoopsLocal::formatTimestamp($last_login,"elapse") : '';
$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> ";
as you can see nowadays XoopsLocal::formatTimestamp($last_login,"elapse") will do the job perfectly
every module developers include me can add a last visit block to his module. because It is not related to any module. it is just some codes to get last_login from users table. (It is better to add to core
)
yesterday Mamba told my via email that it would be good to have it in newbb. so i add it to newbb too
http://svn.code.sf.net/p/xoops/svn/XoopsModules/newbb/branches/irmtfan/newbb/
Therefore it is very easy to add it
but login/register history is a different concept. here you can find all real login/register attempts.(and find whether it is failed or successful)
Today i improved the login/register history functionality and for better performance I add a patch to all $_POST which contained "pass".
Now it is ready to make a block from.
download trunk and test:
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/