diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-03-18 10:14:37 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-03-18 10:14:37 +0000 |
commit | 221001a6dc86c7cd9246b6614adb24c1d88c0067 (patch) | |
tree | fec8527d1155e682313965398d44554636ae9b4f /phpBB/includes | |
parent | afba17e5620891c54b606e218163a5845262bada (diff) | |
download | forums-221001a6dc86c7cd9246b6614adb24c1d88c0067.tar forums-221001a6dc86c7cd9246b6614adb24c1d88c0067.tar.gz forums-221001a6dc86c7cd9246b6614adb24c1d88c0067.tar.bz2 forums-221001a6dc86c7cd9246b6614adb24c1d88c0067.tar.xz forums-221001a6dc86c7cd9246b6614adb24c1d88c0067.zip |
- 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
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/functions.php | 22 | ||||
-rw-r--r-- | phpBB/includes/session.php | 14 |
2 files changed, 21 insertions, 15 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) { |