Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 09:27 am EST
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
{
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;
}
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;
}
10
12
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'
{
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;
}
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;
}
10
17
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)
Arthur (http://www.shrednow.com)
13
16
Quote
Status: offline
ScurvyDawg
Forum User
Full Member
Registered: 11/06/02
Posts: 523
Works great
thanks
thanks
17
16
Quote
All times are EST. The time is now 09:27 am.
- 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