@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -36,8 +37,9 @@ discard block |
||
36 | 37 | static $tried_hook = false; |
37 | 38 | |
38 | 39 | // Check if error logging is actually on. |
39 | - if (empty($modSettings['enableErrorLogging'])) |
|
40 | - return $error_message; |
|
40 | + if (empty($modSettings['enableErrorLogging'])) { |
|
41 | + return $error_message; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | // Basically, htmlspecialchars it minus &. (for entities!) |
43 | 45 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -45,22 +47,26 @@ discard block |
||
45 | 47 | |
46 | 48 | // Add a file and line to the error message? |
47 | 49 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
48 | - if ($file == null) |
|
49 | - $file = ''; |
|
50 | - else |
|
51 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
50 | + if ($file == null) { |
|
51 | + $file = ''; |
|
52 | + } else { |
|
53 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
52 | 54 | $file = str_replace('\\', '/', $file); |
55 | + } |
|
53 | 56 | |
54 | - if ($line == null) |
|
55 | - $line = 0; |
|
56 | - else |
|
57 | - $line = (int) $line; |
|
57 | + if ($line == null) { |
|
58 | + $line = 0; |
|
59 | + } else { |
|
60 | + $line = (int) $line; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | // Just in case there's no id_member or IP set yet. |
60 | - if (empty($user_info['id'])) |
|
61 | - $user_info['id'] = 0; |
|
62 | - if (empty($user_info['ip'])) |
|
63 | - $user_info['ip'] = ''; |
|
64 | + if (empty($user_info['id'])) { |
|
65 | + $user_info['id'] = 0; |
|
66 | + } |
|
67 | + if (empty($user_info['ip'])) { |
|
68 | + $user_info['ip'] = ''; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | // Find the best query string we can... |
66 | 72 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
@@ -69,8 +75,9 @@ discard block |
||
69 | 75 | $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
70 | 76 | |
71 | 77 | // Just so we know what board error messages are from. |
72 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
73 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
78 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
79 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
80 | + } |
|
74 | 81 | |
75 | 82 | // What types of categories do we have? |
76 | 83 | $known_error_types = array( |
@@ -132,12 +139,14 @@ discard block |
||
132 | 139 | global $txt; |
133 | 140 | |
134 | 141 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
135 | - if (!empty($status)) |
|
136 | - send_http_status($status); |
|
142 | + if (!empty($status)) { |
|
143 | + send_http_status($status); |
|
144 | + } |
|
137 | 145 | |
138 | 146 | // We don't have $txt yet, but that's okay... |
139 | - if (empty($txt)) |
|
140 | - die($error); |
|
147 | + if (empty($txt)) { |
|
148 | + die($error); |
|
149 | + } |
|
141 | 150 | |
142 | 151 | log_error_online($error, false); |
143 | 152 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -164,8 +173,9 @@ discard block |
||
164 | 173 | static $fatal_error_called = false; |
165 | 174 | |
166 | 175 | // Send the status header - set this to 0 or false if you don't want to send one at all |
167 | - if (!empty($status)) |
|
168 | - send_http_status($status); |
|
176 | + if (!empty($status)) { |
|
177 | + send_http_status($status); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Try to load a theme if we don't have one. |
171 | 181 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -175,8 +185,9 @@ discard block |
||
175 | 185 | } |
176 | 186 | |
177 | 187 | // If we have no theme stuff we can't have the language file... |
178 | - if (empty($context['theme_loaded'])) |
|
179 | - die($error); |
|
188 | + if (empty($context['theme_loaded'])) { |
|
189 | + die($error); |
|
190 | + } |
|
180 | 191 | |
181 | 192 | $reload_lang_file = true; |
182 | 193 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -212,8 +223,9 @@ discard block |
||
212 | 223 | global $settings, $modSettings, $db_show_debug; |
213 | 224 | |
214 | 225 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
215 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
216 | - return; |
|
226 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
227 | + return; |
|
228 | + } |
|
217 | 229 | |
218 | 230 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
219 | 231 | { |
@@ -221,19 +233,22 @@ discard block |
||
221 | 233 | $count = count($array); |
222 | 234 | for ($i = 0; $i < $count; $i++) |
223 | 235 | { |
224 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
225 | - continue; |
|
236 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
237 | + continue; |
|
238 | + } |
|
226 | 239 | |
227 | 240 | // This is a bug in PHP, with eval, it seems! |
228 | - if (empty($array[$i]['args'])) |
|
229 | - $i++; |
|
241 | + if (empty($array[$i]['args'])) { |
|
242 | + $i++; |
|
243 | + } |
|
230 | 244 | break; |
231 | 245 | } |
232 | 246 | |
233 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
234 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
235 | - else |
|
236 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
247 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
248 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
249 | + } else { |
|
250 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
251 | + } |
|
237 | 252 | } |
238 | 253 | |
239 | 254 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -242,8 +257,9 @@ discard block |
||
242 | 257 | if ($error_level % 255 != E_ERROR) |
243 | 258 | { |
244 | 259 | $temporary = ob_get_contents(); |
245 | - if (substr($temporary, -2) == '="') |
|
246 | - echo '"'; |
|
260 | + if (substr($temporary, -2) == '="') { |
|
261 | + echo '"'; |
|
262 | + } |
|
247 | 263 | } |
248 | 264 | |
249 | 265 | // Debugging! This should look like a PHP error message. |
@@ -259,23 +275,27 @@ discard block |
||
259 | 275 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
260 | 276 | |
261 | 277 | // Dying on these errors only causes MORE problems (blank pages!) |
262 | - if ($file == 'Unknown') |
|
263 | - return; |
|
278 | + if ($file == 'Unknown') { |
|
279 | + return; |
|
280 | + } |
|
264 | 281 | |
265 | 282 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
266 | - if ($error_level % 255 == E_ERROR) |
|
267 | - obExit(false); |
|
268 | - else |
|
269 | - return; |
|
283 | + if ($error_level % 255 == E_ERROR) { |
|
284 | + obExit(false); |
|
285 | + } else { |
|
286 | + return; |
|
287 | + } |
|
270 | 288 | |
271 | 289 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
272 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
273 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
290 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
291 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
292 | + } |
|
274 | 293 | |
275 | 294 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
276 | - if ($error_level % 255 == E_ERROR) |
|
277 | - die('No direct access...'); |
|
278 | -} |
|
295 | + if ($error_level % 255 == E_ERROR) { |
|
296 | + die('No direct access...'); |
|
297 | + } |
|
298 | + } |
|
279 | 299 | |
280 | 300 | /** |
281 | 301 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -291,24 +311,28 @@ discard block |
||
291 | 311 | |
292 | 312 | // Attempt to prevent a recursive loop. |
293 | 313 | ++$level; |
294 | - if ($level > 1) |
|
295 | - return false; |
|
314 | + if ($level > 1) { |
|
315 | + return false; |
|
316 | + } |
|
296 | 317 | |
297 | 318 | // Maybe they came from dlattach or similar? |
298 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
299 | - loadTheme(); |
|
319 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
320 | + loadTheme(); |
|
321 | + } |
|
300 | 322 | |
301 | 323 | // Don't bother indexing errors mate... |
302 | 324 | $context['robot_no_index'] = true; |
303 | 325 | |
304 | - if (!isset($context['error_title'])) |
|
305 | - $context['error_title'] = $txt['error_occured']; |
|
326 | + if (!isset($context['error_title'])) { |
|
327 | + $context['error_title'] = $txt['error_occured']; |
|
328 | + } |
|
306 | 329 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
307 | 330 | |
308 | 331 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
309 | 332 | |
310 | - if (empty($context['page_title'])) |
|
311 | - $context['page_title'] = $context['error_title']; |
|
333 | + if (empty($context['page_title'])) { |
|
334 | + $context['page_title'] = $context['error_title']; |
|
335 | + } |
|
312 | 336 | |
313 | 337 | loadTemplate('Errors'); |
314 | 338 | $context['sub_template'] = 'fatal_error'; |
@@ -316,23 +340,26 @@ discard block |
||
316 | 340 | // If this is SSI, what do they want us to do? |
317 | 341 | if (SMF == 'SSI') |
318 | 342 | { |
319 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
320 | - $ssi_on_error_method(); |
|
321 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
322 | - loadSubTemplate('fatal_error'); |
|
343 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
344 | + $ssi_on_error_method(); |
|
345 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
346 | + loadSubTemplate('fatal_error'); |
|
347 | + } |
|
323 | 348 | |
324 | 349 | // No layers? |
325 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
326 | - exit; |
|
350 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
351 | + exit; |
|
352 | + } |
|
327 | 353 | } |
328 | 354 | // Alternatively from the cron call? |
329 | 355 | elseif (SMF == 'BACKGROUND') |
330 | 356 | { |
331 | 357 | // We can't rely on even having language files available. |
332 | - if (defined('FROM_CLI') && FROM_CLI) |
|
333 | - echo 'cron error: ', $context['error_message']; |
|
334 | - else |
|
335 | - echo 'An error occurred. More information may be available in your logs.'; |
|
358 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
359 | + echo 'cron error: ', $context['error_message']; |
|
360 | + } else { |
|
361 | + echo 'An error occurred. More information may be available in your logs.'; |
|
362 | + } |
|
336 | 363 | exit; |
337 | 364 | } |
338 | 365 | |
@@ -360,8 +387,8 @@ discard block |
||
360 | 387 | |
361 | 388 | set_fatal_error_headers(); |
362 | 389 | |
363 | - if (!empty($maintenance)) |
|
364 | - echo '<!DOCTYPE html> |
|
390 | + if (!empty($maintenance)) { |
|
391 | + echo '<!DOCTYPE html> |
|
365 | 392 | <html> |
366 | 393 | <head> |
367 | 394 | <meta name="robots" content="noindex"> |
@@ -372,6 +399,7 @@ discard block |
||
372 | 399 | ', $mmessage, ' |
373 | 400 | </body> |
374 | 401 | </html>'; |
402 | + } |
|
375 | 403 | |
376 | 404 | die(); |
377 | 405 | } |
@@ -393,15 +421,17 @@ discard block |
||
393 | 421 | // For our purposes, we're gonna want this on if at all possible. |
394 | 422 | $modSettings['cache_enable'] = '1'; |
395 | 423 | |
396 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
397 | - $db_last_error = max($db_last_error, $temp); |
|
424 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
425 | + $db_last_error = max($db_last_error, $temp); |
|
426 | + } |
|
398 | 427 | |
399 | 428 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
400 | 429 | { |
401 | 430 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
402 | 431 | cache_put_data('db_last_error', time(), 600); |
403 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
404 | - logLastDatabaseError(); |
|
432 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
433 | + logLastDatabaseError(); |
|
434 | + } |
|
405 | 435 | |
406 | 436 | // Language files aren't loaded yet :(. |
407 | 437 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -482,12 +512,14 @@ discard block |
||
482 | 512 | global $smcFunc, $user_info, $modSettings; |
483 | 513 | |
484 | 514 | // Don't bother if Who's Online is disabled. |
485 | - if (empty($modSettings['who_enabled'])) |
|
486 | - return; |
|
515 | + if (empty($modSettings['who_enabled'])) { |
|
516 | + return; |
|
517 | + } |
|
487 | 518 | |
488 | 519 | // Maybe they came from SSI or similar where sessions are not recorded? |
489 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
490 | - return; |
|
520 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
521 | + return; |
|
522 | + } |
|
491 | 523 | |
492 | 524 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
493 | 525 | |
@@ -506,8 +538,9 @@ discard block |
||
506 | 538 | $url = smf_json_decode($url, true); |
507 | 539 | $url['error'] = $error; |
508 | 540 | |
509 | - if (!empty($sprintf)) |
|
510 | - $url['error_params'] = $sprintf; |
|
541 | + if (!empty($sprintf)) { |
|
542 | + $url['error_params'] = $sprintf; |
|
543 | + } |
|
511 | 544 | |
512 | 545 | $smcFunc['db_query']('', ' |
513 | 546 | UPDATE {db_prefix}log_online |
@@ -538,10 +571,11 @@ discard block |
||
538 | 571 | |
539 | 572 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
540 | 573 | |
541 | - if (!isset($statuses[$code])) |
|
542 | - header($protocol . ' 500 Internal Server Error'); |
|
543 | - else |
|
544 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
545 | -} |
|
574 | + if (!isset($statuses[$code])) { |
|
575 | + header($protocol . ' 500 Internal Server Error'); |
|
576 | + } else { |
|
577 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
578 | + } |
|
579 | + } |
|
546 | 580 | |
547 | 581 | ?> |
548 | 582 | \ No newline at end of file |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | * @version 2.1 Beta 4 |
60 | 60 | */ |
61 | 61 | |
62 | -if (!defined('SMF')) |
|
62 | +if (!defined('SMF')) { |
|
63 | 63 | die('No direct access...'); |
64 | +} |
|
64 | 65 | |
65 | 66 | /** |
66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
113 | 114 | |
114 | - if ($settings_not_writable) |
|
115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
116 | - elseif ($settings_backup_fail) |
|
117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
115 | + if ($settings_not_writable) { |
|
116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
117 | + } elseif ($settings_backup_fail) { |
|
118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
120 | 122 | |
@@ -168,8 +170,9 @@ discard block |
||
168 | 170 | |
169 | 171 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
170 | 172 | |
171 | - if ($return_config) |
|
172 | - return $config_vars; |
|
173 | + if ($return_config) { |
|
174 | + return $config_vars; |
|
175 | + } |
|
173 | 176 | |
174 | 177 | // Setup the template stuff. |
175 | 178 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -186,8 +189,9 @@ discard block |
||
186 | 189 | $registerSMStats = registerSMStats(); |
187 | 190 | |
188 | 191 | // Failed to register, disable it again. |
189 | - if (empty($registerSMStats)) |
|
190 | - $_POST['enable_sm_stats'] = 0; |
|
192 | + if (empty($registerSMStats)) { |
|
193 | + $_POST['enable_sm_stats'] = 0; |
|
194 | + } |
|
191 | 195 | } |
192 | 196 | |
193 | 197 | saveSettings($config_vars); |
@@ -248,8 +252,9 @@ discard block |
||
248 | 252 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
249 | 253 | $fts_language = array(); |
250 | 254 | |
251 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
252 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
255 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
256 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
257 | + } |
|
253 | 258 | |
254 | 259 | $config_vars = array_merge ($config_vars, array( |
255 | 260 | '', |
@@ -261,8 +266,9 @@ discard block |
||
261 | 266 | |
262 | 267 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
263 | 268 | |
264 | - if ($return_config) |
|
265 | - return $config_vars; |
|
269 | + if ($return_config) { |
|
270 | + return $config_vars; |
|
271 | + } |
|
266 | 272 | |
267 | 273 | // Setup the template stuff. |
268 | 274 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -337,13 +343,15 @@ discard block |
||
337 | 343 | hideGlobalCookies(); |
338 | 344 | });', true); |
339 | 345 | |
340 | - if (empty($user_settings['tfa_secret'])) |
|
341 | - addInlineJavaScript(''); |
|
346 | + if (empty($user_settings['tfa_secret'])) { |
|
347 | + addInlineJavaScript(''); |
|
348 | + } |
|
342 | 349 | |
343 | 350 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
344 | 351 | |
345 | - if ($return_config) |
|
346 | - return $config_vars; |
|
352 | + if ($return_config) { |
|
353 | + return $config_vars; |
|
354 | + } |
|
347 | 355 | |
348 | 356 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
349 | 357 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -354,11 +362,13 @@ discard block |
||
354 | 362 | call_integration_hook('integrate_save_cookie_settings'); |
355 | 363 | |
356 | 364 | // Local and global do not play nicely together. |
357 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
358 | - unset ($_POST['globalCookies']); |
|
365 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
366 | + unset ($_POST['globalCookies']); |
|
367 | + } |
|
359 | 368 | |
360 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
361 | - fatal_lang_error('invalid_cookie_domain', false); |
|
369 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
370 | + fatal_lang_error('invalid_cookie_domain', false); |
|
371 | + } |
|
362 | 372 | |
363 | 373 | saveSettings($config_vars); |
364 | 374 | |
@@ -441,8 +451,9 @@ discard block |
||
441 | 451 | |
442 | 452 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
443 | 453 | |
444 | - if ($return_config) |
|
445 | - return $config_vars; |
|
454 | + if ($return_config) { |
|
455 | + return $config_vars; |
|
456 | + } |
|
446 | 457 | |
447 | 458 | // Saving? |
448 | 459 | if (isset($_GET['save'])) |
@@ -481,8 +492,7 @@ discard block |
||
481 | 492 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
482 | 493 | $cache_level = array($txt['cache_off']); |
483 | 494 | $detected['none'] = $txt['cache_off']; |
484 | - } |
|
485 | - else |
|
495 | + } else |
|
486 | 496 | { |
487 | 497 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
488 | 498 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -519,8 +529,9 @@ discard block |
||
519 | 529 | } |
520 | 530 | } |
521 | 531 | } |
522 | - if ($return_config) |
|
523 | - return $config_vars; |
|
532 | + if ($return_config) { |
|
533 | + return $config_vars; |
|
534 | + } |
|
524 | 535 | |
525 | 536 | // Saving again? |
526 | 537 | if (isset($_GET['save'])) |
@@ -548,8 +559,9 @@ discard block |
||
548 | 559 | $context['save_disabled'] = $context['settings_not_writable']; |
549 | 560 | |
550 | 561 | // Decide what message to show. |
551 | - if (!$context['save_disabled']) |
|
552 | - $context['settings_message'] = $txt['caching_information']; |
|
562 | + if (!$context['save_disabled']) { |
|
563 | + $context['settings_message'] = $txt['caching_information']; |
|
564 | + } |
|
553 | 565 | |
554 | 566 | // Prepare the template. |
555 | 567 | prepareServerSettingsContext($config_vars); |
@@ -572,24 +584,25 @@ discard block |
||
572 | 584 | if (stripos(PHP_OS, 'win') === 0) |
573 | 585 | { |
574 | 586 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
575 | - if (isset($_GET['save'])) |
|
576 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
577 | - } |
|
578 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
587 | + if (isset($_GET['save'])) { |
|
588 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
589 | + } |
|
590 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
579 | 591 | { |
580 | 592 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
581 | - if (isset($_GET['save'])) |
|
582 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
583 | - } |
|
584 | - else |
|
593 | + if (isset($_GET['save'])) { |
|
594 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
595 | + } |
|
596 | + } else |
|
585 | 597 | { |
586 | 598 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
587 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
588 | - $modSettings['load_average'] = (float) $matches[1]; |
|
589 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
590 | - $modSettings['load_average'] = (float) $matches[1]; |
|
591 | - else |
|
592 | - unset($modSettings['load_average']); |
|
599 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
600 | + $modSettings['load_average'] = (float) $matches[1]; |
|
601 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
602 | + $modSettings['load_average'] = (float) $matches[1]; |
|
603 | + } else { |
|
604 | + unset($modSettings['load_average']); |
|
605 | + } |
|
593 | 606 | |
594 | 607 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
595 | 608 | { |
@@ -625,8 +638,9 @@ discard block |
||
625 | 638 | |
626 | 639 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
627 | 640 | |
628 | - if ($return_config) |
|
629 | - return $config_vars; |
|
641 | + if ($return_config) { |
|
642 | + return $config_vars; |
|
643 | + } |
|
630 | 644 | |
631 | 645 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
632 | 646 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -637,24 +651,27 @@ discard block |
||
637 | 651 | // Stupidity is not allowed. |
638 | 652 | foreach ($_POST as $key => $value) |
639 | 653 | { |
640 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
641 | - continue; |
|
642 | - else |
|
643 | - $_POST[$key] = (float) $value; |
|
644 | - |
|
645 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
646 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
647 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
648 | - $_POST['loadavg_forum'] = 10.0; |
|
649 | - elseif ($value < 2) |
|
650 | - $_POST[$key] = 2.0; |
|
654 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
655 | + continue; |
|
656 | + } else { |
|
657 | + $_POST[$key] = (float) $value; |
|
658 | + } |
|
659 | + |
|
660 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
661 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
662 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
663 | + $_POST['loadavg_forum'] = 10.0; |
|
664 | + } elseif ($value < 2) { |
|
665 | + $_POST[$key] = 2.0; |
|
666 | + } |
|
651 | 667 | } |
652 | 668 | |
653 | 669 | call_integration_hook('integrate_save_loadavg_settings'); |
654 | 670 | |
655 | 671 | saveDBSettings($config_vars); |
656 | - if (!isset($_SESSION['adm-save'])) |
|
657 | - $_SESSION['adm-save'] = true; |
|
672 | + if (!isset($_SESSION['adm-save'])) { |
|
673 | + $_SESSION['adm-save'] = true; |
|
674 | + } |
|
658 | 675 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
659 | 676 | } |
660 | 677 | |
@@ -690,10 +707,11 @@ discard block |
||
690 | 707 | |
691 | 708 | if (isset($_SESSION['adm-save'])) |
692 | 709 | { |
693 | - if ($_SESSION['adm-save'] === true) |
|
694 | - $context['saved_successful'] = true; |
|
695 | - else |
|
696 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
710 | + if ($_SESSION['adm-save'] === true) { |
|
711 | + $context['saved_successful'] = true; |
|
712 | + } else { |
|
713 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
714 | + } |
|
697 | 715 | |
698 | 716 | unset($_SESSION['adm-save']); |
699 | 717 | } |
@@ -701,9 +719,9 @@ discard block |
||
701 | 719 | $context['config_vars'] = array(); |
702 | 720 | foreach ($config_vars as $identifier => $config_var) |
703 | 721 | { |
704 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
705 | - $context['config_vars'][] = $config_var; |
|
706 | - else |
|
722 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
723 | + $context['config_vars'][] = $config_var; |
|
724 | + } else |
|
707 | 725 | { |
708 | 726 | $varname = $config_var[0]; |
709 | 727 | global $$varname; |
@@ -738,16 +756,19 @@ discard block |
||
738 | 756 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
739 | 757 | { |
740 | 758 | // Default to a min of 0 if one isn't set |
741 | - if (isset($config_var['min'])) |
|
742 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
743 | - else |
|
744 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
759 | + if (isset($config_var['min'])) { |
|
760 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
761 | + } else { |
|
762 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
763 | + } |
|
745 | 764 | |
746 | - if (isset($config_var['max'])) |
|
747 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
765 | + if (isset($config_var['max'])) { |
|
766 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
767 | + } |
|
748 | 768 | |
749 | - if (isset($config_var['step'])) |
|
750 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
769 | + if (isset($config_var['step'])) { |
|
770 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
771 | + } |
|
751 | 772 | } |
752 | 773 | |
753 | 774 | // If this is a select box handle any data. |
@@ -755,12 +776,13 @@ discard block |
||
755 | 776 | { |
756 | 777 | // If it's associative |
757 | 778 | $config_values = array_values($config_var[4]); |
758 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
759 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
760 | - else |
|
779 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
780 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
781 | + } else |
|
761 | 782 | { |
762 | - foreach ($config_var[4] as $key => $item) |
|
763 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
783 | + foreach ($config_var[4] as $key => $item) { |
|
784 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
785 | + } |
|
764 | 786 | } |
765 | 787 | } |
766 | 788 | } |
@@ -785,10 +807,11 @@ discard block |
||
785 | 807 | |
786 | 808 | if (isset($_SESSION['adm-save'])) |
787 | 809 | { |
788 | - if ($_SESSION['adm-save'] === true) |
|
789 | - $context['saved_successful'] = true; |
|
790 | - else |
|
791 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
810 | + if ($_SESSION['adm-save'] === true) { |
|
811 | + $context['saved_successful'] = true; |
|
812 | + } else { |
|
813 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
814 | + } |
|
792 | 815 | |
793 | 816 | unset($_SESSION['adm-save']); |
794 | 817 | } |
@@ -800,26 +823,30 @@ discard block |
||
800 | 823 | foreach ($config_vars as $config_var) |
801 | 824 | { |
802 | 825 | // HR? |
803 | - if (!is_array($config_var)) |
|
804 | - $context['config_vars'][] = $config_var; |
|
805 | - else |
|
826 | + if (!is_array($config_var)) { |
|
827 | + $context['config_vars'][] = $config_var; |
|
828 | + } else |
|
806 | 829 | { |
807 | 830 | // If it has no name it doesn't have any purpose! |
808 | - if (empty($config_var[1])) |
|
809 | - continue; |
|
831 | + if (empty($config_var[1])) { |
|
832 | + continue; |
|
833 | + } |
|
810 | 834 | |
811 | 835 | // Special case for inline permissions |
812 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
813 | - $inlinePermissions[] = $config_var[1]; |
|
814 | - elseif ($config_var[0] == 'permissions') |
|
815 | - continue; |
|
836 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
837 | + $inlinePermissions[] = $config_var[1]; |
|
838 | + } elseif ($config_var[0] == 'permissions') { |
|
839 | + continue; |
|
840 | + } |
|
816 | 841 | |
817 | - if ($config_var[0] == 'boards') |
|
818 | - $board_list = true; |
|
842 | + if ($config_var[0] == 'boards') { |
|
843 | + $board_list = true; |
|
844 | + } |
|
819 | 845 | |
820 | 846 | // Are we showing the BBC selection box? |
821 | - if ($config_var[0] == 'bbc') |
|
822 | - $bbcChoice[] = $config_var[1]; |
|
847 | + if ($config_var[0] == 'bbc') { |
|
848 | + $bbcChoice[] = $config_var[1]; |
|
849 | + } |
|
823 | 850 | |
824 | 851 | // We need to do some parsing of the value before we pass it in. |
825 | 852 | if (isset($modSettings[$config_var[1]])) |
@@ -838,8 +865,7 @@ discard block |
||
838 | 865 | default: |
839 | 866 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
840 | 867 | } |
841 | - } |
|
842 | - else |
|
868 | + } else |
|
843 | 869 | { |
844 | 870 | // Darn, it's empty. What type is expected? |
845 | 871 | switch ($config_var[0]) |
@@ -879,16 +905,19 @@ discard block |
||
879 | 905 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
880 | 906 | { |
881 | 907 | // Default to a min of 0 if one isn't set |
882 | - if (isset($config_var['min'])) |
|
883 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
884 | - else |
|
885 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
908 | + if (isset($config_var['min'])) { |
|
909 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
910 | + } else { |
|
911 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
912 | + } |
|
886 | 913 | |
887 | - if (isset($config_var['max'])) |
|
888 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
914 | + if (isset($config_var['max'])) { |
|
915 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
916 | + } |
|
889 | 917 | |
890 | - if (isset($config_var['step'])) |
|
891 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
918 | + if (isset($config_var['step'])) { |
|
919 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
920 | + } |
|
892 | 921 | } |
893 | 922 | |
894 | 923 | // If this is a select box handle any data. |
@@ -902,12 +931,13 @@ discard block |
||
902 | 931 | } |
903 | 932 | |
904 | 933 | // If it's associative |
905 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
906 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
907 | - else |
|
934 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
935 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
936 | + } else |
|
908 | 937 | { |
909 | - foreach ($config_var[2] as $key => $item) |
|
910 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
938 | + foreach ($config_var[2] as $key => $item) { |
|
939 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
940 | + } |
|
911 | 941 | } |
912 | 942 | } |
913 | 943 | |
@@ -916,17 +946,19 @@ discard block |
||
916 | 946 | { |
917 | 947 | if (!is_numeric($k)) |
918 | 948 | { |
919 | - if (substr($k, 0, 2) == 'on') |
|
920 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
921 | - else |
|
922 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
949 | + if (substr($k, 0, 2) == 'on') { |
|
950 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
951 | + } else { |
|
952 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
953 | + } |
|
923 | 954 | } |
924 | 955 | |
925 | 956 | // See if there are any other labels that might fit? |
926 | - if (isset($txt['setting_' . $config_var[1]])) |
|
927 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
928 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
929 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
957 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
958 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
959 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
960 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
961 | + } |
|
930 | 962 | } |
931 | 963 | |
932 | 964 | // Set the subtext in case it's part of the label. |
@@ -959,8 +991,9 @@ discard block |
||
959 | 991 | // What are the options, eh? |
960 | 992 | $temp = parse_bbc(false); |
961 | 993 | $bbcTags = array(); |
962 | - foreach ($temp as $tag) |
|
963 | - $bbcTags[] = $tag['tag']; |
|
994 | + foreach ($temp as $tag) { |
|
995 | + $bbcTags[] = $tag['tag']; |
|
996 | + } |
|
964 | 997 | |
965 | 998 | $bbcTags = array_unique($bbcTags); |
966 | 999 | $totalTags = count($bbcTags); |
@@ -975,8 +1008,9 @@ discard block |
||
975 | 1008 | $col = 0; $i = 0; |
976 | 1009 | foreach ($bbcTags as $tag) |
977 | 1010 | { |
978 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
979 | - $col++; |
|
1011 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
1012 | + $col++; |
|
1013 | + } |
|
980 | 1014 | |
981 | 1015 | $context['bbc_columns'][$col][] = array( |
982 | 1016 | 'tag' => $tag, |
@@ -1019,18 +1053,21 @@ discard block |
||
1019 | 1053 | validateToken('admin-ssc'); |
1020 | 1054 | |
1021 | 1055 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
1022 | - if (isset($_POST['cookiename'])) |
|
1023 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1056 | + if (isset($_POST['cookiename'])) { |
|
1057 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1058 | + } |
|
1024 | 1059 | |
1025 | 1060 | // Fix the forum's URL if necessary. |
1026 | 1061 | if (isset($_POST['boardurl'])) |
1027 | 1062 | { |
1028 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1029 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1030 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
1031 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1032 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1033 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1063 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1064 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1065 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1066 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1067 | + } |
|
1068 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1069 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1070 | + } |
|
1034 | 1071 | } |
1035 | 1072 | |
1036 | 1073 | // Any passwords? |
@@ -1065,21 +1102,21 @@ discard block |
||
1065 | 1102 | // Figure out which config vars we're saving here... |
1066 | 1103 | foreach ($config_vars as $var) |
1067 | 1104 | { |
1068 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
1069 | - continue; |
|
1105 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
1106 | + continue; |
|
1107 | + } |
|
1070 | 1108 | |
1071 | 1109 | $config_var = $var[0]; |
1072 | 1110 | |
1073 | 1111 | if (in_array($config_var, $config_passwords)) |
1074 | 1112 | { |
1075 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
1076 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1077 | - } |
|
1078 | - elseif (in_array($config_var, $config_strs)) |
|
1113 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
1114 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1115 | + } |
|
1116 | + } elseif (in_array($config_var, $config_strs)) |
|
1079 | 1117 | { |
1080 | 1118 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
1081 | - } |
|
1082 | - elseif (in_array($config_var, $config_ints)) |
|
1119 | + } elseif (in_array($config_var, $config_ints)) |
|
1083 | 1120 | { |
1084 | 1121 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
1085 | 1122 | |
@@ -1088,17 +1125,17 @@ discard block |
||
1088 | 1125 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
1089 | 1126 | |
1090 | 1127 | // Is there a max value for this as well? |
1091 | - if (isset($var['max'])) |
|
1092 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1093 | - } |
|
1094 | - elseif (in_array($config_var, $config_bools)) |
|
1128 | + if (isset($var['max'])) { |
|
1129 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1130 | + } |
|
1131 | + } elseif (in_array($config_var, $config_bools)) |
|
1095 | 1132 | { |
1096 | - if (!empty($_POST[$config_var])) |
|
1097 | - $new_settings[$config_var] = '1'; |
|
1098 | - else |
|
1099 | - $new_settings[$config_var] = '0'; |
|
1100 | - } |
|
1101 | - else |
|
1133 | + if (!empty($_POST[$config_var])) { |
|
1134 | + $new_settings[$config_var] = '1'; |
|
1135 | + } else { |
|
1136 | + $new_settings[$config_var] = '0'; |
|
1137 | + } |
|
1138 | + } else |
|
1102 | 1139 | { |
1103 | 1140 | // This shouldn't happen, but it might... |
1104 | 1141 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1114,30 +1151,35 @@ discard block |
||
1114 | 1151 | foreach ($config_vars as $config_var) |
1115 | 1152 | { |
1116 | 1153 | // We just saved the file-based settings, so skip their definitions. |
1117 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
1118 | - continue; |
|
1154 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
1155 | + continue; |
|
1156 | + } |
|
1119 | 1157 | |
1120 | 1158 | $new_setting = array($config_var[3], $config_var[0]); |
1121 | 1159 | |
1122 | 1160 | // Select options need carried over, too. |
1123 | - if (isset($config_var[4])) |
|
1124 | - $new_setting[] = $config_var[4]; |
|
1161 | + if (isset($config_var[4])) { |
|
1162 | + $new_setting[] = $config_var[4]; |
|
1163 | + } |
|
1125 | 1164 | |
1126 | 1165 | // Include min and max if necessary |
1127 | - if (isset($config_var['min'])) |
|
1128 | - $new_setting['min'] = $config_var['min']; |
|
1166 | + if (isset($config_var['min'])) { |
|
1167 | + $new_setting['min'] = $config_var['min']; |
|
1168 | + } |
|
1129 | 1169 | |
1130 | - if (isset($config_var['max'])) |
|
1131 | - $new_setting['max'] = $config_var['max']; |
|
1170 | + if (isset($config_var['max'])) { |
|
1171 | + $new_setting['max'] = $config_var['max']; |
|
1172 | + } |
|
1132 | 1173 | |
1133 | 1174 | // Rewrite the definition a bit. |
1134 | 1175 | $new_settings[] = $new_setting; |
1135 | 1176 | } |
1136 | 1177 | |
1137 | 1178 | // Save the new database-based settings, if any. |
1138 | - if (!empty($new_settings)) |
|
1139 | - saveDBSettings($new_settings); |
|
1140 | -} |
|
1179 | + if (!empty($new_settings)) { |
|
1180 | + saveDBSettings($new_settings); |
|
1181 | + } |
|
1182 | + } |
|
1141 | 1183 | |
1142 | 1184 | /** |
1143 | 1185 | * Helper function for saving database settings. |
@@ -1155,22 +1197,25 @@ discard block |
||
1155 | 1197 | $inlinePermissions = array(); |
1156 | 1198 | foreach ($config_vars as $var) |
1157 | 1199 | { |
1158 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
1159 | - continue; |
|
1200 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
1201 | + continue; |
|
1202 | + } |
|
1160 | 1203 | |
1161 | 1204 | // Checkboxes! |
1162 | - elseif ($var[0] == 'check') |
|
1163 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1205 | + elseif ($var[0] == 'check') { |
|
1206 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1207 | + } |
|
1164 | 1208 | // Select boxes! |
1165 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
1166 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1167 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1209 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
1210 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1211 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1168 | 1212 | { |
1169 | 1213 | // For security purposes we validate this line by line. |
1170 | 1214 | $lOptions = array(); |
1171 | - foreach ($_POST[$var[1]] as $invar) |
|
1172 | - if (in_array($invar, array_keys($var[2]))) |
|
1215 | + foreach ($_POST[$var[1]] as $invar) { |
|
1216 | + if (in_array($invar, array_keys($var[2]))) |
|
1173 | 1217 | $lOptions[] = $invar; |
1218 | + } |
|
1174 | 1219 | |
1175 | 1220 | $setArray[$var[1]] = json_encode($lOptions); |
1176 | 1221 | } |
@@ -1184,18 +1229,20 @@ discard block |
||
1184 | 1229 | $request = $smcFunc['db_query']('', ' |
1185 | 1230 | SELECT id_board |
1186 | 1231 | FROM {db_prefix}boards'); |
1187 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1188 | - $board_list[$row[0]] = true; |
|
1232 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1233 | + $board_list[$row[0]] = true; |
|
1234 | + } |
|
1189 | 1235 | |
1190 | 1236 | $smcFunc['db_free_result']($request); |
1191 | 1237 | } |
1192 | 1238 | |
1193 | 1239 | $lOptions = array(); |
1194 | 1240 | |
1195 | - if (!empty($_POST[$var[1]])) |
|
1196 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1241 | + if (!empty($_POST[$var[1]])) { |
|
1242 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1197 | 1243 | if (isset($board_list[$invar])) |
1198 | 1244 | $lOptions[] = $invar; |
1245 | + } |
|
1199 | 1246 | |
1200 | 1247 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
1201 | 1248 | } |
@@ -1209,8 +1256,9 @@ discard block |
||
1209 | 1256 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1210 | 1257 | |
1211 | 1258 | // Do we have a max value for this as well? |
1212 | - if (isset($var['max'])) |
|
1213 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1259 | + if (isset($var['max'])) { |
|
1260 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1261 | + } |
|
1214 | 1262 | } |
1215 | 1263 | // Floating point! |
1216 | 1264 | elseif ($var[0] == 'float') |
@@ -1222,40 +1270,47 @@ discard block |
||
1222 | 1270 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1223 | 1271 | |
1224 | 1272 | // Do we have a max value for this as well? |
1225 | - if (isset($var['max'])) |
|
1226 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1273 | + if (isset($var['max'])) { |
|
1274 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1275 | + } |
|
1227 | 1276 | } |
1228 | 1277 | // Text! |
1229 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
1230 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1278 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
1279 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1280 | + } |
|
1231 | 1281 | // Passwords! |
1232 | 1282 | elseif ($var[0] == 'password') |
1233 | 1283 | { |
1234 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
1235 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1284 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
1285 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1286 | + } |
|
1236 | 1287 | } |
1237 | 1288 | // BBC. |
1238 | 1289 | elseif ($var[0] == 'bbc') |
1239 | 1290 | { |
1240 | 1291 | |
1241 | 1292 | $bbcTags = array(); |
1242 | - foreach (parse_bbc(false) as $tag) |
|
1243 | - $bbcTags[] = $tag['tag']; |
|
1293 | + foreach (parse_bbc(false) as $tag) { |
|
1294 | + $bbcTags[] = $tag['tag']; |
|
1295 | + } |
|
1244 | 1296 | |
1245 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
1246 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
1247 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
1248 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1297 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
1298 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
1299 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
1300 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1301 | + } |
|
1249 | 1302 | |
1250 | 1303 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
1251 | 1304 | } |
1252 | 1305 | // Permissions? |
1253 | - elseif ($var[0] == 'permissions') |
|
1254 | - $inlinePermissions[] = $var[1]; |
|
1306 | + elseif ($var[0] == 'permissions') { |
|
1307 | + $inlinePermissions[] = $var[1]; |
|
1308 | + } |
|
1255 | 1309 | } |
1256 | 1310 | |
1257 | - if (!empty($setArray)) |
|
1258 | - updateSettings($setArray); |
|
1311 | + if (!empty($setArray)) { |
|
1312 | + updateSettings($setArray); |
|
1313 | + } |
|
1259 | 1314 | |
1260 | 1315 | // If we have inline permissions we need to save them. |
1261 | 1316 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1292,18 +1347,21 @@ discard block |
||
1292 | 1347 | // put all of it into an array |
1293 | 1348 | foreach ($info_lines as $line) |
1294 | 1349 | { |
1295 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
1296 | - continue; |
|
1350 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
1351 | + continue; |
|
1352 | + } |
|
1297 | 1353 | |
1298 | 1354 | // new category? |
1299 | - if (strpos($line, '<h2>') !== false) |
|
1300 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1355 | + if (strpos($line, '<h2>') !== false) { |
|
1356 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1357 | + } |
|
1301 | 1358 | |
1302 | 1359 | // load it as setting => value or the old setting local master |
1303 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1304 | - $pinfo[$category][$val[1]] = $val[2]; |
|
1305 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1306 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1360 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1361 | + $pinfo[$category][$val[1]] = $val[2]; |
|
1362 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1363 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1364 | + } |
|
1307 | 1365 | } |
1308 | 1366 | |
1309 | 1367 | // load it in to context and display it |
@@ -1338,8 +1396,9 @@ discard block |
||
1338 | 1396 | $testAPI = new $cache_class_name(); |
1339 | 1397 | |
1340 | 1398 | // No Support? NEXT! |
1341 | - if (!$testAPI->isSupported(true)) |
|
1342 | - continue; |
|
1399 | + if (!$testAPI->isSupported(true)) { |
|
1400 | + continue; |
|
1401 | + } |
|
1343 | 1402 | |
1344 | 1403 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
1345 | 1404 | } |
@@ -1364,8 +1423,9 @@ discard block |
||
1364 | 1423 | global $modSettings, $boardurl, $smcFunc; |
1365 | 1424 | |
1366 | 1425 | // Already have a key? Can't register again. |
1367 | - if (!empty($modSettings['sm_stats_key'])) |
|
1368 | - return true; |
|
1426 | + if (!empty($modSettings['sm_stats_key'])) { |
|
1427 | + return true; |
|
1428 | + } |
|
1369 | 1429 | |
1370 | 1430 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1371 | 1431 | if ($fp) |
@@ -1376,8 +1436,9 @@ discard block |
||
1376 | 1436 | fwrite($fp, $out); |
1377 | 1437 | |
1378 | 1438 | $return_data = ''; |
1379 | - while (!feof($fp)) |
|
1380 | - $return_data .= fgets($fp, 128); |
|
1439 | + while (!feof($fp)) { |
|
1440 | + $return_data .= fgets($fp, 128); |
|
1441 | + } |
|
1381 | 1442 | |
1382 | 1443 | fclose($fp); |
1383 | 1444 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -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 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
120 | 121 | } |
121 | 122 | |
122 | 123 | // Create a date string so we don't overload them with date info. |
123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
125 | - else |
|
126 | - $context['ban_time_format'] = $matches[0]; |
|
124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
126 | + } else { |
|
127 | + $context['ban_time_format'] = $matches[0]; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | $listOptions = array( |
129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
201 | 203 | 'function' => function($rowData) use ($txt) |
202 | 204 | { |
203 | 205 | // This ban never expires...whahaha. |
204 | - if ($rowData['expire_time'] === null) |
|
205 | - return $txt['never']; |
|
206 | + if ($rowData['expire_time'] === null) { |
|
207 | + return $txt['never']; |
|
208 | + } |
|
206 | 209 | |
207 | 210 | // This ban has already expired. |
208 | - elseif ($rowData['expire_time'] < time()) |
|
209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
211 | + elseif ($rowData['expire_time'] < time()) { |
|
212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
213 | + } |
|
210 | 214 | |
211 | 215 | // Still need to wait a few days for this ban to expire. |
212 | - else |
|
213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
216 | + else { |
|
217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
218 | + } |
|
214 | 219 | }, |
215 | 220 | ), |
216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
309 | 314 | ) |
310 | 315 | ); |
311 | 316 | $bans = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $bans[] = $row; |
|
317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
318 | + $bans[] = $row; |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $smcFunc['db_free_result']($request); |
316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
352 | 358 | { |
353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
354 | 360 | |
355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
356 | - BanEdit2(); |
|
361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
362 | + BanEdit2(); |
|
363 | + } |
|
357 | 364 | |
358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
364 | 371 | |
365 | 372 | if (!empty($context['ban_errors'])) |
366 | 373 | { |
367 | - foreach ($context['ban_errors'] as $error) |
|
368 | - $context['error_messages'][$error] = $txt[$error]; |
|
369 | - } |
|
370 | - else |
|
374 | + foreach ($context['ban_errors'] as $error) { |
|
375 | + $context['error_messages'][$error] = $txt[$error]; |
|
376 | + } |
|
377 | + } else |
|
371 | 378 | { |
372 | 379 | // If we're editing an existing ban, get it from the database. |
373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
403 | 410 | 'data' => array( |
404 | 411 | 'function' => function($ban_item) use ($txt) |
405 | 412 | { |
406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
408 | - elseif ($ban_item['type'] == 'user') |
|
409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
410 | - else |
|
411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
415 | + } elseif ($ban_item['type'] == 'user') { |
|
416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
417 | + } else { |
|
418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
419 | + } |
|
412 | 420 | }, |
413 | 421 | 'style' => 'text-align: left;', |
414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
546 | 554 | $context['ban']['from_user'] = true; |
547 | 555 | |
548 | 556 | // Would be nice if we could also ban the hostname. |
549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
559 | + } |
|
551 | 560 | |
552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
615 | 624 | 'items_per_page' => $items_per_page, |
616 | 625 | ) |
617 | 626 | ); |
618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
619 | - fatal_lang_error('ban_not_found', false); |
|
627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
628 | + fatal_lang_error('ban_not_found', false); |
|
629 | + } |
|
620 | 630 | |
621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
653 | 663 | { |
654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
656 | - } |
|
657 | - elseif (!empty($row['hostname'])) |
|
666 | + } elseif (!empty($row['hostname'])) |
|
658 | 667 | { |
659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
661 | - } |
|
662 | - elseif (!empty($row['email_address'])) |
|
670 | + } elseif (!empty($row['email_address'])) |
|
663 | 671 | { |
664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
666 | - } |
|
667 | - elseif (!empty($row['id_member'])) |
|
674 | + } elseif (!empty($row['id_member'])) |
|
668 | 675 | { |
669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
731 | 738 | |
732 | 739 | $return = array(); |
733 | - foreach ($search_list as $key => $callable) |
|
734 | - if (is_callable($callable)) |
|
740 | + foreach ($search_list as $key => $callable) { |
|
741 | + if (is_callable($callable)) |
|
735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
743 | + } |
|
736 | 744 | |
737 | 745 | return $return; |
738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
757 | 765 | 'current_user' => $member_id, |
758 | 766 | ) |
759 | 767 | ); |
760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
770 | + } |
|
762 | 771 | $smcFunc['db_free_result']($request); |
763 | 772 | |
764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
783 | 792 | 'current_user' => $member_id, |
784 | 793 | ) |
785 | 794 | ); |
786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
787 | - $error_ips[] = inet_dtop($row['ip']); |
|
795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
796 | + $error_ips[] = inet_dtop($row['ip']); |
|
797 | + } |
|
788 | 798 | $smcFunc['db_free_result']($request); |
789 | 799 | |
790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
826 | 836 | |
827 | 837 | // Adding a new ban group |
828 | - if (empty($_REQUEST['bg'])) |
|
829 | - $ban_group_id = insertBanGroup($ban_info); |
|
838 | + if (empty($_REQUEST['bg'])) { |
|
839 | + $ban_group_id = insertBanGroup($ban_info); |
|
840 | + } |
|
830 | 841 | // Editing an existing ban group |
831 | - else |
|
832 | - $ban_group_id = updateBanGroup($ban_info); |
|
842 | + else { |
|
843 | + $ban_group_id = updateBanGroup($ban_info); |
|
844 | + } |
|
833 | 845 | |
834 | 846 | if (is_numeric($ban_group_id)) |
835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
840 | 852 | $context['ban'] = $ban_info; |
841 | 853 | } |
842 | 854 | |
843 | - if (isset($_POST['ban_suggestions'])) |
|
844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
855 | + if (isset($_POST['ban_suggestions'])) { |
|
856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
858 | + } |
|
846 | 859 | |
847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
853 | 866 | |
854 | 867 | // Not strictly necessary, but it's nice |
855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
870 | + } |
|
857 | 871 | return BanEdit(); |
858 | 872 | } |
859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -900,10 +914,11 @@ discard block |
||
900 | 914 | |
901 | 915 | foreach ($suggestions as $key => $value) |
902 | 916 | { |
903 | - if (is_array($value)) |
|
904 | - $triggers[$key] = $value; |
|
905 | - else |
|
906 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
917 | + if (is_array($value)) { |
|
918 | + $triggers[$key] = $value; |
|
919 | + } else { |
|
920 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
921 | + } |
|
907 | 922 | } |
908 | 923 | |
909 | 924 | $ban_triggers = validateTriggers($triggers); |
@@ -911,16 +926,18 @@ discard block |
||
911 | 926 | // Time to save! |
912 | 927 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
913 | 928 | { |
914 | - if (empty($ban_id)) |
|
915 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
916 | - else |
|
917 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
929 | + if (empty($ban_id)) { |
|
930 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
931 | + } else { |
|
932 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
933 | + } |
|
934 | + } |
|
935 | + if (!empty($context['ban_errors'])) { |
|
936 | + return $triggers; |
|
937 | + } else { |
|
938 | + return false; |
|
939 | + } |
|
918 | 940 | } |
919 | - if (!empty($context['ban_errors'])) |
|
920 | - return $triggers; |
|
921 | - else |
|
922 | - return false; |
|
923 | -} |
|
924 | 941 | |
925 | 942 | /** |
926 | 943 | * This function removes a bunch of triggers based on ids |
@@ -934,14 +951,17 @@ discard block |
||
934 | 951 | { |
935 | 952 | global $smcFunc, $scripturl; |
936 | 953 | |
937 | - if ($group_id !== false) |
|
938 | - $group_id = (int) $group_id; |
|
954 | + if ($group_id !== false) { |
|
955 | + $group_id = (int) $group_id; |
|
956 | + } |
|
939 | 957 | |
940 | - if (empty($group_id) && empty($items_ids)) |
|
941 | - return false; |
|
958 | + if (empty($group_id) && empty($items_ids)) { |
|
959 | + return false; |
|
960 | + } |
|
942 | 961 | |
943 | - if (!is_array($items_ids)) |
|
944 | - $items_ids = array($items_ids); |
|
962 | + if (!is_array($items_ids)) { |
|
963 | + $items_ids = array($items_ids); |
|
964 | + } |
|
945 | 965 | |
946 | 966 | $log_info = array(); |
947 | 967 | $ban_items = array(); |
@@ -979,8 +999,7 @@ discard block |
||
979 | 999 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
980 | 1000 | 'value' => $ban_items[$row['id_ban']]['ip'], |
981 | 1001 | ); |
982 | - } |
|
983 | - elseif (!empty($row['hostname'])) |
|
1002 | + } elseif (!empty($row['hostname'])) |
|
984 | 1003 | { |
985 | 1004 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
986 | 1005 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -988,8 +1007,7 @@ discard block |
||
988 | 1007 | 'bantype' => 'hostname', |
989 | 1008 | 'value' => $row['hostname'], |
990 | 1009 | ); |
991 | - } |
|
992 | - elseif (!empty($row['email_address'])) |
|
1010 | + } elseif (!empty($row['email_address'])) |
|
993 | 1011 | { |
994 | 1012 | $ban_items[$row['id_ban']]['type'] = 'email'; |
995 | 1013 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -997,8 +1015,7 @@ discard block |
||
997 | 1015 | 'bantype' => 'email', |
998 | 1016 | 'value' => $ban_items[$row['id_ban']]['email'], |
999 | 1017 | ); |
1000 | - } |
|
1001 | - elseif (!empty($row['id_member'])) |
|
1018 | + } elseif (!empty($row['id_member'])) |
|
1002 | 1019 | { |
1003 | 1020 | $ban_items[$row['id_ban']]['type'] = 'user'; |
1004 | 1021 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1031,8 +1048,7 @@ discard block |
||
1031 | 1048 | 'ban_group' => $group_id, |
1032 | 1049 | ) |
1033 | 1050 | ); |
1034 | - } |
|
1035 | - elseif (!empty($items_ids)) |
|
1051 | + } elseif (!empty($items_ids)) |
|
1036 | 1052 | { |
1037 | 1053 | $smcFunc['db_query']('', ' |
1038 | 1054 | DELETE FROM {db_prefix}ban_items |
@@ -1057,13 +1073,15 @@ discard block |
||
1057 | 1073 | { |
1058 | 1074 | global $smcFunc; |
1059 | 1075 | |
1060 | - if (!is_array($group_ids)) |
|
1061 | - $group_ids = array($group_ids); |
|
1076 | + if (!is_array($group_ids)) { |
|
1077 | + $group_ids = array($group_ids); |
|
1078 | + } |
|
1062 | 1079 | |
1063 | 1080 | $group_ids = array_unique($group_ids); |
1064 | 1081 | |
1065 | - if (empty($group_ids)) |
|
1066 | - return false; |
|
1082 | + if (empty($group_ids)) { |
|
1083 | + return false; |
|
1084 | + } |
|
1067 | 1085 | |
1068 | 1086 | $smcFunc['db_query']('', ' |
1069 | 1087 | DELETE FROM {db_prefix}ban_groups |
@@ -1087,21 +1105,23 @@ discard block |
||
1087 | 1105 | { |
1088 | 1106 | global $smcFunc; |
1089 | 1107 | |
1090 | - if (empty($ids)) |
|
1091 | - $smcFunc['db_query']('truncate_table', ' |
|
1108 | + if (empty($ids)) { |
|
1109 | + $smcFunc['db_query']('truncate_table', ' |
|
1092 | 1110 | TRUNCATE {db_prefix}log_banned', |
1093 | 1111 | array( |
1094 | 1112 | ) |
1095 | 1113 | ); |
1096 | - else |
|
1114 | + } else |
|
1097 | 1115 | { |
1098 | - if (!is_array($ids)) |
|
1099 | - $ids = array($ids); |
|
1116 | + if (!is_array($ids)) { |
|
1117 | + $ids = array($ids); |
|
1118 | + } |
|
1100 | 1119 | |
1101 | 1120 | $ids = array_unique($ids); |
1102 | 1121 | |
1103 | - if (empty($ids)) |
|
1104 | - return false; |
|
1122 | + if (empty($ids)) { |
|
1123 | + return false; |
|
1124 | + } |
|
1105 | 1125 | |
1106 | 1126 | $smcFunc['db_query']('', ' |
1107 | 1127 | DELETE FROM {db_prefix}log_banned |
@@ -1127,8 +1147,9 @@ discard block |
||
1127 | 1147 | { |
1128 | 1148 | global $context, $smcFunc; |
1129 | 1149 | |
1130 | - if (empty($triggers)) |
|
1131 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1150 | + if (empty($triggers)) { |
|
1151 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1152 | + } |
|
1132 | 1153 | |
1133 | 1154 | $ban_triggers = array(); |
1134 | 1155 | $log_info = array(); |
@@ -1137,39 +1158,39 @@ discard block |
||
1137 | 1158 | { |
1138 | 1159 | if (!empty($value)) |
1139 | 1160 | { |
1140 | - if ($key == 'member') |
|
1141 | - continue; |
|
1161 | + if ($key == 'member') { |
|
1162 | + continue; |
|
1163 | + } |
|
1142 | 1164 | |
1143 | 1165 | if ($key == 'main_ip') |
1144 | 1166 | { |
1145 | 1167 | $value = trim($value); |
1146 | 1168 | $ip_parts = ip2range($value); |
1147 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
1148 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1149 | - else |
|
1169 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
1170 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1171 | + } else |
|
1150 | 1172 | { |
1151 | 1173 | $ban_triggers['main_ip'] = array( |
1152 | 1174 | 'ip_low' => $ip_parts['low'], |
1153 | 1175 | 'ip_high' => $ip_parts['high'] |
1154 | 1176 | ); |
1155 | 1177 | } |
1156 | - } |
|
1157 | - elseif ($key == 'hostname') |
|
1178 | + } elseif ($key == 'hostname') |
|
1158 | 1179 | { |
1159 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
1160 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
1161 | - else |
|
1180 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
1181 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
1182 | + } else |
|
1162 | 1183 | { |
1163 | 1184 | // Replace the * wildcard by a MySQL wildcard %. |
1164 | 1185 | $value = substr(str_replace('*', '%', $value), 0, 255); |
1165 | 1186 | |
1166 | 1187 | $ban_triggers['hostname']['hostname'] = $value; |
1167 | 1188 | } |
1168 | - } |
|
1169 | - elseif ($key == 'email') |
|
1189 | + } elseif ($key == 'email') |
|
1170 | 1190 | { |
1171 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
1172 | - $context['ban_erros'][] = 'invalid_email'; |
|
1191 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
1192 | + $context['ban_erros'][] = 'invalid_email'; |
|
1193 | + } |
|
1173 | 1194 | |
1174 | 1195 | // Check the user is not banning an admin. |
1175 | 1196 | $request = $smcFunc['db_query']('', ' |
@@ -1183,15 +1204,15 @@ discard block |
||
1183 | 1204 | 'email' => $value, |
1184 | 1205 | ) |
1185 | 1206 | ); |
1186 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1187 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
1207 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1208 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
1209 | + } |
|
1188 | 1210 | $smcFunc['db_free_result']($request); |
1189 | 1211 | |
1190 | 1212 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
1191 | 1213 | |
1192 | 1214 | $ban_triggers['email']['email_address'] = $value; |
1193 | - } |
|
1194 | - elseif ($key == 'user') |
|
1215 | + } elseif ($key == 'user') |
|
1195 | 1216 | { |
1196 | 1217 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
1197 | 1218 | |
@@ -1205,8 +1226,9 @@ discard block |
||
1205 | 1226 | 'username' => $user, |
1206 | 1227 | ) |
1207 | 1228 | ); |
1208 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1209 | - $context['ban_erros'][] = 'invalid_username'; |
|
1229 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1230 | + $context['ban_erros'][] = 'invalid_username'; |
|
1231 | + } |
|
1210 | 1232 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
1211 | 1233 | $smcFunc['db_free_result']($request); |
1212 | 1234 | |
@@ -1214,25 +1236,25 @@ discard block |
||
1214 | 1236 | { |
1215 | 1237 | unset($value); |
1216 | 1238 | $context['ban_erros'][] = 'no_ban_admin'; |
1239 | + } else { |
|
1240 | + $ban_triggers['user']['id_member'] = $value; |
|
1217 | 1241 | } |
1218 | - else |
|
1219 | - $ban_triggers['user']['id_member'] = $value; |
|
1220 | - } |
|
1221 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1242 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1222 | 1243 | { |
1223 | 1244 | // Special case, those two are arrays themselves |
1224 | 1245 | $values = array_unique($value); |
1225 | 1246 | // Don't add the main IP again. |
1226 | - if (isset($triggers['main_ip'])) |
|
1227 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
1247 | + if (isset($triggers['main_ip'])) { |
|
1248 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
1249 | + } |
|
1228 | 1250 | unset($value); |
1229 | 1251 | foreach ($values as $val) |
1230 | 1252 | { |
1231 | 1253 | $val = trim($val); |
1232 | 1254 | $ip_parts = ip2range($val); |
1233 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
1234 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1235 | - else |
|
1255 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
1256 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1257 | + } else |
|
1236 | 1258 | { |
1237 | 1259 | $ban_triggers[$key][] = array( |
1238 | 1260 | 'ip_low' => $ip_parts['low'], |
@@ -1245,15 +1267,16 @@ discard block |
||
1245 | 1267 | ); |
1246 | 1268 | } |
1247 | 1269 | } |
1270 | + } else { |
|
1271 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
1248 | 1272 | } |
1249 | - else |
|
1250 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
1251 | 1273 | |
1252 | - if (isset($value) && !is_array($value)) |
|
1253 | - $log_info[] = array( |
|
1274 | + if (isset($value) && !is_array($value)) { |
|
1275 | + $log_info[] = array( |
|
1254 | 1276 | 'value' => $value, |
1255 | 1277 | 'bantype' => $key, |
1256 | 1278 | ); |
1279 | + } |
|
1257 | 1280 | } |
1258 | 1281 | } |
1259 | 1282 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1273,8 +1296,9 @@ discard block |
||
1273 | 1296 | { |
1274 | 1297 | global $smcFunc, $context; |
1275 | 1298 | |
1276 | - if (empty($group_id)) |
|
1277 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1299 | + if (empty($group_id)) { |
|
1300 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1301 | + } |
|
1278 | 1302 | |
1279 | 1303 | // Preset all values that are required. |
1280 | 1304 | $values = array( |
@@ -1299,18 +1323,21 @@ discard block |
||
1299 | 1323 | foreach ($triggers as $key => $trigger) |
1300 | 1324 | { |
1301 | 1325 | // Exceptions, exceptions, exceptions...always exceptions... :P |
1302 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1303 | - foreach ($trigger as $real_trigger) |
|
1326 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
1327 | + foreach ($trigger as $real_trigger) |
|
1304 | 1328 | $insertTriggers[] = array_merge($values, $real_trigger); |
1305 | - else |
|
1306 | - $insertTriggers[] = array_merge($values, $trigger); |
|
1329 | + } else { |
|
1330 | + $insertTriggers[] = array_merge($values, $trigger); |
|
1331 | + } |
|
1307 | 1332 | } |
1308 | 1333 | |
1309 | - if (empty($insertTriggers)) |
|
1310 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1334 | + if (empty($insertTriggers)) { |
|
1335 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1336 | + } |
|
1311 | 1337 | |
1312 | - if (!empty($context['ban_errors'])) |
|
1313 | - return false; |
|
1338 | + if (!empty($context['ban_errors'])) { |
|
1339 | + return false; |
|
1340 | + } |
|
1314 | 1341 | |
1315 | 1342 | $smcFunc['db_insert']('', |
1316 | 1343 | '{db_prefix}ban_items', |
@@ -1338,15 +1365,19 @@ discard block |
||
1338 | 1365 | { |
1339 | 1366 | global $smcFunc, $context; |
1340 | 1367 | |
1341 | - if (empty($ban_item)) |
|
1342 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1343 | - if (empty($group_id)) |
|
1344 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1345 | - if (empty($trigger)) |
|
1346 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1368 | + if (empty($ban_item)) { |
|
1369 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1370 | + } |
|
1371 | + if (empty($group_id)) { |
|
1372 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1373 | + } |
|
1374 | + if (empty($trigger)) { |
|
1375 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1376 | + } |
|
1347 | 1377 | |
1348 | - if (!empty($context['ban_errors'])) |
|
1349 | - return; |
|
1378 | + if (!empty($context['ban_errors'])) { |
|
1379 | + return; |
|
1380 | + } |
|
1350 | 1381 | |
1351 | 1382 | // Preset all values that are required. |
1352 | 1383 | $values = array( |
@@ -1387,8 +1418,9 @@ discard block |
||
1387 | 1418 | */ |
1388 | 1419 | function logTriggersUpdates($logs, $new = true, $removal = false) |
1389 | 1420 | { |
1390 | - if (empty($logs)) |
|
1391 | - return; |
|
1421 | + if (empty($logs)) { |
|
1422 | + return; |
|
1423 | + } |
|
1392 | 1424 | |
1393 | 1425 | $log_name_map = array( |
1394 | 1426 | 'main_ip' => 'ip_range', |
@@ -1399,14 +1431,15 @@ discard block |
||
1399 | 1431 | ); |
1400 | 1432 | |
1401 | 1433 | // Log the addion of the ban entries into the moderation log. |
1402 | - foreach ($logs as $log) |
|
1403 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1434 | + foreach ($logs as $log) { |
|
1435 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1404 | 1436 | $log_name_map[$log['bantype']] => $log['value'], |
1405 | 1437 | 'new' => empty($new) ? 0 : 1, |
1406 | 1438 | 'remove' => empty($removal) ? 0 : 1, |
1407 | 1439 | 'type' => $log['bantype'], |
1408 | 1440 | )); |
1409 | -} |
|
1441 | + } |
|
1442 | + } |
|
1410 | 1443 | |
1411 | 1444 | /** |
1412 | 1445 | * Updates an existing ban group |
@@ -1420,12 +1453,15 @@ discard block |
||
1420 | 1453 | { |
1421 | 1454 | global $smcFunc, $context; |
1422 | 1455 | |
1423 | - if (empty($ban_info['name'])) |
|
1424 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1425 | - if (empty($ban_info['id'])) |
|
1426 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1427 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1428 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1456 | + if (empty($ban_info['name'])) { |
|
1457 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1458 | + } |
|
1459 | + if (empty($ban_info['id'])) { |
|
1460 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1461 | + } |
|
1462 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1463 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1464 | + } |
|
1429 | 1465 | |
1430 | 1466 | if (!empty($ban_info['id'])) |
1431 | 1467 | { |
@@ -1440,8 +1476,9 @@ discard block |
||
1440 | 1476 | ) |
1441 | 1477 | ); |
1442 | 1478 | |
1443 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1444 | - $context['ban_errors'][] = 'ban_not_found'; |
|
1479 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1480 | + $context['ban_errors'][] = 'ban_not_found'; |
|
1481 | + } |
|
1445 | 1482 | $smcFunc['db_free_result']($request); |
1446 | 1483 | } |
1447 | 1484 | |
@@ -1459,13 +1496,15 @@ discard block |
||
1459 | 1496 | 'new_ban_name' => $ban_info['name'], |
1460 | 1497 | ) |
1461 | 1498 | ); |
1462 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1463 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1499 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1500 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1501 | + } |
|
1464 | 1502 | $smcFunc['db_free_result']($request); |
1465 | 1503 | } |
1466 | 1504 | |
1467 | - if (!empty($context['ban_errors'])) |
|
1468 | - return $ban_info['id']; |
|
1505 | + if (!empty($context['ban_errors'])) { |
|
1506 | + return $ban_info['id']; |
|
1507 | + } |
|
1469 | 1508 | |
1470 | 1509 | $smcFunc['db_query']('', ' |
1471 | 1510 | UPDATE {db_prefix}ban_groups |
@@ -1509,10 +1548,12 @@ discard block |
||
1509 | 1548 | { |
1510 | 1549 | global $smcFunc, $context; |
1511 | 1550 | |
1512 | - if (empty($ban_info['name'])) |
|
1513 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1514 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1515 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1551 | + if (empty($ban_info['name'])) { |
|
1552 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1553 | + } |
|
1554 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1555 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1556 | + } |
|
1516 | 1557 | |
1517 | 1558 | if (!empty($ban_info['name'])) |
1518 | 1559 | { |
@@ -1527,13 +1568,15 @@ discard block |
||
1527 | 1568 | ) |
1528 | 1569 | ); |
1529 | 1570 | |
1530 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
1531 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1571 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
1572 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1573 | + } |
|
1532 | 1574 | $smcFunc['db_free_result']($request); |
1533 | 1575 | } |
1534 | 1576 | |
1535 | - if (!empty($context['ban_errors'])) |
|
1536 | - return; |
|
1577 | + if (!empty($context['ban_errors'])) { |
|
1578 | + return; |
|
1579 | + } |
|
1537 | 1580 | |
1538 | 1581 | // Yes yes, we're ready to add now. |
1539 | 1582 | $ban_info['id'] = $smcFunc['db_insert']('', |
@@ -1550,8 +1593,9 @@ discard block |
||
1550 | 1593 | 1 |
1551 | 1594 | ); |
1552 | 1595 | |
1553 | - if (empty($ban_info['id'])) |
|
1554 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1596 | + if (empty($ban_info['id'])) { |
|
1597 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1598 | + } |
|
1555 | 1599 | |
1556 | 1600 | return $ban_info['id']; |
1557 | 1601 | } |
@@ -1576,24 +1620,24 @@ discard block |
||
1576 | 1620 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
1577 | 1621 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
1578 | 1622 | |
1579 | - if (empty($ban_group)) |
|
1580 | - fatal_lang_error('ban_not_found', false); |
|
1623 | + if (empty($ban_group)) { |
|
1624 | + fatal_lang_error('ban_not_found', false); |
|
1625 | + } |
|
1581 | 1626 | |
1582 | 1627 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
1583 | 1628 | { |
1584 | 1629 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
1585 | 1630 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1586 | - } |
|
1587 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1631 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1588 | 1632 | { |
1589 | 1633 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
1590 | 1634 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
1591 | - if (!empty($_POST['ban_suggestions'])) |
|
1592 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1635 | + if (!empty($_POST['ban_suggestions'])) { |
|
1636 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1637 | + } |
|
1593 | 1638 | |
1594 | 1639 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1595 | - } |
|
1596 | - elseif (isset($_POST['edit_trigger'])) |
|
1640 | + } elseif (isset($_POST['edit_trigger'])) |
|
1597 | 1641 | { |
1598 | 1642 | removeBanTriggers($ban_id); |
1599 | 1643 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1624,8 +1668,7 @@ discard block |
||
1624 | 1668 | ), |
1625 | 1669 | 'is_new' => true, |
1626 | 1670 | ); |
1627 | - } |
|
1628 | - else |
|
1671 | + } else |
|
1629 | 1672 | { |
1630 | 1673 | $request = $smcFunc['db_query']('', ' |
1631 | 1674 | SELECT |
@@ -1642,8 +1685,9 @@ discard block |
||
1642 | 1685 | 'ban_group' => $ban_group, |
1643 | 1686 | ) |
1644 | 1687 | ); |
1645 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1646 | - fatal_lang_error('ban_not_found', false); |
|
1688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1689 | + fatal_lang_error('ban_not_found', false); |
|
1690 | + } |
|
1647 | 1691 | $row = $smcFunc['db_fetch_assoc']($request); |
1648 | 1692 | $smcFunc['db_free_result']($request); |
1649 | 1693 | |
@@ -1692,8 +1736,9 @@ discard block |
||
1692 | 1736 | removeBanTriggers($_POST['remove']); |
1693 | 1737 | |
1694 | 1738 | // Rehabilitate some members. |
1695 | - if ($_REQUEST['entity'] == 'member') |
|
1696 | - updateBanMembers(); |
|
1739 | + if ($_REQUEST['entity'] == 'member') { |
|
1740 | + updateBanMembers(); |
|
1741 | + } |
|
1697 | 1742 | |
1698 | 1743 | // Make sure the ban cache is refreshed. |
1699 | 1744 | updateSettings(array('banLastUpdated' => time())); |
@@ -1806,8 +1851,7 @@ discard block |
||
1806 | 1851 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
1807 | 1852 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
1808 | 1853 | ); |
1809 | - } |
|
1810 | - elseif ($context['selected_entity'] === 'hostname') |
|
1854 | + } elseif ($context['selected_entity'] === 'hostname') |
|
1811 | 1855 | { |
1812 | 1856 | $listOptions['columns']['banned_entity']['data'] = array( |
1813 | 1857 | 'function' => function($rowData) use ($smcFunc) |
@@ -1819,8 +1863,7 @@ discard block |
||
1819 | 1863 | 'default' => 'bi.hostname', |
1820 | 1864 | 'reverse' => 'bi.hostname DESC', |
1821 | 1865 | ); |
1822 | - } |
|
1823 | - elseif ($context['selected_entity'] === 'email') |
|
1866 | + } elseif ($context['selected_entity'] === 'email') |
|
1824 | 1867 | { |
1825 | 1868 | $listOptions['columns']['banned_entity']['data'] = array( |
1826 | 1869 | 'function' => function($rowData) use ($smcFunc) |
@@ -1832,8 +1875,7 @@ discard block |
||
1832 | 1875 | 'default' => 'bi.email_address', |
1833 | 1876 | 'reverse' => 'bi.email_address DESC', |
1834 | 1877 | ); |
1835 | - } |
|
1836 | - elseif ($context['selected_entity'] === 'member') |
|
1878 | + } elseif ($context['selected_entity'] === 'member') |
|
1837 | 1879 | { |
1838 | 1880 | $listOptions['columns']['banned_entity']['data'] = array( |
1839 | 1881 | 'sprintf' => array( |
@@ -1897,8 +1939,9 @@ discard block |
||
1897 | 1939 | ) |
1898 | 1940 | ); |
1899 | 1941 | $ban_triggers = array(); |
1900 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1901 | - $ban_triggers[] = $row; |
|
1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1943 | + $ban_triggers[] = $row; |
|
1944 | + } |
|
1902 | 1945 | $smcFunc['db_free_result']($request); |
1903 | 1946 | |
1904 | 1947 | return $ban_triggers; |
@@ -1954,8 +1997,9 @@ discard block |
||
1954 | 1997 | validateToken('admin-bl'); |
1955 | 1998 | |
1956 | 1999 | // 'Delete all entries' button was pressed. |
1957 | - if (!empty($_POST['removeAll'])) |
|
1958 | - removeBanLogs(); |
|
2000 | + if (!empty($_POST['removeAll'])) { |
|
2001 | + removeBanLogs(); |
|
2002 | + } |
|
1959 | 2003 | // 'Delete selection' button was pressed. |
1960 | 2004 | else |
1961 | 2005 | { |
@@ -2164,12 +2208,15 @@ discard block |
||
2164 | 2208 | $low = inet_dtop($low); |
2165 | 2209 | $high = inet_dtop($high); |
2166 | 2210 | |
2167 | - if ($low == '255.255.255.255') return 'unknown'; |
|
2168 | - if ($low == $high) |
|
2169 | - return $low; |
|
2170 | - else |
|
2171 | - return $low . '-' . $high; |
|
2172 | -} |
|
2211 | + if ($low == '255.255.255.255') { |
|
2212 | + return 'unknown'; |
|
2213 | + } |
|
2214 | + if ($low == $high) { |
|
2215 | + return $low; |
|
2216 | + } else { |
|
2217 | + return $low . '-' . $high; |
|
2218 | + } |
|
2219 | + } |
|
2173 | 2220 | |
2174 | 2221 | /** |
2175 | 2222 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2245,15 +2292,17 @@ discard block |
||
2245 | 2292 | $memberEmailWild = array(); |
2246 | 2293 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2247 | 2294 | { |
2248 | - if ($row['id_member']) |
|
2249 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
2295 | + if ($row['id_member']) { |
|
2296 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
2297 | + } |
|
2250 | 2298 | if ($row['email_address']) |
2251 | 2299 | { |
2252 | 2300 | // Does it have a wildcard - if so we can't do a IN on it. |
2253 | - if (strpos($row['email_address'], '%') !== false) |
|
2254 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2255 | - else |
|
2256 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
2301 | + if (strpos($row['email_address'], '%') !== false) { |
|
2302 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2303 | + } else { |
|
2304 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
2305 | + } |
|
2257 | 2306 | } |
2258 | 2307 | } |
2259 | 2308 | $smcFunc['db_free_result']($request); |
@@ -2304,14 +2353,15 @@ discard block |
||
2304 | 2353 | } |
2305 | 2354 | |
2306 | 2355 | // We welcome our new members in the realm of the banned. |
2307 | - if (!empty($newMembers)) |
|
2308 | - $smcFunc['db_query']('', ' |
|
2356 | + if (!empty($newMembers)) { |
|
2357 | + $smcFunc['db_query']('', ' |
|
2309 | 2358 | DELETE FROM {db_prefix}log_online |
2310 | 2359 | WHERE id_member IN ({array_int:new_banned_members})', |
2311 | 2360 | array( |
2312 | 2361 | 'new_banned_members' => $newMembers, |
2313 | 2362 | ) |
2314 | 2363 | ); |
2364 | + } |
|
2315 | 2365 | |
2316 | 2366 | // Find members that are wrongfully marked as banned. |
2317 | 2367 | $request = $smcFunc['db_query']('', ' |
@@ -2338,9 +2388,10 @@ discard block |
||
2338 | 2388 | } |
2339 | 2389 | $smcFunc['db_free_result']($request); |
2340 | 2390 | |
2341 | - if (!empty($updates)) |
|
2342 | - foreach ($updates as $newStatus => $members) |
|
2391 | + if (!empty($updates)) { |
|
2392 | + foreach ($updates as $newStatus => $members) |
|
2343 | 2393 | updateMemberData($members, array('is_activated' => $newStatus)); |
2394 | + } |
|
2344 | 2395 | |
2345 | 2396 | // Update the latest member and our total members as banning may change them. |
2346 | 2397 | updateStats('member'); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Creates a wave file that spells the letters of $word. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $settings, $user_info; |
33 | 34 | |
34 | 35 | // Allow max 2 requests per 20 seconds. |
35 | - if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) |
|
36 | - die(header('HTTP/1.1 400 Bad Request')); |
|
36 | + if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) { |
|
37 | + die(header('HTTP/1.1 400 Bad Request')); |
|
38 | + } |
|
37 | 39 | cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20); |
38 | 40 | cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20); |
39 | 41 | |
@@ -42,16 +44,19 @@ discard block |
||
42 | 44 | mt_srand(end($tmp)); |
43 | 45 | |
44 | 46 | // Try to see if there's a sound font in the user's language. |
45 | - if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) |
|
46 | - $sound_language = $user_info['language']; |
|
47 | + if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) { |
|
48 | + $sound_language = $user_info['language']; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | // English should be there. |
49 | - elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) |
|
50 | - $sound_language = 'english'; |
|
52 | + elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) { |
|
53 | + $sound_language = 'english'; |
|
54 | + } |
|
51 | 55 | |
52 | 56 | // Guess not... |
53 | - else |
|
54 | - return false; |
|
57 | + else { |
|
58 | + return false; |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // File names are in lower case so lets make sure that we are only using a lower case string |
57 | 62 | $word = strtolower($word); |
@@ -61,20 +66,25 @@ discard block |
||
61 | 66 | for ($i = 0; $i < strlen($word); $i++) |
62 | 67 | { |
63 | 68 | $sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav')); |
64 | - if (strpos($sound_letter, 'data') === false) |
|
65 | - return false; |
|
69 | + if (strpos($sound_letter, 'data') === false) { |
|
70 | + return false; |
|
71 | + } |
|
66 | 72 | |
67 | 73 | $sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8); |
68 | 74 | switch ($word{$i} === 's' ? 0 : mt_rand(0, 2)) |
69 | 75 | { |
70 | - case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
|
71 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
72 | - $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
76 | + case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) { |
|
77 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); |
|
78 | + } |
|
79 | + $k < $m; $k++) { |
|
80 | + $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
81 | + } |
|
73 | 82 | break; |
74 | 83 | |
75 | 84 | case 1: |
76 | - for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) |
|
77 | - $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
85 | + for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) { |
|
86 | + $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
87 | + } |
|
78 | 88 | $sound_word .= str_repeat($sound_letter{$n}, 2); |
79 | 89 | break; |
80 | 90 | |
@@ -82,10 +92,12 @@ discard block |
||
82 | 92 | $shift = 0; |
83 | 93 | for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
84 | 94 | { |
85 | - if (mt_rand(0, 10) === 0) |
|
86 | - $shift += mt_rand(-3, 3); |
|
87 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
88 | - $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
95 | + if (mt_rand(0, 10) === 0) { |
|
96 | + $shift += mt_rand(-3, 3); |
|
97 | + } |
|
98 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) { |
|
99 | + $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
100 | + } |
|
89 | 101 | } |
90 | 102 | break; |
91 | 103 |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
578 | 590 | ) |
579 | 591 | ); |
580 | 592 | $context['theme_options'] = array(); |
581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
595 | + } |
|
583 | 596 | $smcFunc['db_free_result']($request); |
584 | 597 | |
585 | 598 | $context['theme_options_reset'] = false; |
586 | - } |
|
587 | - else |
|
599 | + } else |
|
588 | 600 | { |
589 | 601 | $context['theme_options'] = array(); |
590 | 602 | $context['theme_options_reset'] = true; |
@@ -593,30 +605,32 @@ discard block |
||
593 | 605 | foreach ($context['options'] as $i => $setting) |
594 | 606 | { |
595 | 607 | // Just skip separators |
596 | - if (!is_array($setting)) |
|
597 | - continue; |
|
608 | + if (!is_array($setting)) { |
|
609 | + continue; |
|
610 | + } |
|
598 | 611 | |
599 | 612 | // Is this disabled? |
600 | 613 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
601 | 614 | { |
602 | 615 | unset($context['options'][$i]); |
603 | 616 | continue; |
604 | - } |
|
605 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
617 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
606 | 618 | { |
607 | 619 | unset($context['options'][$i]); |
608 | 620 | continue; |
609 | 621 | } |
610 | 622 | |
611 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
612 | - $context['options'][$i]['type'] = 'checkbox'; |
|
613 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
614 | - $context['options'][$i]['type'] = 'number'; |
|
615 | - elseif ($setting['type'] == 'string') |
|
616 | - $context['options'][$i]['type'] = 'text'; |
|
623 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
624 | + $context['options'][$i]['type'] = 'checkbox'; |
|
625 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
626 | + $context['options'][$i]['type'] = 'number'; |
|
627 | + } elseif ($setting['type'] == 'string') { |
|
628 | + $context['options'][$i]['type'] = 'text'; |
|
629 | + } |
|
617 | 630 | |
618 | - if (isset($setting['options'])) |
|
619 | - $context['options'][$i]['type'] = 'list'; |
|
631 | + if (isset($setting['options'])) { |
|
632 | + $context['options'][$i]['type'] = 'list'; |
|
633 | + } |
|
620 | 634 | |
621 | 635 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
622 | 636 | } |
@@ -641,8 +655,9 @@ discard block |
||
641 | 655 | { |
642 | 656 | global $txt, $context, $settings, $modSettings, $smcFunc; |
643 | 657 | |
644 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
645 | - return ThemeAdmin(); |
|
658 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
659 | + return ThemeAdmin(); |
|
660 | + } |
|
646 | 661 | |
647 | 662 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
648 | 663 | |
@@ -653,8 +668,9 @@ discard block |
||
653 | 668 | isAllowedTo('admin_forum'); |
654 | 669 | |
655 | 670 | // Validate inputs/user. |
656 | - if (empty($_GET['th'])) |
|
657 | - fatal_lang_error('no_theme', false); |
|
671 | + if (empty($_GET['th'])) { |
|
672 | + fatal_lang_error('no_theme', false); |
|
673 | + } |
|
658 | 674 | |
659 | 675 | // Fetch the smiley sets... |
660 | 676 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -662,8 +678,9 @@ discard block |
||
662 | 678 | $context['smiley_sets'] = array( |
663 | 679 | '' => $txt['smileys_no_default'] |
664 | 680 | ); |
665 | - foreach ($sets as $i => $set) |
|
666 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
681 | + foreach ($sets as $i => $set) { |
|
682 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
683 | + } |
|
667 | 684 | |
668 | 685 | $old_id = $settings['theme_id']; |
669 | 686 | $old_settings = $settings; |
@@ -688,8 +705,9 @@ discard block |
||
688 | 705 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
689 | 706 | { |
690 | 707 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
691 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
692 | - eval('global $settings;' . $matches[0]); |
|
708 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
709 | + eval('global $settings;' . $matches[0]); |
|
710 | + } |
|
693 | 711 | } |
694 | 712 | |
695 | 713 | // Submitting! |
@@ -698,37 +716,45 @@ discard block |
||
698 | 716 | checkSession(); |
699 | 717 | validateToken('admin-sts'); |
700 | 718 | |
701 | - if (empty($_POST['options'])) |
|
702 | - $_POST['options'] = array(); |
|
703 | - if (empty($_POST['default_options'])) |
|
704 | - $_POST['default_options'] = array(); |
|
719 | + if (empty($_POST['options'])) { |
|
720 | + $_POST['options'] = array(); |
|
721 | + } |
|
722 | + if (empty($_POST['default_options'])) { |
|
723 | + $_POST['default_options'] = array(); |
|
724 | + } |
|
705 | 725 | |
706 | 726 | // Make sure items are cast correctly. |
707 | 727 | foreach ($context['theme_settings'] as $item) |
708 | 728 | { |
709 | 729 | // Disregard this item if this is just a separator. |
710 | - if (!is_array($item)) |
|
711 | - continue; |
|
730 | + if (!is_array($item)) { |
|
731 | + continue; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | foreach (array('options', 'default_options') as $option) |
714 | 735 | { |
715 | - if (!isset($_POST[$option][$item['id']])) |
|
716 | - continue; |
|
736 | + if (!isset($_POST[$option][$item['id']])) { |
|
737 | + continue; |
|
738 | + } |
|
717 | 739 | // Checkbox. |
718 | - elseif (empty($item['type'])) |
|
719 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
740 | + elseif (empty($item['type'])) { |
|
741 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
742 | + } |
|
720 | 743 | // Number |
721 | - elseif ($item['type'] == 'number') |
|
722 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
744 | + elseif ($item['type'] == 'number') { |
|
745 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
746 | + } |
|
723 | 747 | } |
724 | 748 | } |
725 | 749 | |
726 | 750 | // Set up the sql query. |
727 | 751 | $inserts = array(); |
728 | - foreach ($_POST['options'] as $opt => $val) |
|
729 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
730 | - foreach ($_POST['default_options'] as $opt => $val) |
|
731 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
752 | + foreach ($_POST['options'] as $opt => $val) { |
|
753 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
754 | + } |
|
755 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
756 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
757 | + } |
|
732 | 758 | // If we're actually inserting something.. |
733 | 759 | if (!empty($inserts)) |
734 | 760 | { |
@@ -754,8 +780,9 @@ discard block |
||
754 | 780 | |
755 | 781 | foreach ($settings as $setting => $dummy) |
756 | 782 | { |
757 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
758 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
783 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
784 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
785 | + } |
|
759 | 786 | } |
760 | 787 | |
761 | 788 | $context['settings'] = $context['theme_settings']; |
@@ -764,18 +791,21 @@ discard block |
||
764 | 791 | foreach ($context['settings'] as $i => $setting) |
765 | 792 | { |
766 | 793 | // Separators are dummies, so leave them alone. |
767 | - if (!is_array($setting)) |
|
768 | - continue; |
|
794 | + if (!is_array($setting)) { |
|
795 | + continue; |
|
796 | + } |
|
769 | 797 | |
770 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
771 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
772 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
773 | - $context['settings'][$i]['type'] = 'number'; |
|
774 | - elseif ($setting['type'] == 'string') |
|
775 | - $context['settings'][$i]['type'] = 'text'; |
|
798 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
799 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
800 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
801 | + $context['settings'][$i]['type'] = 'number'; |
|
802 | + } elseif ($setting['type'] == 'string') { |
|
803 | + $context['settings'][$i]['type'] = 'text'; |
|
804 | + } |
|
776 | 805 | |
777 | - if (isset($setting['options'])) |
|
778 | - $context['settings'][$i]['type'] = 'list'; |
|
806 | + if (isset($setting['options'])) { |
|
807 | + $context['settings'][$i]['type'] = 'list'; |
|
808 | + } |
|
779 | 809 | |
780 | 810 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
781 | 811 | } |
@@ -828,8 +858,9 @@ discard block |
||
828 | 858 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
829 | 859 | |
830 | 860 | // You can't delete the default theme! |
831 | - if ($themeID == 1) |
|
832 | - fatal_lang_error('no_access', false); |
|
861 | + if ($themeID == 1) { |
|
862 | + fatal_lang_error('no_access', false); |
|
863 | + } |
|
833 | 864 | |
834 | 865 | $theme_info = get_single_theme($themeID); |
835 | 866 | |
@@ -837,8 +868,9 @@ discard block |
||
837 | 868 | remove_theme($themeID); |
838 | 869 | |
839 | 870 | // And remove all its files and folders too. |
840 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
841 | - remove_dir($theme_info['theme_dir']); |
|
871 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
872 | + remove_dir($theme_info['theme_dir']); |
|
873 | + } |
|
842 | 874 | |
843 | 875 | // Go back to the list page. |
844 | 876 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -863,12 +895,14 @@ discard block |
||
863 | 895 | $enableThemes = explode(',', $modSettings['enableThemes']); |
864 | 896 | |
865 | 897 | // Are we disabling it? |
866 | - if (isset($_GET['disabled'])) |
|
867 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
898 | + if (isset($_GET['disabled'])) { |
|
899 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
900 | + } |
|
868 | 901 | |
869 | 902 | // Nope? then enable it! |
870 | - else |
|
871 | - $enableThemes[] = (string) $themeID; |
|
903 | + else { |
|
904 | + $enableThemes[] = (string) $themeID; |
|
905 | + } |
|
872 | 906 | |
873 | 907 | // Update the setting. |
874 | 908 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -903,18 +937,21 @@ discard block |
||
903 | 937 | |
904 | 938 | $_SESSION['id_theme'] = 0; |
905 | 939 | |
906 | - if (isset($_GET['id'])) |
|
907 | - $_GET['th'] = $_GET['id']; |
|
940 | + if (isset($_GET['id'])) { |
|
941 | + $_GET['th'] = $_GET['id']; |
|
942 | + } |
|
908 | 943 | |
909 | 944 | // Saving a variant cause JS doesn't work - pretend it did ;) |
910 | 945 | if (isset($_POST['save'])) |
911 | 946 | { |
912 | 947 | // Which theme? |
913 | - foreach ($_POST['save'] as $k => $v) |
|
914 | - $_GET['th'] = (int) $k; |
|
948 | + foreach ($_POST['save'] as $k => $v) { |
|
949 | + $_GET['th'] = (int) $k; |
|
950 | + } |
|
915 | 951 | |
916 | - if (isset($_POST['vrt'][$k])) |
|
917 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
952 | + if (isset($_POST['vrt'][$k])) { |
|
953 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
954 | + } |
|
918 | 955 | } |
919 | 956 | |
920 | 957 | // Have we made a decision, or are we just browsing? |
@@ -992,8 +1029,9 @@ discard block |
||
992 | 1029 | else |
993 | 1030 | { |
994 | 1031 | // The forum's default theme is always 0 and we |
995 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
996 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1032 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1033 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1034 | + } |
|
997 | 1035 | |
998 | 1036 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
999 | 1037 | |
@@ -1007,8 +1045,9 @@ discard block |
||
1007 | 1045 | ); |
1008 | 1046 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1009 | 1047 | |
1010 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1011 | - $_SESSION['id_variant'] = 0; |
|
1048 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1049 | + $_SESSION['id_variant'] = 0; |
|
1050 | + } |
|
1012 | 1051 | } |
1013 | 1052 | |
1014 | 1053 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1077,12 +1116,13 @@ discard block |
||
1077 | 1116 | ); |
1078 | 1117 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1079 | 1118 | { |
1080 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1081 | - $context['available_themes'][$row['id_theme']] = array( |
|
1119 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1120 | + $context['available_themes'][$row['id_theme']] = array( |
|
1082 | 1121 | 'id' => $row['id_theme'], |
1083 | 1122 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1084 | 1123 | 'num_users' => 0 |
1085 | 1124 | ); |
1125 | + } |
|
1086 | 1126 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1087 | 1127 | } |
1088 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1095,9 +1135,9 @@ discard block |
||
1095 | 1135 | 'num_users' => 0 |
1096 | 1136 | ); |
1097 | 1137 | $guest_theme = 0; |
1138 | + } else { |
|
1139 | + $guest_theme = $modSettings['theme_guests']; |
|
1098 | 1140 | } |
1099 | - else |
|
1100 | - $guest_theme = $modSettings['theme_guests']; |
|
1101 | 1141 | |
1102 | 1142 | $request = $smcFunc['db_query']('', ' |
1103 | 1143 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1110,15 +1150,17 @@ discard block |
||
1110 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1111 | 1151 | { |
1112 | 1152 | // Figure out which theme it is they are REALLY using. |
1113 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1114 | - $row['id_theme'] = $guest_theme; |
|
1115 | - elseif (empty($modSettings['theme_allow'])) |
|
1116 | - $row['id_theme'] = $guest_theme; |
|
1153 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1154 | + $row['id_theme'] = $guest_theme; |
|
1155 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1156 | + $row['id_theme'] = $guest_theme; |
|
1157 | + } |
|
1117 | 1158 | |
1118 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1119 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1120 | - else |
|
1121 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1159 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1160 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1161 | + } else { |
|
1162 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1163 | + } |
|
1122 | 1164 | } |
1123 | 1165 | $smcFunc['db_free_result']($request); |
1124 | 1166 | |
@@ -1137,8 +1179,9 @@ discard block |
||
1137 | 1179 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1138 | 1180 | ) |
1139 | 1181 | ); |
1140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1141 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1182 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1183 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1184 | + } |
|
1142 | 1185 | $smcFunc['db_free_result']($request); |
1143 | 1186 | } |
1144 | 1187 | |
@@ -1149,17 +1192,18 @@ discard block |
||
1149 | 1192 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1150 | 1193 | { |
1151 | 1194 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1152 | - if ($id_theme == 0) |
|
1153 | - continue; |
|
1195 | + if ($id_theme == 0) { |
|
1196 | + continue; |
|
1197 | + } |
|
1154 | 1198 | |
1155 | 1199 | // The thumbnail needs the correct path. |
1156 | 1200 | $settings['images_url'] = &$theme_data['images_url']; |
1157 | 1201 | |
1158 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1159 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1160 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1161 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1162 | - else |
|
1202 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1203 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1204 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1205 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1206 | + } else |
|
1163 | 1207 | { |
1164 | 1208 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1165 | 1209 | $txt['theme_description'] = ''; |
@@ -1184,15 +1228,17 @@ discard block |
||
1184 | 1228 | loadLanguage('Settings'); |
1185 | 1229 | |
1186 | 1230 | $context['available_themes'][$id_theme]['variants'] = array(); |
1187 | - foreach ($settings['theme_variants'] as $variant) |
|
1188 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1231 | + foreach ($settings['theme_variants'] as $variant) { |
|
1232 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1189 | 1233 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1190 | 1234 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1191 | 1235 | ); |
1236 | + } |
|
1192 | 1237 | |
1193 | 1238 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1194 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1195 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1239 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1240 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1241 | + } |
|
1196 | 1242 | |
1197 | 1243 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1198 | 1244 | // Allow themes to override the text. |
@@ -1208,8 +1254,9 @@ discard block |
||
1208 | 1254 | // As long as we're not doing the default theme... |
1209 | 1255 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1210 | 1256 | { |
1211 | - if ($guest_theme != 0) |
|
1212 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1257 | + if ($guest_theme != 0) { |
|
1258 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1259 | + } |
|
1213 | 1260 | |
1214 | 1261 | $context['available_themes'][0]['id'] = 0; |
1215 | 1262 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1258,14 +1305,16 @@ discard block |
||
1258 | 1305 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1259 | 1306 | |
1260 | 1307 | // Got any info from the specific form? |
1261 | - if (!isset($_POST['save_' . $action])) |
|
1262 | - fatal_lang_error('theme_install_no_action', false); |
|
1308 | + if (!isset($_POST['save_' . $action])) { |
|
1309 | + fatal_lang_error('theme_install_no_action', false); |
|
1310 | + } |
|
1263 | 1311 | |
1264 | 1312 | validateToken('admin-t-' . $action); |
1265 | 1313 | |
1266 | 1314 | // Hopefully the themes directory is writable, or we might have a problem. |
1267 | - if (!is_writable($themedir)) |
|
1268 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1315 | + if (!is_writable($themedir)) { |
|
1316 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1317 | + } |
|
1269 | 1318 | |
1270 | 1319 | // Call the function and handle the result. |
1271 | 1320 | $result = $subActions[$action](); |
@@ -1280,9 +1329,10 @@ discard block |
||
1280 | 1329 | } |
1281 | 1330 | |
1282 | 1331 | // Nope, show a nice error. |
1283 | - else |
|
1284 | - fatal_lang_error('theme_install_no_action', false); |
|
1285 | -} |
|
1332 | + else { |
|
1333 | + fatal_lang_error('theme_install_no_action', false); |
|
1334 | + } |
|
1335 | + } |
|
1286 | 1336 | |
1287 | 1337 | /** |
1288 | 1338 | * Installs a theme from a theme package. |
@@ -1298,8 +1348,9 @@ discard block |
||
1298 | 1348 | $dirtemp = $themedir . '/temp'; |
1299 | 1349 | |
1300 | 1350 | // Make sure the temp dir doesn't already exist |
1301 | - if (file_exists($dirtemp)) |
|
1302 | - remove_dir($dirtemp); |
|
1351 | + if (file_exists($dirtemp)) { |
|
1352 | + remove_dir($dirtemp); |
|
1353 | + } |
|
1303 | 1354 | |
1304 | 1355 | // Create the temp dir. |
1305 | 1356 | mkdir($dirtemp, 0777); |
@@ -1311,17 +1362,20 @@ discard block |
||
1311 | 1362 | smf_chmod($dirtemp, '0755'); |
1312 | 1363 | |
1313 | 1364 | // How about now? |
1314 | - if (!is_writable($dirtemp)) |
|
1315 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1365 | + if (!is_writable($dirtemp)) { |
|
1366 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1367 | + } |
|
1316 | 1368 | } |
1317 | 1369 | |
1318 | 1370 | // This happens when the admin session is gone and the user has to login again. |
1319 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1320 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1371 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1372 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1373 | + } |
|
1321 | 1374 | |
1322 | 1375 | // Another error check layer, something went wrong with the upload. |
1323 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1324 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1376 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1377 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1378 | + } |
|
1325 | 1379 | |
1326 | 1380 | // Get the theme's name. |
1327 | 1381 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1352,11 +1406,10 @@ discard block |
||
1352 | 1406 | |
1353 | 1407 | // return all the info. |
1354 | 1408 | return $context['to_install']; |
1409 | + } else { |
|
1410 | + fatal_lang_error('theme_install_error_title', false); |
|
1411 | + } |
|
1355 | 1412 | } |
1356 | - |
|
1357 | - else |
|
1358 | - fatal_lang_error('theme_install_error_title', false); |
|
1359 | -} |
|
1360 | 1413 | |
1361 | 1414 | /** |
1362 | 1415 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1370,15 +1423,17 @@ discard block |
||
1370 | 1423 | global $forum_version; |
1371 | 1424 | |
1372 | 1425 | // There's gotta be something to work with. |
1373 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1374 | - fatal_lang_error('theme_install_error_title', false); |
|
1426 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1427 | + fatal_lang_error('theme_install_error_title', false); |
|
1428 | + } |
|
1375 | 1429 | |
1376 | 1430 | // Get a cleaner version. |
1377 | 1431 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1378 | 1432 | |
1379 | 1433 | // Is there a theme already named like this? |
1380 | - if (file_exists($themedir . '/' . $name)) |
|
1381 | - fatal_lang_error('theme_install_already_dir', false); |
|
1434 | + if (file_exists($themedir . '/' . $name)) { |
|
1435 | + fatal_lang_error('theme_install_already_dir', false); |
|
1436 | + } |
|
1382 | 1437 | |
1383 | 1438 | // This is a brand new theme so set all possible values. |
1384 | 1439 | $context['to_install'] = array( |
@@ -1398,8 +1453,9 @@ discard block |
||
1398 | 1453 | |
1399 | 1454 | // Buy some time. |
1400 | 1455 | @set_time_limit(600); |
1401 | - if (function_exists('apache_reset_timeout')) |
|
1402 | - @apache_reset_timeout(); |
|
1456 | + if (function_exists('apache_reset_timeout')) { |
|
1457 | + @apache_reset_timeout(); |
|
1458 | + } |
|
1403 | 1459 | |
1404 | 1460 | // Create subdirectories for css and javascript files. |
1405 | 1461 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1435,12 +1491,13 @@ discard block |
||
1435 | 1491 | |
1436 | 1492 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1437 | 1493 | { |
1438 | - if ($row['variable'] == 'theme_templates') |
|
1439 | - $theme_templates = $row['value']; |
|
1440 | - elseif ($row['variable'] == 'theme_layers') |
|
1441 | - $theme_layers = $row['value']; |
|
1442 | - else |
|
1443 | - continue; |
|
1494 | + if ($row['variable'] == 'theme_templates') { |
|
1495 | + $theme_templates = $row['value']; |
|
1496 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1497 | + $theme_layers = $row['value']; |
|
1498 | + } else { |
|
1499 | + continue; |
|
1500 | + } |
|
1444 | 1501 | } |
1445 | 1502 | |
1446 | 1503 | $smcFunc['db_free_result']($request); |
@@ -1499,12 +1556,14 @@ discard block |
||
1499 | 1556 | global $themedir, $themeurl, $context; |
1500 | 1557 | |
1501 | 1558 | // Cannot use the theme dir as a theme dir. |
1502 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1503 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1559 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1560 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1561 | + } |
|
1504 | 1562 | |
1505 | 1563 | // Check is there is "something" on the dir. |
1506 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1507 | - fatal_lang_error('theme_install_error', false); |
|
1564 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1565 | + fatal_lang_error('theme_install_error', false); |
|
1566 | + } |
|
1508 | 1567 | |
1509 | 1568 | $name = basename($_REQUEST['theme_dir']); |
1510 | 1569 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1548,24 +1607,27 @@ discard block |
||
1548 | 1607 | } |
1549 | 1608 | |
1550 | 1609 | // Any special layers? |
1551 | - if (isset($settings['catch_action']['layers'])) |
|
1552 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1610 | + if (isset($settings['catch_action']['layers'])) { |
|
1611 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1612 | + } |
|
1553 | 1613 | |
1554 | 1614 | // Any function to call? |
1555 | 1615 | if (isset($settings['catch_action']['function'])) |
1556 | 1616 | { |
1557 | 1617 | $hook = $settings['catch_action']['function']; |
1558 | 1618 | |
1559 | - if (!isset($settings['catch_action']['filename'])) |
|
1560 | - $settings['catch_action']['filename'] = ''; |
|
1619 | + if (!isset($settings['catch_action']['filename'])) { |
|
1620 | + $settings['catch_action']['filename'] = ''; |
|
1621 | + } |
|
1561 | 1622 | |
1562 | 1623 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1563 | 1624 | call_integration_hook('integrate_wrap_action'); |
1564 | 1625 | } |
1565 | 1626 | // And finally, the main sub template ;). |
1566 | - if (isset($settings['catch_action']['sub_template'])) |
|
1567 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1568 | -} |
|
1627 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1628 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1629 | + } |
|
1630 | + } |
|
1569 | 1631 | |
1570 | 1632 | /** |
1571 | 1633 | * Set an option via javascript. |
@@ -1584,12 +1646,14 @@ discard block |
||
1584 | 1646 | checkSession('get'); |
1585 | 1647 | |
1586 | 1648 | // This good-for-nothing pixel is being used to keep the session alive. |
1587 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1588 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1649 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1650 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1651 | + } |
|
1589 | 1652 | |
1590 | 1653 | // Sorry, guests can't go any further than this. |
1591 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1592 | - obExit(false); |
|
1654 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1655 | + obExit(false); |
|
1656 | + } |
|
1593 | 1657 | |
1594 | 1658 | $reservedVars = array( |
1595 | 1659 | 'actual_theme_url', |
@@ -1612,8 +1676,9 @@ discard block |
||
1612 | 1676 | ); |
1613 | 1677 | |
1614 | 1678 | // Can't change reserved vars. |
1615 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1616 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1679 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1680 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1681 | + } |
|
1617 | 1682 | |
1618 | 1683 | // Use a specific theme? |
1619 | 1684 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1629,8 +1694,9 @@ discard block |
||
1629 | 1694 | { |
1630 | 1695 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
1631 | 1696 | // New thingy... |
1632 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1633 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1697 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1698 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1699 | + } |
|
1634 | 1700 | |
1635 | 1701 | // Change the value to be something nice, |
1636 | 1702 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1660,8 +1726,9 @@ discard block |
||
1660 | 1726 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1661 | 1727 | |
1662 | 1728 | // @todo Should this be removed? |
1663 | - if (isset($_REQUEST['preview'])) |
|
1664 | - die('die() with fire'); |
|
1729 | + if (isset($_REQUEST['preview'])) { |
|
1730 | + die('die() with fire'); |
|
1731 | + } |
|
1665 | 1732 | |
1666 | 1733 | isAllowedTo('admin_forum'); |
1667 | 1734 | loadTemplate('Themes'); |
@@ -1675,11 +1742,11 @@ discard block |
||
1675 | 1742 | foreach ($context['themes'] as $key => $theme) |
1676 | 1743 | { |
1677 | 1744 | // There has to be a Settings template! |
1678 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1679 | - unset($context['themes'][$key]); |
|
1680 | - |
|
1681 | - else |
|
1682 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1745 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1746 | + unset($context['themes'][$key]); |
|
1747 | + } else { |
|
1748 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1749 | + } |
|
1683 | 1750 | } |
1684 | 1751 | |
1685 | 1752 | $context['sub_template'] = 'edit_list'; |
@@ -1694,22 +1761,24 @@ discard block |
||
1694 | 1761 | $context['theme_id'] = $currentTheme['id']; |
1695 | 1762 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1696 | 1763 | |
1697 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1698 | - fatal_lang_error('theme_edit_missing', false); |
|
1764 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1765 | + fatal_lang_error('theme_edit_missing', false); |
|
1766 | + } |
|
1699 | 1767 | |
1700 | 1768 | if (!isset($_REQUEST['filename'])) |
1701 | 1769 | { |
1702 | 1770 | if (isset($_GET['directory'])) |
1703 | 1771 | { |
1704 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1705 | - $_GET['directory'] = ''; |
|
1706 | - else |
|
1772 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1773 | + $_GET['directory'] = ''; |
|
1774 | + } else |
|
1707 | 1775 | { |
1708 | 1776 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1709 | 1777 | |
1710 | 1778 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1711 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1712 | - $_GET['directory'] = ''; |
|
1779 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1780 | + $_GET['directory'] = ''; |
|
1781 | + } |
|
1713 | 1782 | } |
1714 | 1783 | } |
1715 | 1784 | |
@@ -1728,37 +1797,39 @@ discard block |
||
1728 | 1797 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1729 | 1798 | 'size' => '', |
1730 | 1799 | )); |
1800 | + } else { |
|
1801 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1731 | 1802 | } |
1732 | - else |
|
1733 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1734 | 1803 | |
1735 | 1804 | $context['sub_template'] = 'edit_browse'; |
1736 | 1805 | |
1737 | 1806 | return; |
1738 | - } |
|
1739 | - else |
|
1807 | + } else |
|
1740 | 1808 | { |
1741 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1742 | - $_REQUEST['filename'] = ''; |
|
1743 | - else |
|
1809 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1810 | + $_REQUEST['filename'] = ''; |
|
1811 | + } else |
|
1744 | 1812 | { |
1745 | 1813 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1746 | 1814 | |
1747 | 1815 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1748 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1749 | - $_REQUEST['filename'] = ''; |
|
1816 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1817 | + $_REQUEST['filename'] = ''; |
|
1818 | + } |
|
1750 | 1819 | } |
1751 | 1820 | |
1752 | - if (empty($_REQUEST['filename'])) |
|
1753 | - fatal_lang_error('theme_edit_missing', false); |
|
1821 | + if (empty($_REQUEST['filename'])) { |
|
1822 | + fatal_lang_error('theme_edit_missing', false); |
|
1823 | + } |
|
1754 | 1824 | } |
1755 | 1825 | |
1756 | 1826 | if (isset($_POST['save'])) |
1757 | 1827 | { |
1758 | 1828 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1759 | 1829 | { |
1760 | - if (is_array($_POST['entire_file'])) |
|
1761 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1830 | + if (is_array($_POST['entire_file'])) { |
|
1831 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1832 | + } |
|
1762 | 1833 | |
1763 | 1834 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1764 | 1835 | |
@@ -1770,10 +1841,11 @@ discard block |
||
1770 | 1841 | fclose($fp); |
1771 | 1842 | |
1772 | 1843 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1773 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1774 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1775 | - else |
|
1776 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1844 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1845 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1846 | + } else { |
|
1847 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1848 | + } |
|
1777 | 1849 | } |
1778 | 1850 | |
1779 | 1851 | if (!isset($error_file)) |
@@ -1794,10 +1866,11 @@ discard block |
||
1794 | 1866 | $context['sub_template'] = 'edit_file'; |
1795 | 1867 | |
1796 | 1868 | // Recycle the submitted data. |
1797 | - if (is_array($_POST['entire_file'])) |
|
1798 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1799 | - else |
|
1800 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1869 | + if (is_array($_POST['entire_file'])) { |
|
1870 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1871 | + } else { |
|
1872 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1873 | + } |
|
1801 | 1874 | |
1802 | 1875 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1803 | 1876 | |
@@ -1820,17 +1893,17 @@ discard block |
||
1820 | 1893 | $context['sub_template'] = 'edit_style'; |
1821 | 1894 | |
1822 | 1895 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1823 | - } |
|
1824 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1896 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1825 | 1897 | { |
1826 | 1898 | $context['sub_template'] = 'edit_template'; |
1827 | 1899 | |
1828 | - if (!isset($error_file)) |
|
1829 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1830 | - else |
|
1900 | + if (!isset($error_file)) { |
|
1901 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1902 | + } else |
|
1831 | 1903 | { |
1832 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1833 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1904 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1905 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1906 | + } |
|
1834 | 1907 | $file_data = file($error_file); |
1835 | 1908 | unlink($error_file); |
1836 | 1909 | } |
@@ -1844,8 +1917,9 @@ discard block |
||
1844 | 1917 | // Try to format the functions a little nicer... |
1845 | 1918 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1846 | 1919 | |
1847 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1848 | - unset($context['file_parts'][$j]); |
|
1920 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1921 | + unset($context['file_parts'][$j]); |
|
1922 | + } |
|
1849 | 1923 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1850 | 1924 | } |
1851 | 1925 | |
@@ -1854,8 +1928,7 @@ discard block |
||
1854 | 1928 | } |
1855 | 1929 | |
1856 | 1930 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1857 | - } |
|
1858 | - else |
|
1931 | + } else |
|
1859 | 1932 | { |
1860 | 1933 | $context['sub_template'] = 'edit_file'; |
1861 | 1934 | |
@@ -1881,8 +1954,9 @@ discard block |
||
1881 | 1954 | |
1882 | 1955 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1883 | 1956 | |
1884 | - if (empty($_GET['th'])) |
|
1885 | - fatal_lang_error('theme_install_invalid_id'); |
|
1957 | + if (empty($_GET['th'])) { |
|
1958 | + fatal_lang_error('theme_install_invalid_id'); |
|
1959 | + } |
|
1886 | 1960 | |
1887 | 1961 | // Get the theme info. |
1888 | 1962 | $theme = get_single_theme($_GET['th']); |
@@ -1890,25 +1964,24 @@ discard block |
||
1890 | 1964 | |
1891 | 1965 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1892 | 1966 | { |
1893 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1894 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1895 | - |
|
1896 | - else |
|
1897 | - fatal_lang_error('no_access', false); |
|
1967 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1968 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1969 | + } else { |
|
1970 | + fatal_lang_error('no_access', false); |
|
1971 | + } |
|
1898 | 1972 | |
1899 | 1973 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1900 | 1974 | fwrite($fp, file_get_contents($filename)); |
1901 | 1975 | fclose($fp); |
1902 | 1976 | |
1903 | 1977 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1904 | - } |
|
1905 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1978 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1906 | 1979 | { |
1907 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1908 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1909 | - |
|
1910 | - else |
|
1911 | - fatal_lang_error('no_access', false); |
|
1980 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1981 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1982 | + } else { |
|
1983 | + fatal_lang_error('no_access', false); |
|
1984 | + } |
|
1912 | 1985 | |
1913 | 1986 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1914 | 1987 | fwrite($fp, file_get_contents($filename)); |
@@ -1923,16 +1996,18 @@ discard block |
||
1923 | 1996 | $dir = dir($settings['default_theme_dir']); |
1924 | 1997 | while ($entry = $dir->read()) |
1925 | 1998 | { |
1926 | - if (substr($entry, -13) == '.template.php') |
|
1927 | - $templates[] = substr($entry, 0, -13); |
|
1999 | + if (substr($entry, -13) == '.template.php') { |
|
2000 | + $templates[] = substr($entry, 0, -13); |
|
2001 | + } |
|
1928 | 2002 | } |
1929 | 2003 | $dir->close(); |
1930 | 2004 | |
1931 | 2005 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1932 | 2006 | while ($entry = $dir->read()) |
1933 | 2007 | { |
1934 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1935 | - $lang_files[] = $matches[1]; |
|
2008 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2009 | + $lang_files[] = $matches[1]; |
|
2010 | + } |
|
1936 | 2011 | } |
1937 | 2012 | $dir->close(); |
1938 | 2013 | |
@@ -1940,21 +2015,23 @@ discard block |
||
1940 | 2015 | natcasesort($lang_files); |
1941 | 2016 | |
1942 | 2017 | $context['available_templates'] = array(); |
1943 | - foreach ($templates as $template) |
|
1944 | - $context['available_templates'][$template] = array( |
|
2018 | + foreach ($templates as $template) { |
|
2019 | + $context['available_templates'][$template] = array( |
|
1945 | 2020 | 'filename' => $template . '.template.php', |
1946 | 2021 | 'value' => $template, |
1947 | 2022 | 'already_exists' => false, |
1948 | 2023 | 'can_copy' => is_writable($theme['theme_dir']), |
1949 | 2024 | ); |
2025 | + } |
|
1950 | 2026 | $context['available_language_files'] = array(); |
1951 | - foreach ($lang_files as $file) |
|
1952 | - $context['available_language_files'][$file] = array( |
|
2027 | + foreach ($lang_files as $file) { |
|
2028 | + $context['available_language_files'][$file] = array( |
|
1953 | 2029 | 'filename' => $file . '.php', |
1954 | 2030 | 'value' => $file, |
1955 | 2031 | 'already_exists' => false, |
1956 | 2032 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1957 | 2033 | ); |
2034 | + } |
|
1958 | 2035 | |
1959 | 2036 | $dir = dir($theme['theme_dir']); |
1960 | 2037 | while ($entry = $dir->read()) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
31 | 32 | |
32 | 33 | // We should have debug mode enabled, as well as something to display! |
33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
34 | - fatal_lang_error('no_access', false); |
|
34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
35 | + fatal_lang_error('no_access', false); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Don't allow except for administrators. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
41 | 43 | { |
42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
43 | 45 | |
44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
45 | - redirectexit(); |
|
46 | - else |
|
47 | - redirectexit($_SESSION['old_url']); |
|
46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
47 | + redirectexit(); |
|
48 | + } else { |
|
49 | + redirectexit($_SESSION['old_url']); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
83 | 86 | foreach ($query as $line) |
84 | 87 | { |
85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
87 | - $min_indent = strlen($temp[0]); |
|
89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
90 | + $min_indent = strlen($temp[0]); |
|
91 | + } |
|
92 | + } |
|
93 | + foreach ($query as $l => $dummy) { |
|
94 | + $query[$l] = substr($dummy, $min_indent); |
|
88 | 95 | } |
89 | - foreach ($query as $l => $dummy) |
|
90 | - $query[$l] = substr($dummy, $min_indent); |
|
91 | 96 | $query_data['q'] = implode("\n", $query); |
92 | 97 | |
93 | 98 | // Make the filenames look a bit better. |
94 | - if (isset($query_data['f'])) |
|
95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
99 | + if (isset($query_data['f'])) { |
|
100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
98 | - if ($is_select_query) |
|
99 | - $select = $query_data['q']; |
|
100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
104 | + if ($is_select_query) { |
|
105 | + $select = $query_data['q']; |
|
106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
101 | 107 | { |
102 | 108 | $is_select_query = true; |
103 | 109 | $select = $matches[1]; |
104 | - } |
|
105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
106 | 111 | { |
107 | 112 | $is_select_query = true; |
108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
110 | 115 | // Temporary tables created in earlier queries are not explainable. |
111 | 116 | if ($is_select_query) |
112 | 117 | { |
113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
114 | - if (strpos($select, $tmp) !== false) |
|
118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
119 | + if (strpos($select, $tmp) !== false) |
|
115 | 120 | { |
116 | 121 | $is_select_query = false; |
122 | + } |
|
117 | 123 | break; |
118 | 124 | } |
119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
125 | 131 | </a><br>'; |
126 | 132 | |
127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
135 | + } |
|
129 | 136 | |
130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
132 | - else |
|
133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
139 | + } else { |
|
140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
141 | + } |
|
134 | 142 | |
135 | 143 | echo ' |
136 | 144 | </div>'; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Dispatches to the right function based on the given subaction. |
@@ -176,8 +177,9 @@ discard block |
||
176 | 177 | // If it's inherited, just add it as a child. |
177 | 178 | if ($row['id_parent'] != -2) |
178 | 179 | { |
179 | - if (isset($context['groups'][$row['id_parent']])) |
|
180 | - $context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name']; |
|
180 | + if (isset($context['groups'][$row['id_parent']])) { |
|
181 | + $context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name']; |
|
182 | + } |
|
181 | 183 | continue; |
182 | 184 | } |
183 | 185 | |
@@ -202,10 +204,11 @@ discard block |
||
202 | 204 | 'access' => false, |
203 | 205 | ); |
204 | 206 | |
205 | - if ($row['min_posts'] == -1) |
|
206 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
207 | - else |
|
208 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
207 | + if ($row['min_posts'] == -1) { |
|
208 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
209 | + } else { |
|
210 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
211 | + } |
|
209 | 212 | } |
210 | 213 | $smcFunc['db_free_result']($query); |
211 | 214 | |
@@ -221,8 +224,9 @@ discard block |
||
221 | 224 | 'post_group_list' => $postGroups, |
222 | 225 | ) |
223 | 226 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
225 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
227 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
228 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
229 | + } |
|
226 | 230 | $smcFunc['db_free_result']($query); |
227 | 231 | } |
228 | 232 | |
@@ -238,8 +242,9 @@ discard block |
||
238 | 242 | 'normal_group_list' => $normalGroups, |
239 | 243 | ) |
240 | 244 | ); |
241 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
242 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
245 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
246 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
247 | + } |
|
243 | 248 | $smcFunc['db_free_result']($query); |
244 | 249 | |
245 | 250 | // This one is slower, but it's okay... careful not to count twice! |
@@ -256,15 +261,17 @@ discard block |
||
256 | 261 | 'blank_string' => '', |
257 | 262 | ) |
258 | 263 | ); |
259 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
260 | - $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
264 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
265 | + $context['groups'][$row['id_group']]['num_members'] += $row['num_members']; |
|
266 | + } |
|
261 | 267 | $smcFunc['db_free_result']($query); |
262 | 268 | } |
263 | 269 | |
264 | 270 | foreach ($context['groups'] as $id => $data) |
265 | 271 | { |
266 | - if ($data['href'] != '') |
|
267 | - $context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>'; |
|
272 | + if ($data['href'] != '') { |
|
273 | + $context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>'; |
|
274 | + } |
|
268 | 275 | } |
269 | 276 | |
270 | 277 | if (empty($_REQUEST['pid'])) |
@@ -278,9 +285,10 @@ discard block |
||
278 | 285 | 'hidden_permissions' => !empty($context['hidden_permissions']) ? $context['hidden_permissions'] : array(), |
279 | 286 | ) |
280 | 287 | ); |
281 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
282 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
288 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
289 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
283 | 290 | $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] = $row['num_permissions']; |
291 | + } |
|
284 | 292 | $smcFunc['db_free_result']($request); |
285 | 293 | |
286 | 294 | // Get the "default" profile permissions too. |
@@ -297,17 +305,18 @@ discard block |
||
297 | 305 | ); |
298 | 306 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
299 | 307 | { |
300 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
301 | - $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
308 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) { |
|
309 | + $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
310 | + } |
|
302 | 311 | } |
303 | 312 | $smcFunc['db_free_result']($request); |
304 | - } |
|
305 | - else |
|
313 | + } else |
|
306 | 314 | { |
307 | 315 | $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
308 | 316 | |
309 | - if (!isset($context['profiles'][$_REQUEST['pid']])) |
|
310 | - fatal_lang_error('no_access', false); |
|
317 | + if (!isset($context['profiles'][$_REQUEST['pid']])) { |
|
318 | + fatal_lang_error('no_access', false); |
|
319 | + } |
|
311 | 320 | |
312 | 321 | // Change the selected tab to better reflect that this really is a board profile. |
313 | 322 | $context[$context['admin_menu_name']]['current_subsection'] = 'profiles'; |
@@ -323,8 +332,9 @@ discard block |
||
323 | 332 | ); |
324 | 333 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
325 | 334 | { |
326 | - if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
|
327 | - $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
335 | + if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) { |
|
336 | + $context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
|
337 | + } |
|
328 | 338 | } |
329 | 339 | $smcFunc['db_free_result']($request); |
330 | 340 | |
@@ -366,8 +376,8 @@ discard block |
||
366 | 376 | |
367 | 377 | if (!empty($changes)) |
368 | 378 | { |
369 | - foreach ($changes as $profile => $boards) |
|
370 | - $smcFunc['db_query']('', ' |
|
379 | + foreach ($changes as $profile => $boards) { |
|
380 | + $smcFunc['db_query']('', ' |
|
371 | 381 | UPDATE {db_prefix}boards |
372 | 382 | SET id_profile = {int:current_profile} |
373 | 383 | WHERE id_board IN ({array_int:board_list})', |
@@ -376,6 +386,7 @@ discard block |
||
376 | 386 | 'current_profile' => $profile, |
377 | 387 | ) |
378 | 388 | ); |
389 | + } |
|
379 | 390 | } |
380 | 391 | |
381 | 392 | $context['edit_all'] = false; |
@@ -400,8 +411,9 @@ discard block |
||
400 | 411 | ); |
401 | 412 | foreach ($boardList[$catid] as $boardid) |
402 | 413 | { |
403 | - if (!isset($context['profiles'][$boards[$boardid]['profile']])) |
|
404 | - $boards[$boardid]['profile'] = 1; |
|
414 | + if (!isset($context['profiles'][$boards[$boardid]['profile']])) { |
|
415 | + $boards[$boardid]['profile'] = 1; |
|
416 | + } |
|
405 | 417 | |
406 | 418 | $context['categories'][$catid]['boards'][$boardid] = array( |
407 | 419 | 'id' => &$boards[$boardid]['id'], |
@@ -433,64 +445,74 @@ discard block |
||
433 | 445 | loadIllegalGuestPermissions(); |
434 | 446 | |
435 | 447 | // Make sure only one of the quick options was selected. |
436 | - if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) |
|
437 | - fatal_lang_error('permissions_only_one_option', false); |
|
448 | + if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) { |
|
449 | + fatal_lang_error('permissions_only_one_option', false); |
|
450 | + } |
|
438 | 451 | |
439 | - if (empty($_POST['group']) || !is_array($_POST['group'])) |
|
440 | - $_POST['group'] = array(); |
|
452 | + if (empty($_POST['group']) || !is_array($_POST['group'])) { |
|
453 | + $_POST['group'] = array(); |
|
454 | + } |
|
441 | 455 | |
442 | 456 | // Only accept numeric values for selected membergroups. |
443 | - foreach ($_POST['group'] as $id => $group_id) |
|
444 | - $_POST['group'][$id] = (int) $group_id; |
|
457 | + foreach ($_POST['group'] as $id => $group_id) { |
|
458 | + $_POST['group'][$id] = (int) $group_id; |
|
459 | + } |
|
445 | 460 | $_POST['group'] = array_unique($_POST['group']); |
446 | 461 | |
447 | - if (empty($_REQUEST['pid'])) |
|
448 | - $_REQUEST['pid'] = 0; |
|
449 | - else |
|
450 | - $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
|
462 | + if (empty($_REQUEST['pid'])) { |
|
463 | + $_REQUEST['pid'] = 0; |
|
464 | + } else { |
|
465 | + $_REQUEST['pid'] = (int) $_REQUEST['pid']; |
|
466 | + } |
|
451 | 467 | |
452 | 468 | // Fix up the old global to the new default! |
453 | 469 | $bid = max(1, $_REQUEST['pid']); |
454 | 470 | |
455 | 471 | // No modifying the predefined profiles. |
456 | - if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) |
|
457 | - fatal_lang_error('no_access', false); |
|
472 | + if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) { |
|
473 | + fatal_lang_error('no_access', false); |
|
474 | + } |
|
458 | 475 | |
459 | 476 | // Clear out any cached authority. |
460 | 477 | updateSettings(array('settings_updated' => time())); |
461 | 478 | |
462 | 479 | // No groups where selected. |
463 | - if (empty($_POST['group'])) |
|
464 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
480 | + if (empty($_POST['group'])) { |
|
481 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
482 | + } |
|
465 | 483 | |
466 | 484 | // Set a predefined permission profile. |
467 | 485 | if (!empty($_POST['predefined'])) |
468 | 486 | { |
469 | 487 | // Make sure it's a predefined permission set we expect. |
470 | - if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) |
|
471 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
488 | + if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) { |
|
489 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
490 | + } |
|
472 | 491 | |
473 | 492 | foreach ($_POST['group'] as $group_id) |
474 | 493 | { |
475 | - if (!empty($_REQUEST['pid'])) |
|
476 | - setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']); |
|
477 | - else |
|
478 | - setPermissionLevel($_POST['predefined'], $group_id); |
|
494 | + if (!empty($_REQUEST['pid'])) { |
|
495 | + setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']); |
|
496 | + } else { |
|
497 | + setPermissionLevel($_POST['predefined'], $group_id); |
|
498 | + } |
|
479 | 499 | } |
480 | 500 | } |
481 | 501 | // Set a permission profile based on the permissions of a selected group. |
482 | 502 | elseif ($_POST['copy_from'] != 'empty') |
483 | 503 | { |
484 | 504 | // Just checking the input. |
485 | - if (!is_numeric($_POST['copy_from'])) |
|
486 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
505 | + if (!is_numeric($_POST['copy_from'])) { |
|
506 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
507 | + } |
|
487 | 508 | |
488 | 509 | // Make sure the group we're copying to is never included. |
489 | 510 | $_POST['group'] = array_diff($_POST['group'], array($_POST['copy_from'])); |
490 | 511 | |
491 | 512 | // No groups left? Too bad. |
492 | - if (empty($_POST['group'])) |
|
493 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
513 | + if (empty($_POST['group'])) { |
|
514 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
515 | + } |
|
494 | 516 | |
495 | 517 | if (empty($_REQUEST['pid'])) |
496 | 518 | { |
@@ -504,22 +526,26 @@ discard block |
||
504 | 526 | ) |
505 | 527 | ); |
506 | 528 | $target_perm = array(); |
507 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
508 | - $target_perm[$row['permission']] = $row['add_deny']; |
|
529 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
530 | + $target_perm[$row['permission']] = $row['add_deny']; |
|
531 | + } |
|
509 | 532 | $smcFunc['db_free_result']($request); |
510 | 533 | |
511 | 534 | $inserts = array(); |
512 | - foreach ($_POST['group'] as $group_id) |
|
513 | - foreach ($target_perm as $perm => $add_deny) |
|
535 | + foreach ($_POST['group'] as $group_id) { |
|
536 | + foreach ($target_perm as $perm => $add_deny) |
|
514 | 537 | { |
515 | 538 | // No dodgy permissions please! |
516 | 539 | if (!empty($context['illegal_permissions']) && in_array($perm, $context['illegal_permissions'])) |
517 | 540 | continue; |
518 | - if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) |
|
519 | - continue; |
|
541 | + } |
|
542 | + if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) { |
|
543 | + continue; |
|
544 | + } |
|
520 | 545 | |
521 | - if ($group_id != 1 && $group_id != 3) |
|
522 | - $inserts[] = array($perm, $group_id, $add_deny); |
|
546 | + if ($group_id != 1 && $group_id != 3) { |
|
547 | + $inserts[] = array($perm, $group_id, $add_deny); |
|
548 | + } |
|
523 | 549 | } |
524 | 550 | |
525 | 551 | // Delete the previous permissions... |
@@ -559,17 +585,19 @@ discard block |
||
559 | 585 | ) |
560 | 586 | ); |
561 | 587 | $target_perm = array(); |
562 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
563 | - $target_perm[$row['permission']] = $row['add_deny']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $target_perm[$row['permission']] = $row['add_deny']; |
|
590 | + } |
|
564 | 591 | $smcFunc['db_free_result']($request); |
565 | 592 | |
566 | 593 | $inserts = array(); |
567 | - foreach ($_POST['group'] as $group_id) |
|
568 | - foreach ($target_perm as $perm => $add_deny) |
|
594 | + foreach ($_POST['group'] as $group_id) { |
|
595 | + foreach ($target_perm as $perm => $add_deny) |
|
569 | 596 | { |
570 | 597 | // Are these for guests? |
571 | 598 | if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) |
572 | 599 | continue; |
600 | + } |
|
573 | 601 | |
574 | 602 | $inserts[] = array($perm, $group_id, $bid, $add_deny); |
575 | 603 | } |
@@ -607,13 +635,14 @@ discard block |
||
607 | 635 | list ($permissionType, $permission) = explode('/', $_POST['permissions']); |
608 | 636 | |
609 | 637 | // Check whether our input is within expected range. |
610 | - if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) |
|
611 | - redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
638 | + if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) { |
|
639 | + redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']); |
|
640 | + } |
|
612 | 641 | |
613 | 642 | if ($_POST['add_remove'] == 'clear') |
614 | 643 | { |
615 | - if ($permissionType == 'membergroup') |
|
616 | - $smcFunc['db_query']('', ' |
|
644 | + if ($permissionType == 'membergroup') { |
|
645 | + $smcFunc['db_query']('', ' |
|
617 | 646 | DELETE FROM {db_prefix}permissions |
618 | 647 | WHERE id_group IN ({array_int:current_group_list}) |
619 | 648 | AND permission = {string:current_permission} |
@@ -624,8 +653,8 @@ discard block |
||
624 | 653 | 'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(), |
625 | 654 | ) |
626 | 655 | ); |
627 | - else |
|
628 | - $smcFunc['db_query']('', ' |
|
656 | + } else { |
|
657 | + $smcFunc['db_query']('', ' |
|
629 | 658 | DELETE FROM {db_prefix}board_permissions |
630 | 659 | WHERE id_group IN ({array_int:current_group_list}) |
631 | 660 | AND id_profile = {int:current_profile} |
@@ -636,6 +665,7 @@ discard block |
||
636 | 665 | 'current_permission' => $permission, |
637 | 666 | ) |
638 | 667 | ); |
668 | + } |
|
639 | 669 | } |
640 | 670 | // Add a permission (either 'set' or 'deny'). |
641 | 671 | else |
@@ -644,32 +674,36 @@ discard block |
||
644 | 674 | $permChange = array(); |
645 | 675 | foreach ($_POST['group'] as $groupID) |
646 | 676 | { |
647 | - if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
648 | - continue; |
|
677 | + if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
678 | + continue; |
|
679 | + } |
|
649 | 680 | |
650 | - if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) |
|
651 | - $permChange[] = array($permission, $groupID, $add_deny); |
|
652 | - elseif ($permissionType != 'membergroup') |
|
653 | - $permChange[] = array($permission, $groupID, $bid, $add_deny); |
|
681 | + if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) { |
|
682 | + $permChange[] = array($permission, $groupID, $add_deny); |
|
683 | + } elseif ($permissionType != 'membergroup') { |
|
684 | + $permChange[] = array($permission, $groupID, $bid, $add_deny); |
|
685 | + } |
|
654 | 686 | } |
655 | 687 | |
656 | 688 | if (!empty($permChange)) |
657 | 689 | { |
658 | - if ($permissionType == 'membergroup') |
|
659 | - $smcFunc['db_insert']('replace', |
|
690 | + if ($permissionType == 'membergroup') { |
|
691 | + $smcFunc['db_insert']('replace', |
|
660 | 692 | '{db_prefix}permissions', |
661 | 693 | array('permission' => 'string', 'id_group' => 'int', 'add_deny' => 'int'), |
662 | 694 | $permChange, |
663 | 695 | array('permission', 'id_group') |
664 | 696 | ); |
697 | + } |
|
665 | 698 | // Board permissions go into the other table. |
666 | - else |
|
667 | - $smcFunc['db_insert']('replace', |
|
699 | + else { |
|
700 | + $smcFunc['db_insert']('replace', |
|
668 | 701 | '{db_prefix}board_permissions', |
669 | 702 | array('permission' => 'string', 'id_group' => 'int', 'id_profile' => 'int', 'add_deny' => 'int'), |
670 | 703 | $permChange, |
671 | 704 | array('permission', 'id_group', 'id_profile') |
672 | 705 | ); |
706 | + } |
|
673 | 707 | } |
674 | 708 | } |
675 | 709 | |
@@ -687,14 +721,16 @@ discard block |
||
687 | 721 | { |
688 | 722 | global $context, $txt, $smcFunc, $modSettings; |
689 | 723 | |
690 | - if (!isset($_GET['group'])) |
|
691 | - fatal_lang_error('no_access', false); |
|
724 | + if (!isset($_GET['group'])) { |
|
725 | + fatal_lang_error('no_access', false); |
|
726 | + } |
|
692 | 727 | |
693 | 728 | $context['group']['id'] = (int) $_GET['group']; |
694 | 729 | |
695 | 730 | // It's not likely you'd end up here with this setting disabled. |
696 | - if ($_GET['group'] == 1) |
|
697 | - redirectexit('action=admin;area=permissions'); |
|
731 | + if ($_GET['group'] == 1) { |
|
732 | + redirectexit('action=admin;area=permissions'); |
|
733 | + } |
|
698 | 734 | |
699 | 735 | loadAllPermissions(); |
700 | 736 | loadPermissionProfiles(); |
@@ -715,13 +751,14 @@ discard block |
||
715 | 751 | $smcFunc['db_free_result']($result); |
716 | 752 | |
717 | 753 | // Cannot edit an inherited group! |
718 | - if ($parent != -2) |
|
719 | - fatal_lang_error('cannot_edit_permissions_inherited'); |
|
754 | + if ($parent != -2) { |
|
755 | + fatal_lang_error('cannot_edit_permissions_inherited'); |
|
756 | + } |
|
757 | + } elseif ($context['group']['id'] == -1) { |
|
758 | + $context['group']['name'] = $txt['membergroups_guests']; |
|
759 | + } else { |
|
760 | + $context['group']['name'] = $txt['membergroups_members']; |
|
720 | 761 | } |
721 | - elseif ($context['group']['id'] == -1) |
|
722 | - $context['group']['name'] = $txt['membergroups_guests']; |
|
723 | - else |
|
724 | - $context['group']['name'] = $txt['membergroups_members']; |
|
725 | 762 | |
726 | 763 | $context['profile']['id'] = empty($_GET['pid']) ? 0 : (int) $_GET['pid']; |
727 | 764 | |
@@ -767,8 +804,9 @@ discard block |
||
767 | 804 | 'current_group' => $_GET['group'], |
768 | 805 | ) |
769 | 806 | ); |
770 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
771 | - $permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
807 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
808 | + $permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
809 | + } |
|
772 | 810 | $smcFunc['db_free_result']($result); |
773 | 811 | } |
774 | 812 | |
@@ -783,8 +821,9 @@ discard block |
||
783 | 821 | 'current_profile' => $context['permission_type'] == 'membergroup' ? 1 : $context['profile']['id'], |
784 | 822 | ) |
785 | 823 | ); |
786 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
787 | - $permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
824 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
825 | + $permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
|
826 | + } |
|
788 | 827 | $smcFunc['db_free_result']($result); |
789 | 828 | |
790 | 829 | // Loop through each permission and set whether it's checked. |
@@ -803,9 +842,9 @@ discard block |
||
803 | 842 | { |
804 | 843 | $curPerm['any']['select'] = in_array($perm['id'] . '_any', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_any', $permissions[$permissionType]['denied']) ? 'deny' : 'off'); |
805 | 844 | $curPerm['own']['select'] = in_array($perm['id'] . '_own', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_own', $permissions[$permissionType]['denied']) ? 'deny' : 'off'); |
845 | + } else { |
|
846 | + $curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off'); |
|
806 | 847 | } |
807 | - else |
|
808 | - $curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off'); |
|
809 | 848 | |
810 | 849 | // Keep the last value if it's hidden. |
811 | 850 | if ($perm['hidden'] || $permissionArray['hidden']) |
@@ -822,13 +861,13 @@ discard block |
||
822 | 861 | $perm['any']['id'], |
823 | 862 | $curPerm['any']['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['any']['select'], |
824 | 863 | ); |
825 | - } |
|
826 | - else |
|
827 | - $context['hidden_perms'][] = array( |
|
864 | + } else { |
|
865 | + $context['hidden_perms'][] = array( |
|
828 | 866 | $permissionType, |
829 | 867 | $perm['id'], |
830 | 868 | $curPerm['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['select'], |
831 | 869 | ); |
870 | + } |
|
832 | 871 | } |
833 | 872 | } |
834 | 873 | } |
@@ -856,13 +895,14 @@ discard block |
||
856 | 895 | $_GET['pid'] = (int) $_GET['pid']; |
857 | 896 | |
858 | 897 | // Cannot modify predefined profiles. |
859 | - if ($_GET['pid'] > 1 && $_GET['pid'] < 5) |
|
860 | - fatal_lang_error('no_access', false); |
|
898 | + if ($_GET['pid'] > 1 && $_GET['pid'] < 5) { |
|
899 | + fatal_lang_error('no_access', false); |
|
900 | + } |
|
861 | 901 | |
862 | 902 | // Verify this isn't inherited. |
863 | - if ($_GET['group'] == -1 || $_GET['group'] == 0) |
|
864 | - $parent = -2; |
|
865 | - else |
|
903 | + if ($_GET['group'] == -1 || $_GET['group'] == 0) { |
|
904 | + $parent = -2; |
|
905 | + } else |
|
866 | 906 | { |
867 | 907 | $result = $smcFunc['db_query']('', ' |
868 | 908 | SELECT id_parent |
@@ -877,8 +917,9 @@ discard block |
||
877 | 917 | $smcFunc['db_free_result']($result); |
878 | 918 | } |
879 | 919 | |
880 | - if ($parent != -2) |
|
881 | - fatal_lang_error('cannot_edit_permissions_inherited'); |
|
920 | + if ($parent != -2) { |
|
921 | + fatal_lang_error('cannot_edit_permissions_inherited'); |
|
922 | + } |
|
882 | 923 | |
883 | 924 | $givePerms = array('membergroup' => array(), 'board' => array()); |
884 | 925 | |
@@ -896,12 +937,13 @@ discard block |
||
896 | 937 | { |
897 | 938 | if (is_array($perm_array)) |
898 | 939 | { |
899 | - foreach ($perm_array as $permission => $value) |
|
900 | - if ($value == 'on' || $value == 'deny') |
|
940 | + foreach ($perm_array as $permission => $value) { |
|
941 | + if ($value == 'on' || $value == 'deny') |
|
901 | 942 | { |
902 | 943 | // Don't allow people to escalate themselves! |
903 | 944 | if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) |
904 | 945 | continue; |
946 | + } |
|
905 | 947 | |
906 | 948 | $givePerms[$perm_type][] = array($_GET['group'], $permission, $value == 'deny' ? 0 : 1); |
907 | 949 | } |
@@ -946,8 +988,9 @@ discard block |
||
946 | 988 | ); |
947 | 989 | if (!empty($givePerms['board'])) |
948 | 990 | { |
949 | - foreach ($givePerms['board'] as $k => $v) |
|
950 | - $givePerms['board'][$k][] = $profileid; |
|
991 | + foreach ($givePerms['board'] as $k => $v) { |
|
992 | + $givePerms['board'][$k][] = $profileid; |
|
993 | + } |
|
951 | 994 | $smcFunc['db_insert']('replace', |
952 | 995 | '{db_prefix}board_permissions', |
953 | 996 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int', 'id_profile' => 'int'), |
@@ -988,8 +1031,9 @@ discard block |
||
988 | 1031 | |
989 | 1032 | call_integration_hook('integrate_modify_permission_settings', array(&$config_vars)); |
990 | 1033 | |
991 | - if ($return_config) |
|
992 | - return $config_vars; |
|
1034 | + if ($return_config) { |
|
1035 | + return $config_vars; |
|
1036 | + } |
|
993 | 1037 | |
994 | 1038 | $context['page_title'] = $txt['permission_settings_title']; |
995 | 1039 | $context['sub_template'] = 'show_settings'; |
@@ -1040,8 +1084,9 @@ discard block |
||
1040 | 1084 | 'min_posts' => -1, |
1041 | 1085 | ) |
1042 | 1086 | ); |
1043 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1044 | - $post_groups[] = $row['id_group']; |
|
1087 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1088 | + $post_groups[] = $row['id_group']; |
|
1089 | + } |
|
1045 | 1090 | $smcFunc['db_free_result']($request); |
1046 | 1091 | |
1047 | 1092 | // Remove'em. |
@@ -1250,16 +1295,19 @@ discard block |
||
1250 | 1295 | // Make sure we're not granting someone too many permissions! |
1251 | 1296 | foreach ($groupLevels['global'][$level] as $k => $permission) |
1252 | 1297 | { |
1253 | - if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) |
|
1254 | - unset($groupLevels['global'][$level][$k]); |
|
1298 | + if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) { |
|
1299 | + unset($groupLevels['global'][$level][$k]); |
|
1300 | + } |
|
1255 | 1301 | |
1256 | - if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
1257 | - unset($groupLevels['global'][$level][$k]); |
|
1302 | + if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
1303 | + unset($groupLevels['global'][$level][$k]); |
|
1304 | + } |
|
1258 | 1305 | } |
1259 | - if ($group == -1) |
|
1260 | - foreach ($groupLevels['board'][$level] as $k => $permission) |
|
1306 | + if ($group == -1) { |
|
1307 | + foreach ($groupLevels['board'][$level] as $k => $permission) |
|
1261 | 1308 | if (in_array($permission, $context['non_guest_permissions'])) |
1262 | 1309 | unset($groupLevels['board'][$level][$k]); |
1310 | + } |
|
1263 | 1311 | |
1264 | 1312 | // Reset all cached permissions. |
1265 | 1313 | updateSettings(array('settings_updated' => time())); |
@@ -1269,8 +1317,9 @@ discard block |
||
1269 | 1317 | { |
1270 | 1318 | $group = (int) $group; |
1271 | 1319 | |
1272 | - if (empty($groupLevels['global'][$level])) |
|
1273 | - return; |
|
1320 | + if (empty($groupLevels['global'][$level])) { |
|
1321 | + return; |
|
1322 | + } |
|
1274 | 1323 | |
1275 | 1324 | $smcFunc['db_query']('', ' |
1276 | 1325 | DELETE FROM {db_prefix}permissions |
@@ -1292,8 +1341,9 @@ discard block |
||
1292 | 1341 | ); |
1293 | 1342 | |
1294 | 1343 | $groupInserts = array(); |
1295 | - foreach ($groupLevels['global'][$level] as $permission) |
|
1296 | - $groupInserts[] = array($group, $permission); |
|
1344 | + foreach ($groupLevels['global'][$level] as $permission) { |
|
1345 | + $groupInserts[] = array($group, $permission); |
|
1346 | + } |
|
1297 | 1347 | |
1298 | 1348 | $smcFunc['db_insert']('insert', |
1299 | 1349 | '{db_prefix}permissions', |
@@ -1303,8 +1353,9 @@ discard block |
||
1303 | 1353 | ); |
1304 | 1354 | |
1305 | 1355 | $boardInserts = array(); |
1306 | - foreach ($groupLevels['board'][$level] as $permission) |
|
1307 | - $boardInserts[] = array(1, $group, $permission); |
|
1356 | + foreach ($groupLevels['board'][$level] as $permission) { |
|
1357 | + $boardInserts[] = array(1, $group, $permission); |
|
1358 | + } |
|
1308 | 1359 | |
1309 | 1360 | $smcFunc['db_insert']('insert', |
1310 | 1361 | '{db_prefix}board_permissions', |
@@ -1335,8 +1386,9 @@ discard block |
||
1335 | 1386 | if (!empty($groupLevels['board'][$level])) |
1336 | 1387 | { |
1337 | 1388 | $boardInserts = array(); |
1338 | - foreach ($groupLevels['board'][$level] as $permission) |
|
1339 | - $boardInserts[] = array($profile, $group, $permission); |
|
1389 | + foreach ($groupLevels['board'][$level] as $permission) { |
|
1390 | + $boardInserts[] = array($profile, $group, $permission); |
|
1391 | + } |
|
1340 | 1392 | |
1341 | 1393 | $smcFunc['db_insert']('insert', |
1342 | 1394 | '{db_prefix}board_permissions', |
@@ -1359,8 +1411,9 @@ discard block |
||
1359 | 1411 | ) |
1360 | 1412 | ); |
1361 | 1413 | |
1362 | - if (empty($boardLevels[$level])) |
|
1363 | - return; |
|
1414 | + if (empty($boardLevels[$level])) { |
|
1415 | + return; |
|
1416 | + } |
|
1364 | 1417 | |
1365 | 1418 | // Get all the groups... |
1366 | 1419 | $query = $smcFunc['db_query']('', ' |
@@ -1378,8 +1431,9 @@ discard block |
||
1378 | 1431 | $group = $row[0]; |
1379 | 1432 | |
1380 | 1433 | $boardInserts = array(); |
1381 | - foreach ($boardLevels[$level] as $permission) |
|
1382 | - $boardInserts[] = array($profile, $group, $permission); |
|
1434 | + foreach ($boardLevels[$level] as $permission) { |
|
1435 | + $boardInserts[] = array($profile, $group, $permission); |
|
1436 | + } |
|
1383 | 1437 | |
1384 | 1438 | $smcFunc['db_insert']('insert', |
1385 | 1439 | '{db_prefix}board_permissions', |
@@ -1392,8 +1446,9 @@ discard block |
||
1392 | 1446 | |
1393 | 1447 | // Add permissions for ungrouped members. |
1394 | 1448 | $boardInserts = array(); |
1395 | - foreach ($boardLevels[$level] as $permission) |
|
1396 | - $boardInserts[] = array($profile, 0, $permission); |
|
1449 | + foreach ($boardLevels[$level] as $permission) { |
|
1450 | + $boardInserts[] = array($profile, 0, $permission); |
|
1451 | + } |
|
1397 | 1452 | |
1398 | 1453 | $smcFunc['db_insert']('insert', |
1399 | 1454 | '{db_prefix}board_permissions', |
@@ -1403,9 +1458,10 @@ discard block |
||
1403 | 1458 | ); |
1404 | 1459 | } |
1405 | 1460 | // $profile and $group are both null! |
1406 | - else |
|
1407 | - fatal_lang_error('no_access', false); |
|
1408 | -} |
|
1461 | + else { |
|
1462 | + fatal_lang_error('no_access', false); |
|
1463 | + } |
|
1464 | + } |
|
1409 | 1465 | |
1410 | 1466 | /** |
1411 | 1467 | * Load permissions into $context['permissions']. |
@@ -1606,15 +1662,17 @@ discard block |
||
1606 | 1662 | foreach ($permissionList as $permission => $permissionArray) |
1607 | 1663 | { |
1608 | 1664 | // If this is a guest permission we don't do it if it's the guest group. |
1609 | - if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) |
|
1610 | - continue; |
|
1665 | + if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) { |
|
1666 | + continue; |
|
1667 | + } |
|
1611 | 1668 | |
1612 | 1669 | // What groups will this permission be in? |
1613 | 1670 | $own_group = $permissionArray[1]; |
1614 | 1671 | |
1615 | 1672 | // First, Do these groups actually exist - if not add them. |
1616 | - if (!isset($permissionGroups[$permissionType][$own_group])) |
|
1617 | - $permissionGroups[$permissionType][$own_group] = true; |
|
1673 | + if (!isset($permissionGroups[$permissionType][$own_group])) { |
|
1674 | + $permissionGroups[$permissionType][$own_group] = true; |
|
1675 | + } |
|
1618 | 1676 | |
1619 | 1677 | // What column should this be located into? |
1620 | 1678 | $position = !in_array($own_group, $leftPermissionGroups) ? 1 : 0; |
@@ -1622,8 +1680,8 @@ discard block |
||
1622 | 1680 | // If the groups have not yet been created be sure to create them. |
1623 | 1681 | $bothGroups = array('own' => $own_group); |
1624 | 1682 | |
1625 | - foreach ($bothGroups as $group) |
|
1626 | - if (!isset($context['permissions'][$permissionType]['columns'][$position][$group])) |
|
1683 | + foreach ($bothGroups as $group) { |
|
1684 | + if (!isset($context['permissions'][$permissionType]['columns'][$position][$group])) |
|
1627 | 1685 | $context['permissions'][$permissionType]['columns'][$position][$group] = array( |
1628 | 1686 | 'type' => $permissionType, |
1629 | 1687 | 'id' => $group, |
@@ -1633,6 +1691,7 @@ discard block |
||
1633 | 1691 | 'hidden' => false, |
1634 | 1692 | 'permissions' => array() |
1635 | 1693 | ); |
1694 | + } |
|
1636 | 1695 | |
1637 | 1696 | $context['permissions'][$permissionType]['columns'][$position][$own_group]['permissions'][$permission] = array( |
1638 | 1697 | 'id' => $permission, |
@@ -1657,27 +1716,30 @@ discard block |
||
1657 | 1716 | { |
1658 | 1717 | $context['hidden_permissions'][] = $permission . '_own'; |
1659 | 1718 | $context['hidden_permissions'][] = $permission . '_any'; |
1719 | + } else { |
|
1720 | + $context['hidden_permissions'][] = $permission; |
|
1660 | 1721 | } |
1661 | - else |
|
1662 | - $context['hidden_permissions'][] = $permission; |
|
1663 | 1722 | } |
1664 | 1723 | } |
1665 | 1724 | ksort($context['permissions'][$permissionType]['columns']); |
1666 | 1725 | |
1667 | 1726 | // Check we don't leave any empty groups - and mark hidden ones as such. |
1668 | - foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) |
|
1669 | - foreach ($groups as $id => $group) |
|
1727 | + foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) { |
|
1728 | + foreach ($groups as $id => $group) |
|
1670 | 1729 | { |
1671 | 1730 | if (empty($group['permissions'])) |
1672 | 1731 | unset($context['permissions'][$permissionType]['columns'][$column][$id]); |
1732 | + } |
|
1673 | 1733 | else |
1674 | 1734 | { |
1675 | 1735 | $foundNonHidden = false; |
1676 | - foreach ($group['permissions'] as $permission) |
|
1677 | - if (empty($permission['hidden'])) |
|
1736 | + foreach ($group['permissions'] as $permission) { |
|
1737 | + if (empty($permission['hidden'])) |
|
1678 | 1738 | $foundNonHidden = true; |
1679 | - if (!$foundNonHidden) |
|
1680 | - $context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true; |
|
1739 | + } |
|
1740 | + if (!$foundNonHidden) { |
|
1741 | + $context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true; |
|
1742 | + } |
|
1681 | 1743 | } |
1682 | 1744 | } |
1683 | 1745 | } |
@@ -1704,12 +1766,13 @@ discard block |
||
1704 | 1766 | $context['can_change_permissions'] = allowedTo('manage_permissions'); |
1705 | 1767 | |
1706 | 1768 | // Nothing to initialize here. |
1707 | - if (!$context['can_change_permissions']) |
|
1708 | - return; |
|
1769 | + if (!$context['can_change_permissions']) { |
|
1770 | + return; |
|
1771 | + } |
|
1709 | 1772 | |
1710 | 1773 | // Load the permission settings for guests |
1711 | - foreach ($permissions as $permission) |
|
1712 | - $context[$permission] = array( |
|
1774 | + foreach ($permissions as $permission) { |
|
1775 | + $context[$permission] = array( |
|
1713 | 1776 | -1 => array( |
1714 | 1777 | 'id' => -1, |
1715 | 1778 | 'name' => $txt['membergroups_guests'], |
@@ -1723,6 +1786,7 @@ discard block |
||
1723 | 1786 | 'status' => 'off', |
1724 | 1787 | ), |
1725 | 1788 | ); |
1789 | + } |
|
1726 | 1790 | |
1727 | 1791 | $request = $smcFunc['db_query']('', ' |
1728 | 1792 | SELECT id_group, CASE WHEN add_deny = {int:denied} THEN {string:deny} ELSE {string:on} END AS status, permission |
@@ -1736,8 +1800,9 @@ discard block |
||
1736 | 1800 | 'on' => 'on', |
1737 | 1801 | ) |
1738 | 1802 | ); |
1739 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1740 | - $context[$row['permission']][$row['id_group']]['status'] = $row['status']; |
|
1803 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1804 | + $context[$row['permission']][$row['id_group']]['status'] = $row['status']; |
|
1805 | + } |
|
1741 | 1806 | $smcFunc['db_free_result']($request); |
1742 | 1807 | |
1743 | 1808 | $request = $smcFunc['db_query']('', ' |
@@ -1758,14 +1823,15 @@ discard block |
||
1758 | 1823 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1759 | 1824 | { |
1760 | 1825 | // Initialize each permission as being 'off' until proven otherwise. |
1761 | - foreach ($permissions as $permission) |
|
1762 | - if (!isset($context[$permission][$row['id_group']])) |
|
1826 | + foreach ($permissions as $permission) { |
|
1827 | + if (!isset($context[$permission][$row['id_group']])) |
|
1763 | 1828 | $context[$permission][$row['id_group']] = array( |
1764 | 1829 | 'id' => $row['id_group'], |
1765 | 1830 | 'name' => $row['group_name'], |
1766 | 1831 | 'is_postgroup' => $row['min_posts'] != -1, |
1767 | 1832 | 'status' => 'off', |
1768 | 1833 | ); |
1834 | + } |
|
1769 | 1835 | |
1770 | 1836 | $context[$row['permission']][$row['id_group']]['status'] = empty($row['status']) ? 'deny' : ($row['status'] == 1 ? 'on' : 'off'); |
1771 | 1837 | } |
@@ -1779,8 +1845,9 @@ discard block |
||
1779 | 1845 | { |
1780 | 1846 | foreach ($permissions as $permission) |
1781 | 1847 | { |
1782 | - if (isset($context[$permission][$group])) |
|
1783 | - unset($context[$permission][$group]); |
|
1848 | + if (isset($context[$permission][$group])) { |
|
1849 | + unset($context[$permission][$group]); |
|
1850 | + } |
|
1784 | 1851 | } |
1785 | 1852 | } |
1786 | 1853 | |
@@ -1788,8 +1855,9 @@ discard block |
||
1788 | 1855 | $non_guest_perms = array_intersect(str_replace(array('_any', '_own'), '', $permissions), $context['non_guest_permissions']); |
1789 | 1856 | foreach ($non_guest_perms as $permission) |
1790 | 1857 | { |
1791 | - if (isset($context[$permission][-1])) |
|
1792 | - unset($context[$permission][-1]); |
|
1858 | + if (isset($context[$permission][-1])) { |
|
1859 | + unset($context[$permission][-1]); |
|
1860 | + } |
|
1793 | 1861 | } |
1794 | 1862 | |
1795 | 1863 | // Create the token for the separate inline permission verification. |
@@ -1824,8 +1892,9 @@ discard block |
||
1824 | 1892 | global $context, $smcFunc; |
1825 | 1893 | |
1826 | 1894 | // No permissions? Not a great deal to do here. |
1827 | - if (!allowedTo('manage_permissions')) |
|
1828 | - return; |
|
1895 | + if (!allowedTo('manage_permissions')) { |
|
1896 | + return; |
|
1897 | + } |
|
1829 | 1898 | |
1830 | 1899 | // Almighty session check, verify our ways. |
1831 | 1900 | checkSession(); |
@@ -1837,13 +1906,15 @@ discard block |
||
1837 | 1906 | $insertRows = array(); |
1838 | 1907 | foreach ($permissions as $permission) |
1839 | 1908 | { |
1840 | - if (!isset($_POST[$permission])) |
|
1841 | - continue; |
|
1909 | + if (!isset($_POST[$permission])) { |
|
1910 | + continue; |
|
1911 | + } |
|
1842 | 1912 | |
1843 | 1913 | foreach ($_POST[$permission] as $id_group => $value) |
1844 | 1914 | { |
1845 | - if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) |
|
1846 | - $insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0); |
|
1915 | + if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) { |
|
1916 | + $insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0); |
|
1917 | + } |
|
1847 | 1918 | } |
1848 | 1919 | } |
1849 | 1920 | |
@@ -1859,13 +1930,14 @@ discard block |
||
1859 | 1930 | ); |
1860 | 1931 | |
1861 | 1932 | // ...and replace them with new ones. |
1862 | - if (!empty($insertRows)) |
|
1863 | - $smcFunc['db_insert']('insert', |
|
1933 | + if (!empty($insertRows)) { |
|
1934 | + $smcFunc['db_insert']('insert', |
|
1864 | 1935 | '{db_prefix}permissions', |
1865 | 1936 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
1866 | 1937 | $insertRows, |
1867 | 1938 | array('id_group', 'permission') |
1868 | 1939 | ); |
1940 | + } |
|
1869 | 1941 | |
1870 | 1942 | // Do a full child update. |
1871 | 1943 | updateChildPermissions(array(), -1); |
@@ -1892,10 +1964,11 @@ discard block |
||
1892 | 1964 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1893 | 1965 | { |
1894 | 1966 | // Format the label nicely. |
1895 | - if (isset($txt['permissions_profile_' . $row['profile_name']])) |
|
1896 | - $name = $txt['permissions_profile_' . $row['profile_name']]; |
|
1897 | - else |
|
1898 | - $name = $row['profile_name']; |
|
1967 | + if (isset($txt['permissions_profile_' . $row['profile_name']])) { |
|
1968 | + $name = $txt['permissions_profile_' . $row['profile_name']]; |
|
1969 | + } else { |
|
1970 | + $name = $row['profile_name']; |
|
1971 | + } |
|
1899 | 1972 | |
1900 | 1973 | $context['profiles'][$row['id_profile']] = array( |
1901 | 1974 | 'id' => $row['id_profile'], |
@@ -1950,17 +2023,19 @@ discard block |
||
1950 | 2023 | ) |
1951 | 2024 | ); |
1952 | 2025 | $inserts = array(); |
1953 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1954 | - $inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']); |
|
2026 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2027 | + $inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']); |
|
2028 | + } |
|
1955 | 2029 | $smcFunc['db_free_result']($request); |
1956 | 2030 | |
1957 | - if (!empty($inserts)) |
|
1958 | - $smcFunc['db_insert']('insert', |
|
2031 | + if (!empty($inserts)) { |
|
2032 | + $smcFunc['db_insert']('insert', |
|
1959 | 2033 | '{db_prefix}board_permissions', |
1960 | 2034 | array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
1961 | 2035 | $inserts, |
1962 | 2036 | array('id_profile', 'id_group', 'permission') |
1963 | 2037 | ); |
2038 | + } |
|
1964 | 2039 | } |
1965 | 2040 | // Renaming? |
1966 | 2041 | elseif (isset($_POST['rename'])) |
@@ -1969,16 +2044,16 @@ discard block |
||
1969 | 2044 | validateToken('admin-mpp'); |
1970 | 2045 | |
1971 | 2046 | // Just showing the boxes? |
1972 | - if (!isset($_POST['rename_profile'])) |
|
1973 | - $context['show_rename_boxes'] = true; |
|
1974 | - else |
|
2047 | + if (!isset($_POST['rename_profile'])) { |
|
2048 | + $context['show_rename_boxes'] = true; |
|
2049 | + } else |
|
1975 | 2050 | { |
1976 | 2051 | foreach ($_POST['rename_profile'] as $id => $value) |
1977 | 2052 | { |
1978 | 2053 | $value = $smcFunc['htmlspecialchars']($value); |
1979 | 2054 | |
1980 | - if (trim($value) != '' && $id > 4) |
|
1981 | - $smcFunc['db_query']('', ' |
|
2055 | + if (trim($value) != '' && $id > 4) { |
|
2056 | + $smcFunc['db_query']('', ' |
|
1982 | 2057 | UPDATE {db_prefix}permission_profiles |
1983 | 2058 | SET profile_name = {string:profile_name} |
1984 | 2059 | WHERE id_profile = {int:current_profile}', |
@@ -1987,6 +2062,7 @@ discard block |
||
1987 | 2062 | 'profile_name' => $value, |
1988 | 2063 | ) |
1989 | 2064 | ); |
2065 | + } |
|
1990 | 2066 | } |
1991 | 2067 | } |
1992 | 2068 | } |
@@ -1997,9 +2073,10 @@ discard block |
||
1997 | 2073 | validateToken('admin-mpp'); |
1998 | 2074 | |
1999 | 2075 | $profiles = array(); |
2000 | - foreach ($_POST['delete_profile'] as $profile) |
|
2001 | - if ($profile > 4) |
|
2076 | + foreach ($_POST['delete_profile'] as $profile) { |
|
2077 | + if ($profile > 4) |
|
2002 | 2078 | $profiles[] = (int) $profile; |
2079 | + } |
|
2003 | 2080 | |
2004 | 2081 | // Verify it's not in use... |
2005 | 2082 | $request = $smcFunc['db_query']('', ' |
@@ -2011,8 +2088,9 @@ discard block |
||
2011 | 2088 | 'profile_list' => $profiles, |
2012 | 2089 | ) |
2013 | 2090 | ); |
2014 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
2015 | - fatal_lang_error('no_access', false); |
|
2091 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
2092 | + fatal_lang_error('no_access', false); |
|
2093 | + } |
|
2016 | 2094 | $smcFunc['db_free_result']($request); |
2017 | 2095 | |
2018 | 2096 | // Oh well, delete. |
@@ -2036,10 +2114,11 @@ discard block |
||
2036 | 2114 | array( |
2037 | 2115 | ) |
2038 | 2116 | ); |
2039 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2040 | - if (isset($context['profiles'][$row['id_profile']])) |
|
2117 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2118 | + if (isset($context['profiles'][$row['id_profile']])) |
|
2041 | 2119 | { |
2042 | 2120 | $context['profiles'][$row['id_profile']]['in_use'] = true; |
2121 | + } |
|
2043 | 2122 | $context['profiles'][$row['id_profile']]['boards'] = $row['board_count']; |
2044 | 2123 | $context['profiles'][$row['id_profile']]['boards_text'] = $row['board_count'] > 1 ? sprintf($txt['permissions_profile_used_by_many'], $row['board_count']) : $txt['permissions_profile_used_by_' . ($row['board_count'] ? 'one' : 'none')]; |
2045 | 2124 | } |
@@ -2051,8 +2130,9 @@ discard block |
||
2051 | 2130 | { |
2052 | 2131 | // Can't delete special ones. |
2053 | 2132 | $context['profiles'][$id]['can_edit'] = isset($txt['permissions_profile_' . $profile['unformatted_name']]) ? false : true; |
2054 | - if ($context['profiles'][$id]['can_edit']) |
|
2055 | - $context['can_edit_something'] = true; |
|
2133 | + if ($context['profiles'][$id]['can_edit']) { |
|
2134 | + $context['can_edit_something'] = true; |
|
2135 | + } |
|
2056 | 2136 | |
2057 | 2137 | // You can only delete it if you can edit it AND it's not in use. |
2058 | 2138 | $context['profiles'][$id]['can_delete'] = $context['profiles'][$id]['can_edit'] && empty($profile['in_use']) ? true : false; |
@@ -2073,8 +2153,9 @@ discard block |
||
2073 | 2153 | global $smcFunc; |
2074 | 2154 | |
2075 | 2155 | // All the parent groups to sort out. |
2076 | - if (!is_array($parents)) |
|
2077 | - $parents = array($parents); |
|
2156 | + if (!is_array($parents)) { |
|
2157 | + $parents = array($parents); |
|
2158 | + } |
|
2078 | 2159 | |
2079 | 2160 | // Find all the children of this group. |
2080 | 2161 | $request = $smcFunc['db_query']('', ' |
@@ -2101,8 +2182,9 @@ discard block |
||
2101 | 2182 | $parents = array_unique($parents); |
2102 | 2183 | |
2103 | 2184 | // Not a sausage, or a child? |
2104 | - if (empty($children)) |
|
2105 | - return false; |
|
2185 | + if (empty($children)) { |
|
2186 | + return false; |
|
2187 | + } |
|
2106 | 2188 | |
2107 | 2189 | // First off, are we doing general permissions? |
2108 | 2190 | if ($profile < 1 || $profile === null) |
@@ -2117,9 +2199,10 @@ discard block |
||
2117 | 2199 | ) |
2118 | 2200 | ); |
2119 | 2201 | $permissions = array(); |
2120 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2121 | - foreach ($children[$row['id_group']] as $child) |
|
2202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2203 | + foreach ($children[$row['id_group']] as $child) |
|
2122 | 2204 | $permissions[] = array($child, $row['permission'], $row['add_deny']); |
2205 | + } |
|
2123 | 2206 | $smcFunc['db_free_result']($request); |
2124 | 2207 | |
2125 | 2208 | $smcFunc['db_query']('', ' |
@@ -2159,9 +2242,10 @@ discard block |
||
2159 | 2242 | ) |
2160 | 2243 | ); |
2161 | 2244 | $permissions = array(); |
2162 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2163 | - foreach ($children[$row['id_group']] as $child) |
|
2245 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2246 | + foreach ($children[$row['id_group']] as $child) |
|
2164 | 2247 | $permissions[] = array($child, $row['id_profile'], $row['permission'], $row['add_deny']); |
2248 | + } |
|
2165 | 2249 | $smcFunc['db_free_result']($request); |
2166 | 2250 | |
2167 | 2251 | $smcFunc['db_query']('', ' |
@@ -2195,12 +2279,15 @@ discard block |
||
2195 | 2279 | global $context; |
2196 | 2280 | |
2197 | 2281 | $context['illegal_permissions'] = array(); |
2198 | - if (!allowedTo('admin_forum')) |
|
2199 | - $context['illegal_permissions'][] = 'admin_forum'; |
|
2200 | - if (!allowedTo('manage_membergroups')) |
|
2201 | - $context['illegal_permissions'][] = 'manage_membergroups'; |
|
2202 | - if (!allowedTo('manage_permissions')) |
|
2203 | - $context['illegal_permissions'][] = 'manage_permissions'; |
|
2282 | + if (!allowedTo('admin_forum')) { |
|
2283 | + $context['illegal_permissions'][] = 'admin_forum'; |
|
2284 | + } |
|
2285 | + if (!allowedTo('manage_membergroups')) { |
|
2286 | + $context['illegal_permissions'][] = 'manage_membergroups'; |
|
2287 | + } |
|
2288 | + if (!allowedTo('manage_permissions')) { |
|
2289 | + $context['illegal_permissions'][] = 'manage_permissions'; |
|
2290 | + } |
|
2204 | 2291 | |
2205 | 2292 | call_integration_hook('integrate_load_illegal_permissions'); |
2206 | 2293 | } |
@@ -2349,16 +2436,17 @@ discard block |
||
2349 | 2436 | 'attachment' => 'disallow', |
2350 | 2437 | 'children' => array(), |
2351 | 2438 | ); |
2439 | + } elseif (isset($context['profile_groups'][$row['id_parent']])) { |
|
2440 | + $context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name']; |
|
2352 | 2441 | } |
2353 | - elseif (isset($context['profile_groups'][$row['id_parent']])) |
|
2354 | - $context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name']; |
|
2355 | 2442 | } |
2356 | 2443 | $smcFunc['db_free_result']($request); |
2357 | 2444 | |
2358 | 2445 | // What are the permissions we are querying? |
2359 | 2446 | $all_permissions = array(); |
2360 | - foreach ($mappings as $perm_set) |
|
2361 | - $all_permissions = array_merge($all_permissions, $perm_set); |
|
2447 | + foreach ($mappings as $perm_set) { |
|
2448 | + $all_permissions = array_merge($all_permissions, $perm_set); |
|
2449 | + } |
|
2362 | 2450 | |
2363 | 2451 | // If we're saving the changes then do just that - save them. |
2364 | 2452 | if (!empty($_POST['save_changes']) && ($context['current_profile'] == 1 || $context['current_profile'] > 4)) |
@@ -2373,8 +2461,7 @@ discard block |
||
2373 | 2461 | { |
2374 | 2462 | // Turning it on. This seems easy enough. |
2375 | 2463 | updateSettings(array('postmod_active' => 1)); |
2376 | - } |
|
2377 | - else |
|
2464 | + } else |
|
2378 | 2465 | { |
2379 | 2466 | // Turning it off. Not so straightforward. We have to turn off warnings to moderation level, and make everything approved. |
2380 | 2467 | updateSettings(array( |
@@ -2385,8 +2472,7 @@ discard block |
||
2385 | 2472 | require_once($sourcedir . '/PostModeration.php'); |
2386 | 2473 | approveAllData(); |
2387 | 2474 | } |
2388 | - } |
|
2389 | - elseif ($modSettings['postmod_active']) |
|
2475 | + } elseif ($modSettings['postmod_active']) |
|
2390 | 2476 | { |
2391 | 2477 | // We're not saving a new setting - and if it's still enabled we have more work to do. |
2392 | 2478 | |
@@ -2416,21 +2502,22 @@ discard block |
||
2416 | 2502 | // Give them both sets for fun. |
2417 | 2503 | $new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1); |
2418 | 2504 | $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
2505 | + } elseif ($_POST[$index][$group['id']] == 'moderate') { |
|
2506 | + $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
|
2419 | 2507 | } |
2420 | - elseif ($_POST[$index][$group['id']] == 'moderate') |
|
2421 | - $new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1); |
|
2422 | 2508 | } |
2423 | 2509 | } |
2424 | 2510 | } |
2425 | 2511 | |
2426 | 2512 | // Insert new permissions. |
2427 | - if (!empty($new_permissions)) |
|
2428 | - $smcFunc['db_insert']('', |
|
2513 | + if (!empty($new_permissions)) { |
|
2514 | + $smcFunc['db_insert']('', |
|
2429 | 2515 | '{db_prefix}board_permissions', |
2430 | 2516 | array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
2431 | 2517 | $new_permissions, |
2432 | 2518 | array('id_profile', 'id_group', 'permission') |
2433 | 2519 | ); |
2520 | + } |
|
2434 | 2521 | } |
2435 | 2522 | } |
2436 | 2523 | |
@@ -2459,11 +2546,13 @@ discard block |
||
2459 | 2546 | if ($row['add_deny']) |
2460 | 2547 | { |
2461 | 2548 | // Full allowance? |
2462 | - if ($index == 0) |
|
2463 | - $context['profile_groups'][$row['id_group']][$key] = 'allow'; |
|
2549 | + if ($index == 0) { |
|
2550 | + $context['profile_groups'][$row['id_group']][$key] = 'allow'; |
|
2551 | + } |
|
2464 | 2552 | // Otherwise only bother with moderate if not on allow. |
2465 | - elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') |
|
2466 | - $context['profile_groups'][$row['id_group']][$key] = 'moderate'; |
|
2553 | + elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') { |
|
2554 | + $context['profile_groups'][$row['id_group']][$key] = 'moderate'; |
|
2555 | + } |
|
2467 | 2556 | } |
2468 | 2557 | } |
2469 | 2558 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest posts of a forum. |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | censorText($row['body']); |
60 | 61 | |
61 | 62 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
62 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
63 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
63 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
64 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // Build the array. |
66 | 68 | $posts[] = array( |