From 6813967ae1024d386c6f829256a66f9391791dda Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 14 Jun 2007 15:03:52 +0000 Subject: [PATCH] Changing the behaviour of the hideonline permission. Test the current setting before altering the memory limit during install(Bug #12195) And another language var. git-svn-id: file:///svn/phpbb/trunk@7755 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 3 ++- phpBB/includes/functions.php | 22 ++------------- phpBB/includes/session.php | 27 +++++++++++++++++++ phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- phpBB/install/index.php | 25 ++++++++++++++++- phpBB/language/en/ucp.php | 1 + phpBB/memberlist.php | 2 +- .../template/ucp_prefs_personal.html | 2 +- .../template/ucp_prefs_personal.html | 2 +- phpBB/viewonline.php | 2 +- phpBB/viewtopic.php | 2 +- 11 files changed, 62 insertions(+), 28 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index b50e1de896..583b22804b 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -272,7 +272,8 @@ p a {
  • [Fix] Able to delete posts within user prune panel (Bug #11849)
  • [Feature] Allow to specify dimensions of images manually on imageset config (Bug #11675)
  • [Fix] Correctly re-assign query result id after seeking rows (MSSQL/Firebird) (Bug #12369)
  • - +
  • [Feature] Make effect of a changed hideonline permission instantaneous
  • +
  • [Fix] Do not overwrite larger memory values in the installer (Bug #12195)
  • diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b096c7319e..9059352bb7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2130,24 +2130,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); - // Make sure the user is able to hide his session - if (!$viewonline) - { - $check_auth = new auth(); - $check_auth->acl($user->data); - - // Reset online status if not allowed to hide the session... - if (!$check_auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 1 - WHERE session_user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - - unset($check_auth); - } - // Special case... the user is effectively banned, but we allow founders to login if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) { @@ -3959,7 +3941,7 @@ function page_header($page_title = '', $display_online_list = true) $user_colour = ''; } - if ($row['user_allow_viewonline'] && $row['session_viewonline']) + if ($row['session_viewonline']) { $user_online_link = $row['username']; $logged_visible_online++; @@ -3970,7 +3952,7 @@ function page_header($page_title = '', $display_online_list = true) $logged_hidden_online++; } - if (($row['user_allow_viewonline'] && $row['session_viewonline']) || $auth->acl_get('u_viewonline')) + if (($row['session_viewonline']) || $auth->acl_get('u_viewonline')) { if ($row['user_type'] <> USER_IGNORE) { diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 5e22576fdc..4f1732f30c 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1506,6 +1506,33 @@ class user extends session trigger_error('BOARD_UNAVAILABLE'); } } + + // Make sure the user is able to hide his session + if (!$this->data['session_viewonline']) + { + // Reset online status if not allowed to hide the session... + if (!$auth->acl_get('u_hideonline')) + { + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET session_viewonline = 1 + WHERE session_user_id = ' . $this->data['user_id']; + $db->sql_query($sql); + $this->data['session_viewonline'] = 1; + } + } + elseif (!$this->data['user_allow_viewonline']) + { + // the user wants to hide and is allowed to -> cloaking device on. + if ($auth->acl_get('u_hideonline')) + { + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET session_viewonline = 0 + WHERE session_user_id = ' . $this->data['user_id']; + $db->sql_query($sql); + $this->data['session_viewonline'] = 0; + } + } + // Does the user need to change their password? If so, redirect to the // ucp profile reg_details page ... of course do not redirect if we're already in the ucp diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index aa88bfe65f..673da2e819 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -406,7 +406,7 @@ function get_user_information($user_id, $user_row) $update_time = $config['load_online_time'] * 60; if ($row) { - $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] && $user_row['user_allow_viewonline'])) ? true : false; + $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'])) ? true : false; } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 656b6fed95..5a1b997b73 100755 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -104,7 +104,30 @@ else // Try to override some limits - maybe it helps some... @set_time_limit(0); -@ini_set('memory_limit', '128M'); +$mem_limit = @ini_get('memory_limit'); +if (!empty($mem_limit )) +{ + $unit = strtolower(substr($mem_limit, -1, 1)); + $mem_limit = (int)$mem_limit; + if ($unit == 'k') + { + $mem_limit = floor($mem_limit/1024); + } + elseif ($unit == 'g') + { + $mem_limit *= 1024; + } + elseif (is_numeric($unit)) + { + $mem_limit = floor($mem_limit/1048576); + } + $mem_limit = max(128, $mem_limit) . 'M'; +} +else +{ + $mem_limit = '128M'; +} +@ini_set('memory_limit', $mem_limit ); // Include essential scripts require($phpbb_root_path . 'includes/functions.' . $phpEx); diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 6a46ad96fb..304b9952d1 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -210,6 +210,7 @@ $lang = array_merge($lang, array( 'GLOBAL_ANNOUNCEMENT' => 'Global announcement', 'HIDE_ONLINE' => 'Hide my online status', + 'HIDE_ONLINE_EXPLAIN' => 'Changing this setting to "No" won\'t become effective until your next visit to the board.', 'HOLD_NEW_MESSAGES' => 'Do not accept new messages (New messages will be held back until enough space is available)', 'HOLD_NEW_MESSAGES_SHORT' => 'New messages will be held back', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f6420e33f3..3458d45fec 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1434,7 +1434,7 @@ function show_profile($data) if ($config['load_onlinetrack']) { $update_time = $config['load_online_time'] * 60; - $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['user_allow_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; + $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline'])) || $auth->acl_get('u_viewonline'))) ? true : false; } else { diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index b8c70841d7..fea21f9693 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -32,7 +32,7 @@
    -
    +

    {L_HIDE_ONLINE_EXPLAIN}
    diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index ffff4a4280..3546a127f7 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -41,7 +41,7 @@ - {L_HIDE_ONLINE}: + {L_HIDE_ONLINE}:
    {L_HIDE_ONLINE_EXPLAIN} checked="checked" />{L_YES}   checked="checked" />{L_NO} diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 4a862c4367..f655718d7e 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -139,7 +139,7 @@ while ($row = $db->sql_fetchrow($result)) $row['username'] = '' . $row['username'] . ''; } - if (!$row['user_allow_viewonline'] || !$row['session_viewonline']) + if (!$row['session_viewonline']) { $view_online = ($auth->acl_get('u_viewonline')) ? true : false; $logged_hidden_online++; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index e65388d35e..2f6aac1fc6 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1100,7 +1100,7 @@ if ($config['load_onlinetrack'] && sizeof($id_cache)) $update_time = $config['load_online_time'] * 60; while ($row = $db->sql_fetchrow($result)) { - $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline'] && $user_cache[$row['session_user_id']]['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; + $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; } $db->sql_freeresult($result); }