You can get a list of all registered users by requesting a session table. I assume you are using Drupal 6.
<?php
$result = db_query('SELECT uid FROM {sessions} WHERE uid != 0');
$users = array();
while($user = db_fetch_array($result)) {
$users[] = user_load($user);
}
The request excludes sessions for uid = 0, because these are anonymous users. $usersis an array of user objects, as described in the Drupal Docs API .
, , (, ), user_load() while , user_load() . :
<?php
$result = db_query('SELECT u.uid, u.name FROM {sessions} s INNER JOIN {users} u ON u.uid = s.uid WHERE s.uid != 0');
$users = array();
while($users[] = db_fetch_array($result));
- ( ), , (.. , ):
$timestamp = time - 3600; // 3600s is one hour.
$result = db_query('SELECT uid FROM {sessions} WHERE uid != 0 AND timestamp >= %d', $timestamp);
. , , - - 10 , :
$limit = 10;
$result = db_query_range('SELECT uid FROM {sessions} WHERE uid != 0 ORDER BY timestamp DESC', $timestamp, 0, $limit);
, (, $limit 3600s), _set(), variable_get() variable_del().