This is something I made for my site, so people could quickly see who of their friends is online. Feel free to re-write the code, because this code is not perfect: I am not a real programmer, and used some of the vBulletin code (what a shame!).
Install:
Create new plug-in:
Product : vBulletin
Hook Location : process_templates_complete
Title : Friends Online
Execution Order : 5
PHP Code:
if (!$vbulletin->userinfo['userid'])
{
}
else
{
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$buddys = $vbulletin->db->query_read("
SELECT
user.username, user.userid, user.lastactivity
FROM " . TABLE_PREFIX . "userlist AS userlist
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid)
WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy' AND user.lastactivity > $datecut
ORDER BY username ASC
");
$output = '';
while ($buddy = $vbulletin->db->fetch_array($buddys))
{
$output .= ' <a href="member.php?' . $buddy['userid'] . '"><font color=blue><b>' . $buddy['username'] . '</b></font></a> ';
}
if ($output != '')
{
$output = '<font color=black>Friends online:</font>' . $output;
$template_hook['navtab_end'] .= '
<style type="text/css">
#bottom {
position: fixed;
z-index:10000!important;
bottom: 0px;
text-align: right;
background-color: #eeeeee;
}
</style>
<div id="bottom" class="blockhead">
';
$template_hook['navtab_end'] .= $output;
$template_hook['navtab_end'] .= '
</div>
';
}
}