$whosonline = '';
if($mybb->settings['showwol'] != "no" && $mybb->usergroup['canviewonline'] != "no")
{
echo("<table width=\"80%\" class=\"border\" align=\"center\" cellspacing=\"1\" border=\"0\" cellpadding=\"5\">
<tr class=\"Bhead\">
<td align=\"center\" background=\"".$v['httphostwo']."/images/background2.jpg\"><b>Who's online</b></td>
</tr><tr>
<td class=\"link, Bbody\">");
// Get the online users.
$timesearch = time() - $mybb->settings['wolcutoffmins']*60;
$comma = '';
$hpurl = $v['httphostwo'];
$query = $db->query("
SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup
FROM ".TABLE_PREFIX."sessions s
LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
WHERE s.time>'$timesearch'
ORDER BY u.username ASC, s.time DESC
");
$membercount = 0;
$onlinemembers = '';
$guestcount = 0;
$anoncount = 0;
$doneusers = array();
// Loop through all users.
while($user = $db->fetch_array($query))
{
// Create a key to test if this user is a search bot.
$botkey = strtolower(str_replace("bot=", '', $user['sid']));
// Decide what type of user we are dealing with.
if($user['uid'] > 0)
{
// The user is registered.
if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
{
// If the user is logged in anonymously, update the count for that.
if($user['invisible'] == "yes")
{
++$anoncount;
}
++$membercount;
if($user['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes" || $user['uid'] == $mybb->user['uid'])
{
// If this usergroup can see anonymously logged-in users, mark them.
if($user['invisible'] == "yes")
{
$invisiblemark = "*";
}
else
{
$invisiblemark = '';
}
// Properly format the username and assign the template.
$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit2", 1, 0)."\";");
$comma = ", ";
}
// This user has been handled.
$doneusers[$user['uid']] = $user['time'];
}
}
elseif(strstr($user['sid'], "bot=") !== false && $session->bots[$botkey])
{
// The user is a search bot.
$onlinemembers .= $comma.format_name($session->bots[$botkey], $session->botgroup);
$comma = ", ";
++$botcount;
}
else
{
// The user is a guest.
++$guestcount;
}
}
// Build the who's online bit on the index page.
$onlinecount = $membercount + $guestcount;
if($onlinecount != 1)
{
$onlinebit = $lang->online_online_plural;
}
else
{
$onlinebit = $lang->online_online_singular;
}
if($membercount != 1)
{
$memberbit = $lang->online_member_plural;
}
else
{
$memberbit = $lang->online_member_singular;
}
if($anoncount != 1)
{
$anonbit = $lang->online_anon_plural;
}
else
{
$anonbit = $lang->online_anon_singular;
}
if($guestcount != 1)
{
$guestbit = $lang->online_guest_plural;
}
else
{
$guestbit = $lang->online_guest_singular;
}
$lang->online_note = sprintf($lang->online_note, my_number_format($onlinecount), $onlinebit, $mybb->settings['wolcutoffmins'], my_number_format($membercount), $memberbit, my_number_format($anoncount), $anonbit, my_number_format($guestcount), $guestbit);
echo($lang->online_note);
echo($onlinemembers);
echo("</td></tr></table><br />");
}