Completed
Push — release-2.1 ( 4bdd41...11eb43 )
by Mathias
07:36
created
Sources/Load.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2259,9 +2259,9 @@  discard block
 block discarded – undo
2259 2259
  *
2260 2260
  * @uses the template_include() function to include the file.
2261 2261
  * @param string $template_name The name of the template to load
2262
- * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load
2262
+ * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load
2263 2263
  * @param bool $fatal If true, dies with an error message if the template cannot be found
2264
- * @return boolean Whether or not the template was loaded
2264
+ * @return boolean|null Whether or not the template was loaded
2265 2265
  */
2266 2266
 function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
2267 2267
 {
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
  * - all code added with this function is added to the same <style> tag so do make sure your css is valid!
2445 2445
  *
2446 2446
  * @param string $css Some css code
2447
- * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified
2447
+ * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified
2448 2448
  */
2449 2449
 function addInlineCss($css)
2450 2450
 {
@@ -2558,7 +2558,7 @@  discard block
 block discarded – undo
2558 2558
  *
2559 2559
  * @param string $javascript Some JS code
2560 2560
  * @param bool $defer Whether the script should load in <head> or before the closing <html> tag
2561
- * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified
2561
+ * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified
2562 2562
  */
2563 2563
 function addInlineJavaScript($javascript, $defer = false)
2564 2564
 {
@@ -2791,7 +2791,7 @@  discard block
 block discarded – undo
2791 2791
  * It will try to choose only utf8 or non-utf8 languages.
2792 2792
  *
2793 2793
  * @param bool $use_cache Whether or not to use the cache
2794
- * @return array An array of information about available languages
2794
+ * @return string An array of information about available languages
2795 2795
  */
2796 2796
 function getLanguages($use_cache = true)
2797 2797
 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1719,7 +1719,7 @@
 block discarded – undo
1719 1719
 		$id_theme = $modSettings['theme_guests'];
1720 1720
 
1721 1721
 	// We already load the basic stuff?
1722
-	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme )
1722
+	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme)
1723 1723
 	{
1724 1724
 		// Verify the id_theme... no foul play.
1725 1725
 		// Always allow the board specific theme, if they are overriding.
Please login to merge, or discard this patch.
Braces   +785 added lines, -595 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
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
  * Load the $modSettings array.
@@ -25,13 +26,14 @@  discard block
 block discarded – undo
25 26
 	global $cache_enable, $sourcedir, $context;
26 27
 
27 28
 	// Most database systems have not set UTF-8 as their default input charset.
28
-	if (!empty($db_character_set))
29
-		$smcFunc['db_query']('', '
29
+	if (!empty($db_character_set)) {
30
+			$smcFunc['db_query']('', '
30 31
 			SET NAMES {string:db_character_set}',
31 32
 			array(
32 33
 				'db_character_set' => $db_character_set,
33 34
 			)
34 35
 		);
36
+	}
35 37
 
36 38
 	// We need some caching support, maybe.
37 39
 	loadCacheAccelerator();
@@ -46,28 +48,36 @@  discard block
 block discarded – undo
46 48
 			)
47 49
 		);
48 50
 		$modSettings = array();
49
-		if (!$request)
50
-			display_db_error();
51
-		while ($row = $smcFunc['db_fetch_row']($request))
52
-			$modSettings[$row[0]] = $row[1];
51
+		if (!$request) {
52
+					display_db_error();
53
+		}
54
+		while ($row = $smcFunc['db_fetch_row']($request)) {
55
+					$modSettings[$row[0]] = $row[1];
56
+		}
53 57
 		$smcFunc['db_free_result']($request);
54 58
 
55 59
 		// Do a few things to protect against missing settings or settings with invalid values...
56
-		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
57
-			$modSettings['defaultMaxTopics'] = 20;
58
-		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
59
-			$modSettings['defaultMaxMessages'] = 15;
60
-		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
61
-			$modSettings['defaultMaxMembers'] = 30;
62
-		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
63
-			$modSettings['defaultMaxListItems'] = 15;
60
+		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
61
+					$modSettings['defaultMaxTopics'] = 20;
62
+		}
63
+		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
64
+					$modSettings['defaultMaxMessages'] = 15;
65
+		}
66
+		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
67
+					$modSettings['defaultMaxMembers'] = 30;
68
+		}
69
+		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) {
70
+					$modSettings['defaultMaxListItems'] = 15;
71
+		}
64 72
 
65 73
 		// We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded.
66
-		if (!is_array($modSettings['attachmentUploadDir']))
67
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
74
+		if (!is_array($modSettings['attachmentUploadDir'])) {
75
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
76
+		}
68 77
 
69
-		if (!empty($cache_enable))
70
-			cache_put_data('modSettings', $modSettings, 90);
78
+		if (!empty($cache_enable)) {
79
+					cache_put_data('modSettings', $modSettings, 90);
80
+		}
71 81
 	}
72 82
 
73 83
 	$modSettings['cache_enable'] = $cache_enable;
@@ -87,8 +97,9 @@  discard block
 block discarded – undo
87 97
 		};
88 98
 	$fix_utf8mb4 = function($string) use ($utf8, $smcFunc)
89 99
 	{
90
-		if (!$utf8 || $smcFunc['db_mb4'])
91
-			return $string;
100
+		if (!$utf8 || $smcFunc['db_mb4']) {
101
+					return $string;
102
+		}
92 103
 
93 104
 		$i = 0;
94 105
 		$len = strlen($string);
@@ -100,18 +111,15 @@  discard block
 block discarded – undo
100 111
 			{
101 112
 				$new_string .= $string[$i];
102 113
 				$i++;
103
-			}
104
-			elseif ($ord < 224)
114
+			} elseif ($ord < 224)
105 115
 			{
106 116
 				$new_string .= $string[$i] . $string[$i + 1];
107 117
 				$i += 2;
108
-			}
109
-			elseif ($ord < 240)
118
+			} elseif ($ord < 240)
110 119
 			{
111 120
 				$new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2];
112 121
 				$i += 3;
113
-			}
114
-			elseif ($ord < 248)
122
+			} elseif ($ord < 248)
115 123
 			{
116 124
 				// Magic happens.
117 125
 				$val = (ord($string[$i]) & 0x07) << 18;
@@ -155,8 +163,7 @@  discard block
 block discarded – undo
155 163
 			{
156 164
 				$result = array_search($needle, array_slice($haystack_arr, $offset));
157 165
 				return is_int($result) ? $result + $offset : false;
158
-			}
159
-			else
166
+			} else
160 167
 			{
161 168
 				$needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|&quot;|&amp;|&lt;|&gt;|&nbsp;|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
162 169
 				$needle_size = count($needle_arr);
@@ -165,8 +172,9 @@  discard block
 block discarded – undo
165 172
 				while ((int) $result === $result)
166 173
 				{
167 174
 					$offset += $result;
168
-					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
169
-						return $offset;
175
+					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) {
176
+											return $offset;
177
+					}
170 178
 					$result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset));
171 179
 				}
172 180
 				return false;
@@ -204,8 +212,9 @@  discard block
 block discarded – undo
204 212
 			$string = $ent_check($string);
205 213
 			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches);
206 214
 			$string = $matches[0];
207
-			while (strlen($string) > $length)
208
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
215
+			while (strlen($string) > $length) {
216
+							$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
217
+			}
209 218
 			return $string;
210 219
 		},
211 220
 		'ucfirst' => $utf8 ? function($string) use (&$smcFunc)
@@ -215,8 +224,9 @@  discard block
 block discarded – undo
215 224
 		'ucwords' => $utf8 ? function($string) use (&$smcFunc)
216 225
 		{
217 226
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
218
-			for ($i = 0, $n = count($words); $i < $n; $i += 2)
219
-				$words[$i] = $smcFunc['ucfirst']($words[$i]);
227
+			for ($i = 0, $n = count($words); $i < $n; $i += 2) {
228
+							$words[$i] = $smcFunc['ucfirst']($words[$i]);
229
+			}
220 230
 			return implode('', $words);
221 231
 		} : 'ucwords',
222 232
 		'json_decode' => 'smf_json_decode',
@@ -224,16 +234,17 @@  discard block
 block discarded – undo
224 234
 	);
225 235
 
226 236
 	// Setting the timezone is a requirement for some functions.
227
-	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list()))
228
-		date_default_timezone_set($modSettings['default_timezone']);
229
-	else
237
+	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) {
238
+			date_default_timezone_set($modSettings['default_timezone']);
239
+	} else
230 240
 	{
231 241
 		// Get PHP's default timezone, if set
232 242
 		$ini_tz = ini_get('date.timezone');
233
-		if (!empty($ini_tz))
234
-			$modSettings['default_timezone'] = $ini_tz;
235
-		else
236
-			$modSettings['default_timezone'] = '';
243
+		if (!empty($ini_tz)) {
244
+					$modSettings['default_timezone'] = $ini_tz;
245
+		} else {
246
+					$modSettings['default_timezone'] = '';
247
+		}
237 248
 
238 249
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
239 250
 		if (!in_array($modSettings['default_timezone'], timezone_identifiers_list()))
@@ -251,22 +262,26 @@  discard block
 block discarded – undo
251 262
 		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
252 263
 		{
253 264
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
254
-			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
255
-				$modSettings['load_average'] = (float) $matches[1];
256
-			elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0)
257
-				$modSettings['load_average'] = (float) $matches[1];
258
-			else
259
-				unset($modSettings['load_average']);
265
+			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
266
+							$modSettings['load_average'] = (float) $matches[1];
267
+			} elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) {
268
+							$modSettings['load_average'] = (float) $matches[1];
269
+			} else {
270
+							unset($modSettings['load_average']);
271
+			}
260 272
 
261
-			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
262
-				cache_put_data('loadavg', $modSettings['load_average'], 90);
273
+			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
274
+							cache_put_data('loadavg', $modSettings['load_average'], 90);
275
+			}
263 276
 		}
264 277
 
265
-		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
266
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
278
+		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
279
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
280
+		}
267 281
 
268
-		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum'])
269
-			display_loadavg_error();
282
+		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
283
+					display_loadavg_error();
284
+		}
270 285
 	}
271 286
 
272 287
 	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
@@ -287,8 +302,9 @@  discard block
 block discarded – undo
287 302
 	if (defined('SMF_INTEGRATION_SETTINGS'))
288 303
 	{
289 304
 		$integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true);
290
-		foreach ($integration_settings as $hook => $function)
291
-			add_integration_function($hook, $function, '', false);
305
+		foreach ($integration_settings as $hook => $function) {
306
+					add_integration_function($hook, $function, '', false);
307
+		}
292 308
 	}
293 309
 
294 310
 	// Any files to pre include?
@@ -298,8 +314,9 @@  discard block
 block discarded – undo
298 314
 		foreach ($pre_includes as $include)
299 315
 		{
300 316
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
301
-			if (file_exists($include))
302
-				require_once($include);
317
+			if (file_exists($include)) {
318
+							require_once($include);
319
+			}
303 320
 		}
304 321
 	}
305 322
 
@@ -403,27 +420,28 @@  discard block
 block discarded – undo
403 420
 				break;
404 421
 			}
405 422
 		}
423
+	} else {
424
+			$id_member = 0;
406 425
 	}
407
-	else
408
-		$id_member = 0;
409 426
 
410 427
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
411 428
 	{
412 429
 		$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
413 430
 
414
-		if (empty($cookie_data))
415
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
431
+		if (empty($cookie_data)) {
432
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
433
+		}
416 434
 
417 435
 		list ($id_member, $password) = $cookie_data;
418 436
 		$id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;
419
-	}
420
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
437
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
421 438
 	{
422 439
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
423 440
 		$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
424 441
 
425
-		if (empty($cookie_data))
426
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
442
+		if (empty($cookie_data)) {
443
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
444
+		}
427 445
 
428 446
 		list ($id_member, $password, $login_span) = $cookie_data;
429 447
 		$id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0;
@@ -448,24 +466,28 @@  discard block
 block discarded – undo
448 466
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
449 467
 			$smcFunc['db_free_result']($request);
450 468
 
451
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false)
452
-				$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
469
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) {
470
+							$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
471
+			}
453 472
 
454
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
455
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
473
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
474
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
475
+			}
456 476
 		}
457 477
 
458 478
 		// Did we find 'im?  If not, junk it.
459 479
 		if (!empty($user_settings))
460 480
 		{
461 481
 			// As much as the password should be right, we can assume the integration set things up.
462
-			if (!empty($already_verified) && $already_verified === true)
463
-				$check = true;
482
+			if (!empty($already_verified) && $already_verified === true) {
483
+							$check = true;
484
+			}
464 485
 			// SHA-512 hash should be 128 characters long.
465
-			elseif (strlen($password) == 128)
466
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
467
-			else
468
-				$check = false;
486
+			elseif (strlen($password) == 128) {
487
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
488
+			} else {
489
+							$check = false;
490
+			}
469 491
 
470 492
 			// Wrong password or not activated - either way, you're going nowhere.
471 493
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
@@ -474,9 +496,9 @@  discard block
 block discarded – undo
474 496
 				setLoginCookie(-3600, 0);
475 497
 				$user_settings = array();
476 498
 			}
499
+		} else {
500
+					$id_member = 0;
477 501
 		}
478
-		else
479
-			$id_member = 0;
480 502
 
481 503
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
482 504
 		if (!empty($id_member))
@@ -505,8 +527,9 @@  discard block
 block discarded – undo
505 527
 
506 528
 					list ($tfamember, $tfasecret) = $tfa_data;
507 529
 
508
-					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member)
509
-						$tfasecret = null;
530
+					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) {
531
+											$tfasecret = null;
532
+					}
510 533
 				}
511 534
 
512 535
 				if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret)
@@ -526,10 +549,12 @@  discard block
 block discarded – undo
526 549
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
527 550
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
528 551
 		{
529
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
552
+			if ($modSettings['tfa_mode'] == 2) {
553
+				//only do this if we are just forcing SOME membergroups
530 554
 			{
531 555
 				//Build an array of ALL user membergroups.
532 556
 				$full_groups = array($user_settings['id_group']);
557
+			}
533 558
 				if (!empty($user_settings['additional_groups']))
534 559
 				{
535 560
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -549,17 +574,18 @@  discard block
 block discarded – undo
549 574
 				);
550 575
 				$row = $smcFunc['db_fetch_assoc']($request);
551 576
 				$smcFunc['db_free_result']($request);
577
+			} else {
578
+							$row['total'] = 1;
552 579
 			}
553
-			else
554
-				$row['total'] = 1; //simplifies logics in the next "if"
580
+			//simplifies logics in the next "if"
555 581
 
556 582
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
557 583
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
558 584
 
559
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
560
-				redirectexit('action=profile;area=tfasetup;forced');
561
-		}
562
-		else if (!empty($user_settings) && empty($id_member))
585
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
586
+							redirectexit('action=profile;area=tfasetup;forced');
587
+			}
588
+		} else if (!empty($user_settings) && empty($id_member))
563 589
 		{
564 590
 			$user_settings = array();
565 591
 		}
@@ -598,33 +624,37 @@  discard block
 block discarded – undo
598 624
 				updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
599 625
 				$user_settings['last_login'] = time();
600 626
 
601
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
602
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
627
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
628
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
629
+				}
603 630
 
604
-				if (!empty($modSettings['cache_enable']))
605
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
631
+				if (!empty($modSettings['cache_enable'])) {
632
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
633
+				}
606 634
 			}
635
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
636
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
607 637
 		}
608
-		elseif (empty($_SESSION['id_msg_last_visit']))
609
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
610 638
 
611 639
 		$username = $user_settings['member_name'];
612 640
 
613
-		if (empty($user_settings['additional_groups']))
614
-			$user_info = array(
641
+		if (empty($user_settings['additional_groups'])) {
642
+					$user_info = array(
615 643
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
616 644
 			);
617
-		else
618
-			$user_info = array(
645
+		} else {
646
+					$user_info = array(
619 647
 				'groups' => array_merge(
620 648
 					array($user_settings['id_group'], $user_settings['id_post_group']),
621 649
 					explode(',', $user_settings['additional_groups'])
622 650
 				)
623 651
 			);
652
+		}
624 653
 
625 654
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
626
-		foreach ($user_info['groups'] as $k => $v)
627
-			$user_info['groups'][$k] = (int) $v;
655
+		foreach ($user_info['groups'] as $k => $v) {
656
+					$user_info['groups'][$k] = (int) $v;
657
+		}
628 658
 
629 659
 		// This is a logged in user, so definitely not a spider.
630 660
 		$user_info['possibly_robot'] = false;
@@ -638,8 +668,7 @@  discard block
 block discarded – undo
638 668
 			$time_system = new DateTime('now', $tz_system);
639 669
 			$time_user = new DateTime('now', $tz_user);
640 670
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
641
-		}
642
-		else
671
+		} else
643 672
 		{
644 673
 			// !!! Compatibility.
645 674
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
@@ -653,8 +682,9 @@  discard block
 block discarded – undo
653 682
 		$user_info = array('groups' => array(-1));
654 683
 		$user_settings = array();
655 684
 
656
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
657
-			$_COOKIE[$cookiename] = '';
685
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
686
+					$_COOKIE[$cookiename] = '';
687
+		}
658 688
 
659 689
 		// Expire the 2FA cookie
660 690
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
@@ -671,19 +701,20 @@  discard block
 block discarded – undo
671 701
 		}
672 702
 
673 703
 		// Create a login token if it doesn't exist yet.
674
-		if (!isset($_SESSION['token']['post-login']))
675
-			createToken('login');
676
-		else
677
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
704
+		if (!isset($_SESSION['token']['post-login'])) {
705
+					createToken('login');
706
+		} else {
707
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
708
+		}
678 709
 
679 710
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
680 711
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
681 712
 		{
682 713
 			require_once($sourcedir . '/ManageSearchEngines.php');
683 714
 			$user_info['possibly_robot'] = SpiderCheck();
715
+		} elseif (!empty($modSettings['spider_mode'])) {
716
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
684 717
 		}
685
-		elseif (!empty($modSettings['spider_mode']))
686
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
687 718
 		// If we haven't turned on proper spider hunts then have a guess!
688 719
 		else
689 720
 		{
@@ -731,8 +762,9 @@  discard block
 block discarded – undo
731 762
 	$user_info['groups'] = array_unique($user_info['groups']);
732 763
 
733 764
 	// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
734
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
735
-		unset($user_info['ignoreboards'][$tmp]);
765
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
766
+			unset($user_info['ignoreboards'][$tmp]);
767
+	}
736 768
 
737 769
 	// Allow the user to change their language.
738 770
 	if (!empty($modSettings['userLanguage']))
@@ -745,13 +777,14 @@  discard block
 block discarded – undo
745 777
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
746 778
 
747 779
 			// Make it permanent for members.
748
-			if (!empty($user_info['id']))
749
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
750
-			else
751
-				$_SESSION['language'] = $user_info['language'];
780
+			if (!empty($user_info['id'])) {
781
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
782
+			} else {
783
+							$_SESSION['language'] = $user_info['language'];
784
+			}
785
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
786
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
752 787
 		}
753
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
754
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
755 788
 	}
756 789
 
757 790
 	$temp = build_query_board($user_info['id']);
@@ -814,9 +847,9 @@  discard block
 block discarded – undo
814 847
 		}
815 848
 
816 849
 		// Remember redirection is the key to avoiding fallout from your bosses.
817
-		if (!empty($topic))
818
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
819
-		else
850
+		if (!empty($topic)) {
851
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
852
+		} else
820 853
 		{
821 854
 			loadPermissions();
822 855
 			loadTheme();
@@ -834,10 +867,11 @@  discard block
 block discarded – undo
834 867
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
835 868
 	{
836 869
 		// @todo SLOW?
837
-		if (!empty($topic))
838
-			$temp = cache_get_data('topic_board-' . $topic, 120);
839
-		else
840
-			$temp = cache_get_data('board-' . $board, 120);
870
+		if (!empty($topic)) {
871
+					$temp = cache_get_data('topic_board-' . $topic, 120);
872
+		} else {
873
+					$temp = cache_get_data('board-' . $board, 120);
874
+		}
841 875
 
842 876
 		if (!empty($temp))
843 877
 		{
@@ -875,8 +909,9 @@  discard block
 block discarded – undo
875 909
 			$row = $smcFunc['db_fetch_assoc']($request);
876 910
 
877 911
 			// Set the current board.
878
-			if (!empty($row['id_board']))
879
-				$board = $row['id_board'];
912
+			if (!empty($row['id_board'])) {
913
+							$board = $row['id_board'];
914
+			}
880 915
 
881 916
 			// Basic operating information. (globals... :/)
882 917
 			$board_info = array(
@@ -912,21 +947,23 @@  discard block
 block discarded – undo
912 947
 
913 948
 			do
914 949
 			{
915
-				if (!empty($row['id_moderator']))
916
-					$board_info['moderators'][$row['id_moderator']] = array(
950
+				if (!empty($row['id_moderator'])) {
951
+									$board_info['moderators'][$row['id_moderator']] = array(
917 952
 						'id' => $row['id_moderator'],
918 953
 						'name' => $row['real_name'],
919 954
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
920 955
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
921 956
 					);
957
+				}
922 958
 
923
-				if (!empty($row['id_moderator_group']))
924
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
959
+				if (!empty($row['id_moderator_group'])) {
960
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
925 961
 						'id' => $row['id_moderator_group'],
926 962
 						'name' => $row['group_name'],
927 963
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
928 964
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
929 965
 					);
966
+				}
930 967
 			}
931 968
 			while ($row = $smcFunc['db_fetch_assoc']($request));
932 969
 
@@ -958,12 +995,12 @@  discard block
 block discarded – undo
958 995
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
959 996
 			{
960 997
 				// @todo SLOW?
961
-				if (!empty($topic))
962
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
998
+				if (!empty($topic)) {
999
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
1000
+				}
963 1001
 				cache_put_data('board-' . $board, $board_info, 120);
964 1002
 			}
965
-		}
966
-		else
1003
+		} else
967 1004
 		{
968 1005
 			// Otherwise the topic is invalid, there are no moderators, etc.
969 1006
 			$board_info = array(
@@ -977,8 +1014,9 @@  discard block
 block discarded – undo
977 1014
 		$smcFunc['db_free_result']($request);
978 1015
 	}
979 1016
 
980
-	if (!empty($topic))
981
-		$_GET['board'] = (int) $board;
1017
+	if (!empty($topic)) {
1018
+			$_GET['board'] = (int) $board;
1019
+	}
982 1020
 
983 1021
 	if (!empty($board))
984 1022
 	{
@@ -988,10 +1026,12 @@  discard block
 block discarded – undo
988 1026
 		// Now check if the user is a moderator.
989 1027
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
990 1028
 
991
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
992
-			$board_info['error'] = 'access';
993
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
994
-			$board_info['error'] = 'access';
1029
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1030
+					$board_info['error'] = 'access';
1031
+		}
1032
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1033
+					$board_info['error'] = 'access';
1034
+		}
995 1035
 
996 1036
 		// Build up the linktree.
997 1037
 		$context['linktree'] = array_merge(
@@ -1014,8 +1054,9 @@  discard block
 block discarded – undo
1014 1054
 	$context['current_board'] = $board;
1015 1055
 
1016 1056
 	// No posting in redirection boards!
1017
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
1018
-		$board_info['error'] == 'post_in_redirect';
1057
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1058
+			$board_info['error'] == 'post_in_redirect';
1059
+	}
1019 1060
 
1020 1061
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1021 1062
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1041,24 +1082,23 @@  discard block
 block discarded – undo
1041 1082
 			ob_end_clean();
1042 1083
 			header('HTTP/1.1 403 Forbidden');
1043 1084
 			die;
1044
-		}
1045
-		elseif ($board_info['error'] == 'post_in_redirect')
1085
+		} elseif ($board_info['error'] == 'post_in_redirect')
1046 1086
 		{
1047 1087
 			// Slightly different error message here...
1048 1088
 			fatal_lang_error('cannot_post_redirect', false);
1049
-		}
1050
-		elseif ($user_info['is_guest'])
1089
+		} elseif ($user_info['is_guest'])
1051 1090
 		{
1052 1091
 			loadLanguage('Errors');
1053 1092
 			is_not_guest($txt['topic_gone']);
1093
+		} else {
1094
+					fatal_lang_error('topic_gone', false);
1054 1095
 		}
1055
-		else
1056
-			fatal_lang_error('topic_gone', false);
1057 1096
 	}
1058 1097
 
1059
-	if ($user_info['is_mod'])
1060
-		$user_info['groups'][] = 3;
1061
-}
1098
+	if ($user_info['is_mod']) {
1099
+			$user_info['groups'][] = 3;
1100
+	}
1101
+	}
1062 1102
 
