/ Published in: PHP
                    
                                        
Customises the \"who\'s online\" block to show what role type the user has + the links now point to private message instead of profiles.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function online_block() {
$localIP=$_SERVER['SERVER_ADDR'];
//Count users with activity in the past defined period.
$time_period = variable_get('user_block_seconds_online', 150);
//Perform database queries to gather online user lists.
$total_guests = db_result(db_query('SELECT COUNT(hostname) FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period));
$users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period);
$total_users = db_result(db_query('SELECT DISTINCT COUNT(u.uid) FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period));
//Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($total_users && $max_users) {
while ($max_users-- && $account = db_fetch_object($users)) {
$items[] = $account;
}
$output.="<div class=\"item-list\"><h4>Members online</h4><p>Within the last 150 seconds</p><ul>";
//Add the account type.
$acc = "";
$acc = "Gold";
$acc = "Silver";
$acc = "Tim";
$acc = "Performer";
$acc = "Admin";
}
$output .= '<li><a href="/messages/new/'.$items[$i]->uid.'">'.$items[$i]->name.'</a> - ' . $acc . '</li>';
}
$output.="</ul><p>Lurkers online: ".$guests."</p></div>";
}
return $output;
}
URL: http://zoocha.com
Comments
 Subscribe to comments
                    Subscribe to comments
                
                