Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 06:50 pm EDT

Geeklog Forums

"5 latest logged in" block


Status: offline

pernas

Forum User
Newbie
Registered: 11/15/03
Posts: 7
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

Text Formatted Code
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;                                                                                                                                
}
 
 Quote

Striker

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'

Text Formatted Code
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;
}
 
 Quote

Status: offline

geKow

Forum User
Full Member
Registered: 01/12/03
Posts: 445
That one is nice! Thanks Big Grin
 Quote

Status: offline

pernas

Forum User
Newbie
Registered: 11/15/03
Posts: 7
Thanks Smile

/Per
 Quote

Status: offline

arthur

Forum User
Junior
Registered: 10/10/03
Posts: 34
Great! I have added it to shrednow.com and expanded it to the last 10 visitors.
Arthur (http://www.shrednow.com)
 Quote

Status: offline

jetshack

Forum User
Full Member
Registered: 06/29/04
Posts: 122
Location:Texas
very nice!
 Quote

Status: offline

ScurvyDawg

Forum User
Full Member
Registered: 11/06/02
Posts: 523
Works great


thanks
 Quote

All times are EDT. The time is now 06:50 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content