@@ -62,16 +62,17 @@ |
||
62 | 62 | <div id="error_box" class="errorbox"> |
63 | 63 | <ul id="error_list">'; |
64 | 64 | |
65 | - foreach ($context['post_errors'] as $key => $error) |
|
66 | - echo ' |
|
65 | + foreach ($context['post_errors'] as $key => $error) { |
|
66 | + echo ' |
|
67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
68 | + } |
|
68 | 69 | |
69 | 70 | echo ' |
70 | 71 | </ul>'; |
71 | - } |
|
72 | - else |
|
73 | - echo ' |
|
72 | + } else { |
|
73 | + echo ' |
|
74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
75 | + } |
|
75 | 76 | |
76 | 77 | echo ' |
77 | 78 | </div>'; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | { |
28 | 29 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
29 | 30 | |
30 | - if ($test) |
|
31 | - return $supported; |
|
31 | + if ($test) { |
|
32 | + return $supported; |
|
33 | + } |
|
32 | 34 | return parent::isSupported() && $supported; |
33 | 35 | } |
34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
51 | 53 | |
52 | 54 | // An extended key is needed to counteract a bug in APC. |
53 | - if ($value === null) |
|
54 | - return apc_delete($key . 'smf'); |
|
55 | - else |
|
56 | - return apc_store($key . 'smf', $value, $ttl); |
|
55 | + if ($value === null) { |
|
56 | + return apc_delete($key . 'smf'); |
|
57 | + } else { |
|
58 | + return apc_store($key . 'smf', $value, $ttl); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | |
59 | 62 | /** |
@@ -67,9 +70,9 @@ discard block |
||
67 | 70 | // Always returns true. |
68 | 71 | apc_clear_cache('user'); |
69 | 72 | apc_clear_cache('system'); |
73 | + } elseif ($type === 'user') { |
|
74 | + apc_clear_cache('user'); |
|
70 | 75 | } |
71 | - elseif ($type === 'user') |
|
72 | - apc_clear_cache('user'); |
|
73 | 76 | |
74 | 77 | $this->invalidateCache(); |
75 | 78 | return true; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | { |
45 | 46 | $supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0; |
46 | 47 | |
47 | - if ($test) |
|
48 | - return $supported; |
|
48 | + if ($test) { |
|
49 | + return $supported; |
|
50 | + } |
|
49 | 51 | return parent::isSupported() && $supported; |
50 | 52 | } |
51 | 53 | |
@@ -66,10 +68,11 @@ discard block |
||
66 | 68 | { |
67 | 69 | $key = $this->prefix . strtr($key, ':/', '-_'); |
68 | 70 | |
69 | - if ($value === null) |
|
70 | - return xcache_unset($key); |
|
71 | - else |
|
72 | - return xcache_set($key, $value, $ttl); |
|
71 | + if ($value === null) { |
|
72 | + return xcache_unset($key); |
|
73 | + } else { |
|
74 | + return xcache_set($key, $value, $ttl); |
|
75 | + } |
|
73 | 76 | } |
74 | 77 | |
75 | 78 | /** |
@@ -88,10 +91,12 @@ discard block |
||
88 | 91 | } |
89 | 92 | |
90 | 93 | // if passed a type, clear that type out |
91 | - if ($type === '' || $type === 'user') |
|
92 | - xcache_clear_cache(XC_TYPE_VAR, 0); |
|
93 | - if ($type === '' || $type === 'data') |
|
94 | - xcache_clear_cache(XC_TYPE_PHP, 0); |
|
94 | + if ($type === '' || $type === 'user') { |
|
95 | + xcache_clear_cache(XC_TYPE_VAR, 0); |
|
96 | + } |
|
97 | + if ($type === '' || $type === 'data') { |
|
98 | + xcache_clear_cache(XC_TYPE_PHP, 0); |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $this->invalidateCache(); |
97 | 102 | return true; |
@@ -110,8 +115,9 @@ discard block |
||
110 | 115 | // While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves. |
111 | 116 | $config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0); |
112 | 117 | |
113 | - if (!isset($context['settings_post_javascript'])) |
|
114 | - $context['settings_post_javascript'] = ''; |
|
118 | + if (!isset($context['settings_post_javascript'])) { |
|
119 | + $context['settings_post_javascript'] = ''; |
|
120 | + } |
|
115 | 121 | |
116 | 122 | $context['settings_post_javascript'] .= ' |
117 | 123 | $("#cache_accelerator").change(function (e) { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
43 | 44 | |
44 | 45 | // Is the security option off? |
45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
46 | - return; |
|
46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
50 | - return; |
|
51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
52 | + return; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | if (isset($_POST[$type . '_pass'])) |
56 | 59 | { |
57 | 60 | // Check to ensure we're forcing SSL for authentication |
58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
59 | - fatal_lang_error('login_ssl_required'); |
|
61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
62 | + fatal_lang_error('login_ssl_required'); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | checkSession(); |
62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
72 | 76 | } |
73 | 77 | |
74 | 78 | // Better be sure to remember the real referer |
75 | - if (empty($_SESSION['request_referer'])) |
|
76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
77 | - elseif (empty($_POST)) |
|
78 | - unset($_SESSION['request_referer']); |
|
79 | + if (empty($_SESSION['request_referer'])) { |
|
80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
81 | + } elseif (empty($_POST)) { |
|
82 | + unset($_SESSION['request_referer']); |
|
83 | + } |
|
79 | 84 | |
80 | 85 | // Need to type in a password for that, man. |
81 | - if (!isset($_GET['xml'])) |
|
82 | - adminLogin($type); |
|
83 | - else |
|
84 | - return 'session_verify_fail'; |
|
85 | -} |
|
86 | + if (!isset($_GET['xml'])) { |
|
87 | + adminLogin($type); |
|
88 | + } else { |
|
89 | + return 'session_verify_fail'; |
|
90 | + } |
|
91 | + } |
|
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
97 | 103 | |
98 | 104 | // Luckily, this person isn't a guest. |
99 | - if (!$user_info['is_guest']) |
|
100 | - return; |
|
105 | + if (!$user_info['is_guest']) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | // Log what they were trying to do didn't work) |
103 | - if (!empty($modSettings['who_enabled'])) |
|
104 | - $_GET['error'] = 'guest_login'; |
|
110 | + if (!empty($modSettings['who_enabled'])) { |
|
111 | + $_GET['error'] = 'guest_login'; |
|
112 | + } |
|
105 | 113 | writeLog(true); |
106 | 114 | |
107 | 115 | // Just die. |
108 | - if (isset($_REQUEST['xml'])) |
|
109 | - obExit(false); |
|
116 | + if (isset($_REQUEST['xml'])) { |
|
117 | + obExit(false); |
|
118 | + } |
|
110 | 119 | |
111 | 120 | // Attempt to detect if they came from dlattach. |
112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
113 | - loadTheme(); |
|
121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
122 | + loadTheme(); |
|
123 | + } |
|
114 | 124 | |
115 | 125 | // Never redirect to an attachment |
116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | // Load the Login template and language file. |
120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | { |
125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
126 | 137 | redirectexit('action=login'); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | { |
130 | 140 | loadTemplate('Login'); |
131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
156 | 166 | |
157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
158 | - if ($user_info['is_admin']) |
|
159 | - return; |
|
168 | + if ($user_info['is_admin']) { |
|
169 | + return; |
|
170 | + } |
|
160 | 171 | |
161 | 172 | // Only check the ban every so often. (to reduce load.) |
162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
177 | 188 | // Check both IP addresses. |
178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
179 | 190 | { |
180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
181 | - continue; |
|
191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
192 | + continue; |
|
193 | + } |
|
182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
228 | 240 | // Store every type of ban that applies to you in your session. |
229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
230 | 242 | { |
231 | - foreach ($restrictions as $restriction) |
|
232 | - if (!empty($row[$restriction])) |
|
243 | + foreach ($restrictions as $restriction) { |
|
244 | + if (!empty($row[$restriction])) |
|
233 | 245 | { |
234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
247 | + } |
|
235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
251 | + } |
|
238 | 252 | |
239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
240 | - $flag_is_activated = true; |
|
253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
254 | + $flag_is_activated = true; |
|
255 | + } |
|
241 | 256 | } |
242 | 257 | } |
243 | 258 | $smcFunc['db_free_result']($request); |
244 | 259 | } |
245 | 260 | |
246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
261 | 277 | { |
262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
263 | - foreach ($bans as $key => $value) |
|
264 | - $bans[$key] = (int) $value; |
|
279 | + foreach ($bans as $key => $value) { |
|
280 | + $bans[$key] = (int) $value; |
|
281 | + } |
|
265 | 282 | $request = $smcFunc['db_query']('', ' |
266 | 283 | SELECT bi.id_ban, bg.reason |
267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -297,14 +314,15 @@ discard block |
||
297 | 314 | if (isset($_SESSION['ban']['cannot_access'])) |
298 | 315 | { |
299 | 316 | // We don't wanna see you! |
300 | - if (!$user_info['is_guest']) |
|
301 | - $smcFunc['db_query']('', ' |
|
317 | + if (!$user_info['is_guest']) { |
|
318 | + $smcFunc['db_query']('', ' |
|
302 | 319 | DELETE FROM {db_prefix}log_online |
303 | 320 | WHERE id_member = {int:current_member}', |
304 | 321 | array( |
305 | 322 | 'current_member' => $user_info['id'], |
306 | 323 | ) |
307 | 324 | ); |
325 | + } |
|
308 | 326 | |
309 | 327 | // 'Log' the user out. Can't have any funny business... (save the name!) |
310 | 328 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -390,9 +408,10 @@ discard block |
||
390 | 408 | } |
391 | 409 | |
392 | 410 | // Fix up the banning permissions. |
393 | - if (isset($user_info['permissions'])) |
|
394 | - banPermissions(); |
|
395 | -} |
|
411 | + if (isset($user_info['permissions'])) { |
|
412 | + banPermissions(); |
|
413 | + } |
|
414 | + } |
|
396 | 415 | |
397 | 416 | /** |
398 | 417 | * Fix permissions according to ban status. |
@@ -403,8 +422,9 @@ discard block |
||
403 | 422 | global $user_info, $sourcedir, $modSettings, $context; |
404 | 423 | |
405 | 424 | // Somehow they got here, at least take away all permissions... |
406 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
407 | - $user_info['permissions'] = array(); |
|
425 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
426 | + $user_info['permissions'] = array(); |
|
427 | + } |
|
408 | 428 | // Okay, well, you can watch, but don't touch a thing. |
409 | 429 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
410 | 430 | { |
@@ -446,19 +466,20 @@ discard block |
||
446 | 466 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
447 | 467 | foreach ($permission_change as $old => $new) |
448 | 468 | { |
449 | - if (!in_array($old, $user_info['permissions'])) |
|
450 | - unset($permission_change[$old]); |
|
451 | - else |
|
452 | - $user_info['permissions'][] = $new; |
|
469 | + if (!in_array($old, $user_info['permissions'])) { |
|
470 | + unset($permission_change[$old]); |
|
471 | + } else { |
|
472 | + $user_info['permissions'][] = $new; |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
455 | 476 | } |
456 | 477 | |
457 | 478 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
458 | 479 | // Finally, some bits we cache in the session because it saves queries. |
459 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
460 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
461 | - else |
|
480 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
481 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
482 | + } else |
|
462 | 483 | { |
463 | 484 | require_once($sourcedir . '/Subs-Auth.php'); |
464 | 485 | rebuildModCache(); |
@@ -469,14 +490,12 @@ discard block |
||
469 | 490 | { |
470 | 491 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
471 | 492 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
472 | - } |
|
473 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
493 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
474 | 494 | { |
475 | 495 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
476 | 496 | $context['open_mod_reports'] = recountOpenReports('posts'); |
477 | 497 | $context['open_member_reports'] = recountOpenReports('members'); |
478 | - } |
|
479 | - else |
|
498 | + } else |
|
480 | 499 | { |
481 | 500 | $context['open_mod_reports'] = 0; |
482 | 501 | $context['open_member_reports'] = 0; |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | global $user_info, $smcFunc; |
497 | 516 | |
498 | 517 | // Don't log web accelerators, it's very confusing... |
499 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
500 | - return; |
|
518 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
519 | + return; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | $smcFunc['db_insert']('', |
503 | 523 | '{db_prefix}log_banned', |
@@ -507,8 +527,8 @@ discard block |
||
507 | 527 | ); |
508 | 528 | |
509 | 529 | // One extra point for these bans. |
510 | - if (!empty($ban_ids)) |
|
511 | - $smcFunc['db_query']('', ' |
|
530 | + if (!empty($ban_ids)) { |
|
531 | + $smcFunc['db_query']('', ' |
|
512 | 532 | UPDATE {db_prefix}ban_items |
513 | 533 | SET hits = hits + 1 |
514 | 534 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -516,7 +536,8 @@ discard block |
||
516 | 536 | 'ban_ids' => $ban_ids, |
517 | 537 | ) |
518 | 538 | ); |
519 | -} |
|
539 | + } |
|
540 | + } |
|
520 | 541 | |
521 | 542 | /** |
522 | 543 | * Checks if a given email address might be banned. |
@@ -532,8 +553,9 @@ discard block |
||
532 | 553 | global $txt, $smcFunc; |
533 | 554 | |
534 | 555 | // Can't ban an empty email |
535 | - if (empty($email) || trim($email) == '') |
|
536 | - return; |
|
556 | + if (empty($email) || trim($email) == '') { |
|
557 | + return; |
|
558 | + } |
|
537 | 559 | |
538 | 560 | // Let's start with the bans based on your IP/hostname/memberID... |
539 | 561 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -606,16 +628,18 @@ discard block |
||
606 | 628 | if ($type == 'post') |
607 | 629 | { |
608 | 630 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
609 | - if ($check !== $sc) |
|
610 | - $error = 'session_timeout'; |
|
631 | + if ($check !== $sc) { |
|
632 | + $error = 'session_timeout'; |
|
633 | + } |
|
611 | 634 | } |
612 | 635 | |
613 | 636 | // How about $_GET['sesc']? |
614 | 637 | elseif ($type == 'get') |
615 | 638 | { |
616 | 639 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
617 | - if ($check !== $sc) |
|
618 | - $error = 'session_verify_fail'; |
|
640 | + if ($check !== $sc) { |
|
641 | + $error = 'session_verify_fail'; |
|
642 | + } |
|
619 | 643 | } |
620 | 644 | |
621 | 645 | // Or can it be in either? |
@@ -623,13 +647,15 @@ discard block |
||
623 | 647 | { |
624 | 648 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
625 | 649 | |
626 | - if ($check !== $sc) |
|
627 | - $error = 'session_verify_fail'; |
|
650 | + if ($check !== $sc) { |
|
651 | + $error = 'session_verify_fail'; |
|
652 | + } |
|
628 | 653 | } |
629 | 654 | |
630 | 655 | // Verify that they aren't changing user agents on us - that could be bad. |
631 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
632 | - $error = 'session_verify_fail'; |
|
656 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
657 | + $error = 'session_verify_fail'; |
|
658 | + } |
|
633 | 659 | |
634 | 660 | // Make sure a page with session check requirement is not being prefetched. |
635 | 661 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -640,30 +666,35 @@ discard block |
||
640 | 666 | } |
641 | 667 | |
642 | 668 | // Check the referring site - it should be the same server at least! |
643 | - if (isset($_SESSION['request_referer'])) |
|
644 | - $referrer = $_SESSION['request_referer']; |
|
645 | - else |
|
646 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
669 | + if (isset($_SESSION['request_referer'])) { |
|
670 | + $referrer = $_SESSION['request_referer']; |
|
671 | + } else { |
|
672 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
673 | + } |
|
647 | 674 | if (!empty($referrer['host'])) |
648 | 675 | { |
649 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
650 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
651 | - else |
|
652 | - $real_host = $_SERVER['HTTP_HOST']; |
|
676 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
677 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
678 | + } else { |
|
679 | + $real_host = $_SERVER['HTTP_HOST']; |
|
680 | + } |
|
653 | 681 | |
654 | 682 | $parsed_url = parse_url($boardurl); |
655 | 683 | |
656 | 684 | // Are global cookies on? If so, let's check them ;). |
657 | 685 | if (!empty($modSettings['globalCookies'])) |
658 | 686 | { |
659 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
660 | - $parsed_url['host'] = $parts[1]; |
|
687 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
688 | + $parsed_url['host'] = $parts[1]; |
|
689 | + } |
|
661 | 690 | |
662 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
663 | - $referrer['host'] = $parts[1]; |
|
691 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
692 | + $referrer['host'] = $parts[1]; |
|
693 | + } |
|
664 | 694 | |
665 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
666 | - $real_host = $parts[1]; |
|
695 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
696 | + $real_host = $parts[1]; |
|
697 | + } |
|
667 | 698 | } |
668 | 699 | |
669 | 700 | // Okay: referrer must either match parsed_url or real_host. |
@@ -681,12 +712,14 @@ discard block |
||
681 | 712 | $log_error = true; |
682 | 713 | } |
683 | 714 | |
684 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
685 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
715 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
716 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
717 | + } |
|
686 | 718 | |
687 | 719 | // Everything is ok, return an empty string. |
688 | - if (!isset($error)) |
|
689 | - return ''; |
|
720 | + if (!isset($error)) { |
|
721 | + return ''; |
|
722 | + } |
|
690 | 723 | // A session error occurred, show the error. |
691 | 724 | elseif ($is_fatal) |
692 | 725 | { |
@@ -695,13 +728,14 @@ discard block |
||
695 | 728 | ob_end_clean(); |
696 | 729 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
697 | 730 | die; |
731 | + } else { |
|
732 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
698 | 733 | } |
699 | - else |
|
700 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
701 | 734 | } |
702 | 735 | // A session error occurred, return the error to the calling function. |
703 | - else |
|
704 | - return $error; |
|
736 | + else { |
|
737 | + return $error; |
|
738 | + } |
|
705 | 739 | |
706 | 740 | // We really should never fall through here, for very important reasons. Let's make sure. |
707 | 741 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -717,10 +751,9 @@ discard block |
||
717 | 751 | { |
718 | 752 | global $modSettings; |
719 | 753 | |
720 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
721 | - return true; |
|
722 | - |
|
723 | - else |
|
754 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
755 | + return true; |
|
756 | + } else |
|
724 | 757 | { |
725 | 758 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
726 | 759 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -771,9 +804,9 @@ discard block |
||
771 | 804 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
772 | 805 | unset($_SESSION['token'][$type . '-' . $action]); |
773 | 806 | return $return; |
807 | + } else { |
|
808 | + return ''; |
|
774 | 809 | } |
775 | - else |
|
776 | - return ''; |
|
777 | 810 | } |
778 | 811 | |
779 | 812 | // This nasty piece of code validates a token. |
@@ -804,12 +837,14 @@ discard block |
||
804 | 837 | fatal_lang_error('token_verify_fail', false); |
805 | 838 | } |
806 | 839 | // Remove this token as its useless |
807 | - else |
|
808 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
840 | + else { |
|
841 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
842 | + } |
|
809 | 843 | |
810 | 844 | // Randomly check if we should remove some older tokens. |
811 | - if (mt_rand(0, 138) == 23) |
|
812 | - cleanTokens(); |
|
845 | + if (mt_rand(0, 138) == 23) { |
|
846 | + cleanTokens(); |
|
847 | + } |
|
813 | 848 | |
814 | 849 | return false; |
815 | 850 | } |
@@ -824,14 +859,16 @@ discard block |
||
824 | 859 | function cleanTokens($complete = false) |
825 | 860 | { |
826 | 861 | // We appreciate cleaning up after yourselves. |
827 | - if (!isset($_SESSION['token'])) |
|
828 | - return; |
|
862 | + if (!isset($_SESSION['token'])) { |
|
863 | + return; |
|
864 | + } |
|
829 | 865 | |
830 | 866 | // Clean up tokens, trying to give enough time still. |
831 | - foreach ($_SESSION['token'] as $key => $data) |
|
832 | - if ($data[2] + 10800 < time() || $complete) |
|
867 | + foreach ($_SESSION['token'] as $key => $data) { |
|
868 | + if ($data[2] + 10800 < time() || $complete) |
|
833 | 869 | unset($_SESSION['token'][$key]); |
834 | -} |
|
870 | + } |
|
871 | + } |
|
835 | 872 | |
836 | 873 | /** |
837 | 874 | * Check whether a form has been submitted twice. |
@@ -849,37 +886,40 @@ discard block |
||
849 | 886 | { |
850 | 887 | global $context; |
851 | 888 | |
852 | - if (!isset($_SESSION['forms'])) |
|
853 | - $_SESSION['forms'] = array(); |
|
889 | + if (!isset($_SESSION['forms'])) { |
|
890 | + $_SESSION['forms'] = array(); |
|
891 | + } |
|
854 | 892 | |
855 | 893 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
856 | 894 | if ($action == 'register') |
857 | 895 | { |
858 | 896 | $context['form_sequence_number'] = 0; |
859 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
860 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
897 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
898 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
899 | + } |
|
861 | 900 | } |
862 | 901 | // Check whether the submitted number can be found in the session. |
863 | 902 | elseif ($action == 'check') |
864 | 903 | { |
865 | - if (!isset($_REQUEST['seqnum'])) |
|
866 | - return true; |
|
867 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
904 | + if (!isset($_REQUEST['seqnum'])) { |
|
905 | + return true; |
|
906 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
868 | 907 | { |
869 | 908 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
870 | 909 | return true; |
910 | + } elseif ($is_fatal) { |
|
911 | + fatal_lang_error('error_form_already_submitted', false); |
|
912 | + } else { |
|
913 | + return false; |
|
871 | 914 | } |
872 | - elseif ($is_fatal) |
|
873 | - fatal_lang_error('error_form_already_submitted', false); |
|
874 | - else |
|
875 | - return false; |
|
876 | 915 | } |
877 | 916 | // Don't check, just free the stack number. |
878 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
879 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
880 | - elseif ($action != 'free') |
|
881 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
882 | -} |
|
917 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
918 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
919 | + } elseif ($action != 'free') { |
|
920 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
921 | + } |
|
922 | + } |
|
883 | 923 | |
884 | 924 | /** |
885 | 925 | * Check the user's permissions. |
@@ -896,16 +936,19 @@ discard block |
||
896 | 936 | global $user_info, $smcFunc; |
897 | 937 | |
898 | 938 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
899 | - if (empty($permission)) |
|
900 | - return true; |
|
939 | + if (empty($permission)) { |
|
940 | + return true; |
|
941 | + } |
|
901 | 942 | |
902 | 943 | // You're never allowed to do something if your data hasn't been loaded yet! |
903 | - if (empty($user_info)) |
|
904 | - return false; |
|
944 | + if (empty($user_info)) { |
|
945 | + return false; |
|
946 | + } |
|
905 | 947 | |
906 | 948 | // Administrators are supermen :P. |
907 | - if ($user_info['is_admin']) |
|
908 | - return true; |
|
949 | + if ($user_info['is_admin']) { |
|
950 | + return true; |
|
951 | + } |
|
909 | 952 | |
910 | 953 | // Let's ensure this is an array. |
911 | 954 | $permission = (array) $permission; |
@@ -913,14 +956,16 @@ discard block |
||
913 | 956 | // Are we checking the _current_ board, or some other boards? |
914 | 957 | if ($boards === null) |
915 | 958 | { |
916 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
917 | - return true; |
|
959 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
960 | + return true; |
|
961 | + } |
|
918 | 962 | // You aren't allowed, by default. |
919 | - else |
|
920 | - return false; |
|
963 | + else { |
|
964 | + return false; |
|
965 | + } |
|
966 | + } elseif (!is_array($boards)) { |
|
967 | + $boards = array($boards); |
|
921 | 968 | } |
922 | - elseif (!is_array($boards)) |
|
923 | - $boards = array($boards); |
|
924 | 969 | |
925 | 970 | $request = $smcFunc['db_query']('', ' |
926 | 971 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -943,12 +988,14 @@ discard block |
||
943 | 988 | ); |
944 | 989 | |
945 | 990 | // Make sure they can do it on all of the boards. |
946 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
947 | - return false; |
|
991 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
992 | + return false; |
|
993 | + } |
|
948 | 994 | |
949 | 995 | $result = true; |
950 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
951 | - $result &= !empty($row['add_deny']); |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $result &= !empty($row['add_deny']); |
|
998 | + } |
|
952 | 999 | $smcFunc['db_free_result']($request); |
953 | 1000 | |
954 | 1001 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1013,9 +1060,10 @@ discard block |
||
1013 | 1060 | |
1014 | 1061 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1015 | 1062 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1016 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
1017 | - validateSession(); |
|
1018 | -} |
|
1063 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
1064 | + validateSession(); |
|
1065 | + } |
|
1066 | + } |
|
1019 | 1067 | |
1020 | 1068 | /** |
1021 | 1069 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1034,8 +1082,9 @@ discard block |
||
1034 | 1082 | global $user_info, $smcFunc; |
1035 | 1083 | |
1036 | 1084 | // Arrays are nice, most of the time. |
1037 | - if (!is_array($permissions)) |
|
1038 | - $permissions = array($permissions); |
|
1085 | + if (!is_array($permissions)) { |
|
1086 | + $permissions = array($permissions); |
|
1087 | + } |
|
1039 | 1088 | |
1040 | 1089 | /* |
1041 | 1090 | * Set $simple to true to use this function as it were in SMF 2.0.x. |
@@ -1047,13 +1096,14 @@ discard block |
||
1047 | 1096 | // Administrators are all powerful, sorry. |
1048 | 1097 | if ($user_info['is_admin']) |
1049 | 1098 | { |
1050 | - if ($simple) |
|
1051 | - return array(0); |
|
1052 | - else |
|
1099 | + if ($simple) { |
|
1100 | + return array(0); |
|
1101 | + } else |
|
1053 | 1102 | { |
1054 | 1103 | $boards = array(); |
1055 | - foreach ($permissions as $permission) |
|
1056 | - $boards[$permission] = array(0); |
|
1104 | + foreach ($permissions as $permission) { |
|
1105 | + $boards[$permission] = array(0); |
|
1106 | + } |
|
1057 | 1107 | |
1058 | 1108 | return $boards; |
1059 | 1109 | } |
@@ -1085,31 +1135,32 @@ discard block |
||
1085 | 1135 | { |
1086 | 1136 | if ($simple) |
1087 | 1137 | { |
1088 | - if (empty($row['add_deny'])) |
|
1089 | - $deny_boards[] = $row['id_board']; |
|
1090 | - else |
|
1091 | - $boards[] = $row['id_board']; |
|
1092 | - } |
|
1093 | - else |
|
1138 | + if (empty($row['add_deny'])) { |
|
1139 | + $deny_boards[] = $row['id_board']; |
|
1140 | + } else { |
|
1141 | + $boards[] = $row['id_board']; |
|
1142 | + } |
|
1143 | + } else |
|
1094 | 1144 | { |
1095 | - if (empty($row['add_deny'])) |
|
1096 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1097 | - else |
|
1098 | - $boards[$row['permission']][] = $row['id_board']; |
|
1145 | + if (empty($row['add_deny'])) { |
|
1146 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1147 | + } else { |
|
1148 | + $boards[$row['permission']][] = $row['id_board']; |
|
1149 | + } |
|
1099 | 1150 | } |
1100 | 1151 | } |
1101 | 1152 | $smcFunc['db_free_result']($request); |
1102 | 1153 | |
1103 | - if ($simple) |
|
1104 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1105 | - else |
|
1154 | + if ($simple) { |
|
1155 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1156 | + } else |
|
1106 | 1157 | { |
1107 | 1158 | foreach ($permissions as $permission) |
1108 | 1159 | { |
1109 | 1160 | // never had it to start with |
1110 | - if (empty($boards[$permission])) |
|
1111 | - $boards[$permission] = array(); |
|
1112 | - else |
|
1161 | + if (empty($boards[$permission])) { |
|
1162 | + $boards[$permission] = array(); |
|
1163 | + } else |
|
1113 | 1164 | { |
1114 | 1165 | // Or it may have been removed |
1115 | 1166 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1145,10 +1196,11 @@ discard block |
||
1145 | 1196 | |
1146 | 1197 | |
1147 | 1198 | // Moderators are free... |
1148 | - if (!allowedTo('moderate_board')) |
|
1149 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1150 | - else |
|
1151 | - $timeLimit = 2; |
|
1199 | + if (!allowedTo('moderate_board')) { |
|
1200 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1201 | + } else { |
|
1202 | + $timeLimit = 2; |
|
1203 | + } |
|
1152 | 1204 | |
1153 | 1205 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
1154 | 1206 | |
@@ -1175,8 +1227,9 @@ discard block |
||
1175 | 1227 | if ($smcFunc['db_affected_rows']() != 1) |
1176 | 1228 | { |
1177 | 1229 | // Spammer! You only have to wait a *few* seconds! |
1178 | - if (!$only_return_result) |
|
1179 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1230 | + if (!$only_return_result) { |
|
1231 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1232 | + } |
|
1180 | 1233 | |
1181 | 1234 | return true; |
1182 | 1235 | } |
@@ -1194,11 +1247,13 @@ discard block |
||
1194 | 1247 | */ |
1195 | 1248 | function secureDirectory($path, $attachments = false) |
1196 | 1249 | { |
1197 | - if (empty($path)) |
|
1198 | - return 'empty_path'; |
|
1250 | + if (empty($path)) { |
|
1251 | + return 'empty_path'; |
|
1252 | + } |
|
1199 | 1253 | |
1200 | - if (!is_writable($path)) |
|
1201 | - return 'path_not_writable'; |
|
1254 | + if (!is_writable($path)) { |
|
1255 | + return 'path_not_writable'; |
|
1256 | + } |
|
1202 | 1257 | |
1203 | 1258 | $directoryname = basename($path); |
1204 | 1259 | |
@@ -1210,9 +1265,9 @@ discard block |
||
1210 | 1265 | |
1211 | 1266 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1212 | 1267 | |
1213 | - if (file_exists($path . '/.htaccess')) |
|
1214 | - $errors[] = 'htaccess_exists'; |
|
1215 | - else |
|
1268 | + if (file_exists($path . '/.htaccess')) { |
|
1269 | + $errors[] = 'htaccess_exists'; |
|
1270 | + } else |
|
1216 | 1271 | { |
1217 | 1272 | $fh = @fopen($path . '/.htaccess', 'w'); |
1218 | 1273 | if ($fh) { |
@@ -1224,9 +1279,9 @@ discard block |
||
1224 | 1279 | $errors[] = 'htaccess_cannot_create_file'; |
1225 | 1280 | } |
1226 | 1281 | |
1227 | - if (file_exists($path . '/index.php')) |
|
1228 | - $errors[] = 'index-php_exists'; |
|
1229 | - else |
|
1282 | + if (file_exists($path . '/index.php')) { |
|
1283 | + $errors[] = 'index-php_exists'; |
|
1284 | + } else |
|
1230 | 1285 | { |
1231 | 1286 | $fh = @fopen($path . '/index.php', 'w'); |
1232 | 1287 | if ($fh) { |
@@ -1253,11 +1308,12 @@ discard block |
||
1253 | 1308 | $errors[] = 'index-php_cannot_create_file'; |
1254 | 1309 | } |
1255 | 1310 | |
1256 | - if (!empty($errors)) |
|
1257 | - return $errors; |
|
1258 | - else |
|
1259 | - return true; |
|
1260 | -} |
|
1311 | + if (!empty($errors)) { |
|
1312 | + return $errors; |
|
1313 | + } else { |
|
1314 | + return true; |
|
1315 | + } |
|
1316 | + } |
|
1261 | 1317 | |
1262 | 1318 | /** |
1263 | 1319 | * This sets the X-Frame-Options header. |
@@ -1270,14 +1326,16 @@ discard block |
||
1270 | 1326 | global $modSettings; |
1271 | 1327 | |
1272 | 1328 | $option = 'SAMEORIGIN'; |
1273 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
1274 | - $option = $modSettings['frame_security']; |
|
1275 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
1276 | - $option = $override; |
|
1329 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
1330 | + $option = $modSettings['frame_security']; |
|
1331 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
1332 | + $option = $override; |
|
1333 | + } |
|
1277 | 1334 | |
1278 | 1335 | // Don't bother setting the header if we have disabled it. |
1279 | - if ($option == 'DISABLE') |
|
1280 | - return; |
|
1336 | + if ($option == 'DISABLE') { |
|
1337 | + return; |
|
1338 | + } |
|
1281 | 1339 | |
1282 | 1340 | // Finally set it. |
1283 | 1341 | header('X-Frame-Options: ' . $option); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -43,8 +44,9 @@ discard block |
||
43 | 44 | { |
44 | 45 | $supported = is_writable($this->cachedir); |
45 | 46 | |
46 | - if ($test) |
|
47 | - return $supported; |
|
47 | + if ($test) { |
|
48 | + return $supported; |
|
49 | + } |
|
48 | 50 | return parent::isSupported() && $supported; |
49 | 51 | } |
50 | 52 | |
@@ -61,11 +63,13 @@ discard block |
||
61 | 63 | { |
62 | 64 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
63 | 65 | // causing newer files to take effect a while later. |
64 | - if (function_exists('opcache_invalidate')) |
|
65 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
66 | + if (function_exists('opcache_invalidate')) { |
|
67 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
68 | + } |
|
66 | 69 | |
67 | - if (function_exists('apc_delete_file')) |
|
68 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
70 | + if (function_exists('apc_delete_file')) { |
|
71 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
72 | + } |
|
69 | 73 | |
70 | 74 | // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution |
71 | 75 | @include($cachedir . '/data_' . $key . '.php'); |
@@ -89,16 +93,18 @@ discard block |
||
89 | 93 | |
90 | 94 | // Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds |
91 | 95 | // causing newer files to take effect a while later. |
92 | - if (function_exists('opcache_invalidate')) |
|
93 | - opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
96 | + if (function_exists('opcache_invalidate')) { |
|
97 | + opcache_invalidate($cachedir . '/data_' . $key . '.php', true); |
|
98 | + } |
|
94 | 99 | |
95 | - if (function_exists('apc_delete_file')) |
|
96 | - @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
100 | + if (function_exists('apc_delete_file')) { |
|
101 | + @apc_delete_file($cachedir . '/data_' . $key . '.php'); |
|
102 | + } |
|
97 | 103 | |
98 | 104 | // Otherwise custom cache? |
99 | - if ($value === null) |
|
100 | - @unlink($cachedir . '/data_' . $key . '.php'); |
|
101 | - else |
|
105 | + if ($value === null) { |
|
106 | + @unlink($cachedir . '/data_' . $key . '.php'); |
|
107 | + } else |
|
102 | 108 | { |
103 | 109 | $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>'; |
104 | 110 | |
@@ -109,9 +115,9 @@ discard block |
||
109 | 115 | { |
110 | 116 | @unlink($cachedir . '/data_' . $key . '.php'); |
111 | 117 | return false; |
118 | + } else { |
|
119 | + return true; |
|
112 | 120 | } |
113 | - else |
|
114 | - return true; |
|
115 | 121 | } |
116 | 122 | } |
117 | 123 | |
@@ -123,15 +129,17 @@ discard block |
||
123 | 129 | $cachedir = $this->cachedir; |
124 | 130 | |
125 | 131 | // No directory = no game. |
126 | - if (!is_dir($cachedir)) |
|
127 | - return; |
|
132 | + if (!is_dir($cachedir)) { |
|
133 | + return; |
|
134 | + } |
|
128 | 135 | |
129 | 136 | // Remove the files in SMF's own disk cache, if any |
130 | 137 | $dh = opendir($cachedir); |
131 | 138 | while ($file = readdir($dh)) |
132 | 139 | { |
133 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
134 | - @unlink($cachedir . '/' . $file); |
|
140 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
141 | + @unlink($cachedir . '/' . $file); |
|
142 | + } |
|
135 | 143 | } |
136 | 144 | closedir($dh); |
137 | 145 | |
@@ -165,8 +173,9 @@ discard block |
||
165 | 173 | $config_vars[] = $txt['cache_smf_settings']; |
166 | 174 | $config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'); |
167 | 175 | |
168 | - if (!isset($context['settings_post_javascript'])) |
|
169 | - $context['settings_post_javascript'] = ''; |
|
176 | + if (!isset($context['settings_post_javascript'])) { |
|
177 | + $context['settings_post_javascript'] = ''; |
|
178 | + } |
|
170 | 179 | |
171 | 180 | $context['settings_post_javascript'] .= ' |
172 | 181 | $("#cache_accelerator").change(function (e) { |
@@ -187,10 +196,11 @@ discard block |
||
187 | 196 | global $cachedir; |
188 | 197 | |
189 | 198 | // If its invalid, use SMF's. |
190 | - if (is_null($dir) || !is_writable($dir)) |
|
191 | - $this->cachedir = $cachedir; |
|
192 | - else |
|
193 | - $this->cachedir = $dir; |
|
199 | + if (is_null($dir) || !is_writable($dir)) { |
|
200 | + $this->cachedir = $cachedir; |
|
201 | + } else { |
|
202 | + $this->cachedir = $dir; |
|
203 | + } |
|
194 | 204 | } |
195 | 205 | |
196 | 206 | /** |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | { |
28 | 29 | $supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
29 | 30 | |
30 | - if ($test) |
|
31 | - return $supported; |
|
31 | + if ($test) { |
|
32 | + return $supported; |
|
33 | + } |
|
32 | 34 | return parent::isSupported() && $supported; |
33 | 35 | } |
34 | 36 | |
@@ -40,10 +42,11 @@ discard block |
||
40 | 42 | $key = $this->prefix . strtr($key, ':/', '-_'); |
41 | 43 | |
42 | 44 | // Zend's pricey stuff. |
43 | - if (function_exists('zend_shm_cache_fetch')) |
|
44 | - return zend_shm_cache_fetch('SMF::' . $key); |
|
45 | - elseif (function_exists('output_cache_get')) |
|
46 | - return output_cache_get($key, $ttl); |
|
45 | + if (function_exists('zend_shm_cache_fetch')) { |
|
46 | + return zend_shm_cache_fetch('SMF::' . $key); |
|
47 | + } elseif (function_exists('output_cache_get')) { |
|
48 | + return output_cache_get($key, $ttl); |
|
49 | + } |
|
47 | 50 | } |
48 | 51 | |
49 | 52 | /** |
@@ -53,10 +56,11 @@ discard block |
||
53 | 56 | { |
54 | 57 | $key = $this->prefix . strtr($key, ':/', '-_'); |
55 | 58 | |
56 | - if (function_exists('zend_shm_cache_store')) |
|
57 | - return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
58 | - elseif (function_exists('output_cache_put')) |
|
59 | - return output_cache_put($key, $value); |
|
59 | + if (function_exists('zend_shm_cache_store')) { |
|
60 | + return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
61 | + } elseif (function_exists('output_cache_put')) { |
|
62 | + return output_cache_put($key, $value); |
|
63 | + } |
|
60 | 64 | } |
61 | 65 | |
62 | 66 | /** |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | { |
28 | 29 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
29 | 30 | |
30 | - if ($test) |
|
31 | - return $supported; |
|
31 | + if ($test) { |
|
32 | + return $supported; |
|
33 | + } |
|
32 | 34 | return parent::isSupported() && $supported; |
33 | 35 | } |
34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
51 | 53 | |
52 | 54 | // An extended key is needed to counteract a bug in APC. |
53 | - if ($value === null) |
|
54 | - return apcu_delete($key . 'smf'); |
|
55 | - else |
|
56 | - return apcu_store($key . 'smf', $value, $ttl); |
|
55 | + if ($value === null) { |
|
56 | + return apcu_delete($key . 'smf'); |
|
57 | + } else { |
|
58 | + return apcu_store($key . 'smf', $value, $ttl); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | |
59 | 62 | /** |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
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 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -381,8 +395,7 @@ discard block |
||
381 | 395 | |
382 | 396 | // Put the tags back into the body. |
383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
384 | - } |
|
385 | - else |
|
398 | + } else |
|
386 | 399 | { |
387 | 400 | // Just get rid of this evil tag. |
388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
395 | 408 | // Find the position of this again. |
396 | 409 | $start_pos = strpos($text, $matches[0]); |
397 | 410 | $end_pos = false; |
398 | - if ($start_pos === false) |
|
399 | - break; |
|
411 | + if ($start_pos === false) { |
|
412 | + break; |
|
413 | + } |
|
400 | 414 | |
401 | 415 | // This must have an end tag - and we must find the right one. |
402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
429 | 443 | break; |
430 | 444 | } |
431 | 445 | } |
432 | - if ($end_pos === false) |
|
433 | - break; |
|
446 | + if ($end_pos === false) { |
|
447 | + break; |
|
448 | + } |
|
434 | 449 | |
435 | 450 | // Now work out what the attributes are. |
436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
444 | 459 | $v = (int) trim($v); |
445 | 460 | $v = empty($v) ? 1 : $v; |
446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
462 | + } elseif ($s == 'face') { |
|
463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
464 | + } elseif ($s == 'color') { |
|
465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
447 | 466 | } |
448 | - elseif ($s == 'face') |
|
449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
450 | - elseif ($s == 'color') |
|
451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
452 | 467 | } |
453 | 468 | |
454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
456 | 471 | foreach ($tags as $tag) |
457 | 472 | { |
458 | 473 | $before .= $tag[0]; |
459 | - if (isset($tag[1])) |
|
460 | - $after = $tag[1] . $after; |
|
474 | + if (isset($tag[1])) { |
|
475 | + $after = $tag[1] . $after; |
|
476 | + } |
|
461 | 477 | } |
462 | 478 | |
463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
468 | 484 | } |
469 | 485 | |
470 | 486 | // Almost there, just a little more time. |
471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
472 | - @apache_reset_timeout(); |
|
487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
488 | + @apache_reset_timeout(); |
|
489 | + } |
|
473 | 490 | |
474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
525 | 542 | { |
526 | 543 | $inList = true; |
527 | 544 | |
528 | - if ($tag === 'ol') |
|
529 | - $listType = 'decimal'; |
|
530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
531 | - $listType = $listTypeMapping[$match[1]]; |
|
532 | - else |
|
533 | - $listType = null; |
|
545 | + if ($tag === 'ol') { |
|
546 | + $listType = 'decimal'; |
|
547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
548 | + $listType = $listTypeMapping[$match[1]]; |
|
549 | + } else { |
|
550 | + $listType = null; |
|
551 | + } |
|
534 | 552 | |
535 | 553 | $listDepth++; |
536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
594 | 612 | $parts[$i + 1] = ''; |
595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
596 | 614 | $parts[$i + 3] = ''; |
597 | - } |
|
598 | - |
|
599 | - else |
|
615 | + } else |
|
600 | 616 | { |
601 | 617 | // We're in a list item. |
602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
633 | 649 | $parts[$i + 1] = ''; |
634 | 650 | $parts[$i + 2] = ''; |
635 | 651 | $parts[$i + 3] = ''; |
636 | - } |
|
637 | - |
|
638 | - else |
|
652 | + } else |
|
639 | 653 | { |
640 | 654 | // Remove the trailing breaks from the list item. |
641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
674 | 688 | } |
675 | 689 | |
676 | - for ($i = $listDepth; $i > 0; $i--) |
|
677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
692 | + } |
|
678 | 693 | |
679 | 694 | } |
680 | 695 | |
@@ -683,8 +698,9 @@ discard block |
||
683 | 698 | { |
684 | 699 | // Find the position of the image. |
685 | 700 | $start_pos = strpos($text, $matches[0]); |
686 | - if ($start_pos === false) |
|
687 | - break; |
|
701 | + if ($start_pos === false) { |
|
702 | + break; |
|
703 | + } |
|
688 | 704 | $end_pos = $start_pos + strlen($matches[0]); |
689 | 705 | |
690 | 706 | $params = ''; |
@@ -693,12 +709,13 @@ discard block |
||
693 | 709 | $attrs = fetchTagAttributes($matches[1]); |
694 | 710 | foreach ($attrs as $attrib => $value) |
695 | 711 | { |
696 | - if (in_array($attrib, array('width', 'height'))) |
|
697 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
698 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
699 | - $params .= ' alt=' . trim($value); |
|
700 | - elseif ($attrib == 'src') |
|
701 | - $src = trim($value); |
|
712 | + if (in_array($attrib, array('width', 'height'))) { |
|
713 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
714 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
715 | + $params .= ' alt=' . trim($value); |
|
716 | + } elseif ($attrib == 'src') { |
|
717 | + $src = trim($value); |
|
718 | + } |
|
702 | 719 | } |
703 | 720 | |
704 | 721 | $tag = ''; |
@@ -709,10 +726,11 @@ discard block |
||
709 | 726 | { |
710 | 727 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
711 | 728 | |
712 | - if (substr($src, 0, 1) === '/') |
|
713 | - $src = $baseURL . $src; |
|
714 | - else |
|
715 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
729 | + if (substr($src, 0, 1) === '/') { |
|
730 | + $src = $baseURL . $src; |
|
731 | + } else { |
|
732 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
733 | + } |
|
716 | 734 | } |
717 | 735 | |
718 | 736 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -890,20 +908,23 @@ discard block |
||
890 | 908 | }, |
891 | 909 | ); |
892 | 910 | |
893 | - foreach ($tags as $tag => $replace) |
|
894 | - $text = preg_replace_callback($tag, $replace, $text); |
|
911 | + foreach ($tags as $tag => $replace) { |
|
912 | + $text = preg_replace_callback($tag, $replace, $text); |
|
913 | + } |
|
895 | 914 | |
896 | 915 | // Please give us just a little more time. |
897 | - if (connection_aborted() && $context['server']['is_apache']) |
|
898 | - @apache_reset_timeout(); |
|
916 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
917 | + @apache_reset_timeout(); |
|
918 | + } |
|
899 | 919 | |
900 | 920 | // What about URL's - the pain in the ass of the tag world. |
901 | 921 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
902 | 922 | { |
903 | 923 | // Find the position of the URL. |
904 | 924 | $start_pos = strpos($text, $matches[0]); |
905 | - if ($start_pos === false) |
|
906 | - break; |
|
925 | + if ($start_pos === false) { |
|
926 | + break; |
|
927 | + } |
|
907 | 928 | $end_pos = $start_pos + strlen($matches[0]); |
908 | 929 | |
909 | 930 | $tag_type = 'url'; |
@@ -917,8 +938,9 @@ discard block |
||
917 | 938 | $href = trim($value); |
918 | 939 | |
919 | 940 | // Are we dealing with an FTP link? |
920 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
921 | - $tag_type = 'ftp'; |
|
941 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
942 | + $tag_type = 'ftp'; |
|
943 | + } |
|
922 | 944 | |
923 | 945 | // Or is this a link to an email address? |
924 | 946 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -932,28 +954,31 @@ discard block |
||
932 | 954 | { |
933 | 955 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
934 | 956 | |
935 | - if (substr($href, 0, 1) === '/') |
|
936 | - $href = $baseURL . $href; |
|
937 | - else |
|
938 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
957 | + if (substr($href, 0, 1) === '/') { |
|
958 | + $href = $baseURL . $href; |
|
959 | + } else { |
|
960 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
961 | + } |
|
939 | 962 | } |
940 | 963 | } |
941 | 964 | |
942 | 965 | // External URL? |
943 | 966 | if ($attrib == 'target' && $tag_type == 'url') |
944 | 967 | { |
945 | - if (trim($value) == '_blank') |
|
946 | - $tag_type == 'iurl'; |
|
968 | + if (trim($value) == '_blank') { |
|
969 | + $tag_type == 'iurl'; |
|
970 | + } |
|
947 | 971 | } |
948 | 972 | } |
949 | 973 | |
950 | 974 | $tag = ''; |
951 | 975 | if ($href != '') |
952 | 976 | { |
953 | - if ($matches[2] == $href) |
|
954 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
955 | - else |
|
956 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
977 | + if ($matches[2] == $href) { |
|
978 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
979 | + } else { |
|
980 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
981 | + } |
|
957 | 982 | } |
958 | 983 | |
959 | 984 | // Replace the tag |
@@ -992,17 +1017,18 @@ discard block |
||
992 | 1017 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
993 | 1018 | if ($text[$i] == '=') |
994 | 1019 | { |
995 | - if ($tag_state == 0) |
|
996 | - $tag_state = 1; |
|
997 | - elseif ($tag_state == 2) |
|
998 | - $value .= '='; |
|
1020 | + if ($tag_state == 0) { |
|
1021 | + $tag_state = 1; |
|
1022 | + } elseif ($tag_state == 2) { |
|
1023 | + $value .= '='; |
|
1024 | + } |
|
999 | 1025 | } |
1000 | 1026 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1001 | 1027 | elseif ($text[$i] == ' ') |
1002 | 1028 | { |
1003 | - if ($tag_state == 2) |
|
1004 | - $value .= ' '; |
|
1005 | - elseif ($tag_state == 1) |
|
1029 | + if ($tag_state == 2) { |
|
1030 | + $value .= ' '; |
|
1031 | + } elseif ($tag_state == 1) |
|
1006 | 1032 | { |
1007 | 1033 | $attribs[$key] = $value; |
1008 | 1034 | $key = $value = ''; |
@@ -1013,24 +1039,27 @@ discard block |
||
1013 | 1039 | elseif ($text[$i] == '"') |
1014 | 1040 | { |
1015 | 1041 | // Must be either going into or out of a string. |
1016 | - if ($tag_state == 1) |
|
1017 | - $tag_state = 2; |
|
1018 | - else |
|
1019 | - $tag_state = 1; |
|
1042 | + if ($tag_state == 1) { |
|
1043 | + $tag_state = 2; |
|
1044 | + } else { |
|
1045 | + $tag_state = 1; |
|
1046 | + } |
|
1020 | 1047 | } |
1021 | 1048 | // Otherwise it's fine. |
1022 | 1049 | else |
1023 | 1050 | { |
1024 | - if ($tag_state == 0) |
|
1025 | - $key .= $text[$i]; |
|
1026 | - else |
|
1027 | - $value .= $text[$i]; |
|
1051 | + if ($tag_state == 0) { |
|
1052 | + $key .= $text[$i]; |
|
1053 | + } else { |
|
1054 | + $value .= $text[$i]; |
|
1055 | + } |
|
1028 | 1056 | } |
1029 | 1057 | } |
1030 | 1058 | |
1031 | 1059 | // Anything left? |
1032 | - if ($key != '' && $value != '') |
|
1033 | - $attribs[$key] = $value; |
|
1060 | + if ($key != '' && $value != '') { |
|
1061 | + $attribs[$key] = $value; |
|
1062 | + } |
|
1034 | 1063 | |
1035 | 1064 | return $attribs; |
1036 | 1065 | } |
@@ -1046,15 +1075,17 @@ discard block |
||
1046 | 1075 | global $modSettings; |
1047 | 1076 | |
1048 | 1077 | // Don't care about the texts that are too short. |
1049 | - if (strlen($text) < 3) |
|
1050 | - return $text; |
|
1078 | + if (strlen($text) < 3) { |
|
1079 | + return $text; |
|
1080 | + } |
|
1051 | 1081 | |
1052 | 1082 | // A list of tags that's disabled by the admin. |
1053 | 1083 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1054 | 1084 | |
1055 | 1085 | // Add flash if it's disabled as embedded tag. |
1056 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1057 | - $disabled['flash'] = true; |
|
1086 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1087 | + $disabled['flash'] = true; |
|
1088 | + } |
|
1058 | 1089 | |
1059 | 1090 | // Get a list of all the tags that are not disabled. |
1060 | 1091 | $all_tags = parse_bbc(false); |
@@ -1062,10 +1093,12 @@ discard block |
||
1062 | 1093 | $self_closing_tags = array(); |
1063 | 1094 | foreach ($all_tags as $tag) |
1064 | 1095 | { |
1065 | - if (!isset($disabled[$tag['tag']])) |
|
1066 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1067 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1068 | - $self_closing_tags[] = $tag['tag']; |
|
1096 | + if (!isset($disabled[$tag['tag']])) { |
|
1097 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1098 | + } |
|
1099 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1100 | + $self_closing_tags[] = $tag['tag']; |
|
1101 | + } |
|
1069 | 1102 | } |
1070 | 1103 | |
1071 | 1104 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1092,16 +1125,19 @@ discard block |
||
1092 | 1125 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1093 | 1126 | |
1094 | 1127 | // We're closing the exact same tag that we opened. |
1095 | - if ($isClosingTag && $insideTag === $tagName) |
|
1096 | - $insideTag = null; |
|
1128 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1129 | + $insideTag = null; |
|
1130 | + } |
|
1097 | 1131 | |
1098 | 1132 | // We're opening a tag and we're not yet inside one either |
1099 | - elseif (!$isClosingTag && $insideTag === null) |
|
1100 | - $insideTag = $tagName; |
|
1133 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1134 | + $insideTag = $tagName; |
|
1135 | + } |
|
1101 | 1136 | |
1102 | 1137 | // In all other cases, this tag must be invalid |
1103 | - else |
|
1104 | - unset($matches[$i]); |
|
1138 | + else { |
|
1139 | + unset($matches[$i]); |
|
1140 | + } |
|
1105 | 1141 | } |
1106 | 1142 | |
1107 | 1143 | // The next one is gonna be the other one. |
@@ -1109,8 +1145,9 @@ discard block |
||
1109 | 1145 | } |
1110 | 1146 | |
1111 | 1147 | // We're still inside a tag and had no chance for closure? |
1112 | - if ($insideTag !== null) |
|
1113 | - $matches[] = '[/' . $insideTag . ']'; |
|
1148 | + if ($insideTag !== null) { |
|
1149 | + $matches[] = '[/' . $insideTag . ']'; |
|
1150 | + } |
|
1114 | 1151 | |
1115 | 1152 | // And a complete text string again. |
1116 | 1153 | $text = implode('', $matches); |
@@ -1119,8 +1156,9 @@ discard block |
||
1119 | 1156 | // Quickly remove any tags which are back to back. |
1120 | 1157 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1121 | 1158 | $lastlen = 0; |
1122 | - while (strlen($text) !== $lastlen) |
|
1123 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1159 | + while (strlen($text) !== $lastlen) { |
|
1160 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1161 | + } |
|
1124 | 1162 | |
1125 | 1163 | // Need to sort the tags my name length. |
1126 | 1164 | uksort($valid_tags, 'sort_array_length'); |
@@ -1157,8 +1195,9 @@ discard block |
||
1157 | 1195 | $isCompetingTag = in_array($tag, $competing_tags); |
1158 | 1196 | |
1159 | 1197 | // Check if this might be one of those cleaned out tags. |
1160 | - if ($tag === '') |
|
1161 | - continue; |
|
1198 | + if ($tag === '') { |
|
1199 | + continue; |
|
1200 | + } |
|
1162 | 1201 | |
1163 | 1202 | // Special case: inside [code] blocks any code is left untouched. |
1164 | 1203 | elseif ($tag === 'code') |
@@ -1169,8 +1208,9 @@ discard block |
||
1169 | 1208 | $inCode = false; |
1170 | 1209 | |
1171 | 1210 | // Reopen tags that were closed before the code block. |
1172 | - if (!empty($inlineElements)) |
|
1173 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1211 | + if (!empty($inlineElements)) { |
|
1212 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1213 | + } |
|
1174 | 1214 | } |
1175 | 1215 | |
1176 | 1216 | // We're outside a coding and nobbc block and opening it. |
@@ -1199,8 +1239,9 @@ discard block |
||
1199 | 1239 | $inNoBbc = false; |
1200 | 1240 | |
1201 | 1241 | // Some inline elements might've been closed that need reopening. |
1202 | - if (!empty($inlineElements)) |
|
1203 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1242 | + if (!empty($inlineElements)) { |
|
1243 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1244 | + } |
|
1204 | 1245 | } |
1205 | 1246 | |
1206 | 1247 | // We're outside a nobbc and coding block and opening it. |
@@ -1220,8 +1261,9 @@ discard block |
||
1220 | 1261 | } |
1221 | 1262 | |
1222 | 1263 | // So, we're inside one of the special blocks: ignore any tag. |
1223 | - elseif ($inCode || $inNoBbc) |
|
1224 | - continue; |
|
1264 | + elseif ($inCode || $inNoBbc) { |
|
1265 | + continue; |
|
1266 | + } |
|
1225 | 1267 | |
1226 | 1268 | // We're dealing with an opening tag. |
1227 | 1269 | if ($isOpeningTag) |
@@ -1262,8 +1304,9 @@ discard block |
||
1262 | 1304 | if ($parts[$j + 3] === $tag) |
1263 | 1305 | { |
1264 | 1306 | // If it's an opening tag, increase the level. |
1265 | - if ($parts[$j + 2] === '') |
|
1266 | - $curLevel++; |
|
1307 | + if ($parts[$j + 2] === '') { |
|
1308 | + $curLevel++; |
|
1309 | + } |
|
1267 | 1310 | |
1268 | 1311 | // A closing tag, decrease the level. |
1269 | 1312 | else |
@@ -1286,13 +1329,15 @@ discard block |
||
1286 | 1329 | { |
1287 | 1330 | if ($isCompetingTag) |
1288 | 1331 | { |
1289 | - if (!isset($competingElements[$tag])) |
|
1290 | - $competingElements[$tag] = array(); |
|
1332 | + if (!isset($competingElements[$tag])) { |
|
1333 | + $competingElements[$tag] = array(); |
|
1334 | + } |
|
1291 | 1335 | |
1292 | 1336 | $competingElements[$tag][] = $parts[$i + 4]; |
1293 | 1337 | |
1294 | - if (count($competingElements[$tag]) > 1) |
|
1295 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1338 | + if (count($competingElements[$tag]) > 1) { |
|
1339 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1340 | + } |
|
1296 | 1341 | } |
1297 | 1342 | |
1298 | 1343 | $inlineElements[$elementContent] = $tag; |
@@ -1313,15 +1358,17 @@ discard block |
||
1313 | 1358 | $addClosingTags = array(); |
1314 | 1359 | while ($element = array_pop($blockElements)) |
1315 | 1360 | { |
1316 | - if ($element === $tag) |
|
1317 | - break; |
|
1361 | + if ($element === $tag) { |
|
1362 | + break; |
|
1363 | + } |
|
1318 | 1364 | |
1319 | 1365 | // Still a block tag was open not equal to this tag. |
1320 | 1366 | $addClosingTags[] = $element['type']; |
1321 | 1367 | } |
1322 | 1368 | |
1323 | - if (!empty($addClosingTags)) |
|
1324 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1369 | + if (!empty($addClosingTags)) { |
|
1370 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1371 | + } |
|
1325 | 1372 | |
1326 | 1373 | // Apparently the closing tag was not found on the stack. |
1327 | 1374 | if (!is_string($element) || $element !== $tag) |
@@ -1331,8 +1378,7 @@ discard block |
||
1331 | 1378 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1332 | 1379 | continue; |
1333 | 1380 | } |
1334 | - } |
|
1335 | - else |
|
1381 | + } else |
|
1336 | 1382 | { |
1337 | 1383 | // Get rid of this closing tag! |
1338 | 1384 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1361,53 +1407,62 @@ discard block |
||
1361 | 1407 | unset($inlineElements[$tagContentToBeClosed]); |
1362 | 1408 | |
1363 | 1409 | // Was this the tag we were looking for? |
1364 | - if ($tagToBeClosed === $tag) |
|
1365 | - break; |
|
1410 | + if ($tagToBeClosed === $tag) { |
|
1411 | + break; |
|
1412 | + } |
|
1366 | 1413 | |
1367 | 1414 | // Nope, close it and look further! |
1368 | - else |
|
1369 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1415 | + else { |
|
1416 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1417 | + } |
|
1370 | 1418 | } |
1371 | 1419 | |
1372 | 1420 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1373 | 1421 | { |
1374 | 1422 | array_pop($competingElements[$tag]); |
1375 | 1423 | |
1376 | - if (count($competingElements[$tag]) > 0) |
|
1377 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1424 | + if (count($competingElements[$tag]) > 0) { |
|
1425 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1426 | + } |
|
1378 | 1427 | } |
1379 | 1428 | } |
1380 | 1429 | |
1381 | 1430 | // Unexpected closing tag, ex-ter-mi-nate. |
1382 | - else |
|
1383 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1431 | + else { |
|
1432 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1433 | + } |
|
1384 | 1434 | } |
1385 | 1435 | } |
1386 | 1436 | } |
1387 | 1437 | |
1388 | 1438 | // Close the code tags. |
1389 | - if ($inCode) |
|
1390 | - $parts[$i] .= '[/code]'; |
|
1439 | + if ($inCode) { |
|
1440 | + $parts[$i] .= '[/code]'; |
|
1441 | + } |
|
1391 | 1442 | |
1392 | 1443 | // The same for nobbc tags. |
1393 | - elseif ($inNoBbc) |
|
1394 | - $parts[$i] .= '[/nobbc]'; |
|
1444 | + elseif ($inNoBbc) { |
|
1445 | + $parts[$i] .= '[/nobbc]'; |
|
1446 | + } |
|
1395 | 1447 | |
1396 | 1448 | // Still inline tags left unclosed? Close them now, better late than never. |
1397 | - elseif (!empty($inlineElements)) |
|
1398 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1449 | + elseif (!empty($inlineElements)) { |
|
1450 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1451 | + } |
|
1399 | 1452 | |
1400 | 1453 | // Now close the block elements. |
1401 | - if (!empty($blockElements)) |
|
1402 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1454 | + if (!empty($blockElements)) { |
|
1455 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1456 | + } |
|
1403 | 1457 | |
1404 | 1458 | $text = implode('', $parts); |
1405 | 1459 | } |
1406 | 1460 | |
1407 | 1461 | // Final clean up of back to back tags. |
1408 | 1462 | $lastlen = 0; |
1409 | - while (strlen($text) !== $lastlen) |
|
1410 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1463 | + while (strlen($text) !== $lastlen) { |
|
1464 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1465 | + } |
|
1411 | 1466 | |
1412 | 1467 | return $text; |
1413 | 1468 | } |
@@ -1436,22 +1491,25 @@ discard block |
||
1436 | 1491 | $context['template_layers'] = array(); |
1437 | 1492 | // Lets make sure we aren't going to output anything nasty. |
1438 | 1493 | @ob_end_clean(); |
1439 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1440 | - @ob_start('ob_gzhandler'); |
|
1441 | - else |
|
1442 | - @ob_start(); |
|
1494 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1495 | + @ob_start('ob_gzhandler'); |
|
1496 | + } else { |
|
1497 | + @ob_start(); |
|
1498 | + } |
|
1443 | 1499 | |
1444 | 1500 | // If we don't have any locale better avoid broken js |
1445 | - if (empty($txt['lang_locale'])) |
|
1446 | - die(); |
|
1501 | + if (empty($txt['lang_locale'])) { |
|
1502 | + die(); |
|
1503 | + } |
|
1447 | 1504 | |
1448 | 1505 | $file_data = '(function ($) { |
1449 | 1506 | \'use strict\'; |
1450 | 1507 | |
1451 | 1508 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
1452 | - foreach ($editortxt as $key => $val) |
|
1453 | - $file_data .= ' |
|
1509 | + foreach ($editortxt as $key => $val) { |
|
1510 | + $file_data .= ' |
|
1454 | 1511 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
1512 | + } |
|
1455 | 1513 | |
1456 | 1514 | $file_data .= ' |
1457 | 1515 | dateFormat: "day.month.year" |
@@ -1519,8 +1577,9 @@ discard block |
||
1519 | 1577 | ) |
1520 | 1578 | ); |
1521 | 1579 | $icon_data = array(); |
1522 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1523 | - $icon_data[] = $row; |
|
1580 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1581 | + $icon_data[] = $row; |
|
1582 | + } |
|
1524 | 1583 | $smcFunc['db_free_result']($request); |
1525 | 1584 | |
1526 | 1585 | $icons = array(); |
@@ -1535,9 +1594,9 @@ discard block |
||
1535 | 1594 | } |
1536 | 1595 | |
1537 | 1596 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1597 | + } else { |
|
1598 | + $icons = $temp; |
|
1538 | 1599 | } |
1539 | - else |
|
1540 | - $icons = $temp; |
|
1541 | 1600 | } |
1542 | 1601 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1543 | 1602 | |
@@ -1578,8 +1637,9 @@ discard block |
||
1578 | 1637 | { |
1579 | 1638 | // Some general stuff. |
1580 | 1639 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1581 | - if (!empty($context['drafts_autosave'])) |
|
1582 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1640 | + if (!empty($context['drafts_autosave'])) { |
|
1641 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1642 | + } |
|
1583 | 1643 | |
1584 | 1644 | // This really has some WYSIWYG stuff. |
1585 | 1645 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1595,8 +1655,9 @@ discard block |
||
1595 | 1655 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1596 | 1656 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1597 | 1657 | // editor language file |
1598 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1599 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1658 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1659 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1660 | + } |
|
1600 | 1661 | |
1601 | 1662 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1602 | 1663 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1605,11 +1666,12 @@ discard block |
||
1605 | 1666 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
1606 | 1667 | |
1607 | 1668 | // Some hidden information is needed in order to make the spell checking work. |
1608 | - if (!isset($_REQUEST['xml'])) |
|
1609 | - $context['insert_after_template'] .= ' |
|
1669 | + if (!isset($_REQUEST['xml'])) { |
|
1670 | + $context['insert_after_template'] .= ' |
|
1610 | 1671 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1611 | 1672 | <input type="hidden" name="spellstring" value=""> |
1612 | 1673 | </form>'; |
1674 | + } |
|
1613 | 1675 | } |
1614 | 1676 | } |
1615 | 1677 | |
@@ -1775,10 +1837,12 @@ discard block |
||
1775 | 1837 | |
1776 | 1838 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1777 | 1839 | $disabled_tags = array(); |
1778 | - if (!empty($modSettings['disabledBBC'])) |
|
1779 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1780 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1781 | - $disabled_tags[] = 'flash'; |
|
1840 | + if (!empty($modSettings['disabledBBC'])) { |
|
1841 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1842 | + } |
|
1843 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1844 | + $disabled_tags[] = 'flash'; |
|
1845 | + } |
|
1782 | 1846 | |
1783 | 1847 | foreach ($disabled_tags as $tag) |
1784 | 1848 | { |
@@ -1788,9 +1852,10 @@ discard block |
||
1788 | 1852 | $context['disabled_tags']['orderedlist'] = true; |
1789 | 1853 | } |
1790 | 1854 | |
1791 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1792 | - if ($tag === $thisTag) |
|
1855 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1856 | + if ($tag === $thisTag) |
|
1793 | 1857 | $context['disabled_tags'][$tagNameBBC] = true; |
1858 | + } |
|
1794 | 1859 | |
1795 | 1860 | $context['disabled_tags'][trim($tag)] = true; |
1796 | 1861 | } |
@@ -1800,19 +1865,21 @@ discard block |
||
1800 | 1865 | $context['bbc_toolbar'] = array(); |
1801 | 1866 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1802 | 1867 | { |
1803 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1804 | - $context['bbc_toolbar'][$row] = array(); |
|
1868 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1869 | + $context['bbc_toolbar'][$row] = array(); |
|
1870 | + } |
|
1805 | 1871 | $tagsRow = array(); |
1806 | 1872 | foreach ($tagRow as $tag) |
1807 | 1873 | { |
1808 | 1874 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
1809 | 1875 | { |
1810 | 1876 | $tagsRow[] = $tag['code']; |
1811 | - if (isset($tag['image'])) |
|
1812 | - $bbcodes_styles .= ' |
|
1877 | + if (isset($tag['image'])) { |
|
1878 | + $bbcodes_styles .= ' |
|
1813 | 1879 | .sceditor-button-' . $tag['code'] . ' div { |
1814 | 1880 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
1815 | 1881 | }'; |
1882 | + } |
|
1816 | 1883 | if (isset($tag['before'])) |
1817 | 1884 | { |
1818 | 1885 | $context['bbcodes_handlers'] .= ' |
@@ -1826,8 +1893,7 @@ discard block |
||
1826 | 1893 | });'; |
1827 | 1894 | } |
1828 | 1895 | |
1829 | - } |
|
1830 | - else |
|
1896 | + } else |
|
1831 | 1897 | { |
1832 | 1898 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1833 | 1899 | $tagsRow = array(); |
@@ -1838,14 +1904,16 @@ discard block |
||
1838 | 1904 | { |
1839 | 1905 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1840 | 1906 | $tagsRow = array(); |
1841 | - if (!isset($context['disabled_tags']['font'])) |
|
1842 | - $tagsRow[] = 'font'; |
|
1843 | - if (!isset($context['disabled_tags']['size'])) |
|
1844 | - $tagsRow[] = 'size'; |
|
1845 | - if (!isset($context['disabled_tags']['color'])) |
|
1846 | - $tagsRow[] = 'color'; |
|
1847 | - } |
|
1848 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1907 | + if (!isset($context['disabled_tags']['font'])) { |
|
1908 | + $tagsRow[] = 'font'; |
|
1909 | + } |
|
1910 | + if (!isset($context['disabled_tags']['size'])) { |
|
1911 | + $tagsRow[] = 'size'; |
|
1912 | + } |
|
1913 | + if (!isset($context['disabled_tags']['color'])) { |
|
1914 | + $tagsRow[] = 'color'; |
|
1915 | + } |
|
1916 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1849 | 1917 | { |
1850 | 1918 | $tmp = array(); |
1851 | 1919 | $tagsRow[] = 'removeformat'; |
@@ -1856,13 +1924,15 @@ discard block |
||
1856 | 1924 | } |
1857 | 1925 | } |
1858 | 1926 | |
1859 | - if (!empty($tagsRow)) |
|
1860 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1927 | + if (!empty($tagsRow)) { |
|
1928 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1929 | + } |
|
1861 | 1930 | } |
1862 | - if (!empty($bbcodes_styles)) |
|
1863 | - $context['html_headers'] .= ' |
|
1931 | + if (!empty($bbcodes_styles)) { |
|
1932 | + $context['html_headers'] .= ' |
|
1864 | 1933 | <style>' . $bbcodes_styles . ' |
1865 | 1934 | </style>'; |
1935 | + } |
|
1866 | 1936 | } |
1867 | 1937 | |
1868 | 1938 | // Initialize smiley array... if not loaded before. |
@@ -1874,8 +1944,8 @@ discard block |
||
1874 | 1944 | ); |
1875 | 1945 | |
1876 | 1946 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1877 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1878 | - $context['smileys']['postform'][] = array( |
|
1947 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1948 | + $context['smileys']['postform'][] = array( |
|
1879 | 1949 | 'smileys' => array( |
1880 | 1950 | array( |
1881 | 1951 | 'code' => ':)', |
@@ -1961,7 +2031,7 @@ discard block |
||
1961 | 2031 | ), |
1962 | 2032 | 'isLast' => true, |
1963 | 2033 | ); |
1964 | - elseif ($user_info['smiley_set'] != 'none') |
|
2034 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1965 | 2035 | { |
1966 | 2036 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1967 | 2037 | { |
@@ -1984,17 +2054,19 @@ discard block |
||
1984 | 2054 | |
1985 | 2055 | foreach ($context['smileys'] as $section => $smileyRows) |
1986 | 2056 | { |
1987 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
1988 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2057 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2058 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2059 | + } |
|
1989 | 2060 | |
1990 | - if (!empty($smileyRows)) |
|
1991 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2061 | + if (!empty($smileyRows)) { |
|
2062 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2063 | + } |
|
1992 | 2064 | } |
1993 | 2065 | |
1994 | 2066 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2067 | + } else { |
|
2068 | + $context['smileys'] = $temp; |
|
1995 | 2069 | } |
1996 | - else |
|
1997 | - $context['smileys'] = $temp; |
|
1998 | 2070 | } |
1999 | 2071 | } |
2000 | 2072 | |
@@ -2020,8 +2092,9 @@ discard block |
||
2020 | 2092 | loadTemplate('GenericControls'); |
2021 | 2093 | |
2022 | 2094 | // Some javascript ma'am? |
2023 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2024 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2095 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2096 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2097 | + } |
|
2025 | 2098 | |
2026 | 2099 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2027 | 2100 | |
@@ -2034,8 +2107,8 @@ discard block |
||
2034 | 2107 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2035 | 2108 | |
2036 | 2109 | // Log this into our collection. |
2037 | - if ($isNew) |
|
2038 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2110 | + if ($isNew) { |
|
2111 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2039 | 2112 | 'id' => $verificationOptions['id'], |
2040 | 2113 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2041 | 2114 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2046,13 +2119,15 @@ discard block |
||
2046 | 2119 | 'questions' => array(), |
2047 | 2120 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2048 | 2121 | ); |
2122 | + } |
|
2049 | 2123 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2050 | 2124 | |
2051 | 2125 | // Is there actually going to be anything? |
2052 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2053 | - return false; |
|
2054 | - elseif (!$isNew && !$do_test) |
|
2055 | - return true; |
|
2126 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2127 | + return false; |
|
2128 | + } elseif (!$isNew && !$do_test) { |
|
2129 | + return true; |
|
2130 | + } |
|
2056 | 2131 | |
2057 | 2132 | // Sanitize reCAPTCHA fields? |
2058 | 2133 | if ($thisVerification['can_recaptcha']) |
@@ -2065,11 +2140,12 @@ discard block |
||
2065 | 2140 | } |
2066 | 2141 | |
2067 | 2142 | // Add javascript for the object. |
2068 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2069 | - $context['insert_after_template'] .= ' |
|
2143 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2144 | + $context['insert_after_template'] .= ' |
|
2070 | 2145 | <script> |
2071 | 2146 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2072 | 2147 | </script>'; |
2148 | + } |
|
2073 | 2149 | |
2074 | 2150 | // If we want questions do we have a cache of all the IDs? |
2075 | 2151 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2092,8 +2168,9 @@ discard block |
||
2092 | 2168 | unset ($row['id_question']); |
2093 | 2169 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2094 | 2170 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
2095 | - foreach ($row['answers'] as $k => $v) |
|
2096 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2171 | + foreach ($row['answers'] as $k => $v) { |
|
2172 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2173 | + } |
|
2097 | 2174 | |
2098 | 2175 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2099 | 2176 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2104,35 +2181,42 @@ discard block |
||
2104 | 2181 | } |
2105 | 2182 | } |
2106 | 2183 | |
2107 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2108 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2184 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2185 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2186 | + } |
|
2109 | 2187 | |
2110 | 2188 | // Do we need to refresh the verification? |
2111 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2112 | - $force_refresh = true; |
|
2113 | - else |
|
2114 | - $force_refresh = false; |
|
2189 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2190 | + $force_refresh = true; |
|
2191 | + } else { |
|
2192 | + $force_refresh = false; |
|
2193 | + } |
|
2115 | 2194 | |
2116 | 2195 | // This can also force a fresh, although unlikely. |
2117 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2118 | - $force_refresh = true; |
|
2196 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2197 | + $force_refresh = true; |
|
2198 | + } |
|
2119 | 2199 | |
2120 | 2200 | $verification_errors = array(); |
2121 | 2201 | // Start with any testing. |
2122 | 2202 | if ($do_test) |
2123 | 2203 | { |
2124 | 2204 | // This cannot happen! |
2125 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2126 | - fatal_lang_error('no_access', false); |
|
2205 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2206 | + fatal_lang_error('no_access', false); |
|
2207 | + } |
|
2127 | 2208 | // ... nor this! |
2128 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2129 | - fatal_lang_error('no_access', false); |
|
2209 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2210 | + fatal_lang_error('no_access', false); |
|
2211 | + } |
|
2130 | 2212 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2131 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2132 | - fatal_lang_error('no_access', false); |
|
2213 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2214 | + fatal_lang_error('no_access', false); |
|
2215 | + } |
|
2133 | 2216 | // While we're here, did the user do something bad? |
2134 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2135 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2217 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2218 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2219 | + } |
|
2136 | 2220 | |
2137 | 2221 | if ($thisVerification['can_recaptcha']) |
2138 | 2222 | { |
@@ -2143,22 +2227,25 @@ discard block |
||
2143 | 2227 | { |
2144 | 2228 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2145 | 2229 | |
2146 | - if (!$resp->isSuccess()) |
|
2147 | - $verification_errors[] = 'wrong_verification_code'; |
|
2230 | + if (!$resp->isSuccess()) { |
|
2231 | + $verification_errors[] = 'wrong_verification_code'; |
|
2232 | + } |
|
2233 | + } else { |
|
2234 | + $verification_errors[] = 'wrong_verification_code'; |
|
2148 | 2235 | } |
2149 | - else |
|
2150 | - $verification_errors[] = 'wrong_verification_code'; |
|
2151 | 2236 | } |
2152 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2153 | - $verification_errors[] = 'wrong_verification_code'; |
|
2237 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2238 | + $verification_errors[] = 'wrong_verification_code'; |
|
2239 | + } |
|
2154 | 2240 | if ($thisVerification['number_questions']) |
2155 | 2241 | { |
2156 | 2242 | $incorrectQuestions = array(); |
2157 | 2243 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2158 | 2244 | { |
2159 | 2245 | // We don't have this question any more, thus no answers. |
2160 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2161 | - continue; |
|
2246 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2247 | + continue; |
|
2248 | + } |
|
2162 | 2249 | // This is quite complex. We have our question but it might have multiple answers. |
2163 | 2250 | // First, did they actually answer this question? |
2164 | 2251 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2170,24 +2257,28 @@ discard block |
||
2170 | 2257 | else |
2171 | 2258 | { |
2172 | 2259 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2173 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2174 | - $incorrectQuestions[] = $q; |
|
2260 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2261 | + $incorrectQuestions[] = $q; |
|
2262 | + } |
|
2175 | 2263 | } |
2176 | 2264 | } |
2177 | 2265 | |
2178 | - if (!empty($incorrectQuestions)) |
|
2179 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2266 | + if (!empty($incorrectQuestions)) { |
|
2267 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2268 | + } |
|
2180 | 2269 | } |
2181 | 2270 | } |
2182 | 2271 | |
2183 | 2272 | // Any errors means we refresh potentially. |
2184 | 2273 | if (!empty($verification_errors)) |
2185 | 2274 | { |
2186 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2187 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2275 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2276 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2277 | + } |
|
2188 | 2278 | // Too many errors? |
2189 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2190 | - $force_refresh = true; |
|
2279 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2280 | + $force_refresh = true; |
|
2281 | + } |
|
2191 | 2282 | |
2192 | 2283 | // Keep a track of these. |
2193 | 2284 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2220,8 +2311,9 @@ discard block |
||
2220 | 2311 | // Are we overriding the range? |
2221 | 2312 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2222 | 2313 | |
2223 | - for ($i = 0; $i < 6; $i++) |
|
2224 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2314 | + for ($i = 0; $i < 6; $i++) { |
|
2315 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2316 | + } |
|
2225 | 2317 | } |
2226 | 2318 | |
2227 | 2319 | // Getting some new questions? |
@@ -2229,8 +2321,9 @@ discard block |
||
2229 | 2321 | { |
2230 | 2322 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2231 | 2323 | $possible_langs = array(); |
2232 | - if (isset($_SESSION['language'])) |
|
2233 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2324 | + if (isset($_SESSION['language'])) { |
|
2325 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2326 | + } |
|
2234 | 2327 | if (!empty($user_info['language'])); |
2235 | 2328 | $possible_langs[] = $user_info['language']; |
2236 | 2329 | $possible_langs[] = $language; |
@@ -2249,8 +2342,7 @@ discard block |
||
2249 | 2342 | } |
2250 | 2343 | } |
2251 | 2344 | } |
2252 | - } |
|
2253 | - else |
|
2345 | + } else |
|
2254 | 2346 | { |
2255 | 2347 | // Same questions as before. |
2256 | 2348 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2260,8 +2352,9 @@ discard block |
||
2260 | 2352 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2261 | 2353 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2262 | 2354 | { |
2263 | - if (!isset($context['html_headers'])) |
|
2264 | - $context['html_headers'] = ''; |
|
2355 | + if (!isset($context['html_headers'])) { |
|
2356 | + $context['html_headers'] = ''; |
|
2357 | + } |
|
2265 | 2358 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2266 | 2359 | } |
2267 | 2360 | |
@@ -2287,11 +2380,13 @@ discard block |
||
2287 | 2380 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2288 | 2381 | |
2289 | 2382 | // Return errors if we have them. |
2290 | - if (!empty($verification_errors)) |
|
2291 | - return $verification_errors; |
|
2383 | + if (!empty($verification_errors)) { |
|
2384 | + return $verification_errors; |
|
2385 | + } |
|
2292 | 2386 | // If we had a test that one, make a note. |
2293 | - elseif ($do_test) |
|
2294 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2387 | + elseif ($do_test) { |
|
2388 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2389 | + } |
|
2295 | 2390 | |
2296 | 2391 | // Say that everything went well chaps. |
2297 | 2392 | return true; |
@@ -2316,8 +2411,9 @@ discard block |
||
2316 | 2411 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2317 | 2412 | |
2318 | 2413 | // If we're just checking the callback function is registered return true or false. |
2319 | - if ($checkRegistered != null) |
|
2320 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2414 | + if ($checkRegistered != null) { |
|
2415 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2416 | + } |
|
2321 | 2417 | |
2322 | 2418 | checkSession('get'); |
2323 | 2419 | loadTemplate('Xml'); |
@@ -2468,24 +2564,27 @@ discard block |
||
2468 | 2564 | foreach ($possible_versions as $ver) |
2469 | 2565 | { |
2470 | 2566 | $ver = trim($ver); |
2471 | - if (strpos($ver, 'SMF') === 0) |
|
2472 | - $versions[] = $ver; |
|
2567 | + if (strpos($ver, 'SMF') === 0) { |
|
2568 | + $versions[] = $ver; |
|
2569 | + } |
|
2473 | 2570 | } |
2474 | 2571 | } |
2475 | 2572 | $smcFunc['db_free_result']($request); |
2476 | 2573 | |
2477 | 2574 | // Just in case we don't have ANYthing. |
2478 | - if (empty($versions)) |
|
2479 | - $versions = array('SMF 2.0'); |
|
2575 | + if (empty($versions)) { |
|
2576 | + $versions = array('SMF 2.0'); |
|
2577 | + } |
|
2480 | 2578 | |
2481 | - foreach ($versions as $id => $version) |
|
2482 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2579 | + foreach ($versions as $id => $version) { |
|
2580 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2483 | 2581 | $xml_data['items']['children'][] = array( |
2484 | 2582 | 'attributes' => array( |
2485 | 2583 | 'id' => $id, |
2486 | 2584 | ), |
2487 | 2585 | 'value' => $version, |
2488 | 2586 | ); |
2587 | + } |
|
2489 | 2588 | |
2490 | 2589 | return $xml_data; |
2491 | 2590 | } |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl, $modSettings; |
19 | 19 | |
20 | 20 | // If maintenance has finished tell the user. |
21 | - if (!empty($context['maintenance_finished'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['maintenance_finished'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | echo ' |
28 | 29 | <div id="manage_maintenance"> |
@@ -107,11 +108,12 @@ discard block |
||
107 | 108 | <div id="manage_maintenance">'; |
108 | 109 | |
109 | 110 | // If maintenance has finished tell the user. |
110 | - if (!empty($context['maintenance_finished'])) |
|
111 | - echo ' |
|
111 | + if (!empty($context['maintenance_finished'])) { |
|
112 | + echo ' |
|
112 | 113 | <div class="infobox"> |
113 | 114 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | |
116 | 118 | echo ' |
117 | 119 | <div class="cat_bar"> |
@@ -238,11 +240,12 @@ discard block |
||
238 | 240 | <div id="manage_maintenance">'; |
239 | 241 | |
240 | 242 | // If maintenance has finished tell the user. |
241 | - if (!empty($context['maintenance_finished'])) |
|
242 | - echo ' |
|
243 | + if (!empty($context['maintenance_finished'])) { |
|
244 | + echo ' |
|
243 | 245 | <div class="infobox"> |
244 | 246 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
245 | 247 | </div>'; |
248 | + } |
|
246 | 249 | |
247 | 250 | echo ' |
248 | 251 | <div class="cat_bar"> |
@@ -300,9 +303,10 @@ discard block |
||
300 | 303 | <p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p> |
301 | 304 | <div style="display: none; padding: 3px" id="membersPanel">'; |
302 | 305 | |
303 | - foreach ($context['membergroups'] as $group) |
|
304 | - echo ' |
|
306 | + foreach ($context['membergroups'] as $group) { |
|
307 | + echo ' |
|
305 | 308 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
309 | + } |
|
306 | 310 | |
307 | 311 | echo ' |
308 | 312 | </div> |
@@ -346,11 +350,12 @@ discard block |
||
346 | 350 | global $scripturl, $txt, $context, $settings, $modSettings; |
347 | 351 | |
348 | 352 | // If maintenance has finished tell the user. |
349 | - if (!empty($context['maintenance_finished'])) |
|
350 | - echo ' |
|
353 | + if (!empty($context['maintenance_finished'])) { |
|
354 | + echo ' |
|
351 | 355 | <div class="infobox"> |
352 | 356 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
353 | 357 | </div>'; |
358 | + } |
|
354 | 359 | |
355 | 360 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
356 | 361 | echo ' |
@@ -418,19 +423,21 @@ discard block |
||
418 | 423 | <ul>'; |
419 | 424 | |
420 | 425 | // Display a checkbox with every board. |
421 | - foreach ($category['boards'] as $board) |
|
422 | - echo ' |
|
426 | + foreach ($category['boards'] as $board) { |
|
427 | + echo ' |
|
423 | 428 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label></li>'; |
429 | + } |
|
424 | 430 | |
425 | 431 | echo ' |
426 | 432 | </ul> |
427 | 433 | </fieldset>'; |
428 | 434 | |
429 | 435 | // Increase $i, and check if we're at the middle yet. |
430 | - if (++$i == $middle) |
|
431 | - echo ' |
|
436 | + if (++$i == $middle) { |
|
437 | + echo ' |
|
432 | 438 | </div> |
433 | 439 | <div class="floatright" style="width: 49%;">'; |
440 | + } |
|
434 | 441 | } |
435 | 442 | |
436 | 443 | echo ' |
@@ -469,9 +476,10 @@ discard block |
||
469 | 476 | echo ' |
470 | 477 | <optgroup label="', $category['name'], '">'; |
471 | 478 | |
472 | - foreach ($category['boards'] as $board) |
|
473 | - echo ' |
|
479 | + foreach ($category['boards'] as $board) { |
|
480 | + echo ' |
|
474 | 481 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
482 | + } |
|
475 | 483 | |
476 | 484 | echo ' |
477 | 485 | </optgroup>'; |
@@ -489,9 +497,10 @@ discard block |
||
489 | 497 | echo ' |
490 | 498 | <optgroup label="', $category['name'], '">'; |
491 | 499 | |
492 | - foreach ($category['boards'] as $board) |
|
493 | - echo ' |
|
500 | + foreach ($category['boards'] as $board) { |
|
501 | + echo ' |
|
494 | 502 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
503 | + } |
|
495 | 504 | |
496 | 505 | echo ' |
497 | 506 | </optgroup>'; |
@@ -531,9 +540,10 @@ discard block |
||
531 | 540 | ', $txt['database_optimize_attempt'], '<br>'; |
532 | 541 | |
533 | 542 | // List each table being optimized... |
534 | - foreach ($context['optimized_tables'] as $table) |
|
535 | - echo ' |
|
543 | + foreach ($context['optimized_tables'] as $table) { |
|
544 | + echo ' |
|
536 | 545 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
546 | + } |
|
537 | 547 | |
538 | 548 | // How did we go? |
539 | 549 | echo ' |
@@ -590,13 +600,14 @@ discard block |
||
590 | 600 | ', implode('</li><li>', $context['exceeding_messages']), ' |
591 | 601 | </li> |
592 | 602 | </ul>'; |
593 | - if (!empty($context['exceeding_messages_morethan'])) |
|
594 | - echo ' |
|
603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
604 | + echo ' |
|
595 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
596 | - } |
|
597 | - else |
|
598 | - echo ' |
|
606 | + } |
|
607 | + } else { |
|
608 | + echo ' |
|
599 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
610 | + } |
|
600 | 611 | |
601 | 612 | echo ' |
602 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |