當前位置: 首頁>>代碼示例>>PHP>>正文


PHP obtain_guest_count函數代碼示例

本文整理匯總了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));
 }
開發者ID:ZerGabriel,項目名稱:phpbb,代碼行數:10,代碼來源:obtain_online_test.php

示例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;
}
開發者ID:Phatboy82,項目名稱:phpbbgarage,代碼行數:38,代碼來源:functions.php


注:本文中的obtain_guest_count函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。