Quote:
Originally Posted by CAG CheechDogg
Where exactly do I add
PHP Code:
$timecutoff = TIMENOW - $vbulletin->options['cookietimeout'];
|
Anywhere before the db query will be fine.
This is what I now have:
PHP Code:
global $vbulletin, $db;
$groupid = '6,13';
$groupname = 'Math Helpers/Administrators';
$timecutoff = TIMENOW - $vbulletin->options['cookietimeout'];
$output = '<div class="restore"><ul>';
$groupid_arr = explode(',', $groupid);
$qwhere = '';
foreach ($groupid_arr AS $id)
{
$qwhere .= 'OR ' . $id . ' IN (user.membergroupids) ';
}
$users_online = $vbulletin->db->query_read("
SELECT user.*
FROM " . TABLE_PREFIX . "user AS user
INNER JOIN " . TABLE_PREFIX . "session AS session
ON session.userid = user.userid
WHERE user.usergroupid IN (" . $groupid . ")
" . $qwhere . "
AND session.loggedin > 0
AND session.lastactivity >= " . $timecutoff . "
GROUP BY user.userid
ORDER BY user.lastactivity DESC
");
$count = 0;
while ($member = $db->fetch_array($users_online))
{
$output .= '<li>' . helper_link($member, $member['lastactivity']) . '</li>';
$count++;
}
$output .= '</ul></div>';
$output = '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' . $count . ' ' . $groupname . ' Online</div>' . $output;
return $output;
function helper_link($user_name, $dateline)
{
global $vbulletin;
$link = 'member.php?do=getinfo&username=' . $user_name['username'];
if ($user_name['displaygroupid'])
{
$groupid = $user_name['displaygroupid'];
}
else
{
$groupid = $user_name['usergroupid'];
}
$open_tag = $vbulletin->usergroupcache[$groupid]['opentag'];
$close_tag = $vbulletin->usergroupcache[$groupid]['closetag'];
$title = 'Last Activity: ' . vbdate($vbulletin->options['dateformat'], $dateline, 1) . ' at ' . vbdate($vbulletin->options['timeformat'], $dateline);
return '<a title="' . $title . '" href="' . $link . '">' . $open_tag . $user_name['username'] . $close_tag . '</a>';
}