Lionel |
03-08-2005 03:01 AM |
First of all, this is not from me. I merely took the who's online arcade hack and made it for jukebox. I thought that was neat and I want to share.
step 1- create new template jb_jukebox_loggedinuser and put this in there
PHP Code:
<a href="member.php?u=$loggedin[userid]">$loggedin[musername]</a>$loggedin[invisiblemark]$loggedin[buddymark]
Step 2 add this in template jb_JUKEBOX where you want to display it
PHP Code:
<br /> <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="thead" align=left>Users Currently Listening to Music ( Total Users: $totalonline, Members: <b>$numberregistered </b> | Visiting Guests: <b>$numberguest </b> )</td> </tr> <tr> <td class="alt1">$activeusers </td> </tr> </table>
Step 3 put this in the php file before
// ###################### Start Main ###########################################
PHP Code:
// ######################### BEGIN WHOIS ONLINE IN Jukebox ######################### $activeusers = ''; if ($vboptions['displayloggedin']) { $datecut = TIMENOW - $vboptions['cookietimeout']; $numbervisible = 0; $numberregistered = 0; $numberguest = 0; $forumusers = $DB_site->query(" SELECT user.username, (user.options & $_USEROPTIONS[invisible]) AS invisible, user.usergroupid, session.userid, session.inforum, session.lastactivity, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid FROM " . TABLE_PREFIX . "session AS session LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid) WHERE session.lastactivity > $datecut and session.location like '%vb_jukebox%' " . iif($vboptions['displayloggedin'] == 1, "ORDER BY username ASC") . " "); if ($bbuserinfo['userid']) { // fakes the user being online for an initial page view of arcade.php $bbuserinfo['joingroupid'] = iif($bbuserinfo['displaygroupid'], $bbuserinfo['displaygroupid'], $bbuserinfo['usergroupid']); $userinfos = array ( $bbuserinfo['userid'] => array ( 'userid' => $bbuserinfo['userid'], 'username' => $bbuserinfo['username'], 'invisible' => $bbuserinfo['invisible'], 'inforum' => 0, 'lastactivity' => TIMENOW, 'usergroupid' => $bbuserinfo['usergroupid'], 'displaygroupid' => $bbuserinfo['displaygroupid'], ) ); } else { $userinfos = array(); } $inforum = array(); while ($loggedin = $DB_site->fetch_array($forumusers)) { $userid = $loggedin['userid']; if (!$userid) { // Guest $numberguest++; $inforum["$loggedin[inforum]"]++; } else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity'])) { $userinfos["$userid"] = $loggedin; } } foreach($userinfos AS $userid => $loggedin) { $numberregistered++; if ($userid != $bbuserinfo['userid']) { $inforum["$loggedin[inforum]"]++; } $loggedin['musername'] = fetch_musername($loggedin); if (fetch_online_status($loggedin)) { $numbervisible++; eval('$activeusers .= ", ' . fetch_template('jb_jukebox_loggedinuser') . '";'); } } unset($userinfos, $loggedin); $activeusers = substr($activeusers , 2); $DB_site->free_result($loggedins); $totalonline = $numberregistered + $numberguest; $numberinvisible = $numberregistered - $numbervisible; $maxusers = unserialize($datastore['aaamaxloggedin']); if (intval($maxusers['aaamaxonline']) <= $totalonline) { $maxusers['aaamaxonline'] = $totalonline; $maxusers['aaamaxonlinedate'] = TIMENOW; build_datastore('aaamaxloggedin', serialize($maxusers)); } $recordusers = $maxusers['aaamaxonline']; $recorddate = vbdate($vboptions['dateformat'], $maxusers['aaamaxonlinedate'], true); $recordtime = vbdate($vboptions['timeformat'], $maxusers['aaamaxonlinedate']); $show['loggedinusers'] = true; } else { $show['loggedinusers'] = false; } // ###################### Start of getOnlineStatus ####################### function fetch_online_status(&$user, $setstatusimage = false) { global $bbuserinfo, $permissions, $vboptions, $stylevar, $vbphrase; static $buddylist, $datecut; // get variables used by this function if (!is_array($buddylist)) { $datecut = TIMENOW - $vboptions['cookietimeout']; if ($bbuserinfo['buddylist'] = trim($bbuserinfo['buddylist'])) { $buddylist = preg_split('/\s+/', $bbuserinfo['buddylist'], -1, PREG_SPLIT_NO_EMPTY); } else { $buddylist = array(); } } // is the user on bbuser's buddylist? if (in_array($user['userid'], $buddylist)) { $user['buddymark'] = '+'; } else { $user['buddymark'] = ''; } // set the invisible mark to nothing by default $user['invisiblemark'] = ''; $onlinestatus = 0; // now decide if we can see the user or not if ($user['lastactivity'] > $datecut AND $user['lastvisit'] != $user['lastactivity']) { if ($user['invisible']) { if (($permissions['genericpermissions'] & CANSEEHIDDEN) OR $user['userid'] == $bbuserinfo['userid']) { // user is online and invisible BUT bbuser can see them $user['invisiblemark'] = '*'; $onlinestatus = 2; } } else { // user is online and visible $onlinestatus = 1; } } if ($setstatusimage) { eval('$user[\'onlinestatus\'] = "' . fetch_template('postbit_onlinestatus') . '";'); } return $onlinestatus; } // ######### end of Get online Status // ######################### END WHOIS ONLINE IN jukebox#####################
Next, since I have flashchat, I will make it clicking on username starts a chat.
|