Subject: "5 latest logged in" block

Posted on: 08/12/03 07:13am
By: pernas

Hi!

I just wanted to give you this block that shows the site "5 last logged in" users with date and time.

Thanks to everyone (Squatty for his session-block) which helped me with this.

Regards,
Per

function phpblock_5latest()                                                                                                                   
{                                                                                                                                             
    global $_CONF;                                                                                                                            
    $list = "";                                                                                                                               
    $quer = mysql_query ("SELECT uid,lastlogin FROM gl_userinfo ORDER BY lastlogin DESC limit 5");
    while ($line = mysql_fetch_array($quer)){                                                                                                 
    $uidsql= mysql_query ("SELECT username,photo FROM gl_users WHERE uid=$line[uid]");
    $uidresult = DB_fetchArray($uidsql);                                                                                                                                                                               
    $lastlogin = DB_getItem (gl_userinfo, 'lastlogin', "uid = $line[uid]");                                                                   
    $lasttime = COM_getUserDateTimeFormat ($lastlogin);                                                                                       
                                                                                                                                              
    $list = $list.'<a href="'.$_CONF["site_url"].'/users.php?mode=profile&uid='.$line["uid"].'" title="'.$lasttime[0].'">'.$uidresult[username
];                                                                                                                                            

    if ($uidresult[photo] != ""){                                                                                                             
    $list = $list.' <img src="'.$_CONF['layout_url'].'/images/smallcamera.gif" border="0" alt="">';
    }                                                                                                                                         
    $list = $list.'</a><br>';                                                                                                                 
    }                                                                                                                                         
return $list;                                                                                                                                 
}

Re:"5 latest logged in" block

Posted on: 30/12/03 04:57pm
By: Anonymous

Really nice idea for a block, decided to add it to my site, but noticed there were some problems.

Here's some better code that doesnt guess table names, hides invisible users, and doesnt show 'Anonymous'

function phpblock_5latest()
{
    global $_CONF, $_TABLES;
    $list = "";
    $quer = mysql_query ("SELECT u.uid,u.lastlogin,p.showonline FROM {$_TABLES['userinfo']} AS u, {$_TABLES['userprefs']} AS p WHERE u.uid = p.uid AND u.uid != '1' AND p.showonline = '1' ORDER BY lastlogin DESC limit 5");

    while ($line = mysql_fetch_array($quer)){
      $uidsql= mysql_query ("SELECT username,photo FROM {$_TABLES['users']} WHERE uid=$line[uid]");
      $uidresult = DB_fetchArray($uidsql);
      $lastlogin = DB_getItem ($_TABLES['userinfo'], 'lastlogin', "uid = $line[uid]");
      $lasttime = COM_getUserDateTimeFormat ($lastlogin);

      $list = $list.'<a href="'.$_CONF["site_url"].'/users.php?mode=profile&uid='.$line["uid"].'" title="'.$lasttime[0].'">'.$uidresult[username];

      if ($uidresult[photo] != ""){
          $list = $list.' <img src="'.$_CONF['layout_url'].'/images/smallcamera.gif" border="0" alt="">';
      }
          $list = $list.'</a><br>';
      }

      return $list;
}

Re:"5 latest logged in" block

Posted on: 30/12/03 06:40pm
By: geKow

That one is nice! Thanks

Re:"5 latest logged in" block

Posted on: 08/01/04 04:38am
By: pernas

Thanks

/Per

"5 latest logged in" block

Posted on: 19/07/04 04:37pm
By: arthur

Great! I have added it to shrednow.com and expanded it to the last 10 visitors.

"5 latest logged in" block

Posted on: 12/01/05 03:25pm
By: jetshack

very nice!

"5 latest logged in" block

Posted on: 12/01/05 06:51pm
By: ScurvyDawg

Works great


thanks

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=27671