@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
| 31 | 32 | global $context, $txt; |
| 32 | 33 | |
| 33 | 34 | // Old templates might still request this. |
| 34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
| 35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
| 36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $subActions = array( |
| 38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | checkSession(); |
| 100 | 102 | validateToken('admin-regc'); |
| 101 | 103 | |
| 102 | - foreach ($_POST as $key => $value) |
|
| 103 | - if (!is_array($_POST[$key])) |
|
| 104 | + foreach ($_POST as $key => $value) { |
|
| 105 | + if (!is_array($_POST[$key])) |
|
| 104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $regOptions = array( |
| 107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
| 161 | 164 | ) |
| 162 | 165 | ); |
| 163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
| 164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
| 169 | + } |
|
| 166 | 170 | $smcFunc['db_free_result']($request); |
| 171 | + } else { |
|
| 172 | + $context['member_groups'] = array(); |
|
| 167 | 173 | } |
| 168 | - else |
|
| 169 | - $context['member_groups'] = array(); |
|
| 170 | 174 | |
| 171 | 175 | // Basic stuff. |
| 172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | { |
| 208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
| 209 | 213 | // Are we editing this? |
| 210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
| 211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
| 214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
| 215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | } |
| 214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
| 223 | 228 | |
| 224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
| 225 | 230 | |
| 226 | - if ($bytes == strlen($to_write)) |
|
| 227 | - $context['saved_successful'] = true; |
|
| 228 | - else |
|
| 229 | - $context['could_not_save'] = true; |
|
| 231 | + if ($bytes == strlen($to_write)) { |
|
| 232 | + $context['saved_successful'] = true; |
|
| 233 | + } else { |
|
| 234 | + $context['could_not_save'] = true; |
|
| 235 | + } |
|
| 230 | 236 | } |
| 231 | 237 | |
| 232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
| 310 | 316 | |
| 311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
| 312 | 318 | |
| 313 | - if ($return_config) |
|
| 314 | - return $config_vars; |
|
| 319 | + if ($return_config) { |
|
| 320 | + return $config_vars; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // Setup the template |
| 317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
| 322 | 329 | checkSession(); |
| 323 | 330 | |
| 324 | 331 | // Are there some contacts missing? |
| 325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
| 326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
| 333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
| 334 | + } |
|
| 327 | 335 | |
| 328 | 336 | // Post needs to take into account line breaks. |
| 329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = smf_json_decode($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = smf_json_decode($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
| 709 | 739 | ); |
| 710 | 740 | |
| 711 | 741 | // Give the translators some credit for their hard work. |
| 712 | - if (!empty($txt['translation_credits'])) |
|
| 713 | - $context['credits'][] = array( |
|
| 742 | + if (!empty($txt['translation_credits'])) { |
|
| 743 | + $context['credits'][] = array( |
|
| 714 | 744 | 'title' => $txt['credits_groups_translation'], |
| 715 | 745 | 'groups' => array( |
| 716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
| 719 | 749 | ), |
| 720 | 750 | ), |
| 721 | 751 | ); |
| 752 | + } |
|
| 722 | 753 | |
| 723 | 754 | $context['credits'][] = array( |
| 724 | 755 | 'title' => $txt['credits_special'], |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * This is the controlling delegator |
@@ -38,13 +39,15 @@ discard block |
||
| 38 | 39 | ); |
| 39 | 40 | |
| 40 | 41 | // Any subaction? If none, fall through to the main template, which will ask for one. |
| 41 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 42 | - call_helper($subActions[$_REQUEST['sa']]); |
|
| 42 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 43 | + call_helper($subActions[$_REQUEST['sa']]); |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | // Creating a one time token. |
| 45 | - else |
|
| 46 | - createToken('remind'); |
|
| 47 | -} |
|
| 47 | + else { |
|
| 48 | + createToken('remind'); |
|
| 49 | + } |
|
| 50 | + } |
|
| 48 | 51 | |
| 49 | 52 | /** |
| 50 | 53 | * Allows the user to pick how they wish to be reminded |
@@ -62,8 +65,7 @@ discard block |
||
| 62 | 65 | { |
| 63 | 66 | $where = 'id_member = {int:id_member}'; |
| 64 | 67 | $where_params['id_member'] = (int) $_REQUEST['uid']; |
| 65 | - } |
|
| 66 | - elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
| 68 | + } elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
| 67 | 69 | { |
| 68 | 70 | $where = 'member_name = {string:member_name}'; |
| 69 | 71 | $where_params['member_name'] = $_POST['user']; |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // You must enter a username/email address. |
| 74 | - if (empty($where)) |
|
| 75 | - fatal_lang_error('username_no_exist', false); |
|
| 76 | + if (empty($where)) { |
|
| 77 | + fatal_lang_error('username_no_exist', false); |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | // Make sure we are not being slammed |
| 78 | 81 | // Don't call this if you're coming from the "Choose a reminder type" page - otherwise you'll likely get an error |
@@ -101,8 +104,9 @@ discard block |
||
| 101 | 104 | LIMIT 1', |
| 102 | 105 | $where_params |
| 103 | 106 | ); |
| 104 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 105 | - fatal_lang_error('no_user_with_email', false); |
|
| 107 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 108 | + fatal_lang_error('no_user_with_email', false); |
|
| 109 | + } |
|
| 106 | 110 | } |
| 107 | 111 | |
| 108 | 112 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -112,16 +116,18 @@ discard block |
||
| 112 | 116 | if ($row['is_activated'] != 1) |
| 113 | 117 | { |
| 114 | 118 | // Awaiting approval... |
| 115 | - if (trim($row['validation_code']) == '') |
|
| 116 | - fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 117 | - else |
|
| 118 | - fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 119 | + if (trim($row['validation_code']) == '') { |
|
| 120 | + fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 121 | + } else { |
|
| 122 | + fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
| 123 | + } |
|
| 119 | 124 | } |
| 120 | 125 | |
| 121 | 126 | // You can't get emailed if you have no email address. |
| 122 | 127 | $row['email_address'] = trim($row['email_address']); |
| 123 | - if ($row['email_address'] == '') |
|
| 124 | - fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
| 128 | + if ($row['email_address'] == '') { |
|
| 129 | + fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
| 130 | + } |
|
| 125 | 131 | |
| 126 | 132 | // If they have no secret question then they can only get emailed the item, or they are requesting the email, send them an email. |
| 127 | 133 | if (empty($row['secret_question']) || (isset($_POST['reminder_type']) && $_POST['reminder_type'] == 'email')) |
@@ -176,8 +182,9 @@ discard block |
||
| 176 | 182 | loadLanguage('Login'); |
| 177 | 183 | |
| 178 | 184 | // You need a code! |
| 179 | - if (!isset($_REQUEST['code'])) |
|
| 180 | - fatal_lang_error('no_access', false); |
|
| 185 | + if (!isset($_REQUEST['code'])) { |
|
| 186 | + fatal_lang_error('no_access', false); |
|
| 187 | + } |
|
| 181 | 188 | |
| 182 | 189 | // Fill the context array. |
| 183 | 190 | $context += array( |
@@ -203,16 +210,19 @@ discard block |
||
| 203 | 210 | checkSession(); |
| 204 | 211 | validateToken('remind-sp'); |
| 205 | 212 | |
| 206 | - if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) |
|
| 207 | - fatal_lang_error('no_access', false); |
|
| 213 | + if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) { |
|
| 214 | + fatal_lang_error('no_access', false); |
|
| 215 | + } |
|
| 208 | 216 | |
| 209 | 217 | $_POST['u'] = (int) $_POST['u']; |
| 210 | 218 | |
| 211 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
| 212 | - fatal_lang_error('passwords_dont_match', false); |
|
| 219 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
| 220 | + fatal_lang_error('passwords_dont_match', false); |
|
| 221 | + } |
|
| 213 | 222 | |
| 214 | - if ($_POST['passwrd1'] == '') |
|
| 215 | - fatal_lang_error('no_password', false); |
|
| 223 | + if ($_POST['passwrd1'] == '') { |
|
| 224 | + fatal_lang_error('no_password', false); |
|
| 225 | + } |
|
| 216 | 226 | |
| 217 | 227 | loadLanguage('Login'); |
| 218 | 228 | |
@@ -232,8 +242,9 @@ discard block |
||
| 232 | 242 | ); |
| 233 | 243 | |
| 234 | 244 | // Does this user exist at all? |
| 235 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 236 | - fatal_lang_error('invalid_userid', false); |
|
| 245 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 246 | + fatal_lang_error('invalid_userid', false); |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | list ($realCode, $username, $email, $flood_value) = $smcFunc['db_fetch_row']($request); |
| 239 | 250 | $smcFunc['db_free_result']($request); |
@@ -243,8 +254,9 @@ discard block |
||
| 243 | 254 | $passwordError = validatePassword($_POST['passwrd1'], $username, array($email)); |
| 244 | 255 | |
| 245 | 256 | // What - it's not? |
| 246 | - if ($passwordError != null) |
|
| 247 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 257 | + if ($passwordError != null) { |
|
| 258 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | require_once($sourcedir . '/LogInOut.php'); |
| 250 | 262 | |
@@ -291,8 +303,9 @@ discard block |
||
| 291 | 303 | loadLanguage('Login'); |
| 292 | 304 | |
| 293 | 305 | // Check they entered something... |
| 294 | - if (empty($_REQUEST['uid'])) |
|
| 295 | - fatal_lang_error('username_no_exist', false); |
|
| 306 | + if (empty($_REQUEST['uid'])) { |
|
| 307 | + fatal_lang_error('username_no_exist', false); |
|
| 308 | + } |
|
| 296 | 309 | |
| 297 | 310 | // Get the stuff.... |
| 298 | 311 | $request = $smcFunc['db_query']('', ' |
@@ -304,15 +317,17 @@ discard block |
||
| 304 | 317 | 'id_member' => (int) $_REQUEST['uid'], |
| 305 | 318 | ) |
| 306 | 319 | ); |
| 307 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 308 | - fatal_lang_error('username_no_exist', false); |
|
| 320 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 321 | + fatal_lang_error('username_no_exist', false); |
|
| 322 | + } |
|
| 309 | 323 | |
| 310 | 324 | $row = $smcFunc['db_fetch_assoc']($request); |
| 311 | 325 | $smcFunc['db_free_result']($request); |
| 312 | 326 | |
| 313 | 327 | // If there is NO secret question - then throw an error. |
| 314 | - if (trim($row['secret_question']) == '') |
|
| 315 | - fatal_lang_error('registration_no_secret_question', false); |
|
| 328 | + if (trim($row['secret_question']) == '') { |
|
| 329 | + fatal_lang_error('registration_no_secret_question', false); |
|
| 330 | + } |
|
| 316 | 331 | |
| 317 | 332 | // Ask for the answer... |
| 318 | 333 | $context['remind_user'] = $row['id_member']; |
@@ -335,8 +350,9 @@ discard block |
||
| 335 | 350 | validateToken('remind-sai'); |
| 336 | 351 | |
| 337 | 352 | // Hacker? How did you get this far without an email or username? |
| 338 | - if (empty($_REQUEST['uid'])) |
|
| 339 | - fatal_lang_error('username_no_exist', false); |
|
| 353 | + if (empty($_REQUEST['uid'])) { |
|
| 354 | + fatal_lang_error('username_no_exist', false); |
|
| 355 | + } |
|
| 340 | 356 | |
| 341 | 357 | loadLanguage('Login'); |
| 342 | 358 | |
@@ -350,8 +366,9 @@ discard block |
||
| 350 | 366 | 'id_member' => $_REQUEST['uid'], |
| 351 | 367 | ) |
| 352 | 368 | ); |
| 353 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 354 | - fatal_lang_error('username_no_exist', false); |
|
| 369 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 370 | + fatal_lang_error('username_no_exist', false); |
|
| 371 | + } |
|
| 355 | 372 | |
| 356 | 373 | $row = $smcFunc['db_fetch_assoc']($request); |
| 357 | 374 | $smcFunc['db_free_result']($request); |
@@ -364,20 +381,23 @@ discard block |
||
| 364 | 381 | } |
| 365 | 382 | |
| 366 | 383 | // You can't use a blank one! |
| 367 | - if (strlen(trim($_POST['passwrd1'])) === 0) |
|
| 368 | - fatal_lang_error('no_password', false); |
|
| 384 | + if (strlen(trim($_POST['passwrd1'])) === 0) { |
|
| 385 | + fatal_lang_error('no_password', false); |
|
| 386 | + } |
|
| 369 | 387 | |
| 370 | 388 | // They have to be the same too. |
| 371 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
| 372 | - fatal_lang_error('passwords_dont_match', false); |
|
| 389 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
| 390 | + fatal_lang_error('passwords_dont_match', false); |
|
| 391 | + } |
|
| 373 | 392 | |
| 374 | 393 | // Make sure they have a strong enough password. |
| 375 | 394 | require_once($sourcedir . '/Subs-Auth.php'); |
| 376 | 395 | $passwordError = validatePassword($_POST['passwrd1'], $row['member_name'], array($row['email_address'])); |
| 377 | 396 | |
| 378 | 397 | // Invalid? |
| 379 | - if ($passwordError != null) |
|
| 380 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 398 | + if ($passwordError != null) { |
|
| 399 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
| 400 | + } |
|
| 381 | 401 | |
| 382 | 402 | // Alright, so long as 'yer sure. |
| 383 | 403 | updateMemberData($row['id_member'], array('passwd' => hash_password($row['member_name'], $_POST['passwrd1']))); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
| 42 | 43 | $cat_order = array(); |
| 43 | 44 | |
| 44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
| 45 | - if ($catOptions['move_after'] == 0) |
|
| 46 | - $cats[] = $category_id; |
|
| 46 | + if ($catOptions['move_after'] == 0) { |
|
| 47 | + $cats[] = $category_id; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Grab the categories sorted by cat_order. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
| 55 | 57 | ); |
| 56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 57 | 59 | { |
| 58 | - if ($row['id_cat'] != $category_id) |
|
| 59 | - $cats[] = $row['id_cat']; |
|
| 60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
| 61 | - $cats[] = $category_id; |
|
| 60 | + if ($row['id_cat'] != $category_id) { |
|
| 61 | + $cats[] = $row['id_cat']; |
|
| 62 | + } |
|
| 63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
| 64 | + $cats[] = $category_id; |
|
| 65 | + } |
|
| 62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
| 63 | 67 | } |
| 64 | 68 | $smcFunc['db_free_result']($request); |
| 65 | 69 | |
| 66 | 70 | // Set the new order for the categories. |
| 67 | - foreach ($cats as $index => $cat) |
|
| 68 | - if ($index != $cat_order[$cat]) |
|
| 71 | + foreach ($cats as $index => $cat) { |
|
| 72 | + if ($index != $cat_order[$cat]) |
|
| 69 | 73 | $smcFunc['db_query']('', ' |
| 70 | 74 | UPDATE {db_prefix}categories |
| 71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
| 75 | 79 | 'current_category' => $cat, |
| 76 | 80 | ) |
| 77 | 81 | ); |
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // If the category order changed, so did the board order. |
| 80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
| 117 | 122 | )) |
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | - if (empty($catOptions['dont_log'])) |
|
| 121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 125 | + if (empty($catOptions['dont_log'])) { |
|
| 126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
| 127 | + } |
|
| 122 | 128 | } |
| 123 | 129 | } |
| 124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
| 135 | 141 | global $smcFunc; |
| 136 | 142 | |
| 137 | 143 | // Check required values. |
| 138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
| 139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
| 145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | // Set default values. |
| 142 | - if (!isset($catOptions['cat_desc'])) |
|
| 143 | - $catOptions['cat_desc'] = ''; |
|
| 144 | - if (!isset($catOptions['move_after'])) |
|
| 145 | - $catOptions['move_after'] = 0; |
|
| 146 | - if (!isset($catOptions['is_collapsible'])) |
|
| 147 | - $catOptions['is_collapsible'] = true; |
|
| 149 | + if (!isset($catOptions['cat_desc'])) { |
|
| 150 | + $catOptions['cat_desc'] = ''; |
|
| 151 | + } |
|
| 152 | + if (!isset($catOptions['move_after'])) { |
|
| 153 | + $catOptions['move_after'] = 0; |
|
| 154 | + } |
|
| 155 | + if (!isset($catOptions['is_collapsible'])) { |
|
| 156 | + $catOptions['is_collapsible'] = true; |
|
| 157 | + } |
|
| 148 | 158 | // Don't log an edit right after. |
| 149 | 159 | $catOptions['dont_log'] = true; |
| 150 | 160 | |
@@ -212,21 +222,24 @@ discard block |
||
| 212 | 222 | ) |
| 213 | 223 | ); |
| 214 | 224 | $boards_inside = array(); |
| 215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 216 | - $boards_inside[] = $row['id_board']; |
|
| 225 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 226 | + $boards_inside[] = $row['id_board']; |
|
| 227 | + } |
|
| 217 | 228 | $smcFunc['db_free_result']($request); |
| 218 | 229 | |
| 219 | - if (!empty($boards_inside)) |
|
| 220 | - deleteBoards($boards_inside, null); |
|
| 230 | + if (!empty($boards_inside)) { |
|
| 231 | + deleteBoards($boards_inside, null); |
|
| 232 | + } |
|
| 221 | 233 | } |
| 222 | 234 | |
| 223 | 235 | // Make sure the safe category is really safe. |
| 224 | - elseif (in_array($moveBoardsTo, $categories)) |
|
| 225 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 236 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
| 237 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // Move the boards inside the categories to a safe category. |
| 228 | - else |
|
| 229 | - $smcFunc['db_query']('', ' |
|
| 241 | + else { |
|
| 242 | + $smcFunc['db_query']('', ' |
|
| 230 | 243 | UPDATE {db_prefix}boards |
| 231 | 244 | SET id_cat = {int:new_parent_cat} |
| 232 | 245 | WHERE id_cat IN ({array_int:category_list})', |
@@ -235,6 +248,7 @@ discard block |
||
| 235 | 248 | 'new_parent_cat' => $moveBoardsTo, |
| 236 | 249 | ) |
| 237 | 250 | ); |
| 251 | + } |
|
| 238 | 252 | |
| 239 | 253 | // Do the deletion of the category itself |
| 240 | 254 | $smcFunc['db_query']('', ' |
@@ -246,8 +260,9 @@ discard block |
||
| 246 | 260 | ); |
| 247 | 261 | |
| 248 | 262 | // Log what we've done. |
| 249 | - foreach ($categories as $category) |
|
| 250 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 263 | + foreach ($categories as $category) { |
|
| 264 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
| 265 | + } |
|
| 251 | 266 | |
| 252 | 267 | // Get all boards back into the right order. |
| 253 | 268 | reorderBoards(); |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | * @version 2.1 Beta 3 |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -if (!defined('SMF')) |
|
| 19 | +if (!defined('SMF')) { |
|
| 20 | 20 | die('No direct access...'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | function sha1_smf($str) |
| 29 | 30 | { |
| 30 | 31 | // If we have mhash loaded in, use it instead! |
| 31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
| 32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
| 33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
| 35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
| 36 | 38 | |
| 37 | - for ($i = 0; $i < strlen($str); $i++) |
|
| 38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
| 41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
| 70 | 73 | |
| 71 | 74 | for ($j = 0; $j < 80; $j++) |
| 72 | 75 | { |
| 73 | - if ($j < 16) |
|
| 74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 75 | - else |
|
| 76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 76 | + if ($j < 16) { |
|
| 77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 78 | + } else { |
|
| 79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
| 79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
| 103 | 107 | */ |
| 104 | 108 | function sha1_ft($t, $b, $c, $d) |
| 105 | 109 | { |
| 106 | - if ($t < 20) |
|
| 107 | - return ($b & $c) | ((~$b) & $d); |
|
| 108 | - if ($t < 40) |
|
| 109 | - return $b ^ $c ^ $d; |
|
| 110 | - if ($t < 60) |
|
| 111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 110 | + if ($t < 20) { |
|
| 111 | + return ($b & $c) | ((~$b) & $d); |
|
| 112 | + } |
|
| 113 | + if ($t < 40) { |
|
| 114 | + return $b ^ $c ^ $d; |
|
| 115 | + } |
|
| 116 | + if ($t < 60) { |
|
| 117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 118 | + } |
|
| 112 | 119 | |
| 113 | 120 | return $b ^ $c ^ $d; |
| 114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
| 132 | 139 | function sha1_rol($num, $cnt) |
| 133 | 140 | { |
| 134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
| 135 | - if ($num & 0x80000000) |
|
| 136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 137 | - else |
|
| 138 | - $a = $num >> (32 - $cnt); |
|
| 142 | + if ($num & 0x80000000) { |
|
| 143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 144 | + } else { |
|
| 145 | + $a = $num >> (32 - $cnt); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | 148 | return ($num << $cnt) | $a; |
| 141 | 149 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -40,10 +41,11 @@ discard block |
||
| 40 | 41 | ); |
| 41 | 42 | |
| 42 | 43 | // We need to find what's the action. |
| 43 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 44 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 45 | - else |
|
| 46 | - $context['sub_action'] = 'tasks'; |
|
| 44 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 45 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 46 | + } else { |
|
| 47 | + $context['sub_action'] = 'tasks'; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Now for the lovely tabs. That we all love. |
| 49 | 51 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -90,9 +92,10 @@ discard block |
||
| 90 | 92 | |
| 91 | 93 | // Enable and disable as required. |
| 92 | 94 | $enablers = array(0); |
| 93 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
| 94 | - if ($enabled) |
|
| 95 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
| 96 | + if ($enabled) |
|
| 95 | 97 | $enablers[] = (int) $id; |
| 98 | + } |
|
| 96 | 99 | |
| 97 | 100 | // Do the update! |
| 98 | 101 | $smcFunc['db_query']('', ' |
@@ -130,8 +133,9 @@ discard block |
||
| 130 | 133 | |
| 131 | 134 | // Lets figure out which ones they want to run. |
| 132 | 135 | $tasks = array(); |
| 133 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
| 134 | - $tasks[] = (int) $task; |
|
| 136 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
| 137 | + $tasks[] = (int) $task; |
|
| 138 | + } |
|
| 135 | 139 | |
| 136 | 140 | // Load up the tasks. |
| 137 | 141 | $request = $smcFunc['db_query']('', ' |
@@ -151,36 +155,41 @@ discard block |
||
| 151 | 155 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 152 | 156 | { |
| 153 | 157 | // What kind of task are we handling? |
| 154 | - if (!empty($row['callable'])) |
|
| 155 | - $task_string = $row['callable']; |
|
| 158 | + if (!empty($row['callable'])) { |
|
| 159 | + $task_string = $row['callable']; |
|
| 160 | + } |
|
| 156 | 161 | |
| 157 | 162 | // Default SMF task or old mods? |
| 158 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 159 | - $task_string = 'scheduled_' . $row['task']; |
|
| 163 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 164 | + $task_string = 'scheduled_' . $row['task']; |
|
| 165 | + } |
|
| 160 | 166 | |
| 161 | 167 | // One last resource, the task name. |
| 162 | - elseif (!empty($row['task'])) |
|
| 163 | - $task_string = $row['task']; |
|
| 168 | + elseif (!empty($row['task'])) { |
|
| 169 | + $task_string = $row['task']; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $start_time = microtime(); |
| 166 | 173 | // The functions got to exist for us to use it. |
| 167 | - if (empty($task_string)) |
|
| 168 | - continue; |
|
| 174 | + if (empty($task_string)) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 169 | 177 | |
| 170 | 178 | // Try to stop a timeout, this would be bad... |
| 171 | 179 | @set_time_limit(300); |
| 172 | - if (function_exists('apache_reset_timeout')) |
|
| 173 | - @apache_reset_timeout(); |
|
| 180 | + if (function_exists('apache_reset_timeout')) { |
|
| 181 | + @apache_reset_timeout(); |
|
| 182 | + } |
|
| 174 | 183 | |
| 175 | 184 | // Get the callable. |
| 176 | 185 | $callable_task = call_helper($task_string, true); |
| 177 | 186 | |
| 178 | 187 | // Perform the task. |
| 179 | - if (!empty($callable_task)) |
|
| 180 | - $completed = call_user_func($callable_task); |
|
| 181 | - |
|
| 182 | - else |
|
| 183 | - $completed = false; |
|
| 188 | + if (!empty($callable_task)) { |
|
| 189 | + $completed = call_user_func($callable_task); |
|
| 190 | + } else { |
|
| 191 | + $completed = false; |
|
| 192 | + } |
|
| 184 | 193 | |
| 185 | 194 | // Log that we did it ;) |
| 186 | 195 | if ($completed) |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | $smcFunc['db_free_result']($request); |
| 198 | 207 | |
| 199 | 208 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
| 200 | - if (!empty($context['scheduled_errors'])) |
|
| 201 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 209 | + if (!empty($context['scheduled_errors'])) { |
|
| 210 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 211 | + } |
|
| 202 | 212 | |
| 203 | 213 | redirectexit('action=admin;area=scheduledtasks;done'); |
| 204 | 214 | } |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | $context['server_time'] = timeformat(time(), false, 'server'); |
| 371 | 381 | |
| 372 | 382 | // Cleaning... |
| 373 | - if (!isset($_GET['tid'])) |
|
| 374 | - fatal_lang_error('no_access', false); |
|
| 383 | + if (!isset($_GET['tid'])) { |
|
| 384 | + fatal_lang_error('no_access', false); |
|
| 385 | + } |
|
| 375 | 386 | $_GET['tid'] = (int) $_GET['tid']; |
| 376 | 387 | |
| 377 | 388 | // Saving? |
@@ -387,10 +398,12 @@ discard block |
||
| 387 | 398 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
| 388 | 399 | |
| 389 | 400 | // If a half is empty then assume zero offset! |
| 390 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
| 391 | - $matches[2] = 0; |
|
| 392 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
| 393 | - $matches[1] = 0; |
|
| 401 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
| 402 | + $matches[2] = 0; |
|
| 403 | + } |
|
| 404 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
| 405 | + $matches[1] = 0; |
|
| 406 | + } |
|
| 394 | 407 | |
| 395 | 408 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
| 396 | 409 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -400,8 +413,9 @@ discard block |
||
| 400 | 413 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
| 401 | 414 | |
| 402 | 415 | // Don't allow one minute intervals. |
| 403 | - if ($interval == 1 && $unit == 'm') |
|
| 404 | - $interval = 2; |
|
| 416 | + if ($interval == 1 && $unit == 'm') { |
|
| 417 | + $interval = 2; |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Is it disabled? |
| 407 | 421 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -439,8 +453,9 @@ discard block |
||
| 439 | 453 | ); |
| 440 | 454 | |
| 441 | 455 | // Should never, ever, happen! |
| 442 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 443 | - fatal_lang_error('no_access', false); |
|
| 456 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 457 | + fatal_lang_error('no_access', false); |
|
| 458 | + } |
|
| 444 | 459 | |
| 445 | 460 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 446 | 461 | { |
@@ -598,13 +613,14 @@ discard block |
||
| 598 | 613 | ) |
| 599 | 614 | ); |
| 600 | 615 | $log_entries = array(); |
| 601 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 602 | - $log_entries[] = array( |
|
| 616 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 617 | + $log_entries[] = array( |
|
| 603 | 618 | 'id' => $row['id_log'], |
| 604 | 619 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
| 605 | 620 | 'time_run' => $row['time_run'], |
| 606 | 621 | 'time_taken' => $row['time_taken'], |
| 607 | 622 | ); |
| 623 | + } |
|
| 608 | 624 | $smcFunc['db_free_result']($request); |
| 609 | 625 | |
| 610 | 626 | return $log_entries; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | 'is_approved' => 1, |
| 45 | 46 | ) |
| 46 | 47 | ); |
| 47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 48 | - return array(); |
|
| 48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 49 | + return array(); |
|
| 50 | + } |
|
| 49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
| 50 | 52 | $smcFunc['db_free_result']($request); |
| 51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | censorText($row['body']); |
| 55 | 57 | |
| 56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
| 57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Send the data. |
| 61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
| 83 | 86 | |
| 84 | 87 | $context['is_redirect'] = false; |
| 85 | 88 | |
| 86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
| 87 | - $_REQUEST['start'] = 95; |
|
| 89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
| 90 | + $_REQUEST['start'] = 95; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $query_parameters = array(); |
| 90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
| 91 | 95 | { |
| 92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 94 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 98 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 99 | + } |
|
| 95 | 100 | |
| 96 | 101 | if (count($_REQUEST['c']) == 1) |
| 97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
| 107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
| 108 | 113 | $smcFunc['db_free_result']($request); |
| 109 | 114 | |
| 110 | - if (empty($name)) |
|
| 111 | - fatal_lang_error('no_access', false); |
|
| 115 | + if (empty($name)) { |
|
| 116 | + fatal_lang_error('no_access', false); |
|
| 117 | + } |
|
| 112 | 118 | |
| 113 | 119 | $context['linktree'][] = array( |
| 114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | $smcFunc['db_free_result']($request); |
| 142 | 148 | |
| 143 | - if (empty($boards)) |
|
| 144 | - fatal_lang_error('error_no_boards_selected'); |
|
| 149 | + if (empty($boards)) { |
|
| 150 | + fatal_lang_error('error_no_boards_selected'); |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
| 155 | 162 | } |
| 156 | 163 | |
| 157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
| 158 | - } |
|
| 159 | - elseif (!empty($_REQUEST['boards'])) |
|
| 165 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 160 | 166 | { |
| 161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $request = $smcFunc['db_query']('', ' |
| 166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
| 184 | 191 | } |
| 185 | 192 | $smcFunc['db_free_result']($request); |
| 186 | 193 | |
| 187 | - if (empty($boards)) |
|
| 188 | - fatal_lang_error('error_no_boards_selected'); |
|
| 194 | + if (empty($boards)) { |
|
| 195 | + fatal_lang_error('error_no_boards_selected'); |
|
| 196 | + } |
|
| 189 | 197 | |
| 190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
| 199 | 207 | } |
| 200 | 208 | |
| 201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
| 202 | - } |
|
| 203 | - elseif (!empty($board)) |
|
| 210 | + } elseif (!empty($board)) |
|
| 204 | 211 | { |
| 205 | 212 | $request = $smcFunc['db_query']('', ' |
| 206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
| 233 | 240 | } |
| 234 | 241 | |
| 235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
| 236 | - } |
|
| 237 | - else |
|
| 243 | + } else |
|
| 238 | 244 | { |
| 239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
| 272 | - if ($context['is_redirect']) |
|
| 273 | - $messages = 0; |
|
| 278 | + if ($context['is_redirect']) { |
|
| 279 | + $messages = 0; |
|
| 280 | + } |
|
| 274 | 281 | |
| 275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5(json_encode(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
| 276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
| 301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
| 302 | 309 | $cache_results = true; |
| 303 | 310 | unset($query_parameters['max_id_msg']); |
| 311 | + } else { |
|
| 312 | + $done = true; |
|
| 304 | 313 | } |
| 305 | - else |
|
| 306 | - $done = true; |
|
| 307 | 314 | } |
| 308 | 315 | $messages = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $messages[] = $row['id_msg']; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $messages[] = $row['id_msg']; |
|
| 318 | + } |
|
| 311 | 319 | $smcFunc['db_free_result']($request); |
| 312 | - if (!empty($cache_results)) |
|
| 313 | - cache_put_data($key, $messages, 120); |
|
| 320 | + if (!empty($cache_results)) { |
|
| 321 | + cache_put_data($key, $messages, 120); |
|
| 322 | + } |
|
| 314 | 323 | } |
| 315 | 324 | |
| 316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
| 397 | 406 | 'css_class' => 'windowbg', |
| 398 | 407 | ); |
| 399 | 408 | |
| 400 | - if ($user_info['id'] == $row['id_first_member']) |
|
| 401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
| 410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 411 | + } |
|
| 402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
| 403 | 413 | } |
| 404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
| 424 | 434 | $boards = boardsAllowedTo($permission); |
| 425 | 435 | |
| 426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
| 427 | - if (!empty($boards) && $boards[0] == 0) |
|
| 428 | - $boards = array_keys($board_ids[$type]); |
|
| 437 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 438 | + $boards = array_keys($board_ids[$type]); |
|
| 439 | + } |
|
| 429 | 440 | |
| 430 | 441 | // Go through the boards, and look for posts they can do this on. |
| 431 | 442 | foreach ($boards as $board_id) |
| 432 | 443 | { |
| 433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
| 434 | - if (!isset($board_ids[$type][$board_id])) |
|
| 435 | - continue; |
|
| 445 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 436 | 448 | |
| 437 | 449 | // Okay, looks like they can do it for these posts. |
| 438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 440 | 452 | $context['posts'][$counter][$allowed] = true; |
| 453 | + } |
|
| 441 | 454 | } |
| 442 | 455 | } |
| 443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
| 480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
| 481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
| 482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
| 483 | - if ($_REQUEST['action'] == 'unread') |
|
| 484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 485 | - else |
|
| 486 | - $context['page_title'] = $txt['unread_replies']; |
|
| 496 | + if ($_REQUEST['action'] == 'unread') { |
|
| 497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 498 | + } else { |
|
| 499 | + $context['page_title'] = $txt['unread_replies']; |
|
| 500 | + } |
|
| 487 | 501 | |
| 488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
| 489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
| 491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
| 493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
| 502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
| 503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
| 505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
| 507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
| 508 | + } |
|
| 494 | 509 | |
| 495 | 510 | // Parameters for the main query. |
| 496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
| 503 | 518 | if (!empty($_REQUEST['boards'])) |
| 504 | 519 | { |
| 505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 506 | - foreach ($_REQUEST['boards'] as $b) |
|
| 507 | - $boards[] = (int) $b; |
|
| 521 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 522 | + $boards[] = (int) $b; |
|
| 523 | + } |
|
| 508 | 524 | } |
| 509 | 525 | |
| 510 | - if (!empty($board)) |
|
| 511 | - $boards[] = (int) $board; |
|
| 526 | + if (!empty($board)) { |
|
| 527 | + $boards[] = (int) $board; |
|
| 528 | + } |
|
| 512 | 529 | |
| 513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
| 514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
| 525 | 542 | ) |
| 526 | 543 | ); |
| 527 | 544 | |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - if (in_array($row['id_parent'], $boards)) |
|
| 545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 546 | + if (in_array($row['id_parent'], $boards)) |
|
| 530 | 547 | $boards[] = $row['id_board']; |
| 548 | + } |
|
| 531 | 549 | |
| 532 | 550 | $smcFunc['db_free_result']($request); |
| 533 | 551 | |
| 534 | - if (empty($boards)) |
|
| 535 | - fatal_lang_error('error_no_boards_selected'); |
|
| 552 | + if (empty($boards)) { |
|
| 553 | + fatal_lang_error('error_no_boards_selected'); |
|
| 554 | + } |
|
| 536 | 555 | |
| 537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 538 | 557 | $query_parameters['boards'] = $boards; |
| 539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
| 540 | - } |
|
| 541 | - elseif (!empty($board)) |
|
| 559 | + } elseif (!empty($board)) |
|
| 542 | 560 | { |
| 543 | 561 | $query_this_board = 'id_board = {int:board}'; |
| 544 | 562 | $query_parameters['board'] = $board; |
| 545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
| 546 | - } |
|
| 547 | - elseif (!empty($_REQUEST['boards'])) |
|
| 564 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 548 | 565 | { |
| 549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 569 | + } |
|
| 552 | 570 | |
| 553 | 571 | $request = $smcFunc['db_query']('', ' |
| 554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
| 560 | 578 | ) |
| 561 | 579 | ); |
| 562 | 580 | $boards = array(); |
| 563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 564 | - $boards[] = $row['id_board']; |
|
| 581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 582 | + $boards[] = $row['id_board']; |
|
| 583 | + } |
|
| 565 | 584 | $smcFunc['db_free_result']($request); |
| 566 | 585 | |
| 567 | - if (empty($boards)) |
|
| 568 | - fatal_lang_error('error_no_boards_selected'); |
|
| 586 | + if (empty($boards)) { |
|
| 587 | + fatal_lang_error('error_no_boards_selected'); |
|
| 588 | + } |
|
| 569 | 589 | |
| 570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 571 | 591 | $query_parameters['boards'] = $boards; |
| 572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
| 573 | - } |
|
| 574 | - elseif (!empty($_REQUEST['c'])) |
|
| 593 | + } elseif (!empty($_REQUEST['c'])) |
|
| 575 | 594 | { |
| 576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 578 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 597 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 598 | + } |
|
| 579 | 599 | |
| 580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
| 588 | 608 | ) |
| 589 | 609 | ); |
| 590 | 610 | $boards = array(); |
| 591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 592 | - $boards[] = $row['id_board']; |
|
| 611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 612 | + $boards[] = $row['id_board']; |
|
| 613 | + } |
|
| 593 | 614 | $smcFunc['db_free_result']($request); |
| 594 | 615 | |
| 595 | - if (empty($boards)) |
|
| 596 | - fatal_lang_error('error_no_boards_selected'); |
|
| 616 | + if (empty($boards)) { |
|
| 617 | + fatal_lang_error('error_no_boards_selected'); |
|
| 618 | + } |
|
| 597 | 619 | |
| 598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 599 | 621 | $query_parameters['boards'] = $boards; |
| 600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
| 601 | - } |
|
| 602 | - else |
|
| 623 | + } else |
|
| 603 | 624 | { |
| 604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
| 613 | 634 | ) |
| 614 | 635 | ); |
| 615 | 636 | $boards = array(); |
| 616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 617 | - $boards[] = $row['id_board']; |
|
| 637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 638 | + $boards[] = $row['id_board']; |
|
| 639 | + } |
|
| 618 | 640 | $smcFunc['db_free_result']($request); |
| 619 | 641 | |
| 620 | - if (empty($boards)) |
|
| 621 | - fatal_lang_error('error_no_boards_available', false); |
|
| 642 | + if (empty($boards)) { |
|
| 643 | + fatal_lang_error('error_no_boards_available', false); |
|
| 644 | + } |
|
| 622 | 645 | |
| 623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
| 680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
| 681 | 704 | ); |
| 682 | 705 | |
| 683 | - if ($context['showing_all_topics']) |
|
| 684 | - $context['linktree'][] = array( |
|
| 706 | + if ($context['showing_all_topics']) { |
|
| 707 | + $context['linktree'][] = array( |
|
| 685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
| 686 | 709 | 'name' => $txt['unread_topics_all'] |
| 687 | 710 | ); |
| 688 | - else |
|
| 689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 711 | + } else { |
|
| 712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 713 | + } |
|
| 690 | 714 | |
| 691 | 715 | loadTemplate('Recent'); |
| 692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
| 694 | 718 | |
| 695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
| 696 | 720 | $context['icon_sources'] = array(); |
| 697 | - foreach ($context['stable_icons'] as $icon) |
|
| 698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 721 | + foreach ($context['stable_icons'] as $icon) { |
|
| 722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 723 | + } |
|
| 699 | 724 | |
| 700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
| 701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
| 725 | 750 | ); |
| 726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
| 727 | 752 | $smcFunc['db_free_result']($request); |
| 728 | - } |
|
| 729 | - else |
|
| 753 | + } else |
|
| 730 | 754 | { |
| 731 | 755 | $request = $smcFunc['db_query']('', ' |
| 732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
| 742 | 766 | } |
| 743 | 767 | |
| 744 | 768 | // This is needed in case of topics marked unread. |
| 745 | - if (empty($earliest_msg)) |
|
| 746 | - $earliest_msg = 0; |
|
| 747 | - else |
|
| 769 | + if (empty($earliest_msg)) { |
|
| 770 | + $earliest_msg = 0; |
|
| 771 | + } else |
|
| 748 | 772 | { |
| 749 | 773 | // Using caching, when possible, to ignore the below slow query. |
| 750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
| 751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 752 | - else |
|
| 774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
| 775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 776 | + } else |
|
| 753 | 777 | { |
| 754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
| 755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
| 764 | 788 | $smcFunc['db_free_result']($request); |
| 765 | 789 | |
| 766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
| 767 | - if ($earliest_msg2 == 0) |
|
| 768 | - $earliest_msg2 = -1; |
|
| 791 | + if ($earliest_msg2 == 0) { |
|
| 792 | + $earliest_msg2 = -1; |
|
| 793 | + } |
|
| 769 | 794 | |
| 770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
| 771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
| 803 | 828 | 'db_error_skip' => true, |
| 804 | 829 | )) |
| 805 | 830 | ) !== false; |
| 831 | + } else { |
|
| 832 | + $have_temp_table = false; |
|
| 806 | 833 | } |
| 807 | - else |
|
| 808 | - $have_temp_table = false; |
|
| 809 | 834 | |
| 810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
| 811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
| 851 | 876 | |
| 852 | 877 | $context['topics'] = array(); |
| 853 | 878 | $context['no_topic_listing'] = true; |
| 854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
| 855 | - $context['querystring_board_limits'] = ''; |
|
| 856 | - else |
|
| 857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
| 880 | + $context['querystring_board_limits'] = ''; |
|
| 881 | + } else { |
|
| 882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 883 | + } |
|
| 858 | 884 | return; |
| 885 | + } else { |
|
| 886 | + $min_message = (int) $min_message; |
|
| 859 | 887 | } |
| 860 | - else |
|
| 861 | - $min_message = (int) $min_message; |
|
| 862 | 888 | |
| 863 | 889 | $request = $smcFunc['db_query']('substring', ' |
| 864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
| 887 | 913 | 'limit' => $context['topics_per_page'], |
| 888 | 914 | )) |
| 889 | 915 | ); |
| 890 | - } |
|
| 891 | - elseif ($is_topics) |
|
| 916 | + } elseif ($is_topics) |
|
| 892 | 917 | { |
| 893 | 918 | $request = $smcFunc['db_query']('', ' |
| 894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
| 939 | 964 | |
| 940 | 965 | $context['topics'] = array(); |
| 941 | 966 | $context['no_topic_listing'] = true; |
| 942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 943 | - $context['querystring_board_limits'] = ''; |
|
| 944 | - else |
|
| 945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 968 | + $context['querystring_board_limits'] = ''; |
|
| 969 | + } else { |
|
| 970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 971 | + } |
|
| 946 | 972 | return; |
| 973 | + } else { |
|
| 974 | + $min_message = (int) $min_message; |
|
| 947 | 975 | } |
| 948 | - else |
|
| 949 | - $min_message = (int) $min_message; |
|
| 950 | 976 | |
| 951 | 977 | $request = $smcFunc['db_query']('substring', ' |
| 952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
| 976 | 1002 | 'limit' => $context['topics_per_page'], |
| 977 | 1003 | )) |
| 978 | 1004 | ); |
| 979 | - } |
|
| 980 | - else |
|
| 1005 | + } else |
|
| 981 | 1006 | { |
| 982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
| 983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
| 1029 | 1054 | ) !== false; |
| 1030 | 1055 | |
| 1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
| 1032 | - if ($have_temp_table) |
|
| 1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1057 | + if ($have_temp_table) { |
|
| 1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
| 1035 | 1060 | PRIMARY KEY (id_topic) |
| 1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
| 1043 | 1068 | 'db_error_skip' => true, |
| 1044 | 1069 | ) |
| 1045 | 1070 | ) !== false; |
| 1071 | + } |
|
| 1046 | 1072 | } |
| 1047 | 1073 | |
| 1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
| 1058 | 1084 | ); |
| 1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
| 1060 | 1086 | $smcFunc['db_free_result']($request); |
| 1061 | - } |
|
| 1062 | - else |
|
| 1087 | + } else |
|
| 1063 | 1088 | { |
| 1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
| 1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
| 1100 | 1125 | { |
| 1101 | 1126 | $context['topics'] = array(); |
| 1102 | 1127 | $context['no_topic_listing'] = true; |
| 1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1104 | - $context['querystring_board_limits'] = ''; |
|
| 1105 | - else |
|
| 1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1129 | + $context['querystring_board_limits'] = ''; |
|
| 1130 | + } else { |
|
| 1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1132 | + } |
|
| 1107 | 1133 | return; |
| 1108 | 1134 | } |
| 1109 | 1135 | |
| 1110 | - if (!empty($have_temp_table)) |
|
| 1111 | - $request = $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($have_temp_table)) { |
|
| 1137 | + $request = $smcFunc['db_query']('', ' |
|
| 1112 | 1138 | SELECT t.id_topic |
| 1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
| 1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
| 1122 | 1148 | 'limit' => $context['topics_per_page'], |
| 1123 | 1149 | )) |
| 1124 | 1150 | ); |
| 1125 | - else |
|
| 1126 | - $request = $smcFunc['db_query']('', ' |
|
| 1151 | + } else { |
|
| 1152 | + $request = $smcFunc['db_query']('', ' |
|
| 1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
| 1128 | 1154 | FROM {db_prefix}topics AS t |
| 1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
| 1147 | 1173 | 'sort' => $_REQUEST['sort'], |
| 1148 | 1174 | )) |
| 1149 | 1175 | ); |
| 1176 | + } |
|
| 1150 | 1177 | |
| 1151 | 1178 | $topics = array(); |
| 1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1153 | - $topics[] = $row['id_topic']; |
|
| 1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1180 | + $topics[] = $row['id_topic']; |
|
| 1181 | + } |
|
| 1154 | 1182 | $smcFunc['db_free_result']($request); |
| 1155 | 1183 | |
| 1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
| 1158 | 1186 | { |
| 1159 | 1187 | $context['topics'] = array(); |
| 1160 | 1188 | $context['no_topic_listing'] = true; |
| 1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1162 | - $context['querystring_board_limits'] = ''; |
|
| 1163 | - else |
|
| 1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1190 | + $context['querystring_board_limits'] = ''; |
|
| 1191 | + } else { |
|
| 1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1193 | + } |
|
| 1165 | 1194 | return; |
| 1166 | 1195 | } |
| 1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
| 1195 | 1224 | |
| 1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1197 | 1226 | { |
| 1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 1199 | - continue; |
|
| 1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 1228 | + continue; |
|
| 1229 | + } |
|
| 1200 | 1230 | |
| 1201 | 1231 | $topic_ids[] = $row['id_topic']; |
| 1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
| 1204 | 1234 | { |
| 1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
| 1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
| 1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
| 1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1239 | + } |
|
| 1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
| 1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
| 1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1243 | + } |
|
| 1212 | 1244 | |
| 1213 | 1245 | // Censor the subject and message preview. |
| 1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
| 1219 | 1251 | { |
| 1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
| 1221 | 1253 | $row['last_body'] = $row['first_body']; |
| 1222 | - } |
|
| 1223 | - else |
|
| 1254 | + } else |
|
| 1224 | 1255 | { |
| 1225 | 1256 | censorText($row['last_subject']); |
| 1226 | 1257 | censorText($row['last_body']); |
| 1227 | 1258 | } |
| 1228 | - } |
|
| 1229 | - else |
|
| 1259 | + } else |
|
| 1230 | 1260 | { |
| 1231 | 1261 | $row['first_body'] = ''; |
| 1232 | 1262 | $row['last_body'] = ''; |
| 1233 | 1263 | censorText($row['first_subject']); |
| 1234 | 1264 | |
| 1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 1236 | - $row['last_subject'] = $row['first_subject']; |
|
| 1237 | - else |
|
| 1238 | - censorText($row['last_subject']); |
|
| 1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 1266 | + $row['last_subject'] = $row['first_subject']; |
|
| 1267 | + } else { |
|
| 1268 | + censorText($row['last_subject']); |
|
| 1269 | + } |
|
| 1239 | 1270 | } |
| 1240 | 1271 | |
| 1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
| 1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
| 1248 | 1279 | |
| 1249 | 1280 | // If we can use all, show all. |
| 1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
| 1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
| 1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1283 | + } |
|
| 1284 | + } else { |
|
| 1285 | + $pages = ''; |
|
| 1252 | 1286 | } |
| 1253 | 1287 | |
| 1254 | - else |
|
| 1255 | - $pages = ''; |
|
| 1256 | - |
|
| 1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
| 1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1259 | 1290 | { |
| 1260 | 1291 | // First icon first... as you'd expect. |
| 1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1294 | + } |
|
| 1263 | 1295 | // Last icon... last... duh. |
| 1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1298 | + } |
|
| 1266 | 1299 | } |
| 1267 | 1300 | |
| 1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
| 1276 | 1309 | $colorClass = 'windowbg'; |
| 1277 | 1310 | |
| 1278 | 1311 | // Sticky topics should get a different color, too. |
| 1279 | - if ($row['is_sticky']) |
|
| 1280 | - $colorClass .= ' sticky'; |
|
| 1312 | + if ($row['is_sticky']) { |
|
| 1313 | + $colorClass .= ' sticky'; |
|
| 1314 | + } |
|
| 1281 | 1315 | |
| 1282 | 1316 | // Locked topics get special treatment as well. |
| 1283 | - if ($row['locked']) |
|
| 1284 | - $colorClass .= ' locked'; |
|
| 1317 | + if ($row['locked']) { |
|
| 1318 | + $colorClass .= ' locked'; |
|
| 1319 | + } |
|
| 1285 | 1320 | |
| 1286 | 1321 | // And build the array. |
| 1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
| 1378 | 1413 | ); |
| 1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1380 | 1415 | { |
| 1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
| 1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
| 1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1418 | + } |
|
| 1383 | 1419 | } |
| 1384 | 1420 | $smcFunc['db_free_result']($result); |
| 1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
| 1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1395 | 1431 | ); |
| 1396 | 1432 | |
| 1397 | - if ($context['showCheckboxes']) |
|
| 1398 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1433 | + if ($context['showCheckboxes']) { |
|
| 1434 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1399 | 1435 | 'text' => 'quick_mod_markread', |
| 1400 | 1436 | 'image' => 'markselectedread.png', |
| 1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1402 | 1438 | ); |
| 1439 | + } |
|
| 1403 | 1440 | |
| 1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
| 1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1406 | - } |
|
| 1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
| 1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1443 | + } |
|
| 1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1408 | 1445 | { |
| 1409 | 1446 | $context['recent_buttons'] = array( |
| 1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1411 | 1448 | ); |
| 1412 | 1449 | |
| 1413 | - if ($context['showCheckboxes']) |
|
| 1414 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1450 | + if ($context['showCheckboxes']) { |
|
| 1451 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1415 | 1452 | 'text' => 'quick_mod_markread', |
| 1416 | 1453 | 'image' => 'markselectedread.png', |
| 1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1418 | 1455 | ); |
| 1456 | + } |
|
| 1419 | 1457 | } |
| 1420 | 1458 | |
| 1421 | 1459 | // Allow mods to add additional buttons here |