$number = db_result(db_query('SELECT COUNT(uid) AS number FROM {users} WHERE status=1'));
if (user_access('access content')) {
// Count users with activity in the past defined period.
$time_period = variable_get('user_block_seconds_online', 900);
// Perform database queries to gather online user lists.
$guests = db_fetch_object(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period));
$guests_hostname = db_query('SELECT hostname FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period);
$total_guests = db_result($guests_hostname);
$users = db_query('SELECT uid, name, access FROM {users} WHERE access >= %d AND uid != 0 ORDER BY access DESC', time() - $time_period);
$total_users = db_result($users);
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($total_users && $max_users) {
$items = array();
while ($max_users-- && $account = db_fetch_object($users)) {
$items[] = $account;
}
$output.="
$output .= theme('user_list', $items, NULL);
}
// Display a list of currently online guests.
if ($total_guests) {
$output.="
- hostname\">$account->hostname
hostname)."\">".gethostbyaddr($account->hostname)." ";
}
$output.="
$guestitems = array();
while ($guests-- && $account = db_fetch_object($guests_hostname)) {
$guestitems[] = $account->hostname;
$output.="
";
}
}
return $output;
?>