当前位置: 首页>>代码示例>>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;未经允许,请勿转载。