1063 1103
 /**
1064 1104
  * Load this user's permissions.
@@ -1079,8 +1119,9 @@  discard block
 block discarded – undo
1079 1119
 		asort($cache_groups);
1080 1120
 		$cache_groups = implode(',', $cache_groups);
1081 1121
 		// If it's a spider then cache it different.
1082
-		if ($user_info['possibly_robot'])
1083
-			$cache_groups .= '-spider';
1122
+		if ($user_info['possibly_robot']) {
1123
+					$cache_groups .= '-spider';
1124
+		}
1084 1125
 
1085 1126
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1086 1127
 		{
@@ -1088,9 +1129,9 @@  discard block
 block discarded – undo
1088 1129
 			banPermissions();
1089 1130
 
1090 1131
 			return;
1132
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1133
+					list ($user_info['permissions'], $removals) = $temp;
1091 1134
 		}
1092
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1093
-			list ($user_info['permissions'], $removals) = $temp;
1094 1135
 	}
1095 1136
 
1096 1137
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1112,23 +1153,26 @@  discard block
 block discarded – undo
1112 1153
 		$removals = array();
1113 1154
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1114 1155
 		{
1115
-			if (empty($row['add_deny']))
1116
-				$removals[] = $row['permission'];
1117
-			else
1118
-				$user_info['permissions'][] = $row['permission'];
1156
+			if (empty($row['add_deny'])) {
1157
+							$removals[] = $row['permission'];
1158
+			} else {
1159
+							$user_info['permissions'][] = $row['permission'];
1160
+			}
1119 1161
 		}
1120 1162
 		$smcFunc['db_free_result']($request);
1121 1163
 
1122
-		if (isset($cache_groups))
1123
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1164
+		if (isset($cache_groups)) {
1165
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1166
+		}
1124 1167
 	}
1125 1168
 
1126 1169
 	// Get the board permissions.
1127 1170
 	if (!empty($board))
1128 1171
 	{
1129 1172
 		// Make sure the board (if any) has been loaded by loadBoard().
1130
-		if (!isset($board_info['profile']))
1131
-			fatal_lang_error('no_board');
1173
+		if (!isset($board_info['profile'])) {
1174
+					fatal_lang_error('no_board');
1175
+		}
1132 1176
 
1133 1177
 		$request = $smcFunc['db_query']('', '
1134 1178
 			SELECT permission, add_deny
@@ -1144,20 +1188,23 @@  discard block
 block discarded – undo
1144 1188
 		);
1145 1189
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1146 1190
 		{
1147
-			if (empty($row['add_deny']))
1148
-				$removals[] = $row['permission'];
1149
-			else
1150
-				$user_info['permissions'][] = $row['permission'];
1191
+			if (empty($row['add_deny'])) {
1192
+							$removals[] = $row['permission'];
1193
+			} else {
1194
+							$user_info['permissions'][] = $row['permission'];
1195
+			}
1151 1196
 		}
1152 1197
 		$smcFunc['db_free_result']($request);
1153 1198
 	}
1154 1199
 
1155 1200
 	// Remove all the permissions they shouldn't have ;).
1156
-	if (!empty($modSettings['permission_enable_deny']))
1157
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1201
+	if (!empty($modSettings['permission_enable_deny'])) {
1202
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1203
+	}
1158 1204
 
1159
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1160
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1205
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1206
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1207
+	}
1161 1208
 
1162 1209
 	// Banned?  Watch, don't touch..
1163 1210
 	banPermissions();
@@ -1169,17 +1216,18 @@  discard block
 block discarded – undo
1169 1216
 		{
1170 1217
 			require_once($sourcedir . '/Subs-Auth.php');
1171 1218
 			rebuildModCache();
1219
+		} else {
1220
+					$user_info['mod_cache'] = $_SESSION['mc'];
1172 1221
 		}
1173
-		else
1174
-			$user_info['mod_cache'] = $_SESSION['mc'];
1175 1222
 
1176 1223
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1177 1224
 		// For example this drastically simplifies certain changes to the profile area.
1178 1225
 		$user_info['permissions'][] = 'is_not_guest';
1179 1226
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1180 1227
 		$user_info['permissions'][] = 'profile_view_own';
1181
-		if (in_array('profile_view', $user_info['permissions']))
1182
-			$user_info['permissions'][] = 'profile_view_any';
1228
+		if (in_array('profile_view', $user_info['permissions'])) {
1229
+					$user_info['permissions'][] = 'profile_view_any';
1230
+		}
1183 1231
 	}
1184 1232
 }
1185 1233
 
@@ -1197,8 +1245,9 @@  discard block
 block discarded – undo
1197 1245
 	global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1198 1246
 
1199 1247
 	// Can't just look for no users :P.
1200
-	if (empty($users))
1201
-		return array();
1248
+	if (empty($users)) {
1249
+			return array();
1250
+	}
1202 1251
 
1203 1252
 	// Pass the set value
1204 1253
 	$context['loadMemberContext_set'] = $set;
@@ -1213,8 +1262,9 @@  discard block
 block discarded – undo
1213 1262
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1214 1263
 		{
1215 1264
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1216
-			if ($data == null)
1217
-				continue;
1265
+			if ($data == null) {
1266
+							continue;
1267
+			}
1218 1268
 
1219 1269
 			$loaded_ids[] = $data['id_member'];
1220 1270
 			$user_profile[$data['id_member']] = $data;
@@ -1281,16 +1331,19 @@  discard block
 block discarded – undo
1281 1331
 			$row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : '';
1282 1332
 
1283 1333
 			// Take care of proxying avatar if required, do this here for maximum reach
1284
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false)
1285
-				$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1334
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) {
1335
+							$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1336
+			}
1286 1337
 
1287 1338
 			// Keep track of the member's normal member group
1288 1339
 			$row['primary_group'] = $row['member_group'];
1289 1340
 
1290
-			if (isset($row['member_ip']))
1291
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1292
-			if (isset($row['member_ip2']))
1293
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1341
+			if (isset($row['member_ip'])) {
1342
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1343
+			}
1344
+			if (isset($row['member_ip2'])) {
1345
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1346
+			}
1294 1347
 			$new_loaded_ids[] = $row['id_member'];
1295 1348
 			$loaded_ids[] = $row['id_member'];
1296 1349
 			$row['options'] = array();
@@ -1309,8 +1362,9 @@  discard block
 block discarded – undo
1309 1362
 				'loaded_ids' => $new_loaded_ids,
1310 1363
 			)
1311 1364
 		);
1312
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1313
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1365
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1366
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1367
+		}
1314 1368
 		$smcFunc['db_free_result']($request);
1315 1369
 	}
1316 1370
 
@@ -1321,10 +1375,11 @@  discard block
 block discarded – undo
1321 1375
 	{
1322 1376
 		foreach ($loaded_ids as $a_member)
1323 1377
 		{
1324
-			if (!empty($user_profile[$a_member]['additional_groups']))
1325
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1326
-			else
1327
-				$groups = array($user_profile[$a_member]['id_group']);
1378
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1379
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1380
+			} else {
1381
+							$groups = array($user_profile[$a_member]['id_group']);
1382
+			}
1328 1383
 
1329 1384
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1330 1385
 
@@ -1337,8 +1392,9 @@  discard block
 block discarded – undo
1337 1392
 
1338 1393
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1339 1394
 	{
1340
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1341
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1395
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1396
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1397
+		}
1342 1398
 	}
1343 1399
 
1344 1400
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1364,14 +1420,17 @@  discard block
 block discarded – undo
1364 1420
 		foreach ($temp_mods as $id)
1365 1421
 		{
1366 1422
 			// By popular demand, don't show admins or global moderators as moderators.
1367
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1368
-				$user_profile[$id]['member_group'] = $row['member_group'];
1423
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1424
+							$user_profile[$id]['member_group'] = $row['member_group'];
1425
+			}
1369 1426
 
1370 1427
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1371
-			if (!empty($row['icons']))
1372
-				$user_profile[$id]['icons'] = $row['icons'];
1373
-			if (!empty($row['member_group_color']))
1374
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1428
+			if (!empty($row['icons'])) {
1429
+							$user_profile[$id]['icons'] = $row['icons'];
1430
+			}
1431
+			if (!empty($row['member_group_color'])) {
1432
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1433
+			}
1375 1434
 		}
1376 1435
 	}
1377 1436
 
@@ -1393,12 +1452,14 @@  discard block
 block discarded – undo
1393 1452
 	static $loadedLanguages = array();
1394 1453
 
1395 1454
 	// If this person's data is already loaded, skip it.
1396
-	if (isset($dataLoaded[$user]))
1397
-		return true;
1455
+	if (isset($dataLoaded[$user])) {
1456
+			return true;
1457
+	}
1398 1458
 
1399 1459
 	// We can't load guests or members not loaded by loadMemberData()!
1400
-	if ($user == 0)
1401
-		return false;
1460
+	if ($user == 0) {
1461
+			return false;
1462
+	}
1402 1463
 	if (!isset($user_profile[$user]))
1403 1464
 	{
1404 1465
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1424,12 +1485,16 @@  discard block
 block discarded – undo
1424 1485
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1425 1486
 
1426 1487
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1427
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1488
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1489
+		//icon is set and exists
1428 1490
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1429
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1491
+	} elseif (isset($profile['icons'][1])) {
1492
+		//icon is set and doesn't exist, fallback to default
1430 1493
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1431
-	else //not set, bye bye
1494
+	} else {
1495
+		//not set, bye bye
1432 1496
 		$group_icon_url = '';
1497
+	}
1433 1498
 
1434 1499
 	// These minimal values are always loaded
1435 1500
 	$memberContext[$user] = array(
@@ -1448,8 +1513,9 @@  discard block
 block discarded – undo
1448 1513
 	if ($context['loadMemberContext_set'] != 'minimal')
1449 1514
 	{
1450 1515
 		// Go the extra mile and load the user's native language name.
1451
-		if (empty($loadedLanguages))
1452
-			$loadedLanguages = getLanguages();
1516
+		if (empty($loadedLanguages)) {
1517
+					$loadedLanguages = getLanguages();
1518
+		}
1453 1519
 
1454 1520
 		$memberContext[$user] += array(
1455 1521
 			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
@@ -1504,31 +1570,33 @@  discard block
 block discarded – undo
1504 1570
 	{
1505 1571
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1506 1572
 		{
1507
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1508
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1509
-			else
1510
-				$image = get_gravatar_url($profile['email_address']);
1511
-		}
1512
-		else
1573
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1574
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1575
+			} else {
1576
+							$image = get_gravatar_url($profile['email_address']);
1577
+			}
1578
+		} else
1513 1579
 		{
1514 1580
 			// So it's stored in the member table?
1515 1581
 			if (!empty($profile['avatar']))
1516 1582
 			{
1517 1583
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1584
+			} elseif (!empty($profile['filename'])) {
1585
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1518 1586
 			}
1519
-			elseif (!empty($profile['filename']))
1520
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1521 1587
 			// Right... no avatar...use the default one
1522
-			else
1523
-				$image = $modSettings['avatar_url'] . '/default.png';
1588
+			else {
1589
+							$image = $modSettings['avatar_url'] . '/default.png';
1590
+			}
1524 1591
 		}
1525
-		if (!empty($image))
1526
-			$memberContext[$user]['avatar'] = array(
1592
+		if (!empty($image)) {
1593
+					$memberContext[$user]['avatar'] = array(
1527 1594
 				'name' => $profile['avatar'],
1528 1595
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1529 1596
 				'href' => $image,
1530 1597
 				'url' => $image,
1531 1598
 			);
1599
+		}
1532 1600
 	}
1533 1601
 
1534 1602
 	// Are we also loading the members custom fields into context?
@@ -1536,35 +1604,41 @@  discard block
 block discarded – undo
1536 1604
 	{
1537 1605
 		$memberContext[$user]['custom_fields'] = array();
1538 1606
 
1539
-		if (!isset($context['display_fields']))
1540
-			$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1607
+		if (!isset($context['display_fields'])) {
1608
+					$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1609
+		}
1541 1610
 
1542 1611
 		foreach ($context['display_fields'] as $custom)
1543 1612
 		{
1544
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1545
-				continue;
1613
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1614
+							continue;
1615
+			}
1546 1616
 
1547 1617
 			$value = $profile['options'][$custom['col_name']];
1548 1618
 
1549 1619
 			// Don't show the "disabled" option for the "gender" field.
1550
-			if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled')
1551
-				continue;
1620
+			if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') {
1621
+							continue;
1622
+			}
1552 1623
 
1553 1624
 			// BBC?
1554
-			if ($custom['bbc'])
1555
-				$value = parse_bbc($value);
1625
+			if ($custom['bbc']) {
1626
+							$value = parse_bbc($value);
1627
+			}
1556 1628
 			// ... or checkbox?
1557
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1558
-				$value = $value ? $txt['yes'] : $txt['no'];
1629
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1630
+							$value = $value ? $txt['yes'] : $txt['no'];
1631
+			}
1559 1632
 
1560 1633
 			// Enclosing the user input within some other text?
1561
-			if (!empty($custom['enclose']))
1562
-				$value = strtr($custom['enclose'], array(
1634
+			if (!empty($custom['enclose'])) {
1635
+							$value = strtr($custom['enclose'], array(
1563 1636
 					'{SCRIPTURL}' => $scripturl,
1564 1637
 					'{IMAGES_URL}' => $settings['images_url'],
1565 1638
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1566 1639
 					'{INPUT}' => $value,
1567 1640
 				));
1641
+			}
1568 1642
 
1569 1643
 			$memberContext[$user]['custom_fields'][] = array(
1570 1644
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1591,8 +1665,9 @@  discard block
 block discarded – undo
1591 1665
 	global $smcFunc, $txt, $scripturl, $settings;
1592 1666
 
1593 1667
 	// Do not waste my time...
1594
-	if (empty($users) || empty($params))
1595
-		return false;
1668
+	if (empty($users) || empty($params)) {
1669
+			return false;
1670
+	}
1596 1671
 
1597 1672
 	// Make sure it's an array.
1598 1673
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1616,31 +1691,36 @@  discard block
 block discarded – undo
1616 1691
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1617 1692
 	{
1618 1693
 		// BBC?
1619
-		if (!empty($row['bbc']))
1620
-			$row['value'] = parse_bbc($row['value']);
1694
+		if (!empty($row['bbc'])) {
1695
+					$row['value'] = parse_bbc($row['value']);
1696
+		}
1621 1697
 
1622 1698
 		// ... or checkbox?
1623
-		elseif (isset($row['type']) && $row['type'] == 'check')
1624
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1699
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1700
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1701
+		}
1625 1702
 
1626 1703
 		// Enclosing the user input within some other text?
1627
-		if (!empty($row['enclose']))
1628
-			$row['value'] = strtr($row['enclose'], array(
1704
+		if (!empty($row['enclose'])) {
1705
+					$row['value'] = strtr($row['enclose'], array(
1629 1706
 				'{SCRIPTURL}' => $scripturl,
1630 1707
 				'{IMAGES_URL}' => $settings['images_url'],
1631 1708
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1632 1709
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1633 1710
 			));
1711
+		}
1634 1712
 
1635 1713
 		// Send a simple array if there is just 1 param
1636
-		if (count($params) == 1)
1637
-			$return[$row['id_member']] = $row;
1714
+		if (count($params) == 1) {
1715
+					$return[$row['id_member']] = $row;
1716
+		}
1638 1717
 
1639 1718
 		// More than 1? knock yourself out...
1640 1719
 		else
1641 1720
 		{
1642
-			if (!isset($return[$row['id_member']]))
1643
-				$return[$row['id_member']] = array();
1721
+			if (!isset($return[$row['id_member']])) {
1722
+							$return[$row['id_member']] = array();
1723
+			}
1644 1724
 
1645 1725
 			$return[$row['id_member']][$row['variable']] = $row;
1646 1726
 		}
@@ -1674,8 +1754,9 @@  discard block
 block discarded – undo
1674 1754
 	global $context;
1675 1755
 
1676 1756
 	// Don't know any browser!
1677
-	if (empty($context['browser']))
1678
-		detectBrowser();
1757
+	if (empty($context['browser'])) {
1758
+			detectBrowser();
1759
+	}
1679 1760
 
1680 1761
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1681 1762
 }
@@ -1693,8 +1774,9 @@  discard block
 block discarded – undo
1693 1774
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1694 1775
 
1695 1776
 	// The theme was specified by parameter.
1696
-	if (!empty($id_theme))
1697
-		$id_theme = (int) $id_theme;
1777
+	if (!empty($id_theme)) {
1778
+			$id_theme = (int) $id_theme;
1779
+	}
1698 1780
 	// The theme was specified by REQUEST.
1699 1781
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1700 1782
 	{
@@ -1702,54 +1784,61 @@  discard block
 block discarded – undo
1702 1784
 		$_SESSION['id_theme'] = $id_theme;
1703 1785
 	}
1704 1786
 	// The theme was specified by REQUEST... previously.
1705
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1706
-		$id_theme = (int) $_SESSION['id_theme'];
1787
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1788
+			$id_theme = (int) $_SESSION['id_theme'];
1789
+	}
1707 1790
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1708
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1709
-		$id_theme = $user_info['theme'];
1791
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1792
+			$id_theme = $user_info['theme'];
1793
+	}
1710 1794
 	// The theme was specified by the board.
1711
-	elseif (!empty($board_info['theme']))
1712
-		$id_theme = $board_info['theme'];
1795
+	elseif (!empty($board_info['theme'])) {
1796
+			$id_theme = $board_info['theme'];
1797
+	}
1713 1798
 	// The theme is the forum's default.
1714
-	else
1715
-		$id_theme = $modSettings['theme_guests'];
1799
+	else {
1800
+			$id_theme = $modSettings['theme_guests'];
1801
+	}
1716 1802
 
1717 1803
 	// We already load the basic stuff?
1718 1804
 	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme )
1719 1805
 	{
1720 1806
 		// Verify the id_theme... no foul play.
1721 1807
 		// Always allow the board specific theme, if they are overriding.
1722
-		if (!empty($board_info['theme']) && $board_info['override_theme'])
1723
-			$id_theme = $board_info['theme'];
1808
+		if (!empty($board_info['theme']) && $board_info['override_theme']) {
1809
+					$id_theme = $board_info['theme'];
1810
+		}
1724 1811
 		// If they have specified a particular theme to use with SSI allow it to be used.
1725
-		elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1726
-			$id_theme = (int) $id_theme;
1727
-		elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1812
+		elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1813
+					$id_theme = (int) $id_theme;
1814
+		} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1728 1815
 		{
1729 1816
 			$themes = explode(',', $modSettings['enableThemes']);
1730
-			if (!in_array($id_theme, $themes))
1731
-				$id_theme = $modSettings['theme_guests'];
1732
-			else
1733
-				$id_theme = (int) $id_theme;
1817
+			if (!in_array($id_theme, $themes)) {
1818
+							$id_theme = $modSettings['theme_guests'];
1819
+			} else {
1820
+							$id_theme = (int) $id_theme;
1821
+			}
1822
+		} else {
1823
+					$id_theme = (int) $id_theme;
1734 1824
 		}
1735
-		else
1736
-			$id_theme = (int) $id_theme;
1737 1825
 
1738 1826
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1739 1827
 
1740 1828
 		// Disable image proxy if we don't have SSL enabled
1741
-		if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2)
1742
-			$image_proxy_enabled = false;
1829
+		if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) {
1830
+					$image_proxy_enabled = false;
1831
+		}
1743 1832
 
1744 1833
 		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated'])
1745 1834
 		{
1746 1835
 			$themeData = $temp;
1747 1836
 			$flag = true;
1837
+		} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1838
+					$themeData = $temp + array($member => array());
1839
+		} else {
1840
+					$themeData = array(-1 => array(), 0 => array(), $member => array());
1748 1841
 		}
1749
-		elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1750
-			$themeData = $temp + array($member => array());
1751
-		else
1752
-			$themeData = array(-1 => array(), 0 => array(), $member => array());
1753 1842
 
1754 1843
 		if (empty($flag))
1755 1844
 		{
@@ -1768,31 +1857,37 @@  discard block
 block discarded – undo
1768 1857
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1769 1858
 			{
1770 1859
 				// There are just things we shouldn't be able to change as members.
1771
-				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url')))
1772
-					continue;
1860
+				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
1861
+									continue;
1862
+				}
1773 1863
 
1774 1864
 				// If this is the theme_dir of the default theme, store it.
1775
-				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1776
-					$themeData[0]['default_' . $row['variable']] = $row['value'];
1865
+				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1866
+									$themeData[0]['default_' . $row['variable']] = $row['value'];
1867
+				}
1777 1868
 
1778 1869
 				// If this isn't set yet, is a theme option, or is not the default theme..
1779
-				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1780
-					$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1870
+				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1871
+									$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1872
+				}
1781 1873
 			}
1782 1874
 			$smcFunc['db_free_result']($result);
1783 1875
 
1784
-			if (!empty($themeData[-1]))
1785
-				foreach ($themeData[-1] as $k => $v)
1876
+			if (!empty($themeData[-1])) {
1877
+							foreach ($themeData[-1] as $k => $v)
1786 1878
 				{
1787 1879
 					if (!isset($themeData[$member][$k]))
1788 1880
 						$themeData[$member][$k] = $v;
1881
+			}
1789 1882
 				}
1790 1883
 
1791
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1792
-				cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1884
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1885
+							cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1886
+			}
1793 1887
 			// Only if we didn't already load that part of the cache...
1794
-			elseif (!isset($temp))
1795
-				cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1888
+			elseif (!isset($temp)) {
1889
+							cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1890
+			}
1796 1891
 		}
1797 1892
 
1798 1893
 		$settings = $themeData[0];
@@ -1809,22 +1904,26 @@  discard block
 block discarded – undo
1809 1904
 		$settings['template_dirs'][] = $settings['theme_dir'];
1810 1905
 
1811 1906
 		// Based on theme (if there is one).
1812
-		if (!empty($settings['base_theme_dir']))
1813
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1907
+		if (!empty($settings['base_theme_dir'])) {
1908
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1909
+		}
1814 1910
 
1815 1911
 		// Lastly the default theme.
1816
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1817
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1912
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1913
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1914
+		}
1818 1915
 	}
1819 1916
 	
1820 1917
 
1821
-	if (!$initialize)
1822
-		return;
1918
+	if (!$initialize) {
1919
+			return;
1920
+	}
1823 1921
 
1824 1922
 	// Check to see if we're forcing SSL
1825 1923
 	if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) &&
1826
-		(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI')
1827
-		redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://')));
1924
+		(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') {
1925
+			redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://')));
1926
+	}
1828 1927
 
1829 1928
 	// Check to see if they're accessing it from the wrong place.
1830 1929
 	if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME']))
@@ -1832,8 +1931,9 @@  discard block
 block discarded – undo
1832 1931
 		$detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
1833 1932
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1834 1933
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1835
-		if ($temp != '/')
1836
-			$detected_url .= $temp;
1934
+		if ($temp != '/') {
1935
+					$detected_url .= $temp;
1936
+		}
1837 1937
 	}
1838 1938
 	if (isset($detected_url) && $detected_url != $boardurl)
1839 1939
 	{
@@ -1845,8 +1945,9 @@  discard block
 block discarded – undo
1845 1945
 			foreach ($aliases as $alias)
1846 1946
 			{
1847 1947
 				// Rip off all the boring parts, spaces, etc.
1848
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1849
-					$do_fix = true;
1948
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1949
+									$do_fix = true;
1950
+				}
1850 1951
 			}
1851 1952
 		}
1852 1953
 
@@ -1854,20 +1955,22 @@  discard block
 block discarded – undo
1854 1955
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1855 1956
 		{
1856 1957
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1857
-			if (empty($_GET))
1858
-				redirectexit('wwwRedirect');
1859
-			else
1958
+			if (empty($_GET)) {
1959
+							redirectexit('wwwRedirect');
1960
+			} else
1860 1961
 			{
1861 1962
 				list ($k, $v) = each($_GET);
1862 1963
 
1863
-				if ($k != 'wwwRedirect')
1864
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1964
+				if ($k != 'wwwRedirect') {
1965
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1966
+				}
1865 1967
 			}
1866 1968
 		}
1867 1969
 
1868 1970
 		// #3 is just a check for SSL...
1869
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1870
-			$do_fix = true;
1971
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1972
+					$do_fix = true;
1973
+		}
1871 1974
 
1872 1975
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1873 1976
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1901,8 +2004,9 @@  discard block
 block discarded – undo
1901 2004
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1902 2005
 				}
1903 2006
 			}
1904
-			foreach ($context['linktree'] as $k => $dummy)
1905
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2007
+			foreach ($context['linktree'] as $k => $dummy) {
2008
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2009
+			}
1906 2010
 		}
1907 2011
 	}
1908 2012
 	// Set up the contextual user array.
@@ -1921,16 +2025,16 @@  discard block
 block discarded – undo
1921 2025
 			'email' => $user_info['email'],
1922 2026
 			'ignoreusers' => $user_info['ignoreusers'],
1923 2027
 		);
1924
-		if (!$context['user']['is_guest'])
1925
-			$context['user']['name'] = $user_info['name'];
1926
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1927
-			$context['user']['name'] = $txt['guest_title'];
2028
+		if (!$context['user']['is_guest']) {
2029
+					$context['user']['name'] = $user_info['name'];
2030
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2031
+					$context['user']['name'] = $txt['guest_title'];
2032
+		}
1928 2033
 
1929 2034
 		// Determine the current smiley set.
1930 2035
 		$user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];
1931 2036
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1932
-	}
1933
-	else
2037
+	} else
1934 2038
 	{
1935 2039
 		// What to do when there is no $user_info (e.g., an error very early in the login process)
1936 2040
 		$context['user'] = array(
@@ -1964,18 +2068,24 @@  discard block
 block discarded – undo
1964 2068
 	}
1965 2069
 
1966 2070
 	// Some basic information...
1967
-	if (!isset($context['html_headers']))
1968
-		$context['html_headers'] = '';
1969
-	if (!isset($context['javascript_files']))
1970
-		$context['javascript_files'] = array();
1971
-	if (!isset($context['css_files']))
1972
-		$context['css_files'] = array();
1973
-	if (!isset($context['css_header']))
1974
-		$context['css_header'] = array();
1975
-	if (!isset($context['javascript_inline']))
1976
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1977
-	if (!isset($context['javascript_vars']))
1978
-		$context['javascript_vars'] = array();
2071
+	if (!isset($context['html_headers'])) {
2072
+			$context['html_headers'] = '';
2073
+	}
2074
+	if (!isset($context['javascript_files'])) {
2075
+			$context['javascript_files'] = array();
2076
+	}
2077
+	if (!isset($context['css_files'])) {
2078
+			$context['css_files'] = array();
2079
+	}
2080
+	if (!isset($context['css_header'])) {
2081
+			$context['css_header'] = array();
2082
+	}
2083
+	if (!isset($context['javascript_inline'])) {
2084
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2085
+	}
2086
+	if (!isset($context['javascript_vars'])) {
2087
+			$context['javascript_vars'] = array();
2088
+	}
1979 2089
 
1980 2090
 	$context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2';
1981 2091
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -1987,16 +2097,18 @@  discard block
 block discarded – undo
1987 2097
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
1988 2098
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
1989 2099
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
1990
-	if (isset($modSettings['load_average']))
1991
-		$context['load_average'] = $modSettings['load_average'];
2100
+	if (isset($modSettings['load_average'])) {
2101
+			$context['load_average'] = $modSettings['load_average'];
2102
+	}
1992 2103
 
1993 2104
 	// Detect the browser. This is separated out because it's also used in attachment downloads
1994 2105
 	detectBrowser();
1995 2106
 
1996 2107
 	// Set the top level linktree up.
1997 2108
 	// Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet...
1998
-	if (empty($context['linktree']))
1999
-		$context['linktree'] = array();
2109
+	if (empty($context['linktree'])) {
2110
+			$context['linktree'] = array();
2111
+	}
2000 2112
 	array_unshift($context['linktree'], array(
2001 2113
 		'url' => $scripturl,
2002 2114
 		'name' => $context['forum_name_html_safe']
@@ -2005,8 +2117,9 @@  discard block
 block discarded – undo
2005 2117
 	// This allows sticking some HTML on the page output - useful for controls.
2006 2118
 	$context['insert_after_template'] = '';
2007 2119
 
2008
-	if (!isset($txt))
2009
-		$txt = array();
2120
+	if (!isset($txt)) {
2121
+			$txt = array();
2122
+	}
2010 2123
 
2011 2124
 	$simpleActions = array(
2012 2125
 		'findmember',
@@ -2052,9 +2165,10 @@  discard block
 block discarded – undo
2052 2165
 
2053 2166
 	// See if theres any extra param to check.
2054 2167
 	$requiresXML = false;
2055
-	foreach ($extraParams as $key => $extra)
2056
-		if (isset($_REQUEST[$extra]))
2168
+	foreach ($extraParams as $key => $extra) {
2169
+			if (isset($_REQUEST[$extra]))
2057 2170
 			$requiresXML = true;
2171
+	}
2058 2172
 
2059 2173
 	// Output is fully XML, so no need for the index template.
2060 2174
 	if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML))
@@ -2069,37 +2183,39 @@  discard block
 block discarded – undo
2069 2183
 	{
2070 2184
 		loadLanguage('index+Modifications');
2071 2185
 		$context['template_layers'] = array();
2072
-	}
2073
-
2074
-	else
2186
+	} else
2075 2187
 	{
2076 2188
 		// Custom templates to load, or just default?
2077
-		if (isset($settings['theme_templates']))
2078
-			$templates = explode(',', $settings['theme_templates']);
2079
-		else
2080
-			$templates = array('index');
2189
+		if (isset($settings['theme_templates'])) {
2190
+					$templates = explode(',', $settings['theme_templates']);
2191
+		} else {
2192
+					$templates = array('index');
2193
+		}
2081 2194
 
2082 2195
 		// Load each template...
2083
-		foreach ($templates as $template)
2084
-			loadTemplate($template);
2196
+		foreach ($templates as $template) {
2197
+					loadTemplate($template);
2198
+		}
2085 2199
 
2086 2200
 		// ...and attempt to load their associated language files.
2087 2201
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2088 2202
 		loadLanguage($required_files, '', false);
2089 2203
 
2090 2204
 		// Custom template layers?
2091
-		if (isset($settings['theme_layers']))
2092
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2093
-		else
2094
-			$context['template_layers'] = array('html', 'body');
2205
+		if (isset($settings['theme_layers'])) {
2206
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2207
+		} else {
2208
+					$context['template_layers'] = array('html', 'body');
2209
+		}
2095 2210
 	}
2096 2211
 
2097 2212
 	// Initialize the theme.
2098 2213
 	loadSubTemplate('init', 'ignore');
2099 2214
 
2100 2215
 	// Allow overriding the board wide time/number formats.
2101
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2102
-		$user_info['time_format'] = $txt['time_format'];
2216
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2217
+			$user_info['time_format'] = $txt['time_format'];
2218
+	}
2103 2219
 
2104 2220
 	// Set the character set from the template.
2105 2221
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2107,12 +2223,14 @@  discard block
 block discarded – undo
2107 2223
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2108 2224
 
2109 2225
 	// Guests may still need a name.
2110
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2111
-		$context['user']['name'] = $txt['guest_title'];
2226
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2227
+			$context['user']['name'] = $txt['guest_title'];
2228
+	}
2112 2229
 
2113 2230
 	// Any theme-related strings that need to be loaded?
2114
-	if (!empty($settings['require_theme_strings']))
2115
-		loadLanguage('ThemeStrings', '', false);
2231
+	if (!empty($settings['require_theme_strings'])) {
2232
+			loadLanguage('ThemeStrings', '', false);
2233
+	}
2116 2234
 
2117 2235
 	// Make a special URL for the language.
2118 2236
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2123,8 +2241,9 @@  discard block
 block discarded – undo
2123 2241
 	// Here is my luvly Responsive CSS
2124 2242
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive');
2125 2243
 
2126
-	if ($context['right_to_left'])
2127
-		loadCSSFile('rtl.css', array(), 'smf_rtl');
2244
+	if ($context['right_to_left']) {
2245
+			loadCSSFile('rtl.css', array(), 'smf_rtl');
2246
+	}
2128 2247
 
2129 2248
 	// We allow theme variants, because we're cool.
2130 2249
 	$context['theme_variant'] = '';
@@ -2132,14 +2251,17 @@  discard block
 block discarded – undo
2132 2251
 	if (!empty($settings['theme_variants']))
2133 2252
 	{
2134 2253
 		// Overriding - for previews and that ilk.
2135
-		if (!empty($_REQUEST['variant']))
2136
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2254
+		if (!empty($_REQUEST['variant'])) {
2255
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2256
+		}
2137 2257
 		// User selection?
2138
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2139
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2258
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2259
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2260
+		}
2140 2261
 		// If not a user variant, select the default.
2141
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2142
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2262
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2263
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2264
+		}
2143 2265
 
2144 2266
 		// Do this to keep things easier in the templates.
2145 2267
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2148,20 +2270,23 @@  discard block
 block discarded – undo
2148 2270
 		if (!empty($context['theme_variant']))
2149 2271
 		{
2150 2272
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']);
2151
-			if ($context['right_to_left'])
2152
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']);
2273
+			if ($context['right_to_left']) {
2274
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']);
2275
+			}
2153 2276
 		}
2154 2277
 	}
2155 2278
 
2156 2279
 	// Let's be compatible with old themes!
2157
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2158
-		$context['template_layers'] = array('main');
2280
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2281
+			$context['template_layers'] = array('main');
2282
+	}
2159 2283
 
2160 2284
 	$context['tabindex'] = 1;
2161 2285
 
2162 2286
 	// Compatibility.
2163
-	if (!isset($settings['theme_version']))
2164
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2287
+	if (!isset($settings['theme_version'])) {
2288
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2289
+	}
2165 2290
 
2166 2291
 	// Default JS variables for use in every theme
2167 2292
 	$context['javascript_vars'] = array(
@@ -2180,18 +2305,18 @@  discard block
 block discarded – undo
2180 2305
 	);
2181 2306
 
2182 2307
 	// Add the JQuery library to the list of files to load.
2183
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2184
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery');
2185
-
2186
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2187
-		loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery');
2188
-
2189
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2190
-		loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2308
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2309
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery');
2310
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2311
+			loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery');
2312
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2313
+			loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2314
+	}
2191 2315
 
2192 2316
 	// Auto loading? template_javascript() will take care of the local half of this.
2193
-	else
2194
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery');
2317
+	else {
2318
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery');
2319
+	}
2195 2320
 
2196 2321
 	// Queue our JQuery plugins!
2197 2322
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2214,12 +2339,12 @@  discard block
 block discarded – undo
2214 2339
 			require_once($sourcedir . '/ScheduledTasks.php');
2215 2340
 
2216 2341
 			// What to do, what to do?!
2217
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2218
-				AutoTask();
2219
-			else
2220
-				ReduceMailQueue();
2221
-		}
2222
-		else
2342
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2343
+							AutoTask();
2344
+			} else {
2345
+							ReduceMailQueue();
2346
+			}
2347
+		} else
2223 2348
 		{
2224 2349
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2225 2350
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2270,8 +2395,9 @@  discard block
 block discarded – undo
2270 2395
 		foreach ($theme_includes as $include)
2271 2396
 		{
2272 2397
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2273
-			if (file_exists($include))
2274
-				require_once($include);
2398
+			if (file_exists($include)) {
2399
+							require_once($include);
2400
+			}
2275 2401
 		}
2276 2402
 	}
2277 2403
 
@@ -2301,16 +2427,19 @@  discard block
 block discarded – undo
2301 2427
 	// Do any style sheets first, cause we're easy with those.
2302 2428
 	if (!empty($style_sheets))
2303 2429
 	{
2304
-		if (!is_array($style_sheets))
2305
-			$style_sheets = array($style_sheets);
2430
+		if (!is_array($style_sheets)) {
2431
+					$style_sheets = array($style_sheets);
2432
+		}
2306 2433
 
2307
-		foreach ($style_sheets as $sheet)
2308
-			loadCSSFile($sheet . '.css', array(), $sheet);
2434
+		foreach ($style_sheets as $sheet) {
2435
+					loadCSSFile($sheet . '.css', array(), $sheet);
2436
+		}
2309 2437
 	}
2310 2438
 
2311 2439
 	// No template to load?
2312
-	if ($template_name === false)
2313
-		return true;
2440
+	if ($template_name === false) {
2441
+			return true;
2442
+	}
2314 2443
 
2315 2444
 	$loaded = false;
2316 2445
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2325,12 +2454,14 @@  discard block
 block discarded – undo
2325 2454
 
2326 2455
 	if ($loaded)
2327 2456
 	{
2328
-		if ($db_show_debug === true)
2329
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2457
+		if ($db_show_debug === true) {
2458
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2459
+		}
2330 2460
 
2331 2461
 		// If they have specified an initialization function for this template, go ahead and call it now.
2332
-		if (function_exists('template_' . $template_name . '_init'))
2333
-			call_user_func('template_' . $template_name . '_init');
2462
+		if (function_exists('template_' . $template_name . '_init')) {
2463
+					call_user_func('template_' . $template_name . '_init');
2464
+		}
2334 2465
 	}
2335 2466
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2336 2467
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2350,13 +2481,14 @@  discard block
 block discarded – undo
2350 2481
 		loadTemplate($template_name);
2351 2482
 	}
2352 2483
 	// Cause an error otherwise.
2353
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2354
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2355
-	elseif ($fatal)
2356
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2357
-	else
2358
-		return false;
2359
-}
2484
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2485
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2486
+	} elseif ($fatal) {
2487
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2488
+	} else {
2489
+			return false;
2490
+	}
2491
+	}
2360 2492
 
2361 2493
 /**
2362 2494
  * Load a sub-template.
@@ -2374,17 +2506,19 @@  discard block
 block discarded – undo
2374 2506
 {
2375 2507
 	global $context, $txt, $db_show_debug;
2376 2508
 
2377
-	if ($db_show_debug === true)
2378
-		$context['debug']['sub_templates'][] = $sub_template_name;
2509
+	if ($db_show_debug === true) {
2510
+			$context['debug']['sub_templates'][] = $sub_template_name;
2511
+	}
2379 2512
 
2380 2513
 	// Figure out what the template function is named.
2381 2514
 	$theme_function = 'template_' . $sub_template_name;
2382
-	if (function_exists($theme_function))
2383
-		$theme_function();
2384
-	elseif ($fatal === false)
2385
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2386
-	elseif ($fatal !== 'ignore')
2387
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2515
+	if (function_exists($theme_function)) {
2516
+			$theme_function();
2517
+	} elseif ($fatal === false) {
2518
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2519
+	} elseif ($fatal !== 'ignore') {
2520
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2521
+	}
2388 2522
 
2389 2523
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2390 2524
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2421,8 +2555,9 @@  discard block
 block discarded – undo
2421 2555
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2422 2556
 
2423 2557
 	// If this is an external file, automatically set this to false.
2424
-	if (!empty($params['external']))
2425
-		$params['minimize'] = false;
2558
+	if (!empty($params['external'])) {
2559
+			$params['minimize'] = false;
2560
+	}
2426 2561
 
2427 2562
 	// Account for shorthand like admin.css?alp21 filenames
2428 2563
 	$has_seed = strpos($fileName, '.css?');
@@ -2439,13 +2574,10 @@  discard block
 block discarded – undo
2439 2574
 			{
2440 2575
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2441 2576
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2577
+			} else {
2578
+							$fileUrl = false;
2442 2579
 			}
2443
-
2444
-			else
2445
-				$fileUrl = false;
2446
-		}
2447
-
2448
-		else
2580
+		} else
2449 2581
 		{
2450 2582
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2451 2583
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2460,12 +2592,14 @@  discard block
 block discarded – undo
2460 2592
 	}
2461 2593
 
2462 2594
 	// Add it to the array for use in the template
2463
-	if (!empty($fileName))
2464
-		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2595
+	if (!empty($fileName)) {
2596
+			$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2597
+	}
2465 2598
 
2466
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2467
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2468
-}
2599
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2600
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2601
+	}
2602
+	}
2469 2603
 
2470 2604
 /**
2471 2605
  * Add a block of inline css code to be executed later
@@ -2482,8 +2616,9 @@  discard block
 block discarded – undo
2482 2616
 	global $context;
2483 2617
 
2484 2618
 	// Gotta add something...
2485
-	if (empty($css))
2486
-		return false;
2619
+	if (empty($css)) {
2620
+			return false;
2621
+	}
2487 2622
 
2488 2623
 	$context['css_header'][] = $css;
2489 2624
 }
@@ -2518,8 +2653,9 @@  discard block
 block discarded – undo
2518 2653
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2519 2654
 
2520 2655
 	// If this is an external file, automatically set this to false.
2521
-	if (!empty($params['external']))
2522
-		$params['minimize'] = false;
2656
+	if (!empty($params['external'])) {
2657
+			$params['minimize'] = false;
2658
+	}
2523 2659
 
2524 2660
 	// Account for shorthand like admin.js?alp21 filenames
2525 2661
 	$has_seed = strpos($fileName, '.js?');
@@ -2536,16 +2672,12 @@  discard block
 block discarded – undo
2536 2672
 			{
2537 2673
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2538 2674
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2539
-			}
2540
-
2541
-			else
2675
+			} else
2542 2676
 			{
2543 2677
 				$fileUrl = false;
2544 2678
 				$filePath = false;
2545 2679
 			}
2546
-		}
2547
-
2548
-		else
2680
+		} else
2549 2681
 		{
2550 2682
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2551 2683
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2560,9 +2692,10 @@  discard block
 block discarded – undo
2560 2692
 	}
2561 2693
 
2562 2694
 	// Add it to the array for use in the template
2563
-	if (!empty($fileName))
2564
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2565
-}
2695
+	if (!empty($fileName)) {
2696
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2697
+	}
2698
+	}
2566 2699
 
2567 2700
 /**
2568 2701
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2576,9 +2709,10 @@  discard block
 block discarded – undo
2576 2709
 {
2577 2710
 	global $context;
2578 2711
 
2579
-	if (!empty($key) && (!empty($value) || $value === '0'))
2580
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2581
-}
2712
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2713
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2714
+	}
2715
+	}
2582 2716
 
2583 2717
 /**
2584 2718
  * Add a block of inline Javascript code to be executed later
@@ -2595,8 +2729,9 @@  discard block
 block discarded – undo
2595 2729
 {
2596 2730
 	global $context;
2597 2731
 
2598
-	if (empty($javascript))
2599
-		return false;
2732
+	if (empty($javascript)) {
2733
+			return false;
2734
+	}
2600 2735
 
2601 2736
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2602 2737
 }
@@ -2617,15 +2752,18 @@  discard block
 block discarded – undo
2617 2752
 	static $already_loaded = array();
2618 2753
 
2619 2754
 	// Default to the user's language.
2620
-	if ($lang == '')
2621
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2755
+	if ($lang == '') {
2756
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2757
+	}
2622 2758
 
2623 2759
 	// Do we want the English version of language file as fallback?
2624
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2625
-		loadLanguage($template_name, 'english', false);
2760
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2761
+			loadLanguage($template_name, 'english', false);
2762
+	}
2626 2763
 
2627
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2628
-		return $lang;
2764
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2765
+			return $lang;
2766
+	}
2629 2767
 
2630 2768
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2631 2769
 	if (empty($settings['default_theme_dir']))
@@ -2636,8 +2774,9 @@  discard block
 block discarded – undo
2636 2774
 
2637 2775
 	// What theme are we in?
2638 2776
 	$theme_name = basename($settings['theme_url']);
2639
-	if (empty($theme_name))
2640
-		$theme_name = 'unknown';
2777
+	if (empty($theme_name)) {
2778
+			$theme_name = 'unknown';
2779
+	}
2641 2780
 
2642 2781
 	// For each file open it up and write it out!
2643 2782
 	foreach (explode('+', $template_name) as $template)
@@ -2679,8 +2818,9 @@  discard block
 block discarded – undo
2679 2818
 				$found = true;
2680 2819
 
2681 2820
 				// setlocale is required for basename() & pathinfo() to work properly on the selected language
2682
-				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set']))
2683
-					setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2821
+				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) {
2822
+									setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2823
+				}
2684 2824
 
2685 2825
 				break;
2686 2826
 			}
@@ -2720,8 +2860,9 @@  discard block
 block discarded – undo
2720 2860
 	}
2721 2861
 
2722 2862
 	// Keep track of what we're up to soldier.
2723
-	if ($db_show_debug === true)
2724
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2863
+	if ($db_show_debug === true) {
2864
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2865
+	}
2725 2866
 
2726 2867
 	// Remember what we have loaded, and in which language.
2727 2868
 	$already_loaded[$template_name] = $lang;
@@ -2767,8 +2908,9 @@  discard block
 block discarded – undo
2767 2908
 				)
2768 2909
 			);
2769 2910
 			// In the EXTREMELY unlikely event this happens, give an error message.
2770
-			if ($smcFunc['db_num_rows']($result) == 0)
2771
-				fatal_lang_error('parent_not_found', 'critical');
2911
+			if ($smcFunc['db_num_rows']($result) == 0) {
2912
+							fatal_lang_error('parent_not_found', 'critical');
2913
+			}
2772 2914
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2773 2915
 			{
2774 2916
 				if (!isset($boards[$row['id_board']]))
@@ -2785,8 +2927,8 @@  discard block
 block discarded – undo
2785 2927
 					);
2786 2928
 				}
2787 2929
 				// If a moderator exists for this board, add that moderator for all children too.
2788
-				if (!empty($row['id_moderator']))
2789
-					foreach ($boards as $id => $dummy)
2930
+				if (!empty($row['id_moderator'])) {
2931
+									foreach ($boards as $id => $dummy)
2790 2932
 					{
2791 2933
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2792 2934
 							'id' => $row['id_moderator'],
@@ -2794,11 +2936,12 @@  discard block
 block discarded – undo
2794 2936
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2795 2937
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2796 2938
 						);
2939
+				}
2797 2940
 					}
2798 2941
 
2799 2942
 				// If a moderator group exists for this board, add that moderator group for all children too
2800
-				if (!empty($row['id_moderator_group']))
2801
-					foreach ($boards as $id => $dummy)
2943
+				if (!empty($row['id_moderator_group'])) {
2944
+									foreach ($boards as $id => $dummy)
2802 2945
 					{
2803 2946
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2804 2947
 							'id' => $row['id_moderator_group'],
@@ -2806,6 +2949,7 @@  discard block
 block discarded – undo
2806 2949
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2807 2950
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2808 2951
 						);
2952
+				}
2809 2953
 					}
2810 2954
 			}
2811 2955
 			$smcFunc['db_free_result']($result);
@@ -2832,23 +2976,27 @@  discard block
 block discarded – undo
2832 2976
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2833 2977
 	{
2834 2978
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2835
-		if (empty($smcFunc['ucwords']))
2836
-			reloadSettings();
2979
+		if (empty($smcFunc['ucwords'])) {
2980
+					reloadSettings();
2981
+		}
2837 2982
 
2838 2983
 		// If we don't have our theme information yet, let's get it.
2839
-		if (empty($settings['default_theme_dir']))
2840
-			loadTheme(0, false);
2984
+		if (empty($settings['default_theme_dir'])) {
2985
+					loadTheme(0, false);
2986
+		}
2841 2987
 
2842 2988
 		// Default language directories to try.
2843 2989
 		$language_directories = array(
2844 2990
 			$settings['default_theme_dir'] . '/languages',
2845 2991
 		);
2846
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2847
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
2992
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
2993
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
2994
+		}
2848 2995
 
2849 2996
 		// We possibly have a base theme directory.
2850
-		if (!empty($settings['base_theme_dir']))
2851
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
2997
+		if (!empty($settings['base_theme_dir'])) {
2998
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
2999
+		}
2852 3000
 
2853 3001
 		// Remove any duplicates.
2854 3002
 		$language_directories = array_unique($language_directories);
@@ -2862,20 +3010,21 @@  discard block
 block discarded – undo
2862 3010
 		foreach ($language_directories as $language_dir)
2863 3011
 		{
2864 3012
 			// Can't look in here... doesn't exist!
2865
-			if (!file_exists($language_dir))
2866
-				continue;
3013
+			if (!file_exists($language_dir)) {
3014
+							continue;
3015
+			}
2867 3016
 
2868 3017
 			$dir = dir($language_dir);
2869 3018
 			while ($entry = $dir->read())
2870 3019
 			{
2871 3020
 				// Look for the index language file... For good measure skip any "index.language-utf8.php" files
2872
-				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches))
2873
-					continue;
2874
-
2875
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2876
-					$langName = $langList[$matches[1]];
3021
+				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) {
3022
+									continue;
3023
+				}
2877 3024
 
2878
-				else
3025
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
3026
+									$langName = $langList[$matches[1]];
3027
+				} else
2879 3028
 				{
2880 3029
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2881 3030
 
@@ -2916,12 +3065,14 @@  discard block
 block discarded – undo
2916 3065
 		}
2917 3066
 
2918 3067
 		// Do we need to store the lang list?
2919
-		if (empty($langList))
2920
-			updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3068
+		if (empty($langList)) {
3069
+					updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3070
+		}
2921 3071
 
2922 3072
 		// Let's cash in on this deal.
2923
-		if (!empty($modSettings['cache_enable']))
2924
-			cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3073
+		if (!empty($modSettings['cache_enable'])) {
3074
+					cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3075
+		}
2925 3076
 	}
2926 3077
 
2927 3078
 	return $context['languages'];
@@ -2944,8 +3095,9 @@  discard block
 block discarded – undo
2944 3095
 	global $modSettings, $options, $txt;
2945 3096
 	static $censor_vulgar = null, $censor_proper;
2946 3097
 
2947
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2948
-		return $text;
3098
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3099
+			return $text;
3100
+	}
2949 3101
 
2950 3102
 	// If they haven't yet been loaded, load them.
2951 3103
 	if ($censor_vulgar == null)
@@ -2973,9 +3125,9 @@  discard block
 block discarded – undo
2973 3125
 	{
2974 3126
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
2975 3127
 		$text = $func($censor_vulgar, $censor_proper, $text);
3128
+	} else {
3129
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
2976 3130
 	}
2977
-	else
2978
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
2979 3131
 
2980 3132
 	return $text;
2981 3133
 }
@@ -3001,38 +3153,42 @@  discard block
 block discarded – undo
3001 3153
 	@ini_set('track_errors', '1');
3002 3154
 
3003 3155
 	// Don't include the file more than once, if $once is true.
3004
-	if ($once && in_array($filename, $templates))
3005
-		return;
3156
+	if ($once && in_array($filename, $templates)) {
3157
+			return;
3158
+	}
3006 3159
 	// Add this file to the include list, whether $once is true or not.
3007
-	else
3008
-		$templates[] = $filename;
3160
+	else {
3161
+			$templates[] = $filename;
3162
+	}
3009 3163
 
3010 3164
 	// Are we going to use eval?
3011 3165
 	if (empty($modSettings['disableTemplateEval']))
3012 3166
 	{
3013 3167
 		$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
3014 3168
 		$settings['current_include_filename'] = $filename;
3015
-	}
3016
-	else
3169
+	} else
3017 3170
 	{
3018 3171
 		$file_found = file_exists($filename);
3019 3172
 
3020
-		if ($once && $file_found)
3021
-			require_once($filename);
3022
-		elseif ($file_found)
3023
-			require($filename);
3173
+		if ($once && $file_found) {
3174
+					require_once($filename);
3175
+		} elseif ($file_found) {
3176
+					require($filename);
3177
+		}
3024 3178
 	}
3025 3179
 
3026 3180
 	if ($file_found !== true)
3027 3181
 	{
3028 3182
 		ob_end_clean();
3029
-		if (!empty($modSettings['enableCompressedOutput']))
3030
-			@ob_start('ob_gzhandler');
3031
-		else
3032
-			ob_start();
3183
+		if (!empty($modSettings['enableCompressedOutput'])) {
3184
+					@ob_start('ob_gzhandler');
3185
+		} else {
3186
+					ob_start();
3187
+		}
3033 3188
 
3034
-		if (isset($_GET['debug']))
3035
-			header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3189
+		if (isset($_GET['debug'])) {
3190
+					header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3191
+		}
3036 3192
 
3037 3193
 		// Don't cache error pages!!
3038 3194
 		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -3051,12 +3207,13 @@  discard block
 block discarded – undo
3051 3207
 		echo '<!DOCTYPE html>
3052 3208
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
3053 3209
 	<head>';
3054
-		if (isset($context['character_set']))
3055
-			echo '
3210
+		if (isset($context['character_set'])) {
3211
+					echo '
3056 3212
 		<meta charset="', $context['character_set'], '">';
3213
+		}
3057 3214
 
3058
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3059
-			echo '
3215
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3216
+					echo '
3060 3217
 		<title>', $mtitle, '</title>
3061 3218
 	</head>
3062 3219
 	<body>
@@ -3064,8 +3221,8 @@  discard block
 block discarded – undo
3064 3221
 		', $mmessage, '
3065 3222
 	</body>
3066 3223
 </html>';
3067
-		elseif (!allowedTo('admin_forum'))
3068
-			echo '
3224
+		} elseif (!allowedTo('admin_forum')) {
3225
+					echo '
3069 3226
 		<title>', $txt['template_parse_error'], '</title>
3070 3227
 	</head>
3071 3228
 	<body>
@@ -3073,16 +3230,18 @@  discard block
 block discarded – undo
3073 3230
 		', $txt['template_parse_error_message'], '
3074 3231
 	</body>
3075 3232
 </html>';
3076
-		else
3233
+		} else
3077 3234
 		{
3078 3235
 			require_once($sourcedir . '/Subs-Package.php');
3079 3236
 
3080 3237
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3081 3238
 			$error_array = error_get_last();
3082
-			if (empty($error) && ini_get('track_errors') && !empty($error_array))
3083
-				$error = $error_array['message'];
3084
-			if (empty($error))
3085
-				$error = $txt['template_parse_errmsg'];
3239
+			if (empty($error) && ini_get('track_errors') && !empty($error_array)) {
3240
+							$error = $error_array['message'];
3241
+			}
3242
+			if (empty($error)) {
3243
+							$error = $txt['template_parse_errmsg'];
3244
+			}
3086 3245
 
3087 3246
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3088 3247
 
@@ -3093,11 +3252,12 @@  discard block
 block discarded – undo
3093 3252
 		<h3>', $txt['template_parse_error'], '</h3>
3094 3253
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3095 3254
 
3096
-			if (!empty($error))
3097
-				echo '
3255
+			if (!empty($error)) {
3256
+							echo '
3098 3257
 		<hr>
3099 3258
 
3100 3259
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3260
+			}
3101 3261
 
3102 3262
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3103 3263
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3107,10 +3267,11 @@  discard block
 block discarded – undo
3107 3267
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3108 3268
 
3109 3269
 				// Fix the PHP code stuff...
3110
-				if (!isBrowser('gecko'))
3111
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3112
-				else
3113
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3270
+				if (!isBrowser('gecko')) {
3271
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3272
+				} else {
3273
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3274
+				}
3114 3275
 
3115 3276
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3116 3277
 				$j = -1;
@@ -3118,8 +3279,9 @@  discard block
 block discarded – undo
3118 3279
 				{
3119 3280
 					$j++;
3120 3281
 
3121
-					if (substr_count($line, '<br>') == 0)
3122
-						continue;
3282
+					if (substr_count($line, '<br>') == 0) {
3283
+											continue;
3284
+					}
3123 3285
 
3124 3286
 					$n = substr_count($line, '<br>');
3125 3287
 					for ($i = 0; $i < $n; $i++)
@@ -3138,38 +3300,42 @@  discard block
 block discarded – undo
3138 3300
 				// Figure out what the color coding was before...
3139 3301
 				$line = max($match[1] - 9, 1);
3140 3302
 				$last_line = '';
3141
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3142
-					if (strpos($data2[$line2], '<') !== false)
3303
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3304
+									if (strpos($data2[$line2], '<') !== false)
3143 3305
 					{
3144 3306
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3145 3307
 							$last_line = $color_match[1];
3308
+				}
3146 3309
 						break;
3147 3310
 					}
3148 3311
 
3149 3312
 				// Show the relevant lines...
3150 3313
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3151 3314
 				{
3152
-					if ($line == $match[1])
3153
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3315
+					if ($line == $match[1]) {
3316
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3317
+					}
3154 3318
 
3155 3319
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3156
-					if (isset($data2[$line]) && $data2[$line] != '')
3157
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3320
+					if (isset($data2[$line]) && $data2[$line] != '') {
3321
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3322
+					}
3158 3323
 
3159 3324
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3160 3325
 					{
3161 3326
 						$last_line = $color_match[1];
3162 3327
 						echo '</', substr($last_line, 1, 4), '>';
3328
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3329
+											$last_line = '';
3330
+					} elseif ($last_line != '' && $data2[$line] != '') {
3331
+											echo '</', substr($last_line, 1, 4), '>';
3163 3332
 					}
3164
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3165
-						$last_line = '';
3166
-					elseif ($last_line != '' && $data2[$line] != '')
3167
-						echo '</', substr($last_line, 1, 4), '>';
3168 3333
 
3169
-					if ($line == $match[1])
3170
-						echo '</pre></div><pre style="margin: 0;">';
3171
-					else
3172
-						echo "\n";
3334
+					if ($line == $match[1]) {
3335
+											echo '</pre></div><pre style="margin: 0;">';
3336
+					} else {
3337
+											echo "\n";
3338
+					}
3173 3339
 				}
3174 3340
 
3175 3341
 				echo '</pre></div>';
@@ -3193,8 +3359,9 @@  discard block
 block discarded – undo
3193 3359
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port;
3194 3360
 
3195 3361
 	// Figure out what type of database we are using.
3196
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3197
-		$db_type = 'mysql';
3362
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3363
+			$db_type = 'mysql';
3364
+	}
3198 3365
 
3199 3366
 	// Load the file for the database.
3200 3367
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3202,8 +3369,9 @@  discard block
 block discarded – undo
3202 3369
 	$db_options = array();
3203 3370
 
3204 3371
 	// Add in the port if needed
3205
-	if (!empty($db_port))
3206
-		$db_options['port'] = $db_port;
3372
+	if (!empty($db_port)) {
3373
+			$db_options['port'] = $db_port;
3374
+	}
3207 3375
 
3208 3376
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
3209 3377
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3222,13 +3390,15 @@  discard block
 block discarded – undo
3222 3390
 	}
3223 3391
 
3224 3392
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3225
-	if (!$db_connection)
3226
-		display_db_error();
3393
+	if (!$db_connection) {
3394
+			display_db_error();
3395
+	}
3227 3396
 
3228 3397
 	// If in SSI mode fix up the prefix.
3229
-	if (SMF == 'SSI')
3230
-		db_fix_prefix($db_prefix, $db_name);
3231
-}
3398
+	if (SMF == 'SSI') {
3399
+			db_fix_prefix($db_prefix, $db_name);
3400
+	}
3401
+	}
3232 3402
 
3233 3403
 /**
3234 3404
  * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it.
@@ -3242,10 +3412,11 @@  discard block
 block discarded – undo
3242 3412
 	global $sourcedir, $cacheAPI, $cache_accelerator;
3243 3413
 
3244 3414
 	// Not overriding this and we have a cacheAPI, send it back.
3245
-	if (empty($overrideCache) && is_object($cacheAPI))
3246
-		return $cacheAPI;
3247
-	elseif (is_null($cacheAPI))
3248
-		$cacheAPI = false;
3415
+	if (empty($overrideCache) && is_object($cacheAPI)) {
3416
+			return $cacheAPI;
3417
+	} elseif (is_null($cacheAPI)) {
3418
+			$cacheAPI = false;
3419
+	}
3249 3420
 
3250 3421
 	// Make sure our class is in session.
3251 3422
 	require_once($sourcedir . '/Class-CacheAPI.php');
@@ -3266,8 +3437,9 @@  discard block
 block discarded – undo
3266 3437
 		if (!$testAPI->isSupported())
3267 3438
 		{
3268 3439
 			// Can we save ourselves?
3269
-			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf')
3270
-				return loadCacheAccelerator(null, false);
3440
+			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') {
3441
+							return loadCacheAccelerator(null, false);
3442
+			}
3271 3443
 			return false;
3272 3444
 		}
3273 3445
 
@@ -3279,9 +3451,9 @@  discard block
 block discarded – undo
3279 3451
 		{
3280 3452
 			$cacheAPI = $testAPI;
3281 3453
 			return $cacheAPI;
3454
+		} else {
3455
+					return $testAPI;
3282 3456
 		}
3283
-		else
3284
-			return $testAPI;
3285 3457
 	}
3286 3458
 }
3287 3459
 
@@ -3301,8 +3473,9 @@  discard block
 block discarded – undo
3301 3473
 
3302 3474
 	// @todo Why are we doing this if caching is disabled?
3303 3475
 
3304
-	if (function_exists('call_integration_hook'))
3305
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3476
+	if (function_exists('call_integration_hook')) {
3477
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3478
+	}
3306 3479
 
3307 3480
 	/* Refresh the cache if either:
3308 3481
 		1. Caching is disabled.
@@ -3316,16 +3489,19 @@  discard block
 block discarded – undo
3316 3489
 		require_once($sourcedir . '/' . $file);
3317 3490
 		$cache_block = call_user_func_array($function, $params);
3318 3491
 
3319
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3320
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3492
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3493
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3494
+		}
3321 3495
 	}
3322 3496
 
3323 3497
 	// Some cached data may need a freshening up after retrieval.
3324
-	if (!empty($cache_block['post_retri_eval']))
3325
-		eval($cache_block['post_retri_eval']);
3498
+	if (!empty($cache_block['post_retri_eval'])) {
3499
+			eval($cache_block['post_retri_eval']);
3500
+	}
3326 3501
 
3327
-	if (function_exists('call_integration_hook'))
3328
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3502
+	if (function_exists('call_integration_hook')) {
3503
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3504
+	}
3329 3505
 
3330 3506
 	return $cache_block['data'];
3331 3507
 }
@@ -3352,8 +3528,9 @@  discard block
 block discarded – undo
3352 3528
 	global $smcFunc, $cache_enable, $cacheAPI;
3353 3529
 	global $cache_hits, $cache_count, $db_show_debug;
3354 3530
 
3355
-	if (empty($cache_enable) || empty($cacheAPI))
3356
-		return;
3531
+	if (empty($cache_enable) || empty($cacheAPI)) {
3532
+			return;
3533
+	}
3357 3534
 
3358 3535
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3359 3536
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3366,12 +3543,14 @@  discard block
 block discarded – undo
3366 3543
 	$value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value));
3367 3544
 	$cacheAPI->putData($key, $value, $ttl);
3368 3545
 
3369
-	if (function_exists('call_integration_hook'))
3370
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3546
+	if (function_exists('call_integration_hook')) {
3547
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3548
+	}
3371 3549
 
3372
-	if (isset($db_show_debug) && $db_show_debug === true)
3373
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3374
-}
3550
+	if (isset($db_show_debug) && $db_show_debug === true) {
3551
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3552
+	}
3553
+	}
3375 3554
 
3376 3555
 /**
3377 3556
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3387,8 +3566,9 @@  discard block
 block discarded – undo
3387 3566
 	global $smcFunc, $cache_enable, $cacheAPI;
3388 3567
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
3389 3568
 
3390
-	if (empty($cache_enable) || empty($cacheAPI))
3391
-		return;
3569
+	if (empty($cache_enable) || empty($cacheAPI)) {
3570
+			return;
3571
+	}
3392 3572
 
3393 3573
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3394 3574
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3408,16 +3588,18 @@  discard block
 block discarded – undo
3408 3588
 
3409 3589
 		if (empty($value))
3410 3590
 		{
3411
-			if (!is_array($cache_misses))
3412
-				$cache_misses = array();
3591
+			if (!is_array($cache_misses)) {
3592
+							$cache_misses = array();
3593
+			}
3413 3594
 
3414 3595
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3415 3596
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3416 3597
 		}
3417 3598
 	}
3418 3599
 
3419
-	if (function_exists('call_integration_hook') && isset($value))
3420
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3600
+	if (function_exists('call_integration_hook') && isset($value)) {
3601
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3602
+	}
3421 3603
 
3422 3604
 	return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true));
3423 3605
 }
@@ -3439,8 +3621,9 @@  discard block
 block discarded – undo
3439 3621
 	global $cacheAPI;
3440 3622
 
3441 3623
 	// If we can't get to the API, can't do this.
3442
-	if (empty($cacheAPI))
3443
-		return;
3624
+	if (empty($cacheAPI)) {
3625
+			return;
3626
+	}
3444 3627
 
3445 3628
 	// Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure.
3446 3629
 	$cacheAPI->cleanCache($type);
@@ -3465,8 +3648,9 @@  discard block
 block discarded – undo
3465 3648
 	global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret;
3466 3649
 
3467 3650
 	// Come on!
3468
-	if (empty($data))
3469
-		return array();
3651
+	if (empty($data)) {
3652
+			return array();
3653
+	}
3470 3654
 
3471 3655
 	// Set a nice default var.
3472 3656
 	$image = '';
@@ -3474,11 +3658,11 @@  discard block
 block discarded – undo
3474 3658
 	// Gravatar has been set as mandatory!
3475 3659
 	if (!empty($modSettings['gravatarOverride']))
3476 3660
 	{
3477
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3478
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3479
-
3480
-		else if (!empty($data['email']))
3481
-			$image = get_gravatar_url($data['email']);
3661
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3662
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3663
+		} else if (!empty($data['email'])) {
3664
+					$image = get_gravatar_url($data['email']);
3665
+		}
3482 3666
 	}
3483 3667
 
3484 3668
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3490,54 +3674,60 @@  discard block
 block discarded – undo
3490 3674
 			// Gravatar.
3491 3675
 			if (stristr($data['avatar'], 'gravatar://'))
3492 3676
 			{
3493
-				if ($data['avatar'] == 'gravatar://')
3494
-					$image = get_gravatar_url($data['email']);
3495
-
3496
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3497
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3677
+				if ($data['avatar'] == 'gravatar://') {
3678
+									$image = get_gravatar_url($data['email']);
3679
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3680
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3681
+				}
3498 3682
 			}
3499 3683
 
3500 3684
 			// External url.
3501 3685
 			else
3502 3686
 			{
3503 3687
 				// Using ssl?
3504
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false)
3505
-					$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3688
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) {
3689
+									$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3690
+				}
3506 3691
 
3507 3692
 				// Just a plain external url.
3508
-				else
3509
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3693
+				else {
3694
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3695
+				}
3510 3696
 			}
3511 3697
 		}
3512 3698
 
3513 3699
 		// Perhaps this user has an attachment as avatar...
3514
-		else if (!empty($data['filename']))
3515
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3700
+		else if (!empty($data['filename'])) {
3701
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3702
+		}
3516 3703
 
3517 3704
 		// Right... no avatar... use our default image.
3518
-		else
3519
-			$image = $modSettings['avatar_url'] . '/default.png';
3705
+		else {
3706
+					$image = $modSettings['avatar_url'] . '/default.png';
3707
+		}
3520 3708
 	}
3521 3709
 
3522 3710
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3523 3711
 
3524 3712
 	// At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed.
3525
-	if (!empty($image))
3526
-		return array(
3713
+	if (!empty($image)) {
3714
+			return array(
3527 3715
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3528 3716
 			'image' => '<img class="avatar" src="' . $image . '" />',
3529 3717
 			'href' => $image,
3530 3718
 			'url' => $image,
3531 3719
 		);
3720
+	}
3532 3721
 
3533 3722
 	// Fallback to make life easier for everyone...
3534
-	else
3535
-		return array(
3723
+	else {
3724
+			return array(
3536 3725
 			'name' => '',
3537 3726
 			'image' => '',
3538 3727
 			'href' => '',
3539 3728
 			'url' => '',
3540 3729
 		);
3541
-}
3730
+	}
3731
+	}
3542 3732
 
3543 3733
 ?>
3544 3734
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageMaintenance.template.php 1 patch
Braces   +36 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// If maintenance has finished tell the user.
21
-	if (!empty($context['maintenance_finished']))
22
-		echo '
21
+	if (!empty($context['maintenance_finished'])) {
22
+			echo '
23 23
 			<div class="infobox">
24 24
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
25 25
 			</div>';
26
+	}
26 27
 
27 28
 	echo '
28 29
 	<div id="manage_maintenance">
@@ -107,11 +108,12 @@  discard block
 block discarded – undo
107 108
 	<div id="manage_maintenance">';
108 109
 
109 110
 	// If maintenance has finished tell the user.
110
-	if (!empty($context['maintenance_finished']))
111
-		echo '
111
+	if (!empty($context['maintenance_finished'])) {
112
+			echo '
112 113
 			<div class="infobox">
113 114
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
114 115
 			</div>';
116
+	}
115 117
 
116 118
 	echo '
117 119
 		<div class="cat_bar">
@@ -238,11 +240,12 @@  discard block
 block discarded – undo
238 240
 	<div id="manage_maintenance">';
239 241
 
240 242
 	// If maintenance has finished tell the user.
241
-	if (!empty($context['maintenance_finished']))
242
-	echo '
243
+	if (!empty($context['maintenance_finished'])) {
244
+		echo '
243 245
 		<div class="infobox">
244 246
 			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
245 247
 		</div>';
248
+	}
246 249
 
247 250
 	echo '
248 251
 		<div class="cat_bar">
@@ -300,9 +303,10 @@  discard block
 block discarded – undo
300 303
 				<p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p>
301 304
 				<div style="display: none; padding: 3px" id="membersPanel">';
302 305
 
303
-	foreach ($context['membergroups'] as $group)
304
-		echo '
306
+	foreach ($context['membergroups'] as $group) {
307
+			echo '
305 308
 					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>';
309
+	}
306 310
 
307 311
 	echo '
308 312
 				</div>
@@ -346,11 +350,12 @@  discard block
 block discarded – undo
346 350
 	global $scripturl, $txt, $context, $settings, $modSettings;
347 351
 
348 352
 	// If maintenance has finished tell the user.
349
-	if (!empty($context['maintenance_finished']))
350
-		echo '
353
+	if (!empty($context['maintenance_finished'])) {
354
+			echo '
351 355
 			<div class="infobox">
352 356
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
353 357
 			</div>';
358
+	}
354 359
 
355 360
 	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
356 361
 	echo '
@@ -418,19 +423,21 @@  discard block
 block discarded – undo
418 423
 								<ul>';
419 424
 
420 425
 		// Display a checkbox with every board.
421
-		foreach ($category['boards'] as $board)
422
-			echo '
426
+		foreach ($category['boards'] as $board) {
427
+					echo '
423 428
 									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label></li>';
429
+		}
424 430
 
425 431
 		echo '
426 432
 								</ul>
427 433
 							</fieldset>';
428 434
 
429 435
 		// Increase $i, and check if we're at the middle yet.
430
-		if (++$i == $middle)
431
-			echo '
436
+		if (++$i == $middle) {
437
+					echo '
432 438
 						</div>
433 439
 						<div class="floatright" style="width: 49%;">';
440
+		}
434 441
 	}
435 442
 
436 443
 	echo '
@@ -469,9 +476,10 @@  discard block
 block discarded – undo
469 476
 		echo '
470 477
 					<optgroup label="', $category['name'], '">';
471 478
 
472
-		foreach ($category['boards'] as $board)
473
-			echo '
479
+		foreach ($category['boards'] as $board) {
480
+					echo '
474 481
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
482
+		}
475 483
 
476 484
 		echo '
477 485
 					</optgroup>';
@@ -489,9 +497,10 @@  discard block
 block discarded – undo
489 497
 		echo '
490 498
 					<optgroup label="', $category['name'], '">';
491 499
 
492
-		foreach ($category['boards'] as $board)
493
-			echo '
500
+		foreach ($category['boards'] as $board) {
501
+					echo '
494 502
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
503
+		}
495 504
 
496 505
 		echo '
497 506
 					</optgroup>';
@@ -531,9 +540,10 @@  discard block
 block discarded – undo
531 540
 				', $txt['database_optimize_attempt'], '<br>';
532 541
 
533 542
 	// List each table being optimized...
534
-	foreach ($context['optimized_tables'] as $table)
535
-		echo '
543
+	foreach ($context['optimized_tables'] as $table) {
544
+			echo '
536 545
 				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
546
+	}
537 547
 
538 548
 	// How did we go?
539 549
 	echo '
@@ -590,13 +600,14 @@  discard block
 block discarded – undo
590 600
 				', implode('</li><li>', $context['exceeding_messages']), '
591 601
 				</li>
592 602
 			</ul>';
593
-		if (!empty($context['exceeding_messages_morethan']))
594
-			echo '
603
+		if (!empty($context['exceeding_messages_morethan'])) {
604
+					echo '
595 605
 			<p>', $context['exceeding_messages_morethan'], '</p>';
596
-	}
597
-	else
598
-		echo '
606
+		}
607
+	} else {
608
+			echo '
599 609
 			<p class="infobox">', $txt['convert_to_text'], '</p>';
610
+	}
600 611
 
601 612
 	echo '
602 613
 			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.
Sources/Class-CacheAPI.php 1 patch
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Interface cache_api_interface
@@ -182,8 +183,9 @@  discard block
 block discarded – undo
182 183
 	{
183 184
 		global $cache_enable;
184 185
 
185
-		if ($test)
186
-			return true;
186
+		if ($test) {
187
+					return true;
188
+		}
187 189
 		return !empty($cache_enable);
188 190
 	}
189 191
 
@@ -202,18 +204,20 @@  discard block
 block discarded – undo
202 204
 		global $boardurl, $cachedir;
203 205
 
204 206
 		// Find a valid good file to do mtime checks on.
205
-		if (file_exists($cachedir . '/' . 'index.php'))
206
-			$filemtime = $cachedir . '/' . 'index.php';
207
-		elseif (is_dir($cachedir . '/'))
208
-			$filemtime = $cachedir . '/';
209
-		else
210
-			$filemtime = $boardurl . '/index.php';
207
+		if (file_exists($cachedir . '/' . 'index.php')) {
208
+					$filemtime = $cachedir . '/' . 'index.php';
209
+		} elseif (is_dir($cachedir . '/')) {
210
+					$filemtime = $cachedir . '/';
211
+		} else {
212
+					$filemtime = $boardurl . '/index.php';
213
+		}
211 214
 
212 215
 		// Set the default if no prefix was specified.
213
-		if (empty($prefix))
214
-			$this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-';
215
-		else
216
-			$this->prefix = $prefix;
216
+		if (empty($prefix)) {
217
+					$this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-';
218
+		} else {
219
+					$this->prefix = $prefix;
220
+		}
217 221
 
218 222
 		return true;
219 223
 	}
@@ -276,8 +280,9 @@  discard block
 block discarded – undo
276 280
 
277 281
 		// Invalidate cache, to be sure!
278 282
 		// ... as long as index.php can be modified, anyway.
279
-		if (is_writable($cachedir . '/' . 'index.php'))
280
-			@touch($cachedir . '/' . 'index.php');
283
+		if (is_writable($cachedir . '/' . 'index.php')) {
284
+					@touch($cachedir . '/' . 'index.php');
285
+		}
281 286
 
282 287
 		return true;
283 288
 	}
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3014,8 +3014,7 @@
 block discarded – undo
3014 3014
 							<div class="roundframe">
3015 3015
 								<div>
3016 3016
 		', !empty($context['tfa_backup']) ? '
3017
-									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3018
-			($modSettings['tfa_mode'] == 2 ? '
3017
+									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? '
3019 3018
 									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3020 3019
 									<div class="smalltext">', $txt['tfa_desc'], '</div>
3021 3020
 									<div class="floatleft">
Please login to merge, or discard this patch.
Braces   +465 added lines, -346 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 	<script>
24 24
 		disableAutoComplete();
25 25
 	</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 					', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 					<div class="infobox">
35 36
 						', $context['profile_updated'], '
36 37
 					</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -102,8 +104,7 @@  discard block
 block discarded – undo
102 104
 	if (empty($context['unread_alerts']))
103 105
 	{
104 106
 		template_alerts_all_read();
105
-	}
106
-	else
107
+	} else
107 108
 	{
108 109
 		foreach ($context['unread_alerts'] as $id_alert => $details)
109 110
 		{
@@ -164,10 +165,11 @@  discard block
 block discarded – undo
164 165
 			<div class="custom_fields_above_name">
165 166
 				<ul >';
166 167
 
167
-		foreach ($context['print_custom_fields']['above_member'] as $field)
168
-			if (!empty($field['output_html']))
168
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
169
+					if (!empty($field['output_html']))
169 170
 				echo '
170 171
 					<li>', $field['output_html'], '</li>';
172
+		}
171 173
 
172 174
 		echo '
173 175
 				</ul>
@@ -188,10 +190,11 @@  discard block
 block discarded – undo
188 190
 			<div class="custom_fields_below_avatar">
189 191
 				<ul >';
190 192
 
191
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
192
-			if (!empty($field['output_html']))
193
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
194
+					if (!empty($field['output_html']))
193 195
 				echo '
194 196
 					<li>', $field['output_html'], '</li>';
197
+		}
195 198
 
196 199
 		echo '
197 200
 				</ul>
@@ -202,22 +205,25 @@  discard block
 block discarded – undo
202 205
 		echo '
203 206
 			<ul class="clear">';
204 207
 	// Email is only visible if it's your profile or you have the moderate_forum permission
205
-	if ($context['member']['show_email'])
206
-		echo '
208
+	if ($context['member']['show_email']) {
209
+			echo '
207 210
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
211
+	}
208 212
 
209 213
 	// Don't show an icon if they haven't specified a website.
210
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
211
-		echo '
214
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
215
+			echo '
212 216
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
217
+	}
213 218
 
214 219
 	// Are there any custom profile fields as icons?
215 220
 	if (!empty($context['print_custom_fields']['icons']))
216 221
 	{
217
-		foreach ($context['print_custom_fields']['icons'] as $field)
218
-			if (!empty($field['output_html']))
222
+		foreach ($context['print_custom_fields']['icons'] as $field) {
223
+					if (!empty($field['output_html']))
219 224
 				echo '
220 225
 					<li class="custom_field">', $field['output_html'], '</li>';
226
+		}
221 227
 	}
222 228
 
223 229
 	echo '
@@ -225,23 +231,26 @@  discard block
 block discarded – undo
225 231
 			<span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
226 232
 
227 233
 	// Can they add this member as a buddy?
228
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
229
-		echo '
234
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
235
+			echo '
230 236
 				<br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
237
+	}
231 238
 
232 239
 	echo '
233 240
 			</span>';
234 241
 
235
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
236
-		echo '
242
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
243
+			echo '
237 244
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
245
+	}
238 246
 
239 247
 	echo '
240 248
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
241 249
 
242
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
243
-		echo '
250
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
251
+			echo '
244 252
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
253
+	}
245 254
 
246 255
 	echo '
247 256
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -253,10 +262,11 @@  discard block
 block discarded – undo
253 262
 			<div class="custom_fields_bottom">
254 263
 				<ul class="nolist">';
255 264
 
256
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
257
-			if (!empty($field['output_html']))
265
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
266
+					if (!empty($field['output_html']))
258 267
 				echo '
259 268
 					<li>', $field['output_html'], '</li>';
269
+		}
260 270
 
261 271
 		echo '
262 272
 				</ul>
@@ -270,15 +280,17 @@  discard block
 block discarded – undo
270 280
 		<div id="detailedinfo">
271 281
 			<dl class="settings">';
272 282
 
273
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
274
-		echo '
283
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
284
+			echo '
275 285
 				<dt>', $txt['username'], ': </dt>
276 286
 				<dd>', $context['member']['username'], '</dd>';
287
+	}
277 288
 
278
-	if (!isset($context['disabled_fields']['posts']))
279
-		echo '
289
+	if (!isset($context['disabled_fields']['posts'])) {
290
+			echo '
280 291
 				<dt>', $txt['profile_posts'], ': </dt>
281 292
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
293
+	}
282 294
 
283 295
 	if ($context['member']['show_email'])
284 296
 	{
@@ -287,15 +299,17 @@  discard block
 block discarded – undo
287 299
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
288 300
 	}
289 301
 
290
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
291
-		echo '
302
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
303
+			echo '
292 304
 				<dt>', $txt['custom_title'], ': </dt>
293 305
 				<dd>', $context['member']['title'], '</dd>';
306
+	}
294 307
 
295
-	if (!empty($context['member']['blurb']))
296
-		echo '
308
+	if (!empty($context['member']['blurb'])) {
309
+			echo '
297 310
 				<dt>', $txt['personal_text'], ': </dt>
298 311
 				<dd>', $context['member']['blurb'], '</dd>';
312
+	}
299 313
 
300 314
 	echo '
301 315
 				<dt>', $txt['age'], ':</dt>
@@ -309,19 +323,21 @@  discard block
 block discarded – undo
309 323
 	{
310 324
 		$fields = array();
311 325
 
312
-		foreach ($context['print_custom_fields']['standard'] as $field)
313
-			if (!empty($field['output_html']))
326
+		foreach ($context['print_custom_fields']['standard'] as $field) {
327
+					if (!empty($field['output_html']))
314 328
 				$fields[] = $field;
329
+		}
315 330
 
316 331
 		if (count($fields) > 0)
317 332
 		{
318 333
 			echo '
319 334
 				<dl class="settings">';
320 335
 
321
-			foreach ($fields as $field)
322
-				echo '
336
+			foreach ($fields as $field) {
337
+							echo '
323 338
 					<dt>', $field['name'], ':</dt>
324 339
 					<dd>', $field['output_html'], '</dd>';
340
+			}
325 341
 
326 342
 			echo '
327 343
 				</dl>';
@@ -341,9 +357,10 @@  discard block
 block discarded – undo
341 357
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
342 358
 
343 359
 		// Can we provide information on what this means?
344
-		if (!empty($context['warning_status']))
345
-			echo '
360
+		if (!empty($context['warning_status'])) {
361
+					echo '
346 362
 						<span class="smalltext">(', $context['warning_status'], ')</span>';
363
+		}
347 364
 
348 365
 		echo '
349 366
 					</dd>';
@@ -354,9 +371,10 @@  discard block
 block discarded – undo
354 371
 	{
355 372
 
356 373
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
357
-		if (!empty($context['activate_message']))
358
-			echo '
374
+		if (!empty($context['activate_message'])) {
375
+					echo '
359 376
 					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
377
+		}
360 378
 
361 379
 		// If the current member is banned, show a message and possibly a link to the ban.
362 380
 		if (!empty($context['member']['bans']))
@@ -366,9 +384,10 @@  discard block
 block discarded – undo
366 384
 					<dt class="clear" id="ban_info" style="display: none;">
367 385
 						<strong>', $txt['user_banned_by_following'], ':</strong>';
368 386
 
369
-			foreach ($context['member']['bans'] as $ban)
370
-				echo '
387
+			foreach ($context['member']['bans'] as $ban) {
388
+							echo '
371 389
 						<br><span class="smalltext">', $ban['explanation'], '</span>';
390
+			}
372 391
 
373 392
 			echo '
374 393
 					</dt>';
@@ -382,30 +401,34 @@  discard block
 block discarded – undo
382 401
 	// If the person looking is allowed, they can check the members IP address and hostname.
383 402
 	if ($context['can_see_ip'])
384 403
 	{
385
-		if (!empty($context['member']['ip']))
386
-		echo '
404
+		if (!empty($context['member']['ip'])) {
405
+				echo '
387 406
 					<dt>', $txt['ip'], ': </dt>
388 407
 					<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
408
+		}
389 409
 
390
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
391
-			echo '
410
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
411
+					echo '
392 412
 					<dt>', $txt['hostname'], ': </dt>
393 413
 					<dd>', $context['member']['hostname'], '</dd>';
414
+		}
394 415
 	}
395 416
 
396 417
 	echo '
397 418
 					<dt>', $txt['local_time'], ':</dt>
398 419
 					<dd>', $context['member']['local_time'], '</dd>';
399 420
 
400
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
401
-		echo '
421
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
422
+			echo '
402 423
 					<dt>', $txt['language'], ':</dt>
403 424
 					<dd>', $context['member']['language'], '</dd>';
425
+	}
404 426
 
405
-	if ($context['member']['show_last_login'])
406
-		echo '
427
+	if ($context['member']['show_last_login']) {
428
+			echo '
407 429
 					<dt>', $txt['lastLoggedIn'], ': </dt>
408 430
 					<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
431
+	}
409 432
 
410 433
 	echo '
411 434
 				</dl>';
@@ -417,10 +440,11 @@  discard block
 block discarded – undo
417 440
 				<div class="custom_fields_above_signature">
418 441
 					<ul class="nolist">';
419 442
 
420
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
421
-			if (!empty($field['output_html']))
443
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
444
+					if (!empty($field['output_html']))
422 445
 				echo '
423 446
 						<li>', $field['output_html'], '</li>';
447
+		}
424 448
 
425 449
 		echo '
426 450
 					</ul>
@@ -428,12 +452,13 @@  discard block
 block discarded – undo
428 452
 	}
429 453
 
430 454
 	// Show the users signature.
431
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
432
-		echo '
455
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
456
+			echo '
433 457
 				<div class="signature">
434 458
 					<h5>', $txt['signature'], ':</h5>
435 459
 					', $context['member']['signature'], '
436 460
 				</div>';
461
+	}
437 462
 
438 463
 	// Are there any custom profile fields for below the signature?
439 464
 	if (!empty($context['print_custom_fields']['below_signature']))
@@ -442,10 +467,11 @@  discard block
 block discarded – undo
442 467
 				<div class="custom_fields_below_signature">
443 468
 					<ul class="nolist">';
444 469
 
445
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
446
-			if (!empty($field['output_html']))
470
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
471
+					if (!empty($field['output_html']))
447 472
 				echo '
448 473
 						<li>', $field['output_html'], '</li>';
474
+		}
449 475
 
450 476
 		echo '
451 477
 					</ul>
@@ -490,62 +516,70 @@  discard block
 block discarded – undo
490 516
 				</div>
491 517
 				<div class="list_posts">';
492 518
 
493
-			if (!$post['approved'])
494
-				echo '
519
+			if (!$post['approved']) {
520
+							echo '
495 521
 					<div class="approve_post">
496 522
 						<em>', $txt['post_awaiting_approval'], '</em>
497 523
 					</div>';
524
+			}
498 525
 
499 526
 			echo '
500 527
 					', $post['body'], '
501 528
 				</div>';
502 529
 
503
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
504
-				echo '
530
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
531
+							echo '
505 532
 				<div class="floatright">
506 533
 					<ul class="quickbuttons">';
534
+			}
507 535
 
508 536
 			// If they *can* reply?
509
-			if ($post['can_reply'])
510
-				echo '
537
+			if ($post['can_reply']) {
538
+							echo '
511 539
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
540
+			}
512 541
 
513 542
 			// If they *can* quote?
514
-			if ($post['can_quote'])
515
-				echo '
543
+			if ($post['can_quote']) {
544
+							echo '
516 545
 						<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
546
+			}
517 547
 
518 548
 			// How about... even... remove it entirely?!
519
-			if ($post['can_delete'])
520
-				echo '
549
+			if ($post['can_delete']) {
550
+							echo '
521 551
 						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
552
+			}
522 553
 
523
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
524
-				echo '
554
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
555
+							echo '
525 556
 					</ul>
526 557
 				</div>';
558
+			}
527 559
 
528 560
 			echo '
529 561
 			</div>';
530 562
 		}
563
+	} else {
564
+			template_show_list('attachments');
531 565
 	}
532
-	else
533
-		template_show_list('attachments');
534 566
 
535 567
 	// No posts? Just end with a informative message.
536
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
537
-		echo '
568
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
569
+			echo '
538 570
 			<div class="windowbg2">
539 571
 				', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
540 572
 			</div>';
573
+	}
541 574
 
542 575
 	// Show more page numbers.
543
-	if (!empty($context['page_index']))
544
-		echo '
576
+	if (!empty($context['page_index'])) {
577
+			echo '
545 578
 		<div class="pagesection">
546 579
 			<div class="pagelinks">', $context['page_index'], '</div>
547 580
 		</div>';
548
-}
581
+	}
582
+	}
549 583
 
550 584
 /**
551 585
  * Template for showing alerts within the alerts popup
@@ -555,11 +589,12 @@  discard block
 block discarded – undo
555 589
 	global $context, $txt, $scripturl;
556 590
 
557 591
 	// Do we have an update message?
558
-	if (!empty($context['update_message']))
559
-		echo '
592
+	if (!empty($context['update_message'])) {
593
+			echo '
560 594
 		<div class="infobox">
561 595
 			', $context['update_message'], '.
562 596
 		</div>';
597
+	}
563 598
 
564 599
 	echo '
565 600
 		<div class="cat_bar">
@@ -568,13 +603,12 @@  discard block
 block discarded – undo
568 603
 			</h3>
569 604
 		</div>';
570 605
 
571
-	if (empty($context['alerts']))
572
-		echo '
606
+	if (empty($context['alerts'])) {
607
+			echo '
573 608
 		<div class="information">
574 609
 			', $txt['alerts_none'], '
575 610
 		</div>';
576
-
577
-	else
611
+	} else
578 612
 	{
579 613
 		// Start the form.
580 614
 		echo '
@@ -636,12 +670,12 @@  discard block
 block discarded – undo
636 670
 		</div>' : '';
637 671
 
638 672
 	// No drafts? Just show an informative message.
639
-	if (empty($context['drafts']))
640
-		echo '
673
+	if (empty($context['drafts'])) {
674
+			echo '
641 675
 		<div class="windowbg2 centertext">
642 676
 			', $txt['draft_none'], '
643 677
 		</div>';
644
-	else
678
+	} else
645 679
 	{
646 680
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
647 681
 		foreach ($context['drafts'] as $draft)
@@ -652,11 +686,13 @@  discard block
 block discarded – undo
652 686
 					<div class="topic_details">
653 687
 						<h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
654 688
 
655
-			if (!empty($draft['sticky']))
656
-				echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
689
+			if (!empty($draft['sticky'])) {
690
+							echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
691
+			}
657 692
 
658
-			if (!empty($draft['locked']))
659
-				echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
693
+			if (!empty($draft['locked'])) {
694
+							echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
695
+			}
660 696
 
661 697
 			echo '
662 698
 						</h5>
@@ -689,12 +725,13 @@  discard block
 block discarded – undo
689 725
 {
690 726
 	global $context, $scripturl, $txt;
691 727
 
692
-	if (!empty($context['saved_successful']))
693
-		echo '
728
+	if (!empty($context['saved_successful'])) {
729
+			echo '
694 730
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
695
-	elseif (!empty($context['saved_failed']))
696
-		echo '
731
+	} elseif (!empty($context['saved_failed'])) {
732
+			echo '
697 733
 					<div class="errorbox">', $context['saved_failed'], '</div>';
734
+	}
698 735
 
699 736
 	echo '
700 737
 	<div id="edit_buddies">
@@ -708,24 +745,27 @@  discard block
 block discarded – undo
708 745
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
709 746
 				<th scope="col">', $txt['status'], '</th>';
710 747
 
711
-	if (allowedTo('moderate_forum'))
712
-		echo '
748
+	if (allowedTo('moderate_forum')) {
749
+			echo '
713 750
 				<th scope="col">', $txt['email'], '</th>';
751
+	}
714 752
 
715
-	if (!empty($context['custom_pf']))
716
-		foreach ($context['custom_pf'] as $column)
753
+	if (!empty($context['custom_pf'])) {
754
+			foreach ($context['custom_pf'] as $column)
717 755
 				echo '<th scope="col">', $column['label'], '</th>';
756
+	}
718 757
 
719 758
 	echo '
720 759
 				<th scope="col">', $txt['remove'], '</th>
721 760
 			</tr>';
722 761
 
723 762
 	// If they don't have any buddies don't list them!
724
-	if (empty($context['buddies']))
725
-		echo '
763
+	if (empty($context['buddies'])) {
764
+			echo '
726 765
 			<tr class="windowbg">
727 766
 				<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td>
728 767
 			</tr>';
768
+	}
729 769
 
730 770
 		// Now loop through each buddy showing info on each.
731 771
 	else
@@ -737,15 +777,17 @@  discard block
 block discarded – undo
737 777
 					<td>', $buddy['link'], '</td>
738 778
 					<td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>';
739 779
 
740
-			if ($buddy['show_email'])
741
-				echo '
780
+			if ($buddy['show_email']) {
781
+							echo '
742 782
 					<td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>';
783
+			}
743 784
 
744 785
 			// Show the custom profile fields for this user.
745
-			if (!empty($context['custom_pf']))
746
-				foreach ($context['custom_pf'] as $key => $column)
786
+			if (!empty($context['custom_pf'])) {
787
+							foreach ($context['custom_pf'] as $key => $column)
747 788
 					echo '
748 789
 						<td class="lefttext">', $buddy['options'][$key], '</td>';
790
+			}
749 791
 
750 792
 			echo '
751 793
 					<td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td>
@@ -775,9 +817,10 @@  discard block
 block discarded – undo
775 817
 			</dl>
776 818
 		</div>';
777 819
 
778
-	if (!empty($context['token_check']))
779
-		echo '
820
+	if (!empty($context['token_check'])) {
821
+			echo '
780 822
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
823
+	}
781 824
 
782 825
 	echo '
783 826
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -803,12 +846,13 @@  discard block
 block discarded – undo
803 846
 {
804 847
 	global $context, $scripturl, $txt;
805 848
 
806
-	if (!empty($context['saved_successful']))
807
-		echo '
849
+	if (!empty($context['saved_successful'])) {
850
+			echo '
808 851
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
809
-	elseif (!empty($context['saved_failed']))
810
-		echo '
852
+	} elseif (!empty($context['saved_failed'])) {
853
+			echo '
811 854
 					<div class="errorbox">', $context['saved_failed'], '</div>';
855
+	}
812 856
 
813 857
 	echo '
814 858
 	<div id="edit_buddies">
@@ -822,20 +866,22 @@  discard block
 block discarded – undo
822 866
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
823 867
 				<th scope="col">', $txt['status'], '</th>';
824 868
 
825
-	if (allowedTo('moderate_forum'))
826
-		echo '
869
+	if (allowedTo('moderate_forum')) {
870
+			echo '
827 871
 				<th scope="col">', $txt['email'], '</th>';
872
+	}
828 873
 
829 874
 	echo '
830 875
 				<th scope="col">', $txt['ignore_remove'], '</th>
831 876
 			</tr>';
832 877
 
833 878
 	// If they don't have anyone on their ignore list, don't list it!
834
-	if (empty($context['ignore_list']))
835
-		echo '
879
+	if (empty($context['ignore_list'])) {
880
+			echo '
836 881
 			<tr class="windowbg">
837 882
 				<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td>
838 883
 			</tr>';
884
+	}
839 885
 
840 886
 	// Now loop through each buddy showing info on each.
841 887
 	foreach ($context['ignore_list'] as $member)
@@ -845,9 +891,10 @@  discard block
 block discarded – undo
845 891
 				<td>', $member['link'], '</td>
846 892
 				<td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>';
847 893
 
848
-		if ($member['show_email'])
849
-			echo '
894
+		if ($member['show_email']) {
895
+					echo '
850 896
 				<td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>';
897
+		}
851 898
 		echo '
852 899
 				<td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td>
853 900
 			</tr>';
@@ -874,9 +921,10 @@  discard block
 block discarded – undo
874 921
 			</dl>
875 922
 		</div>';
876 923
 
877
-	if (!empty($context['token_check']))
878
-		echo '
924
+	if (!empty($context['token_check'])) {
925
+			echo '
879 926
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
927
+	}
880 928
 
881 929
 	echo '
882 930
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -921,9 +969,10 @@  discard block
 block discarded – undo
921 969
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
922 970
 
923 971
 	// Second address detected?
924
-	if (!empty($context['last_ip2']))
925
-		echo '
972
+	if (!empty($context['last_ip2'])) {
973
+			echo '
926 974
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
975
+	}
927 976
 
928 977
 	echo '
929 978
 				</dd>';
@@ -988,9 +1037,10 @@  discard block
 block discarded – undo
988 1037
 				<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
989 1038
 			</div>
990 1039
 			<div class="windowbg2 noup">';
991
-			foreach ($context['whois_servers'] as $server)
992
-			echo '
1040
+			foreach ($context['whois_servers'] as $server) {
1041
+						echo '
993 1042
 				<a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
1043
+			}
994 1044
 			echo '
995 1045
 			</div>
996 1046
 			<br>';
@@ -1001,10 +1051,10 @@  discard block
 block discarded – undo
1001 1051
 		<div class="cat_bar">
1002 1052
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1003 1053
 		</div>';
1004
-	if (empty($context['ips']))
1005
-		echo '
1054
+	if (empty($context['ips'])) {
1055
+			echo '
1006 1056
 		<p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>';
1007
-	else
1057
+	} else
1008 1058
 	{
1009 1059
 		echo '
1010 1060
 		<table class="table_grid">
@@ -1017,12 +1067,13 @@  discard block
 block discarded – undo
1017 1067
 			<tbody>';
1018 1068
 
1019 1069
 		// Loop through each of the members and display them.
1020
-		foreach ($context['ips'] as $ip => $memberlist)
1021
-			echo '
1070
+		foreach ($context['ips'] as $ip => $memberlist) {
1071
+					echo '
1022 1072
 				<tr class="windowbg">
1023 1073
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1024 1074
 					<td>', implode(', ', $memberlist), '</td>
1025 1075
 				</tr>';
1076
+		}
1026 1077
 
1027 1078
 		echo '
1028 1079
 			</tbody>
@@ -1068,8 +1119,7 @@  discard block
 block discarded – undo
1068 1119
 	{
1069 1120
 		echo '
1070 1121
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1071
-	}
1072
-	else
1122
+	} else
1073 1123
 	{
1074 1124
 		echo '
1075 1125
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1083,9 +1133,10 @@  discard block
 block discarded – undo
1083 1133
 				</div>
1084 1134
 				<div class="windowbg smalltext">
1085 1135
 					', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1086
-				foreach ($context['no_access_boards'] as $no_access_board)
1087
-					echo '
1136
+				foreach ($context['no_access_boards'] as $no_access_board) {
1137
+									echo '
1088 1138
 						<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1139
+				}
1089 1140
 				echo '
1090 1141
 				</div>';
1091 1142
 		}
@@ -1117,12 +1168,13 @@  discard block
 block discarded – undo
1117 1168
 								</td>
1118 1169
 								<td class="smalltext">';
1119 1170
 
1120
-				if ($permission['is_denied'])
1121
-					echo '
1171
+				if ($permission['is_denied']) {
1172
+									echo '
1122 1173
 									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1123
-				else
1124
-					echo '
1174
+				} else {
1175
+									echo '
1125 1176
 									', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
1177
+				}
1126 1178
 
1127 1179
 					echo '
1128 1180
 								</td>
@@ -1132,10 +1184,10 @@  discard block
 block discarded – undo
1132 1184
 						</tbody>
1133 1185
 					</table>
1134 1186
 				</div><br>';
1135
-		}
1136
-		else
1137
-			echo '
1187
+		} else {
1188
+					echo '
1138 1189
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1190
+		}
1139 1191
 
1140 1192
 		// Board permission section.
1141 1193
 		echo '
@@ -1145,14 +1197,16 @@  discard block
 block discarded – undo
1145 1197
 						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1146 1198
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1147 1199
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '&nbsp;</option>';
1148
-				if (!empty($context['boards']))
1149
-					echo '
1200
+				if (!empty($context['boards'])) {
1201
+									echo '
1150 1202
 							<option value="" disabled>---------------------------</option>';
1203
+				}
1151 1204
 
1152 1205
 				// Fill the box with any local permission boards.
1153
-				foreach ($context['boards'] as $board)
1154
-					echo '
1206
+				foreach ($context['boards'] as $board) {
1207
+									echo '
1155 1208
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1209
+				}
1156 1210
 
1157 1211
 				echo '
1158 1212
 						</select>
@@ -1183,8 +1237,7 @@  discard block
 block discarded – undo
1183 1237
 				{
1184 1238
 					echo '
1185 1239
 							<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1186
-				}
1187
-				else
1240
+				} else
1188 1241
 				{
1189 1242
 					echo '
1190 1243
 							', $txt['showPermissions_given'], ': &nbsp;', implode(', ', $permission['groups']['allowed']);
@@ -1196,10 +1249,10 @@  discard block
 block discarded – undo
1196 1249
 			echo '
1197 1250
 				</tbody>
1198 1251
 			</table>';
1199
-		}
1200
-		else
1201
-			echo '
1252
+		} else {
1253
+					echo '
1202 1254
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1255
+		}
1203 1256
 	echo '
1204 1257
 			</div>
1205 1258
 		</div>';
@@ -1241,9 +1294,10 @@  discard block
 block discarded – undo
1241 1294
 			</div>';
1242 1295
 
1243 1296
 	// If they haven't post at all, don't draw the graph.
1244
-	if (empty($context['posts_by_time']))
1245
-		echo '
1297
+	if (empty($context['posts_by_time'])) {
1298
+			echo '
1246 1299
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1300
+	}
1247 1301
 	// Otherwise do!
1248 1302
 	else
1249 1303
 	{
@@ -1282,11 +1336,10 @@  discard block
 block discarded – undo
1282 1336
 					</h3>
1283 1337
 				</div>';
1284 1338
 
1285
-	if (empty($context['popular_boards']))
1286
-		echo '
1339
+	if (empty($context['popular_boards'])) {
1340
+			echo '
1287 1341
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1288
-
1289
-	else
1342
+	} else
1290 1343
 	{
1291 1344
 		echo '
1292 1345
 				<dl class="stats">';
@@ -1317,10 +1370,10 @@  discard block
 block discarded – undo
1317 1370
 					</h3>
1318 1371
 				</div>';
1319 1372
 
1320
-	if (empty($context['board_activity']))
1321
-		echo '
1373
+	if (empty($context['board_activity'])) {
1374
+			echo '
1322 1375
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1323
-	else
1376
+	} else
1324 1377
 	{
1325 1378
 		echo '
1326 1379
 				<dl class="stats">';
@@ -1368,41 +1421,46 @@  discard block
 block discarded – undo
1368 1421
 				<h3 class="catbg profile_hd">';
1369 1422
 
1370 1423
 		// Don't say "Profile" if this isn't the profile...
1371
-		if (!empty($context['profile_header_text']))
1372
-			echo '
1424
+		if (!empty($context['profile_header_text'])) {
1425
+					echo '
1373 1426
 					', $context['profile_header_text'];
1374
-		else
1375
-			echo '
1427
+		} else {
1428
+					echo '
1376 1429
 					', $txt['profile'];
1430
+		}
1377 1431
 
1378 1432
 		echo '
1379 1433
 				</h3>
1380 1434
 			</div>';
1381 1435
 
1382 1436
 	// Have we some description?
1383
-	if ($context['page_desc'])
1384
-		echo '
1437
+	if ($context['page_desc']) {
1438
+			echo '
1385 1439
 			<p class="information">', $context['page_desc'], '</p>';
1440
+	}
1386 1441
 
1387 1442
 	echo '
1388 1443
 			<div class="roundframe">';
1389 1444
 
1390 1445
 	// Any bits at the start?
1391
-	if (!empty($context['profile_prehtml']))
1392
-		echo '
1446
+	if (!empty($context['profile_prehtml'])) {
1447
+			echo '
1393 1448
 				<div>', $context['profile_prehtml'], '</div>';
1449
+	}
1394 1450
 
1395
-	if (!empty($context['profile_fields']))
1396
-		echo '
1451
+	if (!empty($context['profile_fields'])) {
1452
+			echo '
1397 1453
 				<dl class="settings">';
1454
+	}
1398 1455
 
1399 1456
 	// Start the big old loop 'of love.
1400 1457
 	$lastItem = 'hr';
1401 1458
 	foreach ($context['profile_fields'] as $key => $field)
1402 1459
 	{
1403 1460
 		// We add a little hack to be sure we never get more than one hr in a row!
1404
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1405
-			continue;
1461
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1462
+					continue;
1463
+		}
1406 1464
 
1407 1465
 		$lastItem = $field['type'];
1408 1466
 		if ($field['type'] == 'hr')
@@ -1411,48 +1469,50 @@  discard block
 block discarded – undo
1411 1469
 				</dl>
1412 1470
 				<hr>
1413 1471
 				<dl class="settings">';
1414
-		}
1415
-		elseif ($field['type'] == 'callback')
1472
+		} elseif ($field['type'] == 'callback')
1416 1473
 		{
1417 1474
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1418 1475
 			{
1419 1476
 				$callback_func = 'template_profile_' . $field['callback_func'];
1420 1477
 				$callback_func();
1421 1478
 			}
1422
-		}
1423
-		else
1479
+		} else
1424 1480
 		{
1425 1481
 			echo '
1426 1482
 					<dt>
1427 1483
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1428 1484
 
1429 1485
 			// Does it have any subtext to show?
1430
-			if (!empty($field['subtext']))
1431
-				echo '
1486
+			if (!empty($field['subtext'])) {
1487
+							echo '
1432 1488
 						<br>
1433 1489
 						<span class="smalltext">', $field['subtext'], '</span>';
1490
+			}
1434 1491
 
1435 1492
 			echo '
1436 1493
 					</dt>
1437 1494
 					<dd>';
1438 1495
 
1439 1496
 			// Want to put something infront of the box?
1440
-			if (!empty($field['preinput']))
1441
-				echo '
1497
+			if (!empty($field['preinput'])) {
1498
+							echo '
1442 1499
 						', $field['preinput'];
1500
+			}
1443 1501
 
1444 1502
 			// What type of data are we showing?
1445
-			if ($field['type'] == 'label')
1446
-				echo '
1503
+			if ($field['type'] == 'label') {
1504
+							echo '
1447 1505
 						', $field['value'];
1506
+			}
1448 1507
 
1449 1508
 			// Maybe it's a text box - very likely!
1450 1509
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1451 1510
 			{
1452
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1453
-					$type = 'number';
1454
-				else
1455
-					$type = $field['type'];
1511
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1512
+									$type = 'number';
1513
+				} else {
1514
+									$type = $field['type'];
1515
+				}
1456 1516
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1457 1517
 
1458 1518
 
@@ -1460,9 +1520,10 @@  discard block
 block discarded – undo
1460 1520
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1461 1521
 			}
1462 1522
 			// You "checking" me out? ;)
1463
-			elseif ($field['type'] == 'check')
1464
-				echo '
1523
+			elseif ($field['type'] == 'check') {
1524
+							echo '
1465 1525
 						<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1526
+			}
1466 1527
 
1467 1528
 			// Always fun - select boxes!
1468 1529
 			elseif ($field['type'] == 'select')
@@ -1473,13 +1534,15 @@  discard block
 block discarded – undo
1473 1534
 				if (isset($field['options']))
1474 1535
 				{
1475 1536
 					// Is this some code to generate the options?
1476
-					if (!is_array($field['options']))
1477
-						$field['options'] = $field['options']();
1537
+					if (!is_array($field['options'])) {
1538
+											$field['options'] = $field['options']();
1539
+					}
1478 1540
 					// Assuming we now have some!
1479
-					if (is_array($field['options']))
1480
-						foreach ($field['options'] as $value => $name)
1541
+					if (is_array($field['options'])) {
1542
+											foreach ($field['options'] as $value => $name)
1481 1543
 							echo '
1482 1544
 								<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1545
+					}
1483 1546
 				}
1484 1547
 
1485 1548
 				echo '
@@ -1487,25 +1550,28 @@  discard block
 block discarded – undo
1487 1550
 			}
1488 1551
 
1489 1552
 			// Something to end with?
1490
-			if (!empty($field['postinput']))
1491
-				echo '
1553
+			if (!empty($field['postinput'])) {
1554
+							echo '
1492 1555
 							', $field['postinput'];
1556
+			}
1493 1557
 
1494 1558
 			echo '
1495 1559
 					</dd>';
1496 1560
 		}
1497 1561
 	}
1498 1562
 
1499
-	if (!empty($context['profile_fields']))
1500
-		echo '
1563
+	if (!empty($context['profile_fields'])) {
1564
+			echo '
1501 1565
 				</dl>';
1566
+	}
1502 1567
 
1503 1568
 	// Are there any custom profile fields - if so print them!
1504 1569
 	if (!empty($context['custom_fields']))
1505 1570
 	{
1506
-		if ($lastItem != 'hr')
1507
-			echo '
1571
+		if ($lastItem != 'hr') {
1572
+					echo '
1508 1573
 				<hr>';
1574
+		}
1509 1575
 
1510 1576
 		echo '
1511 1577
 				<dl class="settings">';
@@ -1528,13 +1594,14 @@  discard block
 block discarded – undo
1528 1594
 	}
1529 1595
 
1530 1596
 	// Any closing HTML?
1531
-	if (!empty($context['profile_posthtml']))
1532
-		echo '
1597
+	if (!empty($context['profile_posthtml'])) {
1598
+			echo '
1533 1599
 				<div>', $context['profile_posthtml'], '</div>';
1600
+	}
1534 1601
 
1535 1602
 	// Only show the password box if it's actually needed.
1536
-	if ($context['require_password'])
1537
-		echo '
1603
+	if ($context['require_password']) {
1604
+			echo '
1538 1605
 				<dl class="settings">
1539 1606
 					<dt>
1540 1607
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1544,18 +1611,21 @@  discard block
 block discarded – undo
1544 1611
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1545 1612
 					</dd>
1546 1613
 				</dl>';
1614
+	}
1547 1615
 
1548 1616
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1549
-	if (!empty($context['submit_button_text']))
1550
-		echo '
1617
+	if (!empty($context['submit_button_text'])) {
1618
+			echo '
1551 1619
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">';
1552
-	else
1553
-		echo '
1620
+	} else {
1621
+			echo '
1554 1622
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button">';
1623
+	}
1555 1624
 
1556
-	if (!empty($context['token_check']))
1557
-		echo '
1625
+	if (!empty($context['token_check'])) {
1626
+			echo '
1558 1627
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1628
+	}
1559 1629
 
1560 1630
 	echo '
1561 1631
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1565,10 +1635,11 @@  discard block
 block discarded – undo
1565 1635
 		</form>';
1566 1636
 
1567 1637
 	// Any final spellchecking stuff?
1568
-	if (!empty($context['show_spellchecking']))
1569
-		echo '
1638
+	if (!empty($context['show_spellchecking'])) {
1639
+			echo '
1570 1640
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1571
-}
1641
+	}
1642
+	}
1572 1643
 
1573 1644
 /**
1574 1645
  * Personal Message settings.
@@ -1605,10 +1676,11 @@  discard block
 block discarded – undo
1605 1676
 										<select name="pm_receive_from" id="pm_receive_from">
1606 1677
 												<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1607 1678
 
1608
-	if (!empty($modSettings['enable_buddylist']))
1609
-		echo '
1679
+	if (!empty($modSettings['enable_buddylist'])) {
1680
+			echo '
1610 1681
 												<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1611 1682
 												<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1683
+	}
1612 1684
 
1613 1685
 	echo '
1614 1686
 												<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1651,11 +1723,12 @@  discard block
 block discarded – undo
1651 1723
 		if (empty($setting) || !is_array($setting))
1652 1724
 		{
1653 1725
 			// Insert a separator (unless this is the first item in the list)
1654
-			if ($i !== $first_option_key)
1655
-				echo '
1726
+			if ($i !== $first_option_key) {
1727
+							echo '
1656 1728
 				</dl>
1657 1729
 				<hr>
1658 1730
 				<dl class="settings">';
1731
+			}
1659 1732
 
1660 1733
 			// Should we give a name to this section?
1661 1734
 			if (is_string($setting) && !empty($setting))
@@ -1663,51 +1736,56 @@  discard block
 block discarded – undo
1663 1736
 				$titled_section = true;
1664 1737
 				echo '
1665 1738
 					<dt><strong>' . $setting . '</strong></dt><dd></dd>';
1739
+			} else {
1740
+							$titled_section = false;
1666 1741
 			}
1667
-			else
1668
-				$titled_section = false;
1669 1742
 
1670 1743
 			continue;
1671 1744
 		}
1672 1745
 
1673 1746
 		// Is this disabled?
1674
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1675
-			continue;
1676
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1677
-			continue;
1678
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1679
-			continue;
1680
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1681
-			continue;
1682
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1683
-			continue;
1684
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1685
-			continue;
1686
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1687
-			continue;
1747
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1748
+					continue;
1749
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1750
+					continue;
1751
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1752
+					continue;
1753
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1754
+					continue;
1755
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1756
+					continue;
1757
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1758
+					continue;
1759
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1760
+					continue;
1761
+		}
1688 1762
 
1689 1763
 		// Some of these may not be set...  Set to defaults here
1690 1764
 		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1691
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1692
-			$context['member']['options'][$setting['id']] = 0;
1765
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1766
+					$context['member']['options'][$setting['id']] = 0;
1767
+		}
1693 1768
 
1694
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1695
-			$setting['type'] = 'checkbox';
1696
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1697
-			$setting['type'] = 'number';
1698
-		elseif ($setting['type'] == 'string')
1699
-			$setting['type'] = 'text';
1769
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1770
+					$setting['type'] = 'checkbox';
1771
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1772
+					$setting['type'] = 'number';
1773
+		} elseif ($setting['type'] == 'string') {
1774
+					$setting['type'] = 'text';
1775
+		}
1700 1776
 
1701
-		if (isset($setting['options']))
1702
-			$setting['type'] = 'list';
1777
+		if (isset($setting['options'])) {
1778
+					$setting['type'] = 'list';
1779
+		}
1703 1780
 
1704 1781
 		echo '
1705 1782
 					<dt>
1706 1783
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1707 1784
 
1708
-		if (isset($setting['description']))
1709
-			echo '
1785
+		if (isset($setting['description'])) {
1786
+					echo '
1710 1787
 						<br><span class="smalltext">', $setting['description'], '</span>';
1788
+		}
1711 1789
 		echo '
1712 1790
 					</dt>
1713 1791
 					<dd>';
@@ -1745,13 +1823,11 @@  discard block
 block discarded – undo
1745 1823
 
1746 1824
 				echo '
1747 1825
 						<input type="number"', $min . $max . $step;
1748
-			}
1749
-			else if (isset($setting['type']) && $setting['type'] == 'url')
1826
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
1750 1827
 			{
1751 1828
 				echo'
1752 1829
 						<input type="url"';
1753
-			}
1754
-			else
1830
+			} else
1755 1831
 			{
1756 1832
 				echo '
1757 1833
 						<input type="text"';
@@ -1790,8 +1866,8 @@  discard block
 block discarded – undo
1790 1866
 				<dl class="settings">';
1791 1867
 
1792 1868
 	// Allow notification on announcements to be disabled?
1793
-	if (!empty($modSettings['allow_disableAnnounce']))
1794
-		echo '
1869
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1870
+			echo '
1795 1871
 					<dt>
1796 1872
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1797 1873
 					</dt>
@@ -1799,9 +1875,10 @@  discard block
 block discarded – undo
1799 1875
 						<input type="hidden" name="notify_announcements" value="0">
1800 1876
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1801 1877
 					</dd>';
1878
+	}
1802 1879
 
1803
-	if (!empty($modSettings['enable_ajax_alerts']))
1804
-		echo '
1880
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1881
+			echo '
1805 1882
 					<dt>
1806 1883
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1807 1884
 					</dt>
@@ -1809,6 +1886,7 @@  discard block
 block discarded – undo
1809 1886
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1810 1887
 					</dd>
1811 1888
 		';
1889
+	}
1812 1890
 
1813 1891
 	echo '
1814 1892
 				</dl>
@@ -1838,9 +1916,10 @@  discard block
 block discarded – undo
1838 1916
 					<td colspan="3">';
1839 1917
 				$label = $txt['alert_opt_' . $opts[1]];
1840 1918
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1841
-				if ($label_pos == 'before')
1842
-					echo '
1919
+				if ($label_pos == 'before') {
1920
+									echo '
1843 1921
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1922
+				}
1844 1923
 
1845 1924
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1846 1925
 				switch ($opts[0])
@@ -1852,17 +1931,19 @@  discard block
 block discarded – undo
1852 1931
 					case 'select':
1853 1932
 						echo '
1854 1933
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1855
-						foreach ($opts['opts'] as $k => $v)
1856
-							echo '
1934
+						foreach ($opts['opts'] as $k => $v) {
1935
+													echo '
1857 1936
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1937
+						}
1858 1938
 						echo '
1859 1939
 						</select>';
1860 1940
 						break;
1861 1941
 				}
1862 1942
 
1863
-				if ($label_pos == 'after')
1864
-					echo '
1943
+				if ($label_pos == 'after') {
1944
+									echo '
1865 1945
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1946
+				}
1866 1947
 
1867 1948
 				echo '
1868 1949
 					</td>
@@ -1976,11 +2057,12 @@  discard block
 block discarded – undo
1976 2057
 			<p class="information">', $txt['groupMembership_info'], '</p>';
1977 2058
 
1978 2059
 	// Do we have an update message?
1979
-	if (!empty($context['update_message']))
1980
-		echo '
2060
+	if (!empty($context['update_message'])) {
2061
+			echo '
1981 2062
 			<div class="infobox">
1982 2063
 				', $context['update_message'], '.
1983 2064
 			</div>';
2065
+	}
1984 2066
 
1985 2067
 	echo '
1986 2068
 		<div id="groups">';
@@ -2002,8 +2084,7 @@  discard block
 block discarded – undo
2002 2084
 					</div>
2003 2085
 				</div>
2004 2086
 			</div>';
2005
-	}
2006
-	else
2087
+	} else
2007 2088
 	{
2008 2089
 		echo '
2009 2090
 			<div class="title_bar">
@@ -2015,27 +2096,30 @@  discard block
 block discarded – undo
2015 2096
 			echo '
2016 2097
 					<div class="windowbg" id="primdiv_', $group['id'], '">';
2017 2098
 
2018
-				if ($context['can_edit_primary'])
2019
-					echo '
2099
+				if ($context['can_edit_primary']) {
2100
+									echo '
2020 2101
 						<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2102
+				}
2021 2103
 
2022 2104
 				echo '
2023 2105
 						<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2024 2106
 
2025 2107
 				// Can they leave their group?
2026
-				if ($group['can_leave'])
2027
-					echo '
2108
+				if ($group['can_leave']) {
2109
+									echo '
2028 2110
 						<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2111
+				}
2029 2112
 
2030 2113
 				echo '
2031 2114
 					</div>';
2032 2115
 		}
2033 2116
 
2034
-		if ($context['can_edit_primary'])
2035
-			echo '
2117
+		if ($context['can_edit_primary']) {
2118
+					echo '
2036 2119
 			<div class="padding righttext">
2037 2120
 				<input type="submit" value="', $txt['make_primary'], '" class="button">
2038 2121
 			</div>';
2122
+		}
2039 2123
 
2040 2124
 		// Any groups they can join?
2041 2125
 		if (!empty($context['groups']['available']))
@@ -2051,15 +2135,16 @@  discard block
 block discarded – undo
2051 2135
 					<div class="windowbg">
2052 2136
 						<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2053 2137
 
2054
-				if ($group['type'] == 3)
2055
-					echo '
2138
+				if ($group['type'] == 3) {
2139
+									echo '
2056 2140
 						<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2057
-				elseif ($group['type'] == 2 && $group['pending'])
2058
-					echo '
2141
+				} elseif ($group['type'] == 2 && $group['pending']) {
2142
+									echo '
2059 2143
 						<span class="floatright">', $txt['approval_pending'], '</span>';
2060
-				elseif ($group['type'] == 2)
2061
-					echo '
2144
+				} elseif ($group['type'] == 2) {
2145
+									echo '
2062 2146
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2147
+				}
2063 2148
 
2064 2149
 				echo '
2065 2150
 					</div>';
@@ -2082,9 +2167,10 @@  discard block
 block discarded – undo
2082 2167
 
2083 2168
 			prevDiv.className = "windowbg";
2084 2169
 		}';
2085
-		if (isset($context['groups']['member'][$context['primary_group']]))
2086
-			echo '
2170
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2171
+					echo '
2087 2172
 		highlightSelected("primdiv_' . $context['primary_group'] . '");';
2173
+		}
2088 2174
 		echo '
2089 2175
 	</script>';
2090 2176
 	}
@@ -2092,9 +2178,10 @@  discard block
 block discarded – undo
2092 2178
 	echo '
2093 2179
 		</div>';
2094 2180
 
2095
-	if (!empty($context['token_check']))
2096
-		echo '
2181
+	if (!empty($context['token_check'])) {
2182
+			echo '
2097 2183
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2184
+	}
2098 2185
 
2099 2186
 	echo '
2100 2187
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2141,14 +2228,15 @@  discard block
 block discarded – undo
2141 2228
 
2142 2229
 		foreach ($category['boards'] as $board)
2143 2230
 		{
2144
-			if ($i == $limit)
2145
-				echo '
2231
+			if ($i == $limit) {
2232
+							echo '
2146 2233
 						</ul>
2147 2234
 					</li>
2148 2235
 				</ul>
2149 2236
 				<ul class="ignoreboards floatright">
2150 2237
 					<li class="category">
2151 2238
 						<ul>';
2239
+			}
2152 2240
 
2153 2241
 			echo '
2154 2242
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2194,10 +2282,11 @@  discard block
 block discarded – undo
2194 2282
 
2195 2283
 	// Work out the starting color.
2196 2284
 	$context['current_color'] = $context['colors'][0];
2197
-	foreach ($context['colors'] as $limit => $color)
2198
-		if ($context['member']['warning'] >= $limit)
2285
+	foreach ($context['colors'] as $limit => $color) {
2286
+			if ($context['member']['warning'] >= $limit)
2199 2287
 			$context['current_color'] = $color;
2200
-}
2288
+	}
2289
+	}
2201 2290
 
2202 2291
 // Show all warnings of a user?
2203 2292
 function template_viewWarning()
@@ -2236,14 +2325,15 @@  discard block
 block discarded – undo
2236 2325
 				</dd>';
2237 2326
 
2238 2327
 		// There's some impact of this?
2239
-		if (!empty($context['level_effects'][$context['current_level']]))
2240
-			echo '
2328
+		if (!empty($context['level_effects'][$context['current_level']])) {
2329
+					echo '
2241 2330
 				<dt>
2242 2331
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2243 2332
 				</dt>
2244 2333
 				<dd>
2245 2334
 					', $context['level_effects'][$context['current_level']], '
2246 2335
 				</dd>';
2336
+		}
2247 2337
 
2248 2338
 		echo '
2249 2339
 			</dl>
@@ -2281,10 +2371,11 @@  discard block
 block discarded – undo
2281 2371
 
2282 2372
 			// Otherwise see what we can do...';
2283 2373
 
2284
-	foreach ($context['notification_templates'] as $k => $type)
2285
-		echo '
2374
+	foreach ($context['notification_templates'] as $k => $type) {
2375
+			echo '
2286 2376
 			if (index == ', $k, ')
2287 2377
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2378
+	}
2288 2379
 
2289 2380
 	echo '
2290 2381
 		}
@@ -2294,10 +2385,11 @@  discard block
 block discarded – undo
2294 2385
 			// Also set the right effect.
2295 2386
 			effectText = "";';
2296 2387
 
2297
-	foreach ($context['level_effects'] as $limit => $text)
2298
-		echo '
2388
+	foreach ($context['level_effects'] as $limit => $text) {
2389
+			echo '
2299 2390
 			if (slideAmount >= ', $limit, ')
2300 2391
 				effectText = "', $text, '";';
2392
+	}
2301 2393
 
2302 2394
 	echo '
2303 2395
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2312,31 +2404,34 @@  discard block
 block discarded – undo
2312 2404
 			</h3>
2313 2405
 		</div>';
2314 2406
 
2315
-	if (!$context['user']['is_owner'])
2316
-		echo '
2407
+	if (!$context['user']['is_owner']) {
2408
+			echo '
2317 2409
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2410
+	}
2318 2411
 
2319 2412
 	echo '
2320 2413
 		<div class="windowbg">
2321 2414
 			<dl class="settings">';
2322 2415
 
2323
-	if (!$context['user']['is_owner'])
2324
-		echo '
2416
+	if (!$context['user']['is_owner']) {
2417
+			echo '
2325 2418
 				<dt>
2326 2419
 					<strong>', $txt['profile_warning_name'], ':</strong>
2327 2420
 				</dt>
2328 2421
 				<dd>
2329 2422
 					<strong>', $context['member']['name'], '</strong>
2330 2423
 				</dd>';
2424
+	}
2331 2425
 
2332 2426
 	echo '
2333 2427
 				<dt>
2334 2428
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2335 2429
 
2336 2430
 	// Is there only so much they can apply?
2337
-	if ($context['warning_limit'])
2338
-		echo '
2431
+	if ($context['warning_limit']) {
2432
+			echo '
2339 2433
 					<br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2434
+	}
2340 2435
 
2341 2436
 	echo '
2342 2437
 				</dt>
@@ -2389,9 +2484,10 @@  discard block
 block discarded – undo
2389 2484
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2390 2485
 						<option value="-1" disabled>------------------------------</option>';
2391 2486
 
2392
-		foreach ($context['notification_templates'] as $id_template => $template)
2393
-			echo '
2487
+		foreach ($context['notification_templates'] as $id_template => $template) {
2488
+					echo '
2394 2489
 						<option value="', $id_template, '">', $template['title'], '</option>';
2490
+		}
2395 2491
 
2396 2492
 		echo '
2397 2493
 					</select>
@@ -2404,9 +2500,10 @@  discard block
 block discarded – undo
2404 2500
 			</dl>
2405 2501
 			<div class="righttext">';
2406 2502
 
2407
-	if (!empty($context['token_check']))
2408
-		echo '
2503
+	if (!empty($context['token_check'])) {
2504
+			echo '
2409 2505
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2506
+	}
2410 2507
 
2411 2508
 	echo '
2412 2509
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2422,8 +2519,8 @@  discard block
 block discarded – undo
2422 2519
 	echo '
2423 2520
 	<script>';
2424 2521
 
2425
-	if (!$context['user']['is_owner'])
2426
-		echo '
2522
+	if (!$context['user']['is_owner']) {
2523
+			echo '
2427 2524
 		modifyWarnNotify();
2428 2525
 		$(document).ready(function() {
2429 2526
 			$("#preview_button").click(function() {
@@ -2462,6 +2559,7 @@  discard block
 block discarded – undo
2462 2559
 			});
2463 2560
 			return false;
2464 2561
 		}';
2562
+	}
2465 2563
 
2466 2564
 	echo '
2467 2565
 	</script>';
@@ -2484,16 +2582,18 @@  discard block
 block discarded – undo
2484 2582
 			</div>';
2485 2583
 
2486 2584
 	// If deleting another account give them a lovely info box.
2487
-	if (!$context['user']['is_owner'])
2488
-		echo '
2585
+	if (!$context['user']['is_owner']) {
2586
+			echo '
2489 2587
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2588
+	}
2490 2589
 	echo '
2491 2590
 			<div class="windowbg2">';
2492 2591
 
2493 2592
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2494
-	if ($context['needs_approval'])
2495
-		echo '
2593
+	if ($context['needs_approval']) {
2594
+			echo '
2496 2595
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2596
+	}
2497 2597
 
2498 2598
 	// If the user is deleting their own account warn them first - and require a password!
2499 2599
 	if ($context['user']['is_owner'])
@@ -2505,9 +2605,10 @@  discard block
 block discarded – undo
2505 2605
 					<input type="password" name="oldpasswrd" size="20">&nbsp;&nbsp;&nbsp;&nbsp;
2506 2606
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2507 2607
 
2508
-		if (!empty($context['token_check']))
2509
-			echo '
2608
+		if (!empty($context['token_check'])) {
2609
+					echo '
2510 2610
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2611
+		}
2511 2612
 
2512 2613
 		echo '
2513 2614
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2533,9 +2634,10 @@  discard block
 block discarded – undo
2533 2634
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2534 2635
 					</select>';
2535 2636
 
2536
-			if ($context['show_perma_delete'])
2537
-				echo '
2637
+			if ($context['show_perma_delete']) {
2638
+							echo '
2538 2639
 					<br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2640
+			}
2539 2641
 
2540 2642
 			echo '
2541 2643
 				</div>';
@@ -2548,9 +2650,10 @@  discard block
 block discarded – undo
2548 2650
 				<div>
2549 2651
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2550 2652
 
2551
-		if (!empty($context['token_check']))
2552
-			echo '
2653
+		if (!empty($context['token_check'])) {
2654
+					echo '
2553 2655
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2656
+		}
2554 2657
 
2555 2658
 		echo '
2556 2659
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2576,8 +2679,8 @@  discard block
 block discarded – undo
2576 2679
 					<hr>';
2577 2680
 
2578 2681
 	// Only show the password box if it's actually needed.
2579
-	if ($context['require_password'])
2580
-		echo '
2682
+	if ($context['require_password']) {
2683
+			echo '
2581 2684
 					<dl class="settings">
2582 2685
 						<dt>
2583 2686
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2587,13 +2690,15 @@  discard block
 block discarded – undo
2587 2690
 							<input type="password" name="oldpasswrd" size="20">
2588 2691
 						</dd>
2589 2692
 					</dl>';
2693
+	}
2590 2694
 
2591 2695
 	echo '
2592 2696
 					<div class="righttext">';
2593 2697
 
2594
-		if (!empty($context['token_check']))
2595
-			echo '
2698
+		if (!empty($context['token_check'])) {
2699
+					echo '
2596 2700
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2701
+		}
2597 2702
 
2598 2703
 	echo '
2599 2704
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2620,9 +2725,10 @@  discard block
 block discarded – undo
2620 2725
 			<ul id="list_errors">';
2621 2726
 
2622 2727
 		// Cycle through each error and display an error message.
2623
-		foreach ($context['post_errors'] as $error)
2624
-			echo '
2728
+		foreach ($context['post_errors'] as $error) {
2729
+					echo '
2625 2730
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2731
+		}
2626 2732
 
2627 2733
 		echo '
2628 2734
 			</ul>';
@@ -2648,12 +2754,13 @@  discard block
 block discarded – undo
2648 2754
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2649 2755
 
2650 2756
 		// Fill the select box with all primary member groups that can be assigned to a member.
2651
-		foreach ($context['member_groups'] as $member_group)
2652
-			if (!empty($member_group['can_be_primary']))
2757
+		foreach ($context['member_groups'] as $member_group) {
2758
+					if (!empty($member_group['can_be_primary']))
2653 2759
 				echo '
2654 2760
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2655 2761
 										', $member_group['name'], '
2656 2762
 									</option>';
2763
+		}
2657 2764
 		echo '
2658 2765
 								</select>
2659 2766
 							</dd>
@@ -2665,10 +2772,11 @@  discard block
 block discarded – undo
2665 2772
 									<input type="hidden" name="additional_groups[]" value="0">';
2666 2773
 
2667 2774
 		// For each membergroup show a checkbox so members can be assigned to more than one group.
2668
-		foreach ($context['member_groups'] as $member_group)
2669
-			if ($member_group['can_be_additional'])
2775
+		foreach ($context['member_groups'] as $member_group) {
2776
+					if ($member_group['can_be_additional'])
2670 2777
 				echo '
2671 2778
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2779
+		}
2672 2780
 		echo '
2673 2781
 								</span>
2674 2782
 								<a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a>
@@ -2728,9 +2836,10 @@  discard block
 block discarded – undo
2728 2836
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2729 2837
 								<br>';
2730 2838
 
2731
-	if ($context['show_spellchecking'])
2732
-		echo '
2839
+	if ($context['show_spellchecking']) {
2840
+			echo '
2733 2841
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2842
+	}
2734 2843
 
2735 2844
 		echo '
2736 2845
 							</dt>
@@ -2738,17 +2847,20 @@  discard block
 block discarded – undo
2738 2847
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2739 2848
 
2740 2849
 	// If there is a limit at all!
2741
-	if (!empty($context['signature_limits']['max_length']))
2742
-		echo '
2850
+	if (!empty($context['signature_limits']['max_length'])) {
2851
+			echo '
2743 2852
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2853
+	}
2744 2854
 
2745
-	if (!empty($context['show_preview_button']))
2746
-		echo '
2855
+	if (!empty($context['show_preview_button'])) {
2856
+			echo '
2747 2857
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">';
2858
+	}
2748 2859
 
2749
-	if ($context['signature_warning'])
2750
-		echo '
2860
+	if ($context['signature_warning']) {
2861
+			echo '
2751 2862
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2863
+	}
2752 2864
 
2753 2865
 	// Some javascript used to count how many characters have been used so far in the signature.
2754 2866
 	echo '
@@ -2792,9 +2904,10 @@  discard block
 block discarded – undo
2792 2904
 									<div>
2793 2905
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2794 2906
 		// This lists all the file categories.
2795
-		foreach ($context['avatars'] as $avatar)
2796
-			echo '
2907
+		foreach ($context['avatars'] as $avatar) {
2908
+					echo '
2797 2909
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2910
+		}
2798 2911
 		echo '
2799 2912
 										</select>
2800 2913
 									</div>
@@ -2849,16 +2962,17 @@  discard block
 block discarded – undo
2849 2962
 								<div id="avatar_gravatar">
2850 2963
 									<img src="' . $context['member']['avatar']['href'] . '" alt="" />';
2851 2964
 
2852
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2853
-			echo '
2965
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
2966
+					echo '
2854 2967
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2855
-		else
2968
+		} else
2856 2969
 		{
2857 2970
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2858
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2859
-				$textbox_value = '';
2860
-			else
2861
-				$textbox_value = $context['member']['avatar']['external'];
2971
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
2972
+							$textbox_value = '';
2973
+			} else {
2974
+							$textbox_value = $context['member']['avatar']['external'];
2975
+			}
2862 2976
 
2863 2977
 			echo '
2864 2978
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -2930,8 +3044,9 @@  discard block
 block discarded – undo
2930 3044
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
2931 3045
 
2932 3046
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
2933
-	if (empty($suffix))
2934
-		return;
3047
+	if (empty($suffix)) {
3048
+			return;
3049
+	}
2935 3050
 
2936 3051
 	echo '
2937 3052
 									<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -2953,9 +3068,10 @@  discard block
 block discarded – undo
2953 3068
 							<dd>
2954 3069
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
2955 3070
 	// Help the user by showing a list of common time formats.
2956
-	foreach ($context['easy_timeformats'] as $time_format)
2957
-		echo '
3071
+	foreach ($context['easy_timeformats'] as $time_format) {
3072
+			echo '
2958 3073
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3074
+	}
2959 3075
 	echo '
2960 3076
 								</select><br>
2961 3077
 								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30">
@@ -2991,9 +3107,10 @@  discard block
 block discarded – undo
2991 3107
 							</dt>
2992 3108
 							<dd>
2993 3109
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
2994
-	foreach ($context['smiley_sets'] as $set)
2995
-		echo '
3110
+	foreach ($context['smiley_sets'] as $set) {
3111
+			echo '
2996 3112
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3113
+	}
2997 3114
 	echo '
2998 3115
 								</select>
2999 3116
 								<img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)">
@@ -3044,10 +3161,11 @@  discard block
 block discarded – undo
3044 3161
 										<img src="', $context['tfa_qr_url'], '" alt="">
3045 3162
 									</div>';
3046 3163
 
3047
-	if (!empty($context['from_ajax']))
3048
-		echo '
3164
+	if (!empty($context['from_ajax'])) {
3165
+			echo '
3049 3166
 									<br>
3050 3167
 									<a href="javascript:self.close();"></a>';
3168
+	}
3051 3169
 
3052 3170
 	echo '
3053 3171
 								</div>
@@ -3086,15 +3204,16 @@  discard block
 block discarded – undo
3086 3204
 								<br><div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3087 3205
 							</dt>
3088 3206
 							<dd>';
3089
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3090
-		echo '
3207
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3208
+			echo '
3091 3209
 								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3092
-	elseif (!$context['tfa_enabled'])
3093
-		echo '
3210
+	} elseif (!$context['tfa_enabled']) {
3211
+			echo '
3094 3212
 								', $txt['tfa_profile_disabled'];
3095
-	else
3096
-		echo '
3213
+	} else {
3214
+			echo '
3097 3215
 							', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3216
+	}
3098 3217
 	echo '
3099 3218
 							</dd>';
3100 3219
 }
Please login to merge, or discard this patch.
Themes/default/Search.template.php 1 patch
Braces   +85 added lines, -60 removed lines patch added patch discarded remove patch
@@ -25,13 +25,15 @@  discard block
 block discarded – undo
25 25
 			</h3>
26 26
 		</div>';
27 27
 
28
-	if (!empty($context['search_errors']))
29
-		echo '
28
+	if (!empty($context['search_errors'])) {
29
+			echo '
30 30
 		<div class="errorbox">', implode('<br>', $context['search_errors']['messages']), '</div>';
31
+	}
31 32
 
32
-	if (!empty($context['search_ignored']))
33
-		echo '
33
+	if (!empty($context['search_ignored'])) {
34
+			echo '
34 35
 		<p class="noticebox">', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p>';
36
+	}
35 37
 
36 38
 	echo '
37 39
 		<div id="advanced_search" class="roundframe">
@@ -42,9 +44,10 @@  discard block
 block discarded – undo
42 44
 				<dd>
43 45
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
44 46
 
45
-	if (empty($modSettings['search_simple_fulltext']))
46
-		echo '
47
+	if (empty($modSettings['search_simple_fulltext'])) {
48
+			echo '
47 49
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
50
+	}
48 51
 
49 52
 	echo '
50 53
 				</dd>
@@ -115,11 +118,12 @@  discard block
 block discarded – undo
115 118
 	}
116 119
 
117 120
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
118
-	if (!empty($context['search_params']['topic']))
119
-		echo '
121
+	if (!empty($context['search_params']['topic'])) {
122
+			echo '
120 123
 				<p>', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.</p>
121 124
 				<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
122 125
 				<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
126
+	}
123 127
 
124 128
 	echo '
125 129
 		</div>';
@@ -149,14 +153,15 @@  discard block
 block discarded – undo
149 153
 
150 154
 			foreach ($category['boards'] as $board)
151 155
 			{
152
-				if ($i == $limit)
153
-					echo '
156
+				if ($i == $limit) {
157
+									echo '
154 158
 							</ul>
155 159
 						</li>
156 160
 					</ul>
157 161
 					<ul class="ignoreboards floatright">
158 162
 						<li class="category">
159 163
 							<ul>';
164
+				}
160 165
 
161 166
 				echo '
162 167
 								<li class="board">
@@ -244,13 +249,15 @@  discard block
 block discarded – undo
244 249
 		<div class="roundframe">';
245 250
 
246 251
 		// Did they make any typos or mistakes, perhaps?
247
-		if (isset($context['did_you_mean']))
248
-			echo '
252
+		if (isset($context['did_you_mean'])) {
253
+					echo '
249 254
 			<p>', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.</p>';
255
+		}
250 256
 
251
-		if (!empty($context['search_ignored']))
252
-			echo '
257
+		if (!empty($context['search_ignored'])) {
258
+					echo '
253 259
 			<p>', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p>';
260
+		}
254 261
 
255 262
 		echo '
256 263
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -272,10 +279,11 @@  discard block
 block discarded – undo
272 279
 					<input type="hidden" name="maxage" value="', !empty($context['search_params']['maxage']) ? $context['search_params']['maxage'] : '9999', '">
273 280
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
274 281
 				</div>';
275
-		if (!empty($context['search_params']['brd']))
276
-			foreach ($context['search_params']['brd'] as $board_id)
282
+		if (!empty($context['search_params']['brd'])) {
283
+					foreach ($context['search_params']['brd'] as $board_id)
277 284
 				echo '
278 285
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
286
+		}
279 287
 
280 288
 		echo '
281 289
 			</form>
@@ -286,17 +294,19 @@  discard block
 block discarded – undo
286 294
 	if ($context['compact'])
287 295
 	{
288 296
 		// Quick moderation set to checkboxes? Oh, how fun :/.
289
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
290
-			echo '
297
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
298
+					echo '
291 299
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
300
+		}
292 301
 
293 302
 	echo '
294 303
 		<div class="cat_bar">
295 304
 			<h3 class="catbg">
296 305
 				<span class="floatright">';
297
-					if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
298
-					echo '
306
+					if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
307
+										echo '
299 308
 							<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
309
+					}
300 310
 				echo '
301 311
 				</span>
302 312
 				<span class="generic_icons filter"></span>&nbsp;', $txt['mlist_search_results'], ':&nbsp;', $context['search_params']['search'], '
@@ -304,14 +314,15 @@  discard block
 block discarded – undo
304 314
 		</div>';
305 315
 
306 316
 		// was anything even found?
307
-		if (!empty($context['topics']))
308
-		echo'
317
+		if (!empty($context['topics'])) {
318
+				echo'
309 319
 		<div class="pagesection">
310 320
 			<span>', $context['page_index'], '</span>
311 321
 		</div>';
312
-		else
313
-			echo '
322
+		} else {
323
+					echo '
314 324
 			<div class="roundframe">', $txt['find_no_results'], '</div>';
325
+		}
315 326
 
316 327
 		// while we have results to show ...
317 328
 		while ($topic = $context['get_topics']())
@@ -339,38 +350,43 @@  discard block
 block discarded – undo
339 350
 					{
340 351
 						echo '
341 352
 						<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
342
-					}
343
-					else
353
+					} else
344 354
 					{
345
-						if ($topic['quick_mod']['remove'])
346
-							echo '
355
+						if ($topic['quick_mod']['remove']) {
356
+													echo '
347 357
 						<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
358
+						}
348 359
 
349
-						if ($topic['quick_mod']['lock'])
350
-							echo '
360
+						if ($topic['quick_mod']['lock']) {
361
+													echo '
351 362
 						<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
363
+						}
352 364
 
353
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
354
-							echo '
365
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
366
+													echo '
355 367
 						<br>';
368
+						}
356 369
 
357
-						if ($topic['quick_mod']['sticky'])
358
-							echo '
370
+						if ($topic['quick_mod']['sticky']) {
371
+													echo '
359 372
 						<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
373
+						}
360 374
 
361
-						if ($topic['quick_mod']['move'])
362
-							echo '
375
+						if ($topic['quick_mod']['move']) {
376
+													echo '
363 377
 						<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
378
+						}
364 379
 					}
365 380
 
366 381
 					echo '
367 382
 					</div>';
368 383
 				}
369 384
 
370
-				if ($message['body_highlighted'] != '')
371
-					echo '
385
+				if ($message['body_highlighted'] != '') {
386
+									echo '
372 387
 					<br class="clear">
373 388
 					<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
389
+				}
374 390
 			}
375 391
 
376 392
 			echo '
@@ -378,11 +394,12 @@  discard block
 block discarded – undo
378 394
 			</div>';
379 395
 
380 396
 		}
381
-		if (!empty($context['topics']))
382
-		echo '
397
+		if (!empty($context['topics'])) {
398
+				echo '
383 399
 		<div class="pagesection">
384 400
 			<span>', $context['page_index'], '</span>
385 401
 		</div>';
402
+		}
386 403
 
387 404
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
388 405
 		{
@@ -392,17 +409,19 @@  discard block
 block discarded – undo
392 409
 					<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
393 410
 						<option value="">--------</option>';
394 411
 
395
-			foreach ($context['qmod_actions'] as $qmod_action)
396
-				if ($context['can_' . $qmod_action])
412
+			foreach ($context['qmod_actions'] as $qmod_action) {
413
+							if ($context['can_' . $qmod_action])
397 414
 					echo '
398 415
 							<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
416
+			}
399 417
 
400 418
 			echo '
401 419
 					</select>';
402 420
 
403
-			if ($context['can_move'])
404
-				echo '
421
+			if ($context['can_move']) {
422
+							echo '
405 423
 				<span id="quick_mod_jump_to">&nbsp;</span>';
424
+			}
406 425
 
407 426
 			echo '
408 427
 					<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -412,13 +431,13 @@  discard block
 block discarded – undo
412 431
 		}
413 432
 
414 433
 
415
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
416
-			echo '
434
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
435
+					echo '
417 436
 			<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
418 437
 		</form>';
438
+		}
419 439
 
420
-	}
421
-	else
440
+	} else
422 441
 	{
423 442
 		echo '
424 443
 		<div class="cat_bar">
@@ -430,9 +449,10 @@  discard block
 block discarded – undo
430 449
 			<span>', $context['page_index'], '</span>
431 450
 		</div>';
432 451
 
433
-		if (empty($context['topics']))
434
-			echo '
452
+		if (empty($context['topics'])) {
453
+					echo '
435 454
 		<div class="information">(', $txt['search_no_results'], ')</div>';
455
+		}
436 456
 
437 457
 		while ($topic = $context['get_topics']())
438 458
 		{
@@ -447,23 +467,27 @@  discard block
 block discarded – undo
447 467
 					</div>
448 468
 					<div class="list_posts">', $message['body_highlighted'], '</div>';
449 469
 
450
-			if ($topic['can_reply'])
451
-				echo '
470
+			if ($topic['can_reply']) {
471
+							echo '
452 472
 						<ul class="quickbuttons">';
473
+			}
453 474
 
454 475
 				// If they *can* reply?
455
-			if ($topic['can_reply'])
456
-				echo '
476
+			if ($topic['can_reply']) {
477
+							echo '
457 478
 							<li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
479
+			}
458 480
 
459 481
 				// If they *can* quote?
460
-			if ($topic['can_quote'])
461
-				echo '
482
+			if ($topic['can_quote']) {
483
+							echo '
462 484
 							<li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
485
+			}
463 486
 
464
-			if ($topic['can_reply'])
465
-				echo '
487
+			if ($topic['can_reply']) {
488
+							echo '
466 489
 						</ul>';
490
+			}
467 491
 			echo '
468 492
 					<br class="clear">
469 493
 				</div>';
@@ -482,8 +506,8 @@  discard block
 block discarded – undo
482 506
 		<div class="smalltext righttext" id="search_jump_to">&nbsp;</div>
483 507
 		<script>';
484 508
 
485
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
486
-		echo '
509
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
510
+			echo '
487 511
 				if (typeof(window.XMLHttpRequest) != "undefined")
488 512
 					aJumpTo[aJumpTo.length] = new JumpTo({
489 513
 						sContainerId: "quick_mod_jump_to",
@@ -498,6 +522,7 @@  discard block
 block discarded – undo
498 522
 						bDisabled: true,
499 523
 						sCustomName: "move_to"
500 524
 					});';
525
+	}
501 526
 
502 527
 	echo '
503 528
 			if (typeof(window.XMLHttpRequest) != "undefined")
Please login to merge, or discard this patch.
Themes/default/ManagePermissions.template.php 1 patch
Braces   +159 added lines, -122 removed lines patch added patch discarded remove patch
@@ -19,26 +19,28 @@  discard block
 block discarded – undo
19 19
 	global $context, $settings, $scripturl, $txt, $modSettings;
20 20
 
21 21
 	// Not allowed to edit?
22
-	if (!$context['can_modify'])
23
-		echo '
22
+	if (!$context['can_modify']) {
23
+			echo '
24 24
 	<div class="errorbox">
25 25
 		', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
26 26
 	</div>';
27
+	}
27 28
 
28 29
 	echo '
29 30
 	<div id="admin_form_wrapper">
30 31
 		<form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">';
31 32
 
32
-		if (!empty($context['profile']))
33
-			echo '
33
+		if (!empty($context['profile'])) {
34
+					echo '
34 35
 			<div class="cat_bar">
35 36
 				<h3 class="catbg">', $txt['permissions_for_profile'], ': &quot;', $context['profile']['name'], '&quot;</h3>
36 37
 			</div>';
37
-		else
38
-			echo '
38
+		} else {
39
+					echo '
39 40
 			<div class="cat_bar">
40 41
 				<h3 class="catbg">', $txt['permissions_title'], '</h3>
41 42
 			</div>';
43
+		}
42 44
 
43 45
 		echo '
44 46
 			<table class="table_grid">
@@ -47,13 +49,14 @@  discard block
 block discarded – undo
47 49
 						<th>', $txt['membergroups_name'], '</th>
48 50
 						<th class="small_table">', $txt['membergroups_members_top'], '</th>';
49 51
 
50
-			if (empty($modSettings['permission_enable_deny']))
51
-				echo '
52
+			if (empty($modSettings['permission_enable_deny'])) {
53
+							echo '
52 54
 						<th class="small_table">', $txt['membergroups_permissions'], '</th>';
53
-			else
54
-				echo '
55
+			} else {
56
+							echo '
55 57
 						<th class="small_table">', $txt['permissions_allowed'], '</th>
56 58
 						<th class="small_table">', $txt['permissions_denied'], '</th>';
59
+			}
57 60
 
58 61
 			echo '
59 62
 						<th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th>
@@ -71,22 +74,24 @@  discard block
 block discarded – undo
71 74
 						<td>
72 75
 							', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a>' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '&nbsp;<span>', $group['name'], '</span>';
73 76
 
74
-		if (!empty($group['children']))
75
-			echo '
77
+		if (!empty($group['children'])) {
78
+					echo '
76 79
 							<br>
77 80
 							<span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
81
+		}
78 82
 
79 83
 		echo '
80 84
 						</td>
81 85
 						<td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>';
82 86
 
83
-		if (empty($modSettings['permission_enable_deny']))
84
-			echo '
87
+		if (empty($modSettings['permission_enable_deny'])) {
88
+					echo '
85 89
 						<td>', $group['num_permissions']['allowed'], '</td>';
86
-		else
87
-			echo '
90
+		} else {
91
+					echo '
88 92
 						<td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>', $group['num_permissions']['allowed'], '</td>
89 93
 						<td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '>', $group['num_permissions']['denied'], '</td>';
94
+		}
90 95
 
91 96
 		echo '
92 97
 						<td>', $group['allow_modify'] ? '<a href="' . $scripturl . '?action=admin;area=permissions;sa=modify;group=' . $group['id'] . (empty($context['profile']) ? '' : ';pid=' . $context['profile']['id']) . '">' . ($context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view']) . '</a>' : '', '</td>
@@ -133,9 +138,10 @@  discard block
 block discarded – undo
133 138
 								<option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
134 139
 		foreach ($context['groups'] as $group)
135 140
 		{
136
-			if ($group['id'] != 1)
137
-				echo '
141
+			if ($group['id'] != 1) {
142
+							echo '
138 143
 								<option value="', $group['id'], '">', $group['name'], '</option>';
144
+			}
139 145
 		}
140 146
 
141 147
 		echo '
@@ -145,9 +151,10 @@  discard block
 block discarded – undo
145 151
 							<select name="add_remove">
146 152
 								<option value="add">', $txt['permissions_add'], '...</option>
147 153
 								<option value="clear">', $txt['permissions_remove'], '...</option>';
148
-		if (!empty($modSettings['permission_enable_deny']))
149
-			echo '
154
+		if (!empty($modSettings['permission_enable_deny'])) {
155
+					echo '
150 156
 								<option value="deny">', $txt['permissions_deny'], '...</option>';
157
+		}
151 158
 		echo '
152 159
 							</select>
153 160
 						</dt>
@@ -156,30 +163,34 @@  discard block
 block discarded – undo
156 163
 								<option value="">(', $txt['permissions_select_permission'], ')</option>';
157 164
 		foreach ($context['permissions'] as $permissionType)
158 165
 		{
159
-			if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
160
-				continue;
166
+			if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) {
167
+							continue;
168
+			}
161 169
 
162 170
 			foreach ($permissionType['columns'] as $column)
163 171
 			{
164 172
 				foreach ($column as $permissionGroup)
165 173
 				{
166
-					if ($permissionGroup['hidden'])
167
-						continue;
174
+					if ($permissionGroup['hidden']) {
175
+											continue;
176
+					}
168 177
 
169 178
 					echo '
170 179
 								<option value="" disabled>[', $permissionGroup['name'], ']</option>';
171 180
 					foreach ($permissionGroup['permissions'] as $perm)
172 181
 					{
173
-						if ($perm['hidden'])
174
-							continue;
182
+						if ($perm['hidden']) {
183
+													continue;
184
+						}
175 185
 
176
-						if ($perm['has_own_any'])
177
-							echo '
186
+						if ($perm['has_own_any']) {
187
+													echo '
178 188
 								<option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
179 189
 								<option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
180
-						else
181
-							echo '
190
+						} else {
191
+													echo '
182 192
 								<option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
193
+						}
183 194
 					}
184 195
 				}
185 196
 			}
@@ -246,9 +257,10 @@  discard block
 block discarded – undo
246 257
 		}
247 258
 	</script>';
248 259
 
249
-		if (!empty($context['profile']))
250
-			echo '
260
+		if (!empty($context['profile'])) {
261
+					echo '
251 262
 			<input type="hidden" name="pid" value="', $context['profile']['id'], '">';
263
+		}
252 264
 
253 265
 		echo '
254 266
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -293,9 +305,10 @@  discard block
 block discarded – undo
293 305
 				<h3 class="subbg">', $category['name'], '</h3>
294 306
 			</div>';
295 307
 
296
-		if (!empty($category['boards']))
297
-			echo '
308
+		if (!empty($category['boards'])) {
309
+					echo '
298 310
 				<ul class="perm_boards flow_hidden">';
311
+		}
299 312
 
300 313
 		foreach ($category['boards'] as $board)
301 314
 		{
@@ -312,33 +325,36 @@  discard block
 block discarded – undo
312 325
 				echo '
313 326
 							<select name="boardprofile[', $board['id'], ']">';
314 327
 
315
-				foreach ($context['profiles'] as $id => $profile)
316
-					echo '
328
+				foreach ($context['profiles'] as $id => $profile) {
329
+									echo '
317 330
 								<option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
331
+				}
318 332
 
319 333
 				echo '
320 334
 							</select>';
321
-			}
322
-			else
323
-				echo '
335
+			} else {
336
+							echo '
324 337
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>';
338
+			}
325 339
 
326 340
 			echo '
327 341
 						</span>
328 342
 					</li>';
329 343
 		}
330 344
 
331
-		if (!empty($category['boards']))
332
-			echo '
345
+		if (!empty($category['boards'])) {
346
+					echo '
333 347
 				</ul>';
348
+		}
334 349
 	}
335 350
 
336
-	if ($context['edit_all'])
337
-		echo '
351
+	if ($context['edit_all']) {
352
+			echo '
338 353
 			<input type="submit" name="save_changes" value="', $txt['save'], '" class="button">';
339
-	else
340
-		echo '
354
+	} else {
355
+			echo '
341 356
 			<a class="button" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>';
357
+	}
342 358
 
343 359
 	echo '
344 360
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -378,12 +394,13 @@  discard block
 block discarded – undo
378 394
 					<tr class="windowbg">
379 395
 						<td>';
380 396
 
381
-		if (!empty($context['show_rename_boxes']) && $profile['can_edit'])
382
-			echo '
397
+		if (!empty($context['show_rename_boxes']) && $profile['can_edit']) {
398
+					echo '
383 399
 							<input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '">';
384
-		else
385
-			echo '
400
+		} else {
401
+					echo '
386 402
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>';
403
+		}
387 404
 
388 405
 		echo '
389 406
 						</td>
@@ -403,9 +420,10 @@  discard block
 block discarded – undo
403 420
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
404 421
 				<input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">';
405 422
 
406
-	if ($context['can_edit_something'])
407
-		echo '
423
+	if ($context['can_edit_something']) {
424
+			echo '
408 425
 				<input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button">';
426
+	}
409 427
 
410 428
 	echo '
411 429
 				<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '/>
@@ -430,9 +448,10 @@  discard block
 block discarded – undo
430 448
 					<dd>
431 449
 						<select name="copy_from">';
432 450
 
433
-	foreach ($context['profiles'] as $id => $profile)
434
-		echo '
451
+	foreach ($context['profiles'] as $id => $profile) {
452
+			echo '
435 453
 							<option value="', $id, '">', $profile['name'], '</option>';
454
+	}
436 455
 
437 456
 	echo '
438 457
 						</select>
@@ -460,8 +479,7 @@  discard block
 block discarded – undo
460 479
 		<div class="errorbox">
461 480
 			', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
462 481
 		</div>';
463
-	}
464
-	else
482
+	} else
465 483
 	{
466 484
 		echo '
467 485
 		<script>
@@ -481,21 +499,23 @@  discard block
 block discarded – undo
481 499
 	<div id="admincenter">
482 500
 		<form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">';
483 501
 
484
-	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
485
-		echo '
502
+	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) {
503
+			echo '
486 504
 			<div class="information">
487 505
 				', $txt['permissions_option_desc'], '
488 506
 			</div>';
507
+	}
489 508
 
490 509
 	echo '
491 510
 			<div class="cat_bar">
492 511
 				<h3 class="catbg">';
493
-	if ($context['permission_type'] == 'board')
494
-		echo '
512
+	if ($context['permission_type'] == 'board') {
513
+			echo '
495 514
 				', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
496
-	else
497
-		echo '
515
+	} else {
516
+			echo '
498 517
 				', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
518
+	}
499 519
 	echo '
500 520
 				</h3>
501 521
 			</div>';
@@ -518,15 +538,17 @@  discard block
 block discarded – undo
518 538
 		template_modify_group_display('board');
519 539
 	}
520 540
 
521
-	if ($context['profile']['can_modify'])
522
-		echo '
541
+	if ($context['profile']['can_modify']) {
542
+			echo '
523 543
 			<div class="padding">
524 544
 				<input type="submit" value="', $txt['permissions_commit'], '" class="button">
525 545
 			</div>';
546
+	}
526 547
 
527
-	foreach ($context['hidden_perms'] as $hidden_perm)
528
-		echo '
548
+	foreach ($context['hidden_perms'] as $hidden_perm) {
549
+			echo '
529 550
 			<input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">';
551
+	}
530 552
 
531 553
 	echo '
532 554
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -554,17 +576,19 @@  discard block
 block discarded – undo
554 576
 
555 577
 		foreach ($column as $permissionGroup)
556 578
 		{
557
-			if (empty($permissionGroup['permissions']))
558
-				continue;
579
+			if (empty($permissionGroup['permissions'])) {
580
+							continue;
581
+			}
559 582
 
560 583
 			// Are we likely to have something in this group to display or is it all hidden?
561 584
 			$has_display_content = false;
562 585
 			if (!$permissionGroup['hidden'])
563 586
 			{
564 587
 				// Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
565
-				foreach ($permissionGroup['permissions'] as $permission)
566
-					if (!$permission['hidden'])
588
+				foreach ($permissionGroup['permissions'] as $permission) {
589
+									if (!$permission['hidden'])
567 590
 						$has_display_content = true;
591
+				}
568 592
 
569 593
 				if ($has_display_content)
570 594
 				{
@@ -573,10 +597,11 @@  discard block
 block discarded – undo
573 597
 							<th></th>
574 598
 							<th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>';
575 599
 
576
-					if ($context['group']['id'] != -1)
577
-						echo '
600
+					if ($context['group']['id'] != -1) {
601
+											echo '
578 602
 							<th>', $txt['permissions_option_own'], '</th>
579 603
 							<th>', $txt['permissions_option_any'], '</th>';
604
+					}
580 605
 
581 606
 						echo '
582 607
 						</tr>';
@@ -599,17 +624,18 @@  discard block
 block discarded – undo
599 624
 						// Guests can't do their own thing.
600 625
 						if ($context['group']['id'] != -1)
601 626
 						{
602
-							if (empty($modSettings['permission_enable_deny']))
603
-								echo '
627
+							if (empty($modSettings['permission_enable_deny'])) {
628
+															echo '
604 629
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" ', $disable_field, '/>';
605
-							else
630
+							} else
606 631
 							{
607 632
 								echo '
608 633
 								<select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>';
609 634
 
610
-								foreach (array('on', 'off', 'deny') as $c)
611
-									echo '
635
+								foreach (array('on', 'off', 'deny') as $c) {
636
+																	echo '
612 637
 									<option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
638
+								}
613 639
 							echo '
614 640
 								</select>';
615 641
 							}
@@ -619,39 +645,41 @@  discard block
 block discarded – undo
619 645
 							<td>';
620 646
 						}
621 647
 
622
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
623
-							echo '
648
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
649
+													echo '
624 650
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '/>';
625
-						else
651
+						} else
626 652
 						{
627 653
 							echo '
628 654
 								<select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>';
629 655
 
630
-							foreach (array('on', 'off', 'deny') as $c)
631
-								echo '
656
+							foreach (array('on', 'off', 'deny') as $c) {
657
+															echo '
632 658
 									<option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
659
+							}
633 660
 							echo '
634 661
 								</select>';
635 662
 						}
636
-					}
637
-					else
663
+					} else
638 664
 					{
639
-						if ($context['group']['id'] != -1)
640
-							echo '
665
+						if ($context['group']['id'] != -1) {
666
+													echo '
641 667
 							</td>
642 668
 							<td>';
669
+						}
643 670
 
644
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
645
-							echo '
671
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
672
+													echo '
646 673
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '/>';
647
-						else
674
+						} else
648 675
 						{
649 676
 							echo '
650 677
 								<select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>';
651 678
 
652
-							foreach (array('on', 'off', 'deny') as $c)
653
-								echo '
679
+							foreach (array('on', 'off', 'deny') as $c) {
680
+															echo '
654 681
 									<option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
682
+							}
655 683
 							echo '
656 684
 								</select>';
657 685
 						}
@@ -681,11 +709,11 @@  discard block
 block discarded – undo
681 709
 	echo '
682 710
 											<fieldset id="', $context['current_permission'], '">
683 711
 												<legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>';
684
-	if (empty($modSettings['permission_enable_deny']))
685
-		echo '
712
+	if (empty($modSettings['permission_enable_deny'])) {
713
+			echo '
686 714
 												<ul>';
687
-	else
688
-		echo '
715
+	} else {
716
+			echo '
689 717
 												<div class="information">', $txt['permissions_option_desc'], '</div>
690 718
 												<dl class="settings">
691 719
 													<dt>
@@ -695,46 +723,51 @@  discard block
 block discarded – undo
695 723
 													</dt>
696 724
 													<dd>
697 725
 													</dd>';
726
+	}
698 727
 	foreach ($context['member_groups'] as $group)
699 728
 	{
700
-		if (!empty($modSettings['permission_enable_deny']))
701
-			echo '
729
+		if (!empty($modSettings['permission_enable_deny'])) {
730
+					echo '
702 731
 													<dt>';
703
-		else
704
-			echo '
732
+		} else {
733
+					echo '
705 734
 													<li>';
735
+		}
706 736
 
707
-		if (empty($modSettings['permission_enable_deny']))
708
-			echo '
737
+		if (empty($modSettings['permission_enable_deny'])) {
738
+					echo '
709 739
 														<input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '>';
710
-		else
711
-			echo '
740
+		} else {
741
+					echo '
712 742
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '></span>
713 743
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', '></span>
714 744
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', '></span>';
745
+		}
715 746
 
716
-		if (!empty($modSettings['permission_enable_deny']))
717
-			echo '
747
+		if (!empty($modSettings['permission_enable_deny'])) {
748
+					echo '
718 749
 													</dt>
719 750
 													<dd>
720 751
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
721 752
 													</dd>';
722
-		else
723
-			echo '
753
+		} else {
754
+					echo '
724 755
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
725 756
 													</li>';
757
+		}
726 758
 	}
727 759
 
728
-	if (empty($modSettings['permission_enable_deny']))
729
-		echo '
760
+	if (empty($modSettings['permission_enable_deny'])) {
761
+			echo '
730 762
 													<li>
731 763
 														<input type="checkbox" onclick="invertAll(this, this.form, \''. $context['current_permission'] . '[\');">
732 764
 														<span>', $txt['check_all'], '</span>
733 765
 													</li>
734 766
 												</ul>';
735
-	else
736
-		echo '
767
+	} else {
768
+			echo '
737 769
 												</dl>';
770
+	}
738 771
 
739 772
 	echo '
740 773
 											</fieldset>
@@ -774,9 +807,10 @@  discard block
 block discarded – undo
774 807
 	if (!empty($modSettings['postmod_active']))
775 808
 	{
776 809
 		// Got advanced permissions - if so warn!
777
-		if (!empty($modSettings['permission_enable_deny']))
778
-			echo '
810
+		if (!empty($modSettings['permission_enable_deny'])) {
811
+					echo '
779 812
 							<div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
813
+		}
780 814
 
781 815
 		echo '
782 816
 							<div class="padding">
@@ -791,10 +825,11 @@  discard block
 block discarded – undo
791 825
 									', $txt['permissions_post_moderation_select'], ':
792 826
 									<select name="pid" onchange="document.forms.postmodForm.submit();">';
793 827
 
794
-		foreach ($context['profiles'] as $profile)
795
-			if ($profile['can_modify'])
828
+		foreach ($context['profiles'] as $profile) {
829
+					if ($profile['can_modify'])
796 830
 				echo '
797 831
 										<option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
832
+		}
798 833
 
799 834
 		echo '
800 835
 									</select>
@@ -815,11 +850,12 @@  discard block
 block discarded – undo
815 850
 											', $txt['permissions_post_moderation_replies_any'], '
816 851
 										</th>';
817 852
 
818
-		if ($modSettings['attachmentEnable'] == 1)
819
-			echo '
853
+		if ($modSettings['attachmentEnable'] == 1) {
854
+					echo '
820 855
 										<th class="centercol" colspan="3">
821 856
 											', $txt['permissions_post_moderation_attachments'], '
822 857
 										</th>';
858
+		}
823 859
 
824 860
 		echo '
825 861
 									</tr>
@@ -837,11 +873,12 @@  discard block
 block discarded – undo
837 873
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
838 874
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
839 875
 
840
-		if ($modSettings['attachmentEnable'] == 1)
841
-			echo '
876
+		if ($modSettings['attachmentEnable'] == 1) {
877
+					echo '
842 878
 										<th><span class="generic_icons post_moderation_allow"></span></th>
843 879
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
844 880
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
881
+		}
845 882
 
846 883
 		echo '
847 884
 									</tr>
@@ -854,9 +891,10 @@  discard block
 block discarded – undo
854 891
 									<tr class="windowbg">
855 892
 										<td class="half_table">
856 893
 											<span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
857
-				if (!empty($group['children']))
858
-					echo '
894
+				if (!empty($group['children'])) {
895
+									echo '
859 896
 											<br><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
897
+				}
860 898
 
861 899
 				echo '
862 900
 										</td>
@@ -869,8 +907,7 @@  discard block
 block discarded – undo
869 907
 				{
870 908
 				echo '
871 909
 										<td colspan="3"></td>';
872
-				}
873
-				else
910
+				} else
874 911
 				{
875 912
 					echo '
876 913
 										<td class="centercol"><input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', '></td>
Please login to merge, or discard this patch.
Sources/CacheAPI-postgres.php 1 patch
Braces   +28 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * PostgreSQL Cache API class
@@ -49,8 +50,9 @@  discard block
 block discarded – undo
49 50
 
50 51
 		$result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache'));
51 52
 
52
-		if (pg_affected_rows($result) === 0)
53
-			pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))');			
53
+		if (pg_affected_rows($result) === 0) {
54
+					pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))');
55
+		}
54 56
 	}
55 57
 
56 58
 	/**
@@ -60,14 +62,16 @@  discard block
 block discarded – undo
60 62
 	{
61 63
 		global $smcFunc, $db_connection;
62 64
 
63
-		if ($smcFunc['db_title'] !== 'PostgreSQL')
64
-			return false;
65
+		if ($smcFunc['db_title'] !== 'PostgreSQL') {
66
+					return false;
67
+		}
65 68
 
66 69
 		$result = pg_query($db_connection, 'SHOW server_version_num');
67 70
 		$res = pg_fetch_assoc($result);
68 71
 		
69
-		if ($res['server_version_num'] < 90500)
70
-			return false;
72
+		if ($res['server_version_num'] < 90500) {
73
+					return false;
74
+		}
71 75
 		
72 76
 		return $test ? true : parent::isSupported();
73 77
 	}
@@ -81,13 +85,15 @@  discard block
 block discarded – undo
81 85
 
82 86
 		$ttl = time() - $ttl;
83 87
 		
84
-		if (empty($this->pg_get_data_prep))
85
-			$this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1');
88
+		if (empty($this->pg_get_data_prep)) {
89
+					$this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1');
90
+		}
86 91
 			
87 92
 		$result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl));
88 93
 		
89
-		if (pg_affected_rows($result) === 0)
90
-			return null;
94
+		if (pg_affected_rows($result) === 0) {
95
+					return null;
96
+		}
91 97
 
92 98
 		$res = pg_fetch_assoc($result);
93 99
 
@@ -101,23 +107,26 @@  discard block
 block discarded – undo
101 107
 	{
102 108
 		global  $db_prefix, $db_connection;
103 109
 
104
-		if (!isset($value))
105
-			$value = '';
110
+		if (!isset($value)) {
111
+					$value = '';
112
+		}
106 113
 
107 114
 		$ttl = time() + $ttl;
108 115
 
109
-		if (empty($this->pg_put_data_prep))
110
-			$this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data',
116
+		if (empty($this->pg_put_data_prep)) {
117
+					$this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data',
111 118
 				'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3)
112 119
 				ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl'
113 120
 			);
121
+		}
114 122
 
115 123
 		$result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl));
116 124
 
117
-		if (pg_affected_rows($result) > 0)
118
-			return true;
119
-		else
120
-			return false;
125
+		if (pg_affected_rows($result) > 0) {
126
+					return true;
127
+		} else {
128
+					return false;
129
+		}
121 130
 	}
122 131
 
123 132
 	/**
Please login to merge, or discard this patch.
Sources/Subs-Db-mysql.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 
255 255
 		case 'datetime':
256 256
 			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
257
-				return 'str_to_date('.
258
-					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
257
+				return 'str_to_date(' .
258
+					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) .
259 259
 					',\'%Y-%m-%d %h:%i:%s\')';
260 260
 			else
261 261
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	{
840 840
 		$count = count($insertRows);
841 841
 		$ai = 0;
842
-		for($i = 0; $i < $count; $i++)
842
+		for ($i = 0; $i < $count; $i++)
843 843
 		{
844 844
 			$old_id = $smcFunc['db_insert_id']();
845 845
 			
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
 				$count2 = count($indexed_columns);
866 866
 				for ($x = 0; $x < $count2; $x++)
867 867
 				{
868
-					$where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x];
868
+					$where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x];
869 869
 					if (($x + 1) < $count2)
870 870
 						$where_string += ' AND ';
871 871
 				}
872 872
 
873
-				$request = $smcFunc['db_query']('','
874
-					SELECT `'. $keys[0] . '` FROM ' . $table .'
873
+				$request = $smcFunc['db_query']('', '
874
+					SELECT `'. $keys[0] . '` FROM ' . $table . '
875 875
 					WHERE ' . $where_string . ' LIMIT 1',
876 876
 					array()
877 877
 				);
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 			$return_var = array();
901 901
 			$count = count($insertRows);
902 902
 			$start = smf_db_insert_id($table, $keys[0]);
903
-			for ($i = 0; $i < $count; $i++ )
903
+			for ($i = 0; $i < $count; $i++)
904 904
 				$return_var[] = $start + $i;
905 905
 		}
906 906
 		return $return_var;
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', 
1034 1034
 		$error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6],
1035 1035
 		$error_array[7], $error_array[8]);
1036
-	mysqli_stmt_execute ($mysql_error_data_prep);
1036
+	mysqli_stmt_execute($mysql_error_data_prep);
1037 1037
 }
1038 1038
 
1039 1039
 ?>
1040 1040
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +274 added lines, -203 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
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
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']))
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc'])) {
38
+			$smcFunc += array(
38 39
 			'db_query'                  => 'smf_db_query',
39 40
 			'db_quote'                  => 'smf_db_quote',
40 41
 			'db_fetch_assoc'            => 'mysqli_fetch_assoc',
@@ -62,9 +63,11 @@  discard block
 block discarded – undo
62 63
 			'db_fetch_all'              => 'smf_db_fetch_all',
63 64
 			'db_error_insert'			=> 'smf_db_error_insert',
64 65
 		);
66
+	}
65 67
 
66
-	if (!empty($db_options['persist']))
67
-		$db_server = 'p:' . $db_server;
68
+	if (!empty($db_options['persist'])) {
69
+			$db_server = 'p:' . $db_server;
70
+	}
68 71
 
69 72
 	$connection = mysqli_init();
70 73
 
@@ -73,24 +76,27 @@  discard block
 block discarded – undo
73 76
 	$success = false;
74 77
 
75 78
 	if ($connection) {
76
-		if (!empty($db_options['port']))
77
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
78
-		else
79
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
79
+		if (!empty($db_options['port'])) {
80
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
81
+		} else {
82
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
83
+		}
80 84
 	}
81 85
 
82 86
 	// Something's wrong, show an error if its fatal (which we assume it is)
83 87
 	if ($success === false)
84 88
 	{
85
-		if (!empty($db_options['non_fatal']))
86
-			return null;
87
-		else
88
-			display_db_error();
89
+		if (!empty($db_options['non_fatal'])) {
90
+					return null;
91
+		} else {
92
+					display_db_error();
93
+		}
89 94
 	}
90 95
 
91 96
 	// Select the database, unless told not to
92
-	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal']))
93
-		display_db_error();
97
+	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) {
98
+			display_db_error();
99
+	}
94 100
 
95 101
 	$smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'',
96 102
 		array(),
@@ -166,34 +172,42 @@  discard block
 block discarded – undo
166 172
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
167 173
 
168 174
 	list ($values, $connection) = $db_callback;
169
-	if (!is_object($connection))
170
-		display_db_error();
175
+	if (!is_object($connection)) {
176
+			display_db_error();
177
+	}
171 178
 
172
-	if ($matches[1] === 'db_prefix')
173
-		return $db_prefix;
179
+	if ($matches[1] === 'db_prefix') {
180
+			return $db_prefix;
181
+	}
174 182
 
175
-	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false)
176
-		return $user_info[$matches[1]];
183
+	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) {
184
+			return $user_info[$matches[1]];
185
+	}
177 186
 
178
-	if ($matches[1] === 'empty')
179
-		return '\'\'';
187
+	if ($matches[1] === 'empty') {
188
+			return '\'\'';
189
+	}
180 190
 
181
-	if (!isset($matches[2]))
182
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
191
+	if (!isset($matches[2])) {
192
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
193
+	}
183 194
 
184
-	if ($matches[1] === 'literal')
185
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
195
+	if ($matches[1] === 'literal') {
196
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
197
+	}
186 198
 
187
-	if (!isset($values[$matches[2]]))
188
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
199
+	if (!isset($values[$matches[2]])) {
200
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
201
+	}
189 202
 
190 203
 	$replacement = $values[$matches[2]];
191 204
 
192 205
 	switch ($matches[1])
193 206
 	{
194 207
 		case 'int':
195
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
196
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
208
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
209
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
210
+			}
197 211
 			return (string) (int) $replacement;
198 212
 		break;
199 213
 
@@ -205,65 +219,73 @@  discard block
 block discarded – undo
205 219
 		case 'array_int':
206 220
 			if (is_array($replacement))
207 221
 			{
208
-				if (empty($replacement))
209
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
222
+				if (empty($replacement)) {
223
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
224
+				}
210 225
 
211 226
 				foreach ($replacement as $key => $value)
212 227
 				{
213
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
214
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
228
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
229
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
230
+					}
215 231
 
216 232
 					$replacement[$key] = (string) (int) $value;
217 233
 				}
218 234
 
219 235
 				return implode(', ', $replacement);
236
+			} else {
237
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
220 238
 			}
221
-			else
222
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
223 239
 
224 240
 		break;
225 241
 
226 242
 		case 'array_string':
227 243
 			if (is_array($replacement))
228 244
 			{
229
-				if (empty($replacement))
230
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
245
+				if (empty($replacement)) {
246
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
247
+				}
231 248
 
232
-				foreach ($replacement as $key => $value)
233
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
249
+				foreach ($replacement as $key => $value) {
250
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
251
+				}
234 252
 
235 253
 				return implode(', ', $replacement);
254
+			} else {
255
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
236 256
 			}
237
-			else
238
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
239 257
 		break;
240 258
 
241 259
 		case 'date':
242
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
243
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
244
-			else
245
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
260
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
261
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
262
+			} else {
263
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
264
+			}
246 265
 		break;
247 266
 
248 267
 		case 'time':
249
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
250
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
251
-			else
252
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
268
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
269
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
270
+			} else {
271
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
272
+			}
253 273
 		break;
254 274
 
255 275
 		case 'datetime':
256
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
257
-				return 'str_to_date('.
276
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
277
+							return 'str_to_date('.
258 278
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
259 279
 					',\'%Y-%m-%d %h:%i:%s\')';
260
-			else
261
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
280
+			} else {
281
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
282
+			}
262 283
 		break;
263 284
 
264 285
 		case 'float':
265
-			if (!is_numeric($replacement))
266
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
286
+			if (!is_numeric($replacement)) {
287
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
288
+			}
267 289
 			return (string) (float) $replacement;
268 290
 		break;
269 291
 
@@ -277,32 +299,37 @@  discard block
 block discarded – undo
277 299
 		break;
278 300
 
279 301
 		case 'inet':
280
-			if ($replacement == 'null' || $replacement == '')
281
-				return 'null';
282
-			if (!isValidIP($replacement))
283
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
302
+			if ($replacement == 'null' || $replacement == '') {
303
+							return 'null';
304
+			}
305
+			if (!isValidIP($replacement)) {
306
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
307
+			}
284 308
 			//we don't use the native support of mysql > 5.6.2
285 309
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
286 310
 
287 311
 		case 'array_inet':
288 312
 			if (is_array($replacement))
289 313
 			{
290
-				if (empty($replacement))
291
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
314
+				if (empty($replacement)) {
315
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
316
+				}
292 317
 
293 318
 				foreach ($replacement as $key => $value)
294 319
 				{
295
-					if ($replacement == 'null' || $replacement == '')
296
-						$replacement[$key] = 'null';
297
-					if (!isValidIP($value))
298
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
320
+					if ($replacement == 'null' || $replacement == '') {
321
+											$replacement[$key] = 'null';
322
+					}
323
+					if (!isValidIP($value)) {
324
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
325
+					}
299 326
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
300 327
 				}
301 328
 
302 329
 				return implode(', ', $replacement);
330
+			} else {
331
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
303 332
 			}
304
-			else
305
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
306 333
 		break;
307 334
 
308 335
 		default:
@@ -378,22 +405,25 @@  discard block
 block discarded – undo
378 405
 		// Are we in SSI mode?  If so try that username and password first
379 406
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
380 407
 		{
381
-			if (empty($db_persist))
382
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
383
-			else
384
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
408
+			if (empty($db_persist)) {
409
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
410
+			} else {
411
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
412
+			}
385 413
 		}
386 414
 		// Fall back to the regular username and password if need be
387 415
 		if (!$db_connection)
388 416
 		{
389
-			if (empty($db_persist))
390
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
391
-			else
392
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
417
+			if (empty($db_persist)) {
418
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
419
+			} else {
420
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
421
+			}
393 422
 		}
394 423
 
395
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
396
-			$db_connection = false;
424
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
425
+					$db_connection = false;
426
+		}
397 427
 
398 428
 		$connection = $db_connection;
399 429
 	}
@@ -401,18 +431,20 @@  discard block
 block discarded – undo
401 431
 	// One more query....
402 432
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
403 433
 
404
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
405
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
434
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
435
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
436
+	}
406 437
 
407 438
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
408 439
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
409 440
 	{
410 441
 		// Add before LIMIT
411
-		if ($pos = strpos($db_string, 'LIMIT '))
412
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
413
-		else
414
-			// Append it.
442
+		if ($pos = strpos($db_string, 'LIMIT ')) {
443
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
444
+		} else {
445
+					// Append it.
415 446
 			$db_string .= "\n\t\t\tORDER BY null";
447
+		}
416 448
 	}
417 449
 
418 450
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -434,8 +466,9 @@  discard block
 block discarded – undo
434 466
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
435 467
 
436 468
 		// Initialize $db_cache if not already initialized.
437
-		if (!isset($db_cache))
438
-			$db_cache = array();
469
+		if (!isset($db_cache)) {
470
+					$db_cache = array();
471
+		}
439 472
 
440 473
 		if (!empty($_SESSION['debug_redirect']))
441 474
 		{
@@ -461,17 +494,18 @@  discard block
 block discarded – undo
461 494
 		while (true)
462 495
 		{
463 496
 			$pos = strpos($db_string, '\'', $pos + 1);
464
-			if ($pos === false)
465
-				break;
497
+			if ($pos === false) {
498
+							break;
499
+			}
466 500
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
467 501
 
468 502
 			while (true)
469 503
 			{
470 504
 				$pos1 = strpos($db_string, '\'', $pos + 1);
471 505
 				$pos2 = strpos($db_string, '\\', $pos + 1);
472
-				if ($pos1 === false)
473
-					break;
474
-				elseif ($pos2 === false || $pos2 > $pos1)
506
+				if ($pos1 === false) {
507
+									break;
508
+				} elseif ($pos2 === false || $pos2 > $pos1)
475 509
 				{
476 510
 					$pos = $pos1;
477 511
 					break;
@@ -487,29 +521,35 @@  discard block
 block discarded – undo
487 521
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
488 522
 
489 523
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
490
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
491
-			$fail = true;
524
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
525
+					$fail = true;
526
+		}
492 527
 		// Trying to change passwords, slow us down, or something?
493
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
494
-			$fail = true;
495
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
496
-			$fail = true;
528
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
529
+					$fail = true;
530
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
531
+					$fail = true;
532
+		}
497 533
 
498
-		if (!empty($fail) && function_exists('log_error'))
499
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
534
+		if (!empty($fail) && function_exists('log_error')) {
535
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
536
+		}
500 537
 	}
501 538
 
502
-	if (empty($db_unbuffered))
503
-		$ret = @mysqli_query($connection, $db_string);
504
-	else
505
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
539
+	if (empty($db_unbuffered)) {
540
+			$ret = @mysqli_query($connection, $db_string);
541
+	} else {
542
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
543
+	}
506 544
 
507
-	if ($ret === false && empty($db_values['db_error_skip']))
508
-		$ret = smf_db_error($db_string, $connection);
545
+	if ($ret === false && empty($db_values['db_error_skip'])) {
546
+			$ret = smf_db_error($db_string, $connection);
547
+	}
509 548
 
510 549
 	// Debugging.
511
-	if (isset($db_show_debug) && $db_show_debug === true)
512
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
550
+	if (isset($db_show_debug) && $db_show_debug === true) {
551
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
552
+	}
513 553
 
514 554
 	return $ret;
515 555
 }
@@ -556,12 +596,13 @@  discard block
 block discarded – undo
556 596
 	// Decide which connection to use
557 597
 	$connection = $connection === null ? $db_connection : $connection;
558 598
 
559
-	if ($type == 'begin')
560
-		return @mysqli_query($connection, 'BEGIN');
561
-	elseif ($type == 'rollback')
562
-		return @mysqli_query($connection, 'ROLLBACK');
563
-	elseif ($type == 'commit')
564
-		return @mysqli_query($connection, 'COMMIT');
599
+	if ($type == 'begin') {
600
+			return @mysqli_query($connection, 'BEGIN');
601
+	} elseif ($type == 'rollback') {
602
+			return @mysqli_query($connection, 'ROLLBACK');
603
+	} elseif ($type == 'commit') {
604
+			return @mysqli_query($connection, 'COMMIT');
605
+	}
565 606
 
566 607
 	return false;
567 608
 }
@@ -601,8 +642,9 @@  discard block
 block discarded – undo
601 642
 	//    2013: Lost connection to server during query.
602 643
 
603 644
 	// Log the error.
604
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
605
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
645
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
646
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
647
+	}
606 648
 
607 649
 	// Database error auto fixing ;).
608 650
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -611,8 +653,9 @@  discard block
 block discarded – undo
611 653
 		$old_cache = @$modSettings['cache_enable'];
612 654
 		$modSettings['cache_enable'] = '1';
613 655
 
614
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
615
-			$db_last_error = max(@$db_last_error, $temp);
656
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
657
+					$db_last_error = max(@$db_last_error, $temp);
658
+		}
616 659
 
617 660
 		if (@$db_last_error < time() - 3600 * 24 * 3)
618 661
 		{
@@ -628,8 +671,9 @@  discard block
 block discarded – undo
628 671
 					foreach ($tables as $table)
629 672
 					{
630 673
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
631
-						if (trim($table) != '')
632
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
674
+						if (trim($table) != '') {
675
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
676
+						}
633 677
 					}
634 678
 				}
635 679
 
@@ -638,8 +682,9 @@  discard block
 block discarded – undo
638 682
 			// Table crashed.  Let's try to fix it.
639 683
 			elseif ($query_errno == 1016)
640 684
 			{
641
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
642
-					$fix_tables = array('`' . $match[1] . '`');
685
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
686
+									$fix_tables = array('`' . $match[1] . '`');
687
+				}
643 688
 			}
644 689
 			// Indexes crashed.  Should be easy to fix!
645 690
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -658,13 +703,15 @@  discard block
 block discarded – undo
658 703
 
659 704
 			// Make a note of the REPAIR...
660 705
 			cache_put_data('db_last_error', time(), 600);
661
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
662
-				updateSettingsFile(array('db_last_error' => time()));
706
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
707
+							updateSettingsFile(array('db_last_error' => time()));
708
+			}
663 709
 
664 710
 			// Attempt to find and repair the broken table.
665
-			foreach ($fix_tables as $table)
666
-				$smcFunc['db_query']('', "
711
+			foreach ($fix_tables as $table) {
712
+							$smcFunc['db_query']('', "
667 713
 					REPAIR TABLE $table", false, false);
714
+			}
668 715
 
669 716
 			// And send off an email!
670 717
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -673,11 +720,12 @@  discard block
 block discarded – undo
673 720
 
674 721
 			// Try the query again...?
675 722
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
676
-			if ($ret !== false)
677
-				return $ret;
723
+			if ($ret !== false) {
724
+							return $ret;
725
+			}
726
+		} else {
727
+					$modSettings['cache_enable'] = $old_cache;
678 728
 		}
679
-		else
680
-			$modSettings['cache_enable'] = $old_cache;
681 729
 
682 730
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
683 731
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -687,22 +735,25 @@  discard block
 block discarded – undo
687 735
 				// Are we in SSI mode?  If so try that username and password first
688 736
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
689 737
 				{
690
-					if (empty($db_persist))
691
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
692
-					else
693
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
738
+					if (empty($db_persist)) {
739
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
740
+					} else {
741
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
742
+					}
694 743
 				}
695 744
 				// Fall back to the regular username and password if need be
696 745
 				if (!$db_connection)
697 746
 				{
698
-					if (empty($db_persist))
699
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
700
-					else
701
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
747
+					if (empty($db_persist)) {
748
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
749
+					} else {
750
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
751
+					}
702 752
 				}
703 753
 
704
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
705
-					$db_connection = false;
754
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
755
+									$db_connection = false;
756
+				}
706 757
 			}
707 758
 
708 759
 			if ($db_connection)
@@ -713,24 +764,27 @@  discard block
 block discarded – undo
713 764
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
714 765
 
715 766
 					$new_errno = mysqli_errno($db_connection);
716
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
717
-						break;
767
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
768
+											break;
769
+					}
718 770
 				}
719 771
 
720 772
 				// If it failed again, shucks to be you... we're not trying it over and over.
721
-				if ($ret !== false)
722
-					return $ret;
773
+				if ($ret !== false) {
774
+									return $ret;
775
+				}
723 776
 			}
724 777
 		}
725 778
 		// Are they out of space, perhaps?
726 779
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
727 780
 		{
728
-			if (!isset($txt))
729
-				$query_error .= ' - check database storage space.';
730
-			else
781
+			if (!isset($txt)) {
782
+							$query_error .= ' - check database storage space.';
783
+			} else
731 784
 			{
732
-				if (!isset($txt['mysql_error_space']))
733
-					loadLanguage('Errors');
785
+				if (!isset($txt['mysql_error_space'])) {
786
+									loadLanguage('Errors');
787
+				}
734 788
 
735 789
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
736 790
 			}
@@ -738,15 +792,17 @@  discard block
 block discarded – undo
738 792
 	}
739 793
 
740 794
 	// Nothing's defined yet... just die with it.
741
-	if (empty($context) || empty($txt))
742
-		die($query_error);
795
+	if (empty($context) || empty($txt)) {
796
+			die($query_error);
797
+	}
743 798
 
744 799
 	// Show an error message, if possible.
745 800
 	$context['error_title'] = $txt['database_error'];
746
-	if (allowedTo('admin_forum'))
747
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
748
-	else
749
-		$context['error_message'] = $txt['try_again'];
801
+	if (allowedTo('admin_forum')) {
802
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
803
+	} else {
804
+			$context['error_message'] = $txt['try_again'];
805
+	}
750 806
 
751 807
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
752 808
 	{
@@ -778,8 +834,9 @@  discard block
 block discarded – undo
778 834
 	$return_var = null;
779 835
 
780 836
 	// With nothing to insert, simply return.
781
-	if (empty($data))
782
-		return;
837
+	if (empty($data)) {
838
+			return;
839
+	}
783 840
 
784 841
 	// Replace the prefix holder with the actual prefix.
785 842
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
@@ -789,23 +846,26 @@  discard block
 block discarded – undo
789 846
 	if (!empty($keys) && (count($keys) > 0) && $returnmode > 0)
790 847
 	{
791 848
 		$with_returning = true;
792
-		if ($returnmode == 2)
793
-			$return_var = array();
849
+		if ($returnmode == 2) {
850
+					$return_var = array();
851
+		}
794 852
 	}
795 853
 
796 854
 	// Inserting data as a single row can be done as a single array.
797
-	if (!is_array($data[array_rand($data)]))
798
-		$data = array($data);
855
+	if (!is_array($data[array_rand($data)])) {
856
+			$data = array($data);
857
+	}
799 858
 
800 859
 	// Create the mold for a single row insert.
801 860
 	$insertData = '(';
802 861
 	foreach ($columns as $columnName => $type)
803 862
 	{
804 863
 		// Are we restricting the length?
805
-		if (strpos($type, 'string-') !== false)
806
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
807
-		else
808
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
864
+		if (strpos($type, 'string-') !== false) {
865
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
866
+		} else {
867
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
868
+		}
809 869
 	}
810 870
 	$insertData = substr($insertData, 0, -2) . ')';
811 871
 
@@ -814,8 +874,9 @@  discard block
 block discarded – undo
814 874
 
815 875
 	// Here's where the variables are injected to the query.
816 876
 	$insertRows = array();
817
-	foreach ($data as $dataRow)
818
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
877
+	foreach ($data as $dataRow) {
878
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
879
+	}
819 880
 
820 881
 	// Determine the method of insertion.
821 882
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -834,8 +895,7 @@  discard block
 block discarded – undo
834 895
 			),
835 896
 			$connection
836 897
 		);
837
-	}
838
-	else //special way for ignore method with returning
898
+	} else //special way for ignore method with returning
839 899
 	{
840 900
 		$count = count($insertRows);
841 901
 		$ai = 0;
@@ -855,19 +915,21 @@  discard block
 block discarded – undo
855 915
 			);
856 916
 			$new_id = $smcFunc['db_insert_id']();
857 917
 			
858
-			if ($last_id != $new_id) //the inserted value was new
918
+			if ($last_id != $new_id) {
919
+				//the inserted value was new
859 920
 			{
860 921
 				$ai = $new_id;
861 922
 			}
862
-			else	// the inserted value already exists we need to find the pk
923
+			} else	// the inserted value already exists we need to find the pk
863 924
 			{
864 925
 				$where_string = '';
865 926
 				$count2 = count($indexed_columns);
866 927
 				for ($x = 0; $x < $count2; $x++)
867 928
 				{
868 929
 					$where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x];
869
-					if (($x + 1) < $count2)
870
-						$where_string += ' AND ';
930
+					if (($x + 1) < $count2) {
931
+											$where_string += ' AND ';
932
+					}
871 933
 				}
872 934
 
873 935
 				$request = $smcFunc['db_query']('','
@@ -883,25 +945,27 @@  discard block
 block discarded – undo
883 945
 				}
884 946
 			}
885 947
 			
886
-			if ($returnmode == 1)
887
-				$return_var = $ai;
888
-			else if ($returnmode == 2)
889
-				$return_var[] = $ai;
948
+			if ($returnmode == 1) {
949
+							$return_var = $ai;
950
+			} else if ($returnmode == 2) {
951
+							$return_var[] = $ai;
952
+			}
890 953
 		}
891 954
 	}
892 955
 	
893 956
 
894 957
 	if ($with_returning)
895 958
 	{
896
-		if ($returnmode == 1 && empty($return_var))
897
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
898
-		else if ($returnmode == 2 && empty($return_var))
959
+		if ($returnmode == 1 && empty($return_var)) {
960
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
961
+		} else if ($returnmode == 2 && empty($return_var))
899 962
 		{
900 963
 			$return_var = array();
901 964
 			$count = count($insertRows);
902 965
 			$start = smf_db_insert_id($table, $keys[0]);
903
-			for ($i = 0; $i < $count; $i++ )
904
-				$return_var[] = $start + $i;
966
+			for ($i = 0; $i < $count; $i++ ) {
967
+							$return_var[] = $start + $i;
968
+			}
905 969
 		}
906 970
 		return $return_var;
907 971
 	}
@@ -919,8 +983,9 @@  discard block
 block discarded – undo
919 983
  */
920 984
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
921 985
 {
922
-	if (empty($log_message))
923
-		$log_message = $error_message;
986
+	if (empty($log_message)) {
987
+			$log_message = $error_message;
988
+	}
924 989
 
925 990
 	foreach (debug_backtrace() as $step)
926 991
 	{
@@ -939,12 +1004,14 @@  discard block
 block discarded – undo
939 1004
 	}
940 1005
 
941 1006
 	// A special case - we want the file and line numbers for debugging.
942
-	if ($error_type == 'return')
943
-		return array($file, $line);
1007
+	if ($error_type == 'return') {
1008
+			return array($file, $line);
1009
+	}
944 1010
 
945 1011
 	// Is always a critical error.
946
-	if (function_exists('log_error'))
947
-		log_error($log_message, 'critical', $file, $line);
1012
+	if (function_exists('log_error')) {
1013
+			log_error($log_message, 'critical', $file, $line);
1014
+	}
948 1015
 
949 1016
 	if (function_exists('fatal_error'))
950 1017
 	{
@@ -952,12 +1019,12 @@  discard block
 block discarded – undo
952 1019
 
953 1020
 		// Cannot continue...
954 1021
 		exit;
1022
+	} elseif ($error_type) {
1023
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
1024
+	} else {
1025
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
1026
+	}
955 1027
 	}
956
-	elseif ($error_type)
957
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
958
-	else
959
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
960
-}
961 1028
 
962 1029
 /**
963 1030
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -974,10 +1041,11 @@  discard block
 block discarded – undo
974 1041
 		'\\' => '\\\\',
975 1042
 	);
976 1043
 
977
-	if ($translate_human_wildcards)
978
-		$replacements += array(
1044
+	if ($translate_human_wildcards) {
1045
+			$replacements += array(
979 1046
 			'*' => '%',
980 1047
 		);
1048
+	}
981 1049
 
982 1050
 	return strtr($string, $replacements);
983 1051
 }
@@ -991,8 +1059,9 @@  discard block
 block discarded – undo
991 1059
  */
992 1060
 function smf_is_resource($result)
993 1061
 {
994
-	if ($result instanceof mysqli_result)
995
-		return true;
1062
+	if ($result instanceof mysqli_result) {
1063
+			return true;
1064
+	}
996 1065
 
997 1066
 	return false;
998 1067
 }
@@ -1020,16 +1089,18 @@  discard block
 block discarded – undo
1020 1089
 	global  $db_prefix, $db_connection;
1021 1090
 	static $mysql_error_data_prep;
1022 1091
 
1023
-	if (empty($mysql_error_data_prep))
1024
-			$mysql_error_data_prep = mysqli_prepare($db_connection,
1092
+	if (empty($mysql_error_data_prep)) {
1093
+				$mysql_error_data_prep = mysqli_prepare($db_connection,
1025 1094
 				'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line)
1026 1095
 													VALUES(		?,		?,		unhex(?), ?, 		?,		?,			?,		?,	?)'
1027 1096
 			);
1097
+	}
1028 1098
 
1029
-	if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false)
1030
-		$error_array[2] = bin2hex(inet_pton($error_array[2]));
1031
-	else
1032
-		$error_array[2] = null;
1099
+	if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) {
1100
+			$error_array[2] = bin2hex(inet_pton($error_array[2]));
1101
+	} else {
1102
+			$error_array[2] = null;
1103
+	}
1033 1104
 	mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', 
1034 1105
 		$error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6],
1035 1106
 		$error_array[7], $error_array[8]);
Please login to merge, or discard this patch.
Sources/Admin.php 1 patch
Braces   +75 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
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
  * The main admin handling function.<br>
@@ -444,8 +445,9 @@  discard block
 block discarded – undo
444 445
 		foreach ($admin_includes as $include)
445 446
 		{
446 447
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
447
-			if (file_exists($include))
448
-				require_once($include);
448
+			if (file_exists($include)) {
449
+							require_once($include);
450
+			}
449 451
 		}
450 452
 	}
451 453
 
@@ -457,24 +459,27 @@  discard block
 block discarded – undo
457 459
 	unset($admin_areas);
458 460
 
459 461
 	// Nothing valid?
460
-	if ($admin_include_data == false)
461
-		fatal_lang_error('no_access', false);
462
+	if ($admin_include_data == false) {
463
+			fatal_lang_error('no_access', false);
464
+	}
462 465
 
463 466
 	// Build the link tree.
464 467
 	$context['linktree'][] = array(
465 468
 		'url' => $scripturl . '?action=admin',
466 469
 		'name' => $txt['admin_center'],
467 470
 	);
468
-	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index')
469
-		$context['linktree'][] = array(
471
+	if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
472
+			$context['linktree'][] = array(
470 473
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'],
471 474
 			'name' => $admin_include_data['label'],
472 475
 		);
473
-	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label'])
474
-		$context['linktree'][] = array(
476
+	}
477
+	if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
478
+			$context['linktree'][] = array(
475 479
 			'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'],
476 480
 			'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0],
477 481
 		);
482
+	}
478 483
 
479 484
 	// Make a note of the Unique ID for this menu.
480 485
 	$context['admin_menu_id'] = $context['max_menu_id'];
@@ -484,16 +489,18 @@  discard block
 block discarded – undo
484 489
 	$context['admin_area'] = $admin_include_data['current_area'];
485 490
 
486 491
 	// Now - finally - call the right place!
487
-	if (isset($admin_include_data['file']))
488
-		require_once($sourcedir . '/' . $admin_include_data['file']);
492
+	if (isset($admin_include_data['file'])) {
493
+			require_once($sourcedir . '/' . $admin_include_data['file']);
494
+	}
489 495
 
490 496
 	// Get the right callable.
491 497
 	$call = call_helper($admin_include_data['function'], true);
492 498
 
493 499
 	// Is it valid?
494
-	if (!empty($call))
495
-		call_user_func($call);
496
-}
500
+	if (!empty($call)) {
501
+			call_user_func($call);
502
+	}
503
+	}
497 504
 
498 505
 /**
499 506
  * The main administration section.
@@ -547,13 +554,14 @@  discard block
 block discarded – undo
547 554
 
548 555
 	$context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin';
549 556
 	$context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center'];
550
-	if ($context['admin_area'] != 'credits')
551
-		$context[$context['admin_menu_name']]['tab_data'] = array(
557
+	if ($context['admin_area'] != 'credits') {
558
+			$context[$context['admin_menu_name']]['tab_data'] = array(
552 559
 			'title' => $txt['admin_center'],
553 560
 			'help' => '',
554 561
 			'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong>
555 562
 						' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']),
556 563
 		);
564
+	}
557 565
 
558 566
 	// Lastly, fill in the blanks in the support resources paragraphs.
559 567
 	$txt['support_resources_p1'] = sprintf($txt['support_resources_p1'],
@@ -571,9 +579,10 @@  discard block
 block discarded – undo
571 579
 		'https://www.simplemachines.org/redirect/customize_support'
572 580
 	);
573 581
 
574
-	if ($context['admin_area'] == 'admin')
575
-		loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin');
576
-}
582
+	if ($context['admin_area'] == 'admin') {
583
+			loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin');
584
+	}
585
+	}
577 586
 
578 587
 /**
579 588
  * Get one of the admin information files from Simple Machines.
@@ -584,8 +593,9 @@  discard block
 block discarded – undo
584 593
 
585 594
 	setMemoryLimit('32M');
586 595
 
587
-	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename']))
588
-		fatal_lang_error('no_access', false);
596
+	if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) {
597
+			fatal_lang_error('no_access', false);
598
+	}
589 599
 
590 600
 	// Strip off the forum cache part or we won't find it...
591 601
 	$_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']);
@@ -600,27 +610,30 @@  discard block
 block discarded – undo
600 610
 		)
601 611
 	);
602 612
 
603
-	if ($smcFunc['db_num_rows']($request) == 0)
604
-		fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
613
+	if ($smcFunc['db_num_rows']($request) == 0) {
614
+			fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404);
615
+	}
605 616
 
606 617
 	list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request);
607 618
 	$smcFunc['db_free_result']($request);
608 619
 
609 620
 	// @todo Temp
610 621
 	// Figure out if sesc is still being used.
611
-	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript')
612
-		$file_data = '
622
+	if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') {
623
+			$file_data = '
613 624
 if (!(\'smfForum_sessionvar\' in window))
614 625
 	window.smfForum_sessionvar = \'sesc\';
615 626
 ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'='));
627
+	}
616 628
 
617 629
 	$context['template_layers'] = array();
618 630
 	// Lets make sure we aren't going to output anything nasty.
619 631
 	@ob_end_clean();
620
-	if (!empty($modSettings['enableCompressedOutput']))
621
-		@ob_start('ob_gzhandler');
622
-	else
623
-		@ob_start();
632
+	if (!empty($modSettings['enableCompressedOutput'])) {
633
+			@ob_start('ob_gzhandler');
634
+	} else {
635
+			@ob_start();
636
+	}
624 637
 
625 638
 	// Make sure they know what type of file we are.
626 639
 	header('Content-Type: ' . $filetype);
@@ -660,11 +673,12 @@  discard block
 block discarded – undo
660 673
 		updateAdminPreferences();
661 674
 	}
662 675
 
663
-	if (trim($context['search_term']) == '')
664
-		$context['search_results'] = array();
665
-	else
666
-		call_helper($subActions[$context['search_type']]);
667
-}
676
+	if (trim($context['search_term']) == '') {
677
+			$context['search_results'] = array();
678
+	} else {
679
+			call_helper($subActions[$context['search_type']]);
680
+	}
681
+	}
668 682
 
669 683
 /**
670 684
  * A complicated but relatively quick internal search.
@@ -728,8 +742,9 @@  discard block
 block discarded – undo
728 742
 
729 743
 	loadLanguage(implode('+', $language_files));
730 744
 
731
-	foreach ($include_files as $file)
732
-		require_once($sourcedir . '/' . $file . '.php');
745
+	foreach ($include_files as $file) {
746
+			require_once($sourcedir . '/' . $file . '.php');
747
+	}
733 748
 
734 749
 	/* This is the huge array that defines everything... it's a huge array of items formatted as follows:
735 750
 		0 = Language index (Can be array of indexes) to search through for this setting.
@@ -753,11 +768,12 @@  discard block
 block discarded – undo
753 768
 		foreach ($section['areas'] as $menu_key => $menu_item)
754 769
 		{
755 770
 			$search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key);
756
-			if (!empty($menu_item['subsections']))
757
-				foreach ($menu_item['subsections'] as $key => $sublabel)
771
+			if (!empty($menu_item['subsections'])) {
772
+							foreach ($menu_item['subsections'] as $key => $sublabel)
758 773
 				{
759 774
 					if (isset($sublabel['label']))
760 775
 						$search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key);
776
+			}
761 777
 				}
762 778
 		}
763 779
 	}
@@ -767,9 +783,10 @@  discard block
 block discarded – undo
767 783
 		// Get a list of their variables.
768 784
 		$config_vars = $setting_area[0](true);
769 785
 
770
-		foreach ($config_vars as $var)
771
-			if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
786
+		foreach ($config_vars as $var) {
787
+					if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc')))
772 788
 				$search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : '');
789
+		}
773 790
 	}
774 791
 
775 792
 	$context['page_title'] = $txt['admin_search_results'];
@@ -782,8 +799,9 @@  discard block
 block discarded – undo
782 799
 		foreach ($data as $item)
783 800
 		{
784 801
 			$found = false;
785
-			if (!is_array($item[0]))
786
-				$item[0] = array($item[0]);
802
+			if (!is_array($item[0])) {
803
+							$item[0] = array($item[0]);
804
+			}
787 805
 			foreach ($item[0] as $term)
788 806
 			{
789 807
 				if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false))
@@ -841,8 +859,9 @@  discard block
 block discarded – undo
841 859
 	$postVars = explode(' ', $context['search_term']);
842 860
 
843 861
 	// Encode the search data.
844
-	foreach ($postVars as $k => $v)
845
-		$postVars[$k] = urlencode($v);
862
+	foreach ($postVars as $k => $v) {
863
+			$postVars[$k] = urlencode($v);
864
+	}
846 865
 
847 866
 	// This is what we will send.
848 867
 	$postVars = implode('+', $postVars);
@@ -854,8 +873,9 @@  discard block
 block discarded – undo
854 873
 	$search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars);
855 874
 
856 875
 	// If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded?
857
-	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true)
858
-		fatal_lang_error('cannot_connect_doc_site');
876
+	if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) {
877
+			fatal_lang_error('cannot_connect_doc_site');
878
+	}
859 879
 
860 880
 	$search_results = $matches[1];
861 881
 
@@ -867,8 +887,9 @@  discard block
 block discarded – undo
867 887
 	$results = new xmlArray($search_results, false);
868 888
 
869 889
 	// Move through the api layer.
870
-	if (!$results->exists('api'))
871
-		fatal_lang_error('cannot_connect_doc_site');
890
+	if (!$results->exists('api')) {
891
+			fatal_lang_error('cannot_connect_doc_site');
892
+	}
872 893
 
873 894
 	// Are there actually some results?
874 895
 	if ($results->exists('api/query/search/p'))
@@ -904,8 +925,9 @@  discard block
 block discarded – undo
904 925
 	);
905 926
 
906 927
 	// If it's not got a sa set it must have come here for first time, pretend error log should be reversed.
907
-	if (!isset($_REQUEST['sa']))
908
-		$_REQUEST['desc'] = true;
928
+	if (!isset($_REQUEST['sa'])) {
929
+			$_REQUEST['desc'] = true;
930
+	}
909 931
 
910 932
 	// Setup some tab stuff.
911 933
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -955,9 +977,10 @@  discard block
 block discarded – undo
955 977
 	unset($_SESSION['admin_time']);
956 978
 
957 979
 	// Clean any admin tokens as well.
958
-	foreach ($_SESSION['token'] as $key => $token)
959
-		if (strpos($key, '-admin') !== false)
980
+	foreach ($_SESSION['token'] as $key => $token) {
981
+			if (strpos($key, '-admin') !== false)
960 982
 			unset($_SESSION['token'][$key]);
983
+	}
961 984
 
962 985
 	redirectexit();
963 986
 }
Please login to merge, or discard this patch.