<?php
if (user_access('access content')) {
// Count users active within the defined period.
$interval = time() - variable_get('user_block_seconds_online', 900);
// Perform database queries to gather online user lists. We use s.timestamp
// rather than u.access because it is much faster.
$authenticated_users = db_query('
SELECT DISTINCT
u.uid, u.name, u.picture, 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'
, $interval);
$authenticated_count = 0;
$max_users = 20;
$items = array();
while ($account = db_fetch_object($authenticated_users)) {
if ($max_users > 0) {
$items[] = $account;
$max_users--;
}
$authenticated_count++;
}
// Format the output with proper grammar.
$output = $authenticated_count == 1 ?
t('There is only 1 member online.') :
t('There are currently '.$authenticated_count.' members online.');
// Display a list of currently online users.
if ($authenticated_count) {
foreach ($items as $u){
$output .= '<div class="mini-user-panel">'."\n";
$output .= theme('user_picture', $u);
$output .= '<div class="name">'. theme('username', $u) .'</div>'."\n";
$output .= '</div>';
}
}
print $output;
}
?>
if (user_access('access content')) {
// Count users active within the defined period.
$interval = time() - variable_get('user_block_seconds_online', 900);
// Perform database queries to gather online user lists. We use s.timestamp
// rather than u.access because it is much faster.
$authenticated_users = db_query('
SELECT DISTINCT
u.uid, u.name, u.picture, 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'
, $interval);
$authenticated_count = 0;
$max_users = 20;
$items = array();
while ($account = db_fetch_object($authenticated_users)) {
if ($max_users > 0) {
$items[] = $account;
$max_users--;
}
$authenticated_count++;
}
// Format the output with proper grammar.
$output = $authenticated_count == 1 ?
t('There is only 1 member online.') :
t('There are currently '.$authenticated_count.' members online.');
// Display a list of currently online users.
if ($authenticated_count) {
foreach ($items as $u){
$output .= '<div class="mini-user-panel">'."\n";
$output .= theme('user_picture', $u);
$output .= '<div class="name">'. theme('username', $u) .'</div>'."\n";
$output .= '</div>';
}
}
print $output;
}
?>
1 comments :
Nice drupal 6 custom information.
Post a Comment
Hi there! Please leave your message here. Also, I may not be able to respond to your query right away. So please bear with me. Thanks. :)