aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/functions.php22
-rw-r--r--phpBB/includes/session.php14
-rw-r--r--phpBB/install/database_update.php6
-rw-r--r--phpBB/viewforum.php2
-rw-r--r--phpBB/viewonline.php5
5 files changed, 27 insertions, 22 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 6d05ddabe5..886ea7197f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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.
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 91b412b075..9aee53531c 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -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)
{
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 39e0d8131e..856640b58b 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -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'),
),
),
);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 878791088d..e8e6fab47a 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -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') . '&amp;redirect=' . urlencode(str_replace('&amp;', '&', build_url(array('_f_')))),
+ 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&amp;redirect=' . urlencode(str_replace('&amp;', '&', build_url())),
));
page_footer();
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index ea29e09660..788861915c 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -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))
{