mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 15:45:34 +02:00
- some changes to the recent session change
- display errors on inserting sessions - fix database updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8438 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
afba17e562
commit
221001a6dc
@ -3154,12 +3154,13 @@ function obtain_users_online($forum_id = 0)
|
||||
{
|
||||
global $db, $config, $user;
|
||||
$logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0;
|
||||
$reading_sql = $prev_session_ip = '';
|
||||
$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(),
|
||||
@ -3168,6 +3169,7 @@ function obtain_users_online($forum_id = 0)
|
||||
'hidden_online' => 0,
|
||||
'guests_online' => 0,
|
||||
);
|
||||
|
||||
if ($config['load_online_guests'])
|
||||
{
|
||||
$online_users['guests_online'] = obtain_guest_count($forum_id);
|
||||
@ -3175,6 +3177,7 @@ function obtain_users_online($forum_id = 0)
|
||||
|
||||
// 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))) .
|
||||
@ -3184,7 +3187,6 @@ function obtain_users_online($forum_id = 0)
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
|
||||
// Skip multiple sessions for one user
|
||||
if (!isset($online_users['online_users'][$row['session_user_id']]))
|
||||
{
|
||||
@ -3217,7 +3219,7 @@ function obtain_users_online_string($online_users, $forum_id = 0)
|
||||
global $db, $user, $auth;
|
||||
$user_online_link = $online_userlist = '';
|
||||
|
||||
if (count($online_users['online_users']))
|
||||
if (sizeof($online_users['online_users']))
|
||||
{
|
||||
$sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour
|
||||
FROM ' . USERS_TABLE . ' u
|
||||
@ -3225,15 +3227,21 @@ function obtain_users_online_string($online_users, $forum_id = 0)
|
||||
ORDER BY u.username_clean ASC';
|
||||
$result = $db->sql_query($sql, 100);
|
||||
|
||||
$userlist_array = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
// User is logged in and therefore not a guest
|
||||
if ($row['user_id'] != ANONYMOUS)
|
||||
// Skip multiple sessions for one user
|
||||
if ($row['user_id'] != $prev_user_id)
|
||||
{
|
||||
if (isset($online_users['hidden_users'][$row['user_id']]))
|
||||
{
|
||||
$row['username'] = '<em>' . $row['username'] . '</em>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['username'] = '<em>' . $row['username'] . '</em>';
|
||||
$logged_hidden_online++;
|
||||
}
|
||||
|
||||
if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
@ -3342,11 +3350,11 @@ function page_header($page_title = '', $display_online_list = true)
|
||||
|
||||
if ($config['load_online'] && $config['load_online_time'] && $display_online_list)
|
||||
{
|
||||
|
||||
$f = request_var('f', 0);
|
||||
$f = max($f, 0);
|
||||
$online_users = obtain_users_online($f);
|
||||
$user_online_strings = obtain_users_online_string($online_users, $f);
|
||||
|
||||
$l_online_users = $user_online_strings['l_online_users'];
|
||||
$online_userlist = $user_online_strings['online_userlist'];
|
||||
$total_online_users = $online_users['total_online'];
|
||||
@ -3414,7 +3422,7 @@ function page_header($page_title = '', $display_online_list = true)
|
||||
$user_lang = $user->lang['USER_LANG'];
|
||||
if (strpos($user_lang, '-x-') !== false)
|
||||
{
|
||||
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
|
||||
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
|
||||
}
|
||||
|
||||
// The following assigns all _common_ variables that may be used at any point in a template.
|
||||
|
@ -130,7 +130,7 @@ class session
|
||||
'root_script_path' => str_replace(' ', '%20', htmlspecialchars($root_script_path)),
|
||||
|
||||
'page' => $page,
|
||||
'forum' => (isset($_REQUEST['f']) && $_REQUEST['f'] > 0) ? (int) $_REQUEST['f'] : 0,
|
||||
'forum' => (isset($_REQUEST['f']) && $_REQUEST['f'] > 0) ? (int) $_REQUEST['f'] : 0,
|
||||
);
|
||||
|
||||
return $page_array;
|
||||
@ -185,11 +185,6 @@ class session
|
||||
$this->forwarded_for = '';
|
||||
}
|
||||
|
||||
// Add forum to the page for tracking online users - also adding a "x" to the end to properly identify the number
|
||||
$this->page['page'] .= (isset($_REQUEST['f'])) ? ((strpos($this->page['page'], '?') !== false) ? '&' : '?') . '_f_=' . (int) $_REQUEST['f'] . 'x' : '';
|
||||
|
||||
|
||||
|
||||
if (isset($_COOKIE[$config['cookie_name'] . '_sid']) || isset($_COOKIE[$config['cookie_name'] . '_u']))
|
||||
{
|
||||
$this->cookie_data['u'] = request_var($config['cookie_name'] . '_u', 0, false, true);
|
||||
@ -614,6 +609,8 @@ class session
|
||||
// Limit new sessions in 1 minute period (if required)
|
||||
if (empty($this->data['session_time']) && $config['active_sessions'])
|
||||
{
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$sql = 'SELECT COUNT(session_id) AS sessions
|
||||
FROM ' . SESSIONS_TABLE . '
|
||||
WHERE session_time >= ' . ($this->time_now - 60);
|
||||
@ -629,6 +626,9 @@ class session
|
||||
}
|
||||
}
|
||||
|
||||
// Since we re-create the session id here, the inserted row must be unique. Therefore, we display potential errors.
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$this->session_id = $this->data['session_id'] = md5(unique_id());
|
||||
|
||||
$sql_ary['session_id'] = (string) $this->session_id;
|
||||
@ -638,8 +638,6 @@ class session
|
||||
$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
// Regenerate autologin/persistent login key
|
||||
if ($session_autologin)
|
||||
{
|
||||
|
@ -486,14 +486,14 @@ $database_update_info = array(
|
||||
),
|
||||
'add_index' => array(
|
||||
SESSIONS_TABLE => array(
|
||||
'session_forum_id' => 'session_forum_id',
|
||||
'session_forum_id' => array('session_forum_id'),
|
||||
),
|
||||
GROUP_TABLE => array(
|
||||
GROUPS_TABLE => array(
|
||||
'group_legend_name' => array('group_legend', 'group_name'),
|
||||
),
|
||||
),
|
||||
'drop_keys' => array(
|
||||
GROUP_TABLE => array('group_legend'),
|
||||
GROUPS_TABLE => array('group_legend'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -158,7 +158,7 @@ if (!$auth->acl_get('f_read', $forum_id))
|
||||
$template->assign_vars(array(
|
||||
'S_NO_READ_ACCESS' => true,
|
||||
'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false,
|
||||
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url(array('_f_')))),
|
||||
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())),
|
||||
));
|
||||
|
||||
page_footer();
|
||||
|
@ -122,7 +122,7 @@ if (!$show_guests)
|
||||
}
|
||||
|
||||
// Get user list
|
||||
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline
|
||||
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id
|
||||
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
|
||||
WHERE u.user_id = s.session_user_id
|
||||
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
|
||||
@ -208,8 +208,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||
case 'posting':
|
||||
case 'viewforum':
|
||||
case 'viewtopic':
|
||||
preg_match('#_f_=([0-9]+)x#i', $row['session_page'], $forum_id);
|
||||
$forum_id = (sizeof($forum_id)) ? (int) $forum_id[1] : 0;
|
||||
$forum_id = $row['session_forum_id'];
|
||||
|
||||
if ($forum_id && $auth->acl_get('f_list', $forum_id))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user