本文整理匯總了PHP中obtain_guest_count函數的典型用法代碼示例。如果您正苦於以下問題:PHP obtain_guest_count函數的具體用法?PHP obtain_guest_count怎麽用?PHP obtain_guest_count使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了obtain_guest_count函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_obtain_guest_count
/**
* @dataProvider obtain_guest_count_data
*/
public function test_obtain_guest_count($forum_id, $expected)
{
$this->db->sql_query('DELETE FROM phpbb_sessions');
$time = time();
$this->create_guest_sessions($time);
$this->assertEquals($expected, obtain_guest_count($forum_id));
}
示例2: obtain_users_online
/**
* Queries the session table to get information about online users
* @param int $forum_id Limits the search to the forum with this id
* @return array An array containing the ids of online, hidden and visible users, as well as statistical info
*/
function obtain_users_online($forum_id = 0)
{
global $db, $config, $user;
$reading_sql = '';
if ($forum_id !== 0) {
$reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id;
}
$online_users = array('online_users' => array(), 'hidden_users' => array(), 'total_online' => 0, 'visible_online' => 0, 'hidden_online' => 0, 'guests_online' => 0);
if ($config['load_online_guests']) {
$online_users['guests_online'] = obtain_guest_count($forum_id);
}
// a little discrete magic to cache this for 30 seconds
$time = time() - intval($config['load_online_time']) * 60;
$sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline
FROM ' . SESSIONS_TABLE . ' s
WHERE s.session_time >= ' . ($time - (int) ($time % 30)) . $reading_sql . ' AND s.session_user_id <> ' . ANONYMOUS;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
// Skip multiple sessions for one user
if (!isset($online_users['online_users'][$row['session_user_id']])) {
$online_users['online_users'][$row['session_user_id']] = (int) $row['session_user_id'];
if ($row['session_viewonline']) {
$online_users['visible_online']++;
} else {
$online_users['hidden_users'][$row['session_user_id']] = (int) $row['session_user_id'];
$online_users['hidden_online']++;
}
}
}
$online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online'];
$db->sql_freeresult($result);
return $online_users;
}