Completed
Push — release-2.1 ( e55abf...f15ab1 )
by
unknown
08:31
created
other/Settings.php 1 patch
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -185,17 +185,21 @@  discard block
 block discarded – undo
185 185
 $tasksdir = $sourcedir . '/tasks';
186 186
 
187 187
 # Make sure the paths are correct... at least try to fix them.
188
-if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
188
+if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) {
189 189
 	$boarddir = dirname(__FILE__);
190
-if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources'))
190
+}
191
+if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) {
191 192
 	$sourcedir = $boarddir . '/Sources';
192
-if (!file_exists($cachedir) && file_exists($boarddir . '/cache'))
193
+}
194
+if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) {
193 195
 	$cachedir = $boarddir . '/cache';
196
+}
194 197
 
195 198
 ########## Error-Catching ##########
196 199
 # Note: You shouldn't touch these settings.
197
-if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php'))
200
+if (file_exists((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php')) {
198 201
 	include((isset($cachedir) ? $cachedir : dirname(__FILE__)) . '/db_last_error.php');
202
+}
199 203
 
200 204
 if (!isset($db_last_error))
201 205
 {
@@ -207,10 +211,11 @@  discard block
 block discarded – undo
207 211
 if (file_exists(dirname(__FILE__) . '/install.php'))
208 212
 {
209 213
 	$secure = false;
210
-	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
211
-		$secure = true;
212
-	elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
213
-		$secure = true;
214
+	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
215
+			$secure = true;
216
+	} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
217
+			$secure = true;
218
+	}
214 219
 
215 220
 	header('location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit;
216 221
 }
Please login to merge, or discard this patch.
Sources/Subs-Post.php 1 patch
Braces   +532 added lines, -397 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Takes a message and parses it, returning nothing.
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $user_info, $modSettings, $context, $sourcedir;
32 33
 
33 34
 	// This line makes all languages *theoretically* work even with the wrong charset ;).
34
-	if (empty($context['utf8']))
35
-		$message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
35
+	if (empty($context['utf8'])) {
36
+			$message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
37
+	}
36 38
 
37 39
 	// Clean up after nobbc ;).
38 40
 	$message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a)
@@ -47,17 +49,19 @@  discard block
 block discarded – undo
47 49
 	$message = preg_replace('~\.{100,}~', '...', $message);
48 50
 
49 51
 	// Trim off trailing quotes - these often happen by accident.
50
-	while (substr($message, -7) == '[quote]')
51
-		$message = substr($message, 0, -7);
52
-	while (substr($message, 0, 8) == '[/quote]')
53
-		$message = substr($message, 8);
52
+	while (substr($message, -7) == '[quote]') {
53
+			$message = substr($message, 0, -7);
54
+	}
55
+	while (substr($message, 0, 8) == '[/quote]') {
56
+			$message = substr($message, 8);
57
+	}
54 58
 
55 59
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
56 60
 	$in_tag = false;
57 61
 	$had_tag = false;
58 62
 	$codeopen = 0;
59
-	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches))
60
-		foreach ($matches[0] as $index => $dummy)
63
+	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) {
64
+			foreach ($matches[0] as $index => $dummy)
61 65
 		{
62 66
 			// Closing?
63 67
 			if (!empty($matches[2][$index]))
@@ -65,6 +69,7 @@  discard block
 block discarded – undo
65 69
 				// If it's closing and we're not in a tag we need to open it...
66 70
 				if (!$in_tag)
67 71
 					$codeopen = true;
72
+	}
68 73
 				// Either way we ain't in one any more.
69 74
 				$in_tag = false;
70 75
 			}
@@ -73,17 +78,20 @@  discard block
 block discarded – undo
73 78
 			{
74 79
 				$had_tag = true;
75 80
 				// If we're in a tag don't do nought!
76
-				if (!$in_tag)
77
-					$in_tag = true;
81
+				if (!$in_tag) {
82
+									$in_tag = true;
83
+				}
78 84
 			}
79 85
 		}
80 86
 
81 87
 	// If we have an open tag, close it.
82
-	if ($in_tag)
83
-		$message .= '[/code]';
88
+	if ($in_tag) {
89
+			$message .= '[/code]';
90
+	}
84 91
 	// Open any ones that need to be open, only if we've never had a tag.
85
-	if ($codeopen && !$had_tag)
86
-		$message = '[code]' . $message;
92
+	if ($codeopen && !$had_tag) {
93
+			$message = '[code]' . $message;
94
+	}
87 95
 
88 96
 	// Now that we've fixed all the code tags, let's fix the img and url tags...
89 97
 	$parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -109,23 +117,26 @@  discard block
 block discarded – undo
109 117
 	fixTags($message);
110 118
 
111 119
 	// Replace /me.+?\n with [me=name]dsf[/me]\n.
112
-	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
113
-		$message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message);
114
-	else
115
-		$message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
120
+	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) {
121
+			$message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message);
122
+	} else {
123
+			$message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
124
+	}
116 125
 
117 126
 	if (!$previewing && strpos($message, '[html]') !== false)
118 127
 	{
119
-		if (allowedTo('admin_forum'))
120
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
128
+		if (allowedTo('admin_forum')) {
129
+					$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
121 130
 				return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => '
', '  ' => '  ', '[' => '[', ']' => ']')) . '[/html]';
131
+		}
122 132
 			}, $message);
123 133
 
124 134
 		// We should edit them out, or else if an admin edits the message they will get shown...
125 135
 		else
126 136
 		{
127
-			while (strpos($message, '[html]') !== false)
128
-				$message = preg_replace('~\[[/]?html\]~i', '', $message);
137
+			while (strpos($message, '[html]') !== false) {
138
+							$message = preg_replace('~\[[/]?html\]~i', '', $message);
139
+			}
129 140
 		}
130 141
 	}
131 142
 
@@ -147,10 +158,12 @@  discard block
 block discarded – undo
147 158
 
148 159
 	$list_open = substr_count($message, '[list]') + substr_count($message, '[list ');
149 160
 	$list_close = substr_count($message, '[/list]');
150
-	if ($list_close - $list_open > 0)
151
-		$message = str_repeat('[list]', $list_close - $list_open) . $message;
152
-	if ($list_open - $list_close > 0)
153
-		$message = $message . str_repeat('[/list]', $list_open - $list_close);
161
+	if ($list_close - $list_open > 0) {
162
+			$message = str_repeat('[list]', $list_close - $list_open) . $message;
163
+	}
164
+	if ($list_open - $list_close > 0) {
165
+			$message = $message . str_repeat('[/list]', $list_open - $list_close);
166
+	}
154 167
 
155 168
 	$mistake_fixes = array(
156 169
 		// Find [table]s not followed by [tr].
@@ -199,8 +212,9 @@  discard block
 block discarded – undo
199 212
 	);
200 213
 
201 214
 	// Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.)
202
-	for ($j = 0; $j < 3; $j++)
203
-		$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
215
+	for ($j = 0; $j < 3; $j++) {
216
+			$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
217
+	}
204 218
 
205 219
 	// Remove empty bbc from the sections outside the code tags
206 220
 	$allowedEmpty = array(
@@ -211,24 +225,28 @@  discard block
 block discarded – undo
211 225
 	require_once($sourcedir . '/Subs.php');
212 226
 
213 227
 	$alltags = array();
214
-	foreach (($codes = parse_bbc(false)) as $code)
215
-		if (!in_array($code['tag'], $allowedEmpty))
228
+	foreach (($codes = parse_bbc(false)) as $code) {
229
+			if (!in_array($code['tag'], $allowedEmpty))
216 230
 			$alltags[] = $code['tag'];
231
+	}
217 232
 
218 233
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
219 234
 
220
-	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message))
221
-		$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
235
+	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) {
236
+			$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
237
+	}
222 238
 
223 239
 	// Restore code blocks
224
-	if (!empty($code_tags))
225
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
240
+	if (!empty($code_tags)) {
241
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
242
+	}
226 243
 
227 244
 	// Restore white space entities
228
-	if (!$previewing)
229
-		$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
230
-	else
231
-		$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
245
+	if (!$previewing) {
246
+			$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
247
+	} else {
248
+			$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
249
+	}
232 250
 
233 251
 	// Now let's quickly clean up things that will slow our parser (which are common in posted code.)
234 252
 	$message = strtr($message, array('[]' => '&#91;]', '[&#039;' => '&#91;&#039;'));
@@ -271,8 +289,9 @@  discard block
 block discarded – undo
271 289
 		return "[time]" . timeformat("$m[1]", false) . "[/time]";
272 290
 	}, $message);
273 291
 
274
-	if (!empty($code_tags))
275
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
292
+	if (!empty($code_tags)) {
293
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
294
+	}
276 295
 
277 296
 	// Change breaks back to \n's and &nsbp; back to spaces.
278 297
 	return preg_replace('~<br( /)?' . '>~', "\n", str_replace('&nbsp;', ' ', $message));
@@ -353,8 +372,9 @@  discard block
 block discarded – undo
353 372
 	);
354 373
 
355 374
 	// Fix each type of tag.
356
-	foreach ($fixArray as $param)
357
-		fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
375
+	foreach ($fixArray as $param) {
376
+			fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
377
+	}
358 378
 
359 379
 	// Now fix possible security problems with images loading links automatically...
360 380
 	$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m)
@@ -390,16 +410,19 @@  discard block
 block discarded – undo
390 410
 					$desired_height = $height;
391 411
 				}
392 412
 				// Scale it to the width...
393
-				elseif (empty($desired_width) && !empty($height))
394
-					$desired_width = (int) (($desired_height * $width) / $height);
413
+				elseif (empty($desired_width) && !empty($height)) {
414
+									$desired_width = (int) (($desired_height * $width) / $height);
415
+				}
395 416
 				// Scale if to the height.
396
-				elseif (!empty($width))
397
-					$desired_height = (int) (($desired_width * $height) / $width);
417
+				elseif (!empty($width)) {
418
+									$desired_height = (int) (($desired_width * $height) / $width);
419
+				}
398 420
 			}
399 421
 
400 422
 			// If the width and height are fine, just continue along...
401
-			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height'])
402
-				continue;
423
+			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) {
424
+							continue;
425
+			}
403 426
 
404 427
 			// Too bad, it's too wide.  Make it as wide as the maximum.
405 428
 			if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width']))
@@ -419,8 +442,9 @@  discard block
 block discarded – undo
419 442
 		}
420 443
 
421 444
 		// If any img tags were actually changed...
422
-		if (!empty($replaces))
423
-			$message = strtr($message, $replaces);
445
+		if (!empty($replaces)) {
446
+					$message = strtr($message, $replaces);
447
+		}
424 448
 	}
425 449
 }
426 450
 
@@ -439,10 +463,11 @@  discard block
 block discarded – undo
439 463
 {
440 464
 	global $boardurl, $scripturl;
441 465
 
442
-	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0)
443
-		$domain_url = $match[1];
444
-	else
445
-		$domain_url = $boardurl . '/';
466
+	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) {
467
+			$domain_url = $match[1];
468
+	} else {
469
+			$domain_url = $boardurl . '/';
470
+	}
446 471
 
447 472
 	$replaces = array();
448 473
 
@@ -450,11 +475,11 @@  discard block
 block discarded – undo
450 475
 	{
451 476
 		$quoted = preg_match('~\[(' . $myTag . ')=&quot;~', $message);
452 477
 		preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '&quot;(.*?)&quot;' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
478
+	} elseif ($hasEqualSign) {
479
+			preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
480
+	} else {
481
+			preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
453 482
 	}
454
-	elseif ($hasEqualSign)
455
-		preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
456
-	else
457
-		preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
458 483
 
459 484
 	foreach ($matches[0] as $k => $dummy)
460 485
 	{
@@ -467,49 +492,53 @@  discard block
 block discarded – undo
467 492
 		foreach ($protocols as $protocol)
468 493
 		{
469 494
 			$found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0;
470
-			if ($found)
471
-				break;
495
+			if ($found) {
496
+							break;
497
+			}
472 498
 		}
473 499
 
474 500
 		if (!$found && $protocols[0] == 'http')
475 501
 		{
476
-			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//')
477
-				$replace = $domain_url . $replace;
478
-			elseif (substr($replace, 0, 1) == '?')
479
-				$replace = $scripturl . $replace;
480
-			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
502
+			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') {
503
+							$replace = $domain_url . $replace;
504
+			} elseif (substr($replace, 0, 1) == '?') {
505
+							$replace = $scripturl . $replace;
506
+			} elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
481 507
 			{
482 508
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
483 509
 				$this_tag = 'iurl';
484 510
 				$this_close = 'iurl';
511
+			} elseif (substr($replace, 0, 2) != '//') {
512
+							$replace = $protocols[0] . '://' . $replace;
485 513
 			}
486
-			elseif (substr($replace, 0, 2) != '//')
487
-				$replace = $protocols[0] . '://' . $replace;
488
-		}
489
-		elseif (!$found && $protocols[0] == 'ftp')
490
-			$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
491
-		elseif (!$found)
492
-			$replace = $protocols[0] . '://' . $replace;
493
-
494
-		if ($hasEqualSign && $embeddedUrl)
495
-			$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
496
-		elseif ($hasEqualSign)
497
-			$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
498
-		elseif ($embeddedUrl)
499
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
500
-		else
501
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
514
+		} elseif (!$found && $protocols[0] == 'ftp') {
515
+					$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
516
+		} elseif (!$found) {
517
+					$replace = $protocols[0] . '://' . $replace;
518
+		}
519
+
520
+		if ($hasEqualSign && $embeddedUrl) {
521
+					$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
522
+		} elseif ($hasEqualSign) {
523
+					$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
524
+		} elseif ($embeddedUrl) {
525
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
526
+		} else {
527
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
528
+		}
502 529
 	}
503 530
 
504 531
 	foreach ($replaces as $k => $v)
505 532
 	{
506
-		if ($k == $v)
507
-			unset($replaces[$k]);
533
+		if ($k == $v) {
534
+					unset($replaces[$k]);
535
+		}
508 536
 	}
509 537
 
510
-	if (!empty($replaces))
511
-		$message = strtr($message, $replaces);
512
-}
538
+	if (!empty($replaces)) {
539
+			$message = strtr($message, $replaces);
540
+	}
541
+	}
513 542
 
514 543
 /**
515 544
  * This function sends an email to the specified recipient(s).
@@ -553,8 +582,9 @@  discard block
 block discarded – undo
553 582
 	}
554 583
 
555 584
 	// Nothing left? Nothing else to do
556
-	if (empty($to_array))
557
-		return true;
585
+	if (empty($to_array)) {
586
+			return true;
587
+	}
558 588
 
559 589
 	// Once upon a time, Hotmail could not interpret non-ASCII mails.
560 590
 	// In honour of those days, it's still called the 'hotmail fix'.
@@ -571,15 +601,17 @@  discard block
 block discarded – undo
571 601
 		}
572 602
 
573 603
 		// Call this function recursively for the hotmail addresses.
574
-		if (!empty($hotmail_to))
575
-			$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
604
+		if (!empty($hotmail_to)) {
605
+					$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
606
+		}
576 607
 
577 608
 		// The remaining addresses no longer need the fix.
578 609
 		$hotmail_fix = false;
579 610
 
580 611
 		// No other addresses left? Return instantly.
581
-		if (empty($to_array))
582
-			return $mail_result;
612
+		if (empty($to_array)) {
613
+					return $mail_result;
614
+		}
583 615
 	}
584 616
 
585 617
 	// Get rid of entities.
@@ -604,13 +636,15 @@  discard block
 block discarded – undo
604 636
 	$headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
605 637
 	$headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
606 638
 
607
-	if ($message_id !== null && empty($modSettings['mail_no_message_id']))
608
-		$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
639
+	if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
640
+			$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
641
+	}
609 642
 	$headers .= 'X-Mailer: SMF' . $line_break;
610 643
 
611 644
 	// Pass this to the integration before we start modifying the output -- it'll make it easier later.
612
-	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true))
613
-		return false;
645
+	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) {
646
+			return false;
647
+	}
614 648
 
615 649
 	// Save the original message...
616 650
 	$orig_message = $message;
@@ -659,17 +693,19 @@  discard block
 block discarded – undo
659 693
 	}
660 694
 
661 695
 	// Are we using the mail queue, if so this is where we butt in...
662
-	if ($priority != 0)
663
-		return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
696
+	if ($priority != 0) {
697
+			return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
698
+	}
664 699
 
665 700
 	// If it's a priority mail, send it now - note though that this should NOT be used for sending many at once.
666 701
 	elseif (!empty($modSettings['mail_limit']))
667 702
 	{
668 703
 		list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
669
-		if (empty($mails_this_minute) || time() > $last_mail_time + 60)
670
-			$new_queue_stat = time() . '|' . 1;
671
-		else
672
-			$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
704
+		if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
705
+					$new_queue_stat = time() . '|' . 1;
706
+		} else {
707
+					$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
708
+		}
673 709
 
674 710
 		updateSettings(array('mail_recent' => $new_queue_stat));
675 711
 	}
@@ -703,8 +739,7 @@  discard block
 block discarded – undo
703 739
 					log_error(sprintf($txt['mail_send_unable'], $to));
704 740
 					$mail_result = false;
705 741
 				}
706
-			}
707
-			catch(ErrorException $e)
742
+			} catch(ErrorException $e)
708 743
 			{
709 744
 				log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine());
710 745
 				log_error(sprintf($txt['mail_send_unable'], $to));
@@ -714,12 +749,13 @@  discard block
 block discarded – undo
714 749
 
715 750
 			// Wait, wait, I'm still sending here!
716 751
 			@set_time_limit(300);
717
-			if (function_exists('apache_reset_timeout'))
718
-				@apache_reset_timeout();
752
+			if (function_exists('apache_reset_timeout')) {
753
+							@apache_reset_timeout();
754
+			}
719 755
 		}
756
+	} else {
757
+			$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
720 758
 	}
721
-	else
722
-		$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
723 759
 
724 760
 	// Everything go smoothly?
725 761
 	return $mail_result;
@@ -745,8 +781,9 @@  discard block
 block discarded – undo
745 781
 	static $cur_insert = array();
746 782
 	static $cur_insert_len = 0;
747 783
 
748
-	if ($cur_insert_len == 0)
749
-		$cur_insert = array();
784
+	if ($cur_insert_len == 0) {
785
+			$cur_insert = array();
786
+	}
750 787
 
751 788
 	// If we're flushing, make the final inserts - also if we're near the MySQL length limit!
752 789
 	if (($flush || $cur_insert_len > 800000) && !empty($cur_insert))
@@ -821,8 +858,9 @@  discard block
 block discarded – undo
821 858
 	}
822 859
 
823 860
 	// If they are using SSI there is a good chance obExit will never be called.  So lets be nice and flush it for them.
824
-	if (SMF === 'SSI' || SMF === 'BACKGROUND')
825
-		return AddMailQueue(true);
861
+	if (SMF === 'SSI' || SMF === 'BACKGROUND') {
862
+			return AddMailQueue(true);
863
+	}
826 864
 
827 865
 	return true;
828 866
 }
@@ -853,23 +891,26 @@  discard block
 block discarded – undo
853 891
 		'sent' => array()
854 892
 	);
855 893
 
856
-	if ($from === null)
857
-		$from = array(
894
+	if ($from === null) {
895
+			$from = array(
858 896
 			'id' => $user_info['id'],
859 897
 			'name' => $user_info['name'],
860 898
 			'username' => $user_info['username']
861 899
 		);
900
+	}
862 901
 
863 902
 	// This is the one that will go in their inbox.
864 903
 	$htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
865 904
 	preparsecode($htmlmessage);
866 905
 	$htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
867
-	if ($smcFunc['strlen']($htmlsubject) > 100)
868
-		$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
906
+	if ($smcFunc['strlen']($htmlsubject) > 100) {
907
+			$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
908
+	}
869 909
 
870 910
 	// Make sure is an array
871
-	if (!is_array($recipients))
872
-		$recipients = array($recipients);
911
+	if (!is_array($recipients)) {
912
+			$recipients = array($recipients);
913
+	}
873 914
 
874 915
 	// Integrated PMs
875 916
 	call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
@@ -897,21 +938,23 @@  discard block
 block discarded – undo
897 938
 				'usernames' => array_keys($usernames),
898 939
 			)
899 940
 		);
900
-		while ($row = $smcFunc['db_fetch_assoc']($request))
901
-			if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
941
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
942
+					if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
902 943
 				$usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member'];
944
+		}
903 945
 		$smcFunc['db_free_result']($request);
904 946
 
905 947
 		// Replace the usernames with IDs. Drop usernames that couldn't be found.
906
-		foreach ($recipients as $rec_type => $rec)
907
-			foreach ($rec as $id => $member)
948
+		foreach ($recipients as $rec_type => $rec) {
949
+					foreach ($rec as $id => $member)
908 950
 			{
909 951
 				if (is_numeric($recipients[$rec_type][$id]))
910 952
 					continue;
953
+		}
911 954
 
912
-				if (!empty($usernames[$member]))
913
-					$recipients[$rec_type][$id] = $usernames[$member];
914
-				else
955
+				if (!empty($usernames[$member])) {
956
+									$recipients[$rec_type][$id] = $usernames[$member];
957
+				} else
915 958
 				{
916 959
 					$log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
917 960
 					unset($recipients[$rec_type][$id]);
@@ -949,8 +992,9 @@  discard block
 block discarded – undo
949 992
 		$delete = false;
950 993
 		foreach ($criteria as $criterium)
951 994
 		{
952
-			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false))
953
-				$delete = true;
995
+			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) {
996
+							$delete = true;
997
+			}
954 998
 			// If we're adding and one criteria don't match then we stop!
955 999
 			elseif (!$row['is_or'])
956 1000
 			{
@@ -958,8 +1002,9 @@  discard block
 block discarded – undo
958 1002
 				break;
959 1003
 			}
960 1004
 		}
961
-		if ($delete)
962
-			$deletes[$row['id_member']] = 1;
1005
+		if ($delete) {
1006
+					$deletes[$row['id_member']] = 1;
1007
+		}
963 1008
 	}
964 1009
 	$smcFunc['db_free_result']($request);
965 1010
 
@@ -974,8 +1019,9 @@  discard block
 block discarded – undo
974 1019
 			array(
975 1020
 			)
976 1021
 		);
977
-		while ($row = $smcFunc['db_fetch_assoc']($request))
978
-			$message_limit_cache[$row['id_group']] = $row['max_messages'];
1022
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1023
+					$message_limit_cache[$row['id_group']] = $row['max_messages'];
1024
+		}
979 1025
 		$smcFunc['db_free_result']($request);
980 1026
 	}
981 1027
 
@@ -983,8 +1029,9 @@  discard block
 block discarded – undo
983 1029
 	require_once($sourcedir . '/Subs-Members.php');
984 1030
 	$pmReadGroups = groupsAllowedTo('pm_read');
985 1031
 
986
-	if (empty($modSettings['permission_enable_deny']))
987
-		$pmReadGroups['denied'] = array();
1032
+	if (empty($modSettings['permission_enable_deny'])) {
1033
+			$pmReadGroups['denied'] = array();
1034
+	}
988 1035
 
989 1036
 	// Load their alert preferences
990 1037
 	require_once($sourcedir . '/Subs-Notify.php');
@@ -1016,8 +1063,9 @@  discard block
 block discarded – undo
1016 1063
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1017 1064
 	{
1018 1065
 		// Don't do anything for members to be deleted!
1019
-		if (isset($deletes[$row['id_member']]))
1020
-			continue;
1066
+		if (isset($deletes[$row['id_member']])) {
1067
+					continue;
1068
+		}
1021 1069
 
1022 1070
 		// Load the preferences for this member (if any)
1023 1071
 		$prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array();
@@ -1038,8 +1086,9 @@  discard block
 block discarded – undo
1038 1086
 		{
1039 1087
 			foreach ($groups as $id)
1040 1088
 			{
1041
-				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id])
1042
-					$message_limit = $message_limit_cache[$id];
1089
+				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) {
1090
+									$message_limit = $message_limit_cache[$id];
1091
+				}
1043 1092
 			}
1044 1093
 
1045 1094
 			if ($message_limit > 0 && $message_limit <= $row['instant_messages'])
@@ -1087,8 +1136,9 @@  discard block
 block discarded – undo
1087 1136
 	$smcFunc['db_free_result']($request);
1088 1137
 
1089 1138
 	// Only 'send' the message if there are any recipients left.
1090
-	if (empty($all_to))
1091
-		return $log;
1139
+	if (empty($all_to)) {
1140
+			return $log;
1141
+	}
1092 1142
 
1093 1143
 	// Insert the message itself and then grab the last insert id.
1094 1144
 	$id_pm = $smcFunc['db_insert']('',
@@ -1109,8 +1159,8 @@  discard block
 block discarded – undo
1109 1159
 	if (!empty($id_pm))
1110 1160
 	{
1111 1161
 		// If this is new we need to set it part of it's own conversation.
1112
-		if (empty($pm_head))
1113
-			$smcFunc['db_query']('', '
1162
+		if (empty($pm_head)) {
1163
+					$smcFunc['db_query']('', '
1114 1164
 				UPDATE {db_prefix}personal_messages
1115 1165
 				SET id_pm_head = {int:id_pm_head}
1116 1166
 				WHERE id_pm = {int:id_pm_head}',
@@ -1118,6 +1168,7 @@  discard block
 block discarded – undo
1118 1168
 					'id_pm_head' => $id_pm,
1119 1169
 				)
1120 1170
 			);
1171
+		}
1121 1172
 
1122 1173
 		// Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
1123 1174
 		$smcFunc['db_query']('', '
@@ -1133,8 +1184,9 @@  discard block
 block discarded – undo
1133 1184
 		foreach ($all_to as $to)
1134 1185
 		{
1135 1186
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
1136
-			if (!in_array($to, $recipients['bcc']))
1137
-				$to_list[] = $to;
1187
+			if (!in_array($to, $recipients['bcc'])) {
1188
+							$to_list[] = $to;
1189
+			}
1138 1190
 		}
1139 1191
 
1140 1192
 		$smcFunc['db_insert']('insert',
@@ -1152,9 +1204,9 @@  discard block
 block discarded – undo
1152 1204
 	{
1153 1205
 		censorText($message);
1154 1206
 		$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
1207
+	} else {
1208
+			$message = '';
1155 1209
 	}
1156
-	else
1157
-		$message = '';
1158 1210
 
1159 1211
 	$to_names = array();
1160 1212
 	if (count($to_list) > 1)
@@ -1167,8 +1219,9 @@  discard block
 block discarded – undo
1167 1219
 				'to_members' => $to_list,
1168 1220
 			)
1169 1221
 		);
1170
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1171
-			$to_names[] = un_htmlspecialchars($row['real_name']);
1222
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1223
+					$to_names[] = un_htmlspecialchars($row['real_name']);
1224
+		}
1172 1225
 		$smcFunc['db_free_result']($request);
1173 1226
 	}
1174 1227
 	$replacements = array(
@@ -1196,11 +1249,13 @@  discard block
 block discarded – undo
1196 1249
 	loadLanguage('index+PersonalMessage');
1197 1250
 
1198 1251
 	// Add one to their unread and read message counts.
1199
-	foreach ($all_to as $k => $id)
1200
-		if (isset($deletes[$id]))
1252
+	foreach ($all_to as $k => $id) {
1253
+			if (isset($deletes[$id]))
1201 1254
 			unset($all_to[$k]);
1202
-	if (!empty($all_to))
1203
-		updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1255
+	}
1256
+	if (!empty($all_to)) {
1257
+			updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1258
+	}
1204 1259
 
1205 1260
 	return $log;
1206 1261
 }
@@ -1230,15 +1285,17 @@  discard block
 block discarded – undo
1230 1285
 		// Let's, for now, assume there are only &#021;'ish characters.
1231 1286
 		$simple = true;
1232 1287
 
1233
-		foreach ($matches[1] as $entity)
1234
-			if ($entity > 128)
1288
+		foreach ($matches[1] as $entity) {
1289
+					if ($entity > 128)
1235 1290
 				$simple = false;
1291
+		}
1236 1292
 		unset($matches);
1237 1293
 
1238
-		if ($simple)
1239
-			$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1294
+		if ($simple) {
1295
+					$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1240 1296
 			{
1241 1297
 				return chr("$m[1]");
1298
+		}
1242 1299
 			}, $string);
1243 1300
 		else
1244 1301
 		{
@@ -1246,8 +1303,9 @@  discard block
 block discarded – undo
1246 1303
 			if (!$context['utf8'] && function_exists('iconv'))
1247 1304
 			{
1248 1305
 				$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1249
-				if ($newstring)
1250
-					$string = $newstring;
1306
+				if ($newstring) {
1307
+									$string = $newstring;
1308
+				}
1251 1309
 			}
1252 1310
 
1253 1311
 			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
@@ -1263,23 +1321,25 @@  discard block
 block discarded – undo
1263 1321
 		if (!$context['utf8'] && function_exists('iconv'))
1264 1322
 		{
1265 1323
 			$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1266
-			if ($newstring)
1267
-				$string = $newstring;
1324
+			if ($newstring) {
1325
+							$string = $newstring;
1326
+			}
1268 1327
 		}
1269 1328
 
1270 1329
 		$entityConvert = function($m)
1271 1330
 		{
1272 1331
 			$c = $m[1];
1273
-			if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
1274
-				return $c;
1275
-			elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
1276
-				return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1277
-			elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
1278
-				return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1279
-			elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
1280
-				return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1281
-			else
1282
-				return "";
1332
+			if (strlen($c) === 1 && ord($c[0]) <= 0x7F) {
1333
+							return $c;
1334
+			} elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) {
1335
+							return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1336
+			} elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) {
1337
+							return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1338
+			} elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) {
1339
+							return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1340
+			} else {
1341
+							return "";
1342
+			}
1283 1343
 		};
1284 1344
 
1285 1345
 		// Convert all 'special' characters to HTML entities.
@@ -1293,19 +1353,20 @@  discard block
 block discarded – undo
1293 1353
 		$string = base64_encode($string);
1294 1354
 
1295 1355
 		// Show the characterset and the transfer-encoding for header strings.
1296
-		if ($with_charset)
1297
-			$string = '=?' . $charset . '?B?' . $string . '?=';
1356
+		if ($with_charset) {
1357
+					$string = '=?' . $charset . '?B?' . $string . '?=';
1358
+		}
1298 1359
 
1299 1360
 		// Break it up in lines (mail body).
1300
-		else
1301
-			$string = chunk_split($string, 76, $line_break);
1361
+		else {
1362
+					$string = chunk_split($string, 76, $line_break);
1363
+		}
1302 1364
 
1303 1365
 		return array($charset, $string, 'base64');
1366
+	} else {
1367
+			return array($charset, $string, '7bit');
1368
+	}
1304 1369
 	}
1305
-
1306
-	else
1307
-		return array($charset, $string, '7bit');
1308
-}
1309 1370
 
1310 1371
 /**
1311 1372
  * Sends mail, like mail() but over SMTP.
@@ -1329,8 +1390,9 @@  discard block
 block discarded – undo
1329 1390
 	if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
1330 1391
 	{
1331 1392
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
1332
-		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
1333
-			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1393
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
1394
+					$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1395
+		}
1334 1396
 
1335 1397
 		if ($socket)
1336 1398
 		{
@@ -1351,8 +1413,9 @@  discard block
 block discarded – undo
1351 1413
 		// Maybe we can still save this?  The port might be wrong.
1352 1414
 		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
1353 1415
 		{
1354
-			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
1355
-				log_error($txt['smtp_port_ssl']);
1416
+			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
1417
+							log_error($txt['smtp_port_ssl']);
1418
+			}
1356 1419
 		}
1357 1420
 
1358 1421
 		// Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
@@ -1364,20 +1427,23 @@  discard block
 block discarded – undo
1364 1427
 	}
1365 1428
 
1366 1429
 	// Wait for a response of 220, without "-" continuer.
1367
-	if (!server_parse(null, $socket, '220'))
1368
-		return false;
1430
+	if (!server_parse(null, $socket, '220')) {
1431
+			return false;
1432
+	}
1369 1433
 
1370 1434
 	// Try and determine the servers name, fall back to the mail servers if not found
1371 1435
 	$helo = false;
1372
-	if (function_exists('gethostname') && gethostname() !== false)
1373
-		$helo = gethostname();
1374
-	elseif (function_exists('php_uname'))
1375
-		$helo = php_uname('n');
1376
-	elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME']))
1377
-		$helo = $_SERVER['SERVER_NAME'];
1436
+	if (function_exists('gethostname') && gethostname() !== false) {
1437
+			$helo = gethostname();
1438
+	} elseif (function_exists('php_uname')) {
1439
+			$helo = php_uname('n');
1440
+	} elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) {
1441
+			$helo = $_SERVER['SERVER_NAME'];
1442
+	}
1378 1443
 
1379
-	if (empty($helo))
1380
-		$helo = $modSettings['smtp_host'];
1444
+	if (empty($helo)) {
1445
+			$helo = $modSettings['smtp_host'];
1446
+	}
1381 1447
 
1382 1448
 	// SMTP = 1, SMTP - STARTTLS = 2
1383 1449
 	if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
@@ -1389,33 +1455,39 @@  discard block
 block discarded – undo
1389 1455
 			if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response))
1390 1456
 			{
1391 1457
 				// Send STARTTLS to enable encryption
1392
-				if (!server_parse('STARTTLS', $socket, '220'))
1393
-					return false;
1458
+				if (!server_parse('STARTTLS', $socket, '220')) {
1459
+									return false;
1460
+				}
1394 1461
 				// Enable the encryption
1395
-				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
1396
-					return false;
1462
+				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
1463
+									return false;
1464
+				}
1397 1465
 				// Send the EHLO command again
1398
-				if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
1399
-					return false;
1466
+				if (!server_parse('EHLO ' . $helo, $socket, null) == '250') {
1467
+									return false;
1468
+				}
1400 1469
 			}
1401 1470
 
1402
-			if (!server_parse('AUTH LOGIN', $socket, '334'))
1403
-				return false;
1471
+			if (!server_parse('AUTH LOGIN', $socket, '334')) {
1472
+							return false;
1473
+			}
1404 1474
 			// Send the username and password, encoded.
1405
-			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
1406
-				return false;
1475
+			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
1476
+							return false;
1477
+			}
1407 1478
 			// The password is already encoded ;)
1408
-			if (!server_parse($modSettings['smtp_password'], $socket, '235'))
1409
-				return false;
1479
+			if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
1480
+							return false;
1481
+			}
1482
+		} elseif (!server_parse('HELO ' . $helo, $socket, '250')) {
1483
+					return false;
1410 1484
 		}
1411
-		elseif (!server_parse('HELO ' . $helo, $socket, '250'))
1412
-			return false;
1413
-	}
1414
-	else
1485
+	} else
1415 1486
 	{
1416 1487
 		// Just say "helo".
1417
-		if (!server_parse('HELO ' . $helo, $socket, '250'))
1418
-			return false;
1488
+		if (!server_parse('HELO ' . $helo, $socket, '250')) {
1489
+					return false;
1490
+		}
1419 1491
 	}
1420 1492
 
1421 1493
 	// Fix the message for any lines beginning with a period! (the first is ignored, you see.)
@@ -1428,31 +1500,38 @@  discard block
 block discarded – undo
1428 1500
 		// Reset the connection to send another email.
1429 1501
 		if ($i != 0)
1430 1502
 		{
1431
-			if (!server_parse('RSET', $socket, '250'))
1432
-				return false;
1503
+			if (!server_parse('RSET', $socket, '250')) {
1504
+							return false;
1505
+			}
1433 1506
 		}
1434 1507
 
1435 1508
 		// From, to, and then start the data...
1436
-		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250'))
1437
-			return false;
1438
-		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250'))
1439
-			return false;
1440
-		if (!server_parse('DATA', $socket, '354'))
1441
-			return false;
1509
+		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
1510
+					return false;
1511
+		}
1512
+		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
1513
+					return false;
1514
+		}
1515
+		if (!server_parse('DATA', $socket, '354')) {
1516
+					return false;
1517
+		}
1442 1518
 		fputs($socket, 'Subject: ' . $subject . "\r\n");
1443
-		if (strlen($mail_to) > 0)
1444
-			fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1519
+		if (strlen($mail_to) > 0) {
1520
+					fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1521
+		}
1445 1522
 		fputs($socket, $headers . "\r\n\r\n");
1446 1523
 		fputs($socket, $message . "\r\n");
1447 1524
 
1448 1525
 		// Send a ., or in other words "end of data".
1449
-		if (!server_parse('.', $socket, '250'))
1450
-			return false;
1526
+		if (!server_parse('.', $socket, '250')) {
1527
+					return false;
1528
+		}
1451 1529
 
1452 1530
 		// Almost done, almost done... don't stop me just yet!
1453 1531
 		@set_time_limit(300);
1454
-		if (function_exists('apache_reset_timeout'))
1455
-			@apache_reset_timeout();
1532
+		if (function_exists('apache_reset_timeout')) {
1533
+					@apache_reset_timeout();
1534
+		}
1456 1535
 	}
1457 1536
 	fputs($socket, 'QUIT' . "\r\n");
1458 1537
 	fclose($socket);
@@ -1476,8 +1555,9 @@  discard block
 block discarded – undo
1476 1555
 {
1477 1556
 	global $txt;
1478 1557
 
1479
-	if ($message !== null)
1480
-		fputs($socket, $message . "\r\n");
1558
+	if ($message !== null) {
1559
+			fputs($socket, $message . "\r\n");
1560
+	}
1481 1561
 
1482 1562
 	// No response yet.
1483 1563
 	$server_response = '';
@@ -1493,8 +1573,9 @@  discard block
 block discarded – undo
1493 1573
 		$response .= $server_response;
1494 1574
 	}
1495 1575
 
1496
-	if ($code === null)
1497
-		return substr($server_response, 0, 3);
1576
+	if ($code === null) {
1577
+			return substr($server_response, 0, 3);
1578
+	}
1498 1579
 
1499 1580
 	if (substr($server_response, 0, 3) != $code)
1500 1581
 	{
@@ -1524,8 +1605,9 @@  discard block
 block discarded – undo
1524 1605
 	// Create a pspell or enchant dictionary resource
1525 1606
 	$dict = spell_init();
1526 1607
 
1527
-	if (!isset($_POST['spellstring']) || !$dict)
1528
-		die;
1608
+	if (!isset($_POST['spellstring']) || !$dict) {
1609
+			die;
1610
+	}
1529 1611
 
1530 1612
 	// Construct a bit of Javascript code.
1531 1613
 	$context['spell_js'] = '
@@ -1543,8 +1625,9 @@  discard block
 block discarded – undo
1543 1625
 		$check_word = explode('|', $alphas[$i]);
1544 1626
 
1545 1627
 		// If the word is a known word, or spelled right...
1546
-		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2]))
1547
-			continue;
1628
+		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) {
1629
+					continue;
1630
+		}
1548 1631
 
1549 1632
 		// Find the word, and move up the "last occurrence" to here.
1550 1633
 		$found_words = true;
@@ -1558,20 +1641,23 @@  discard block
 block discarded – undo
1558 1641
 		if (!empty($suggestions))
1559 1642
 		{
1560 1643
 			// But first check they aren't going to be censored - no naughty words!
1561
-			foreach ($suggestions as $k => $word)
1562
-				if ($suggestions[$k] != censorText($word))
1644
+			foreach ($suggestions as $k => $word) {
1645
+							if ($suggestions[$k] != censorText($word))
1563 1646
 					unset($suggestions[$k]);
1647
+			}
1564 1648
 
1565
-			if (!empty($suggestions))
1566
-				$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1649
+			if (!empty($suggestions)) {
1650
+							$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1651
+			}
1567 1652
 		}
1568 1653
 
1569 1654
 		$context['spell_js'] .= ']),';
1570 1655
 	}
1571 1656
 
1572 1657
 	// If words were found, take off the last comma.
1573
-	if ($found_words)
1574
-		$context['spell_js'] = substr($context['spell_js'], 0, -1);
1658
+	if ($found_words) {
1659
+			$context['spell_js'] = substr($context['spell_js'], 0, -1);
1660
+	}
1575 1661
 
1576 1662
 	$context['spell_js'] .= '
1577 1663
 		);';
@@ -1606,11 +1692,13 @@  discard block
 block discarded – undo
1606 1692
 	global $user_info, $smcFunc;
1607 1693
 
1608 1694
 	// Can't do it if there's no topics.
1609
-	if (empty($topics))
1610
-		return;
1695
+	if (empty($topics)) {
1696
+			return;
1697
+	}
1611 1698
 	// It must be an array - it must!
1612
-	if (!is_array($topics))
1613
-		$topics = array($topics);
1699
+	if (!is_array($topics)) {
1700
+			$topics = array($topics);
1701
+	}
1614 1702
 
1615 1703
 	// Get the subject and body...
1616 1704
 	$result = $smcFunc['db_query']('', '
@@ -1658,14 +1746,15 @@  discard block
 block discarded – undo
1658 1746
 	}
1659 1747
 	$smcFunc['db_free_result']($result);
1660 1748
 
1661
-	if (!empty($task_rows))
1662
-		$smcFunc['db_insert']('',
1749
+	if (!empty($task_rows)) {
1750
+			$smcFunc['db_insert']('',
1663 1751
 			'{db_prefix}background_tasks',
1664 1752
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1665 1753
 			$task_rows,
1666 1754
 			array('id_task')
1667 1755
 		);
1668
-}
1756
+	}
1757
+	}
1669 1758
 
1670 1759
 /**
1671 1760
  * Create a post, either as new topic (id_topic = 0) or in an existing one.
@@ -1703,9 +1792,9 @@  discard block
 block discarded – undo
1703 1792
 	$msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true;
1704 1793
 
1705 1794
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
1706
-	if (!$modSettings['postmod_active'])
1707
-		$topicOptions['is_approved'] = true;
1708
-	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1795
+	if (!$modSettings['postmod_active']) {
1796
+			$topicOptions['is_approved'] = true;
1797
+	} elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1709 1798
 	{
1710 1799
 		$request = $smcFunc['db_query']('', '
1711 1800
 			SELECT approved
@@ -1728,8 +1817,7 @@  discard block
 block discarded – undo
1728 1817
 			$posterOptions['id'] = 0;
1729 1818
 			$posterOptions['name'] = $txt['guest_title'];
1730 1819
 			$posterOptions['email'] = '';
1731
-		}
1732
-		elseif ($posterOptions['id'] != $user_info['id'])
1820
+		} elseif ($posterOptions['id'] != $user_info['id'])
1733 1821
 		{
1734 1822
 			$request = $smcFunc['db_query']('', '
1735 1823
 				SELECT member_name, email_address
@@ -1747,12 +1835,11 @@  discard block
 block discarded – undo
1747 1835
 				$posterOptions['id'] = 0;
1748 1836
 				$posterOptions['name'] = $txt['guest_title'];
1749 1837
 				$posterOptions['email'] = '';
1838
+			} else {
1839
+							list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1750 1840
 			}
1751
-			else
1752
-				list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1753 1841
 			$smcFunc['db_free_result']($request);
1754
-		}
1755
-		else
1842
+		} else
1756 1843
 		{
1757 1844
 			$posterOptions['name'] = $user_info['name'];
1758 1845
 			$posterOptions['email'] = $user_info['email'];
@@ -1762,8 +1849,9 @@  discard block
 block discarded – undo
1762 1849
 	if (!empty($modSettings['enable_mentions']))
1763 1850
 	{
1764 1851
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1765
-		if (!empty($msgOptions['mentioned_members']))
1766
-			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1852
+		if (!empty($msgOptions['mentioned_members'])) {
1853
+					$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1854
+		}
1767 1855
 	}
1768 1856
 
1769 1857
 	// It's do or die time: forget any user aborts!
@@ -1796,12 +1884,13 @@  discard block
 block discarded – undo
1796 1884
 	);
1797 1885
 
1798 1886
 	// Something went wrong creating the message...
1799
-	if (empty($msgOptions['id']))
1800
-		return false;
1887
+	if (empty($msgOptions['id'])) {
1888
+			return false;
1889
+	}
1801 1890
 
1802 1891
 	// Fix the attachments.
1803
-	if (!empty($msgOptions['attachments']))
1804
-		$smcFunc['db_query']('', '
1892
+	if (!empty($msgOptions['attachments'])) {
1893
+			$smcFunc['db_query']('', '
1805 1894
 			UPDATE {db_prefix}attachments
1806 1895
 			SET id_msg = {int:id_msg}
1807 1896
 			WHERE id_attach IN ({array_int:attachment_list})',
@@ -1810,6 +1899,7 @@  discard block
 block discarded – undo
1810 1899
 				'id_msg' => $msgOptions['id'],
1811 1900
 			)
1812 1901
 		);
1902
+	}
1813 1903
 
1814 1904
 	// What if we want to export new posts out to a CMS?
1815 1905
 	call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -1886,20 +1976,23 @@  discard block
 block discarded – undo
1886 1976
 			'id_topic' => $topicOptions['id'],
1887 1977
 			'counter_increment' => 1,
1888 1978
 		);
1889
-		if ($msgOptions['approved'])
1890
-			$topics_columns = array(
1979
+		if ($msgOptions['approved']) {
1980
+					$topics_columns = array(
1891 1981
 				'id_member_updated = {int:poster_id}',
1892 1982
 				'id_last_msg = {int:id_msg}',
1893 1983
 				'num_replies = num_replies + {int:counter_increment}',
1894 1984
 			);
1895
-		else
1896
-			$topics_columns = array(
1985
+		} else {
1986
+					$topics_columns = array(
1897 1987
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
1898 1988
 			);
1899
-		if ($topicOptions['lock_mode'] !== null)
1900
-			$topics_columns[] = 'locked = {int:locked}';
1901
-		if ($topicOptions['sticky_mode'] !== null)
1902
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
1989
+		}
1990
+		if ($topicOptions['lock_mode'] !== null) {
1991
+					$topics_columns[] = 'locked = {int:locked}';
1992
+		}
1993
+		if ($topicOptions['sticky_mode'] !== null) {
1994
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
1995
+		}
1903 1996
 
1904 1997
 		call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
1905 1998
 
@@ -1928,8 +2021,8 @@  discard block
 block discarded – undo
1928 2021
 	);
1929 2022
 
1930 2023
 	// Increase the number of posts and topics on the board.
1931
-	if ($msgOptions['approved'])
1932
-		$smcFunc['db_query']('', '
2024
+	if ($msgOptions['approved']) {
2025
+			$smcFunc['db_query']('', '
1933 2026
 			UPDATE {db_prefix}boards
1934 2027
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
1935 2028
 			WHERE id_board = {int:id_board}',
@@ -1937,7 +2030,7 @@  discard block
 block discarded – undo
1937 2030
 				'id_board' => $topicOptions['board'],
1938 2031
 			)
1939 2032
 		);
1940
-	else
2033
+	} else
1941 2034
 	{
1942 2035
 		$smcFunc['db_query']('', '
1943 2036
 			UPDATE {db_prefix}boards
@@ -2007,8 +2100,8 @@  discard block
 block discarded – undo
2007 2100
 		}
2008 2101
 	}
2009 2102
 
2010
-	if ($msgOptions['approved'] && empty($topicOptions['is_approved']))
2011
-		$smcFunc['db_insert']('',
2103
+	if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) {
2104
+			$smcFunc['db_insert']('',
2012 2105
 			'{db_prefix}background_tasks',
2013 2106
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2014 2107
 			array(
@@ -2020,19 +2113,22 @@  discard block
 block discarded – undo
2020 2113
 			),
2021 2114
 			array('id_task')
2022 2115
 		);
2116
+	}
2023 2117
 
2024 2118
 	// If there's a custom search index, it may need updating...
2025 2119
 	require_once($sourcedir . '/Search.php');
2026 2120
 	$searchAPI = findSearchAPI();
2027
-	if (is_callable(array($searchAPI, 'postCreated')))
2028
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2121
+	if (is_callable(array($searchAPI, 'postCreated'))) {
2122
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2123
+	}
2029 2124
 
2030 2125
 	// Increase the post counter for the user that created the post.
2031 2126
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
2032 2127
 	{
2033 2128
 		// Are you the one that happened to create this post?
2034
-		if ($user_info['id'] == $posterOptions['id'])
2035
-			$user_info['posts']++;
2129
+		if ($user_info['id'] == $posterOptions['id']) {
2130
+					$user_info['posts']++;
2131
+		}
2036 2132
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
2037 2133
 	}
2038 2134
 
@@ -2040,19 +2136,21 @@  discard block
 block discarded – undo
2040 2136
 	$_SESSION['last_read_topic'] = 0;
2041 2137
 
2042 2138
 	// Better safe than sorry.
2043
-	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
2044
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2139
+	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) {
2140
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2141
+	}
2045 2142
 
2046 2143
 	// Update all the stats so everyone knows about this new topic and message.
2047 2144
 	updateStats('message', true, $msgOptions['id']);
2048 2145
 
2049 2146
 	// Update the last message on the board assuming it's approved AND the topic is.
2050
-	if ($msgOptions['approved'])
2051
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2147
+	if ($msgOptions['approved']) {
2148
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2149
+	}
2052 2150
 
2053 2151
 	// Queue createPost background notification
2054
-	if ($msgOptions['send_notifications'] && $msgOptions['approved'])
2055
-		$smcFunc['db_insert']('',
2152
+	if ($msgOptions['send_notifications'] && $msgOptions['approved']) {
2153
+			$smcFunc['db_insert']('',
2056 2154
 			'{db_prefix}background_tasks',
2057 2155
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2058 2156
 			array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
@@ -2063,6 +2161,7 @@  discard block
 block discarded – undo
2063 2161
 			)), 0),
2064 2162
 			array('id_task')
2065 2163
 		);
2164
+	}
2066 2165
 
2067 2166
 	// Alright, done now... we can abort now, I guess... at least this much is done.
2068 2167
 	ignore_user_abort($previous_ignore_user_abort);
@@ -2089,14 +2188,18 @@  discard block
 block discarded – undo
2089 2188
 
2090 2189
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
2091 2190
 	$messages_columns = array();
2092
-	if (isset($posterOptions['name']))
2093
-		$messages_columns['poster_name'] = $posterOptions['name'];
2094
-	if (isset($posterOptions['email']))
2095
-		$messages_columns['poster_email'] = $posterOptions['email'];
2096
-	if (isset($msgOptions['icon']))
2097
-		$messages_columns['icon'] = $msgOptions['icon'];
2098
-	if (isset($msgOptions['subject']))
2099
-		$messages_columns['subject'] = $msgOptions['subject'];
2191
+	if (isset($posterOptions['name'])) {
2192
+			$messages_columns['poster_name'] = $posterOptions['name'];
2193
+	}
2194
+	if (isset($posterOptions['email'])) {
2195
+			$messages_columns['poster_email'] = $posterOptions['email'];
2196
+	}
2197
+	if (isset($msgOptions['icon'])) {
2198
+			$messages_columns['icon'] = $msgOptions['icon'];
2199
+	}
2200
+	if (isset($msgOptions['subject'])) {
2201
+			$messages_columns['subject'] = $msgOptions['subject'];
2202
+	}
2100 2203
 	if (isset($msgOptions['body']))
2101 2204
 	{
2102 2205
 		$messages_columns['body'] = $msgOptions['body'];
@@ -2123,8 +2226,9 @@  discard block
 block discarded – undo
2123 2226
 		$messages_columns['modified_reason'] = $msgOptions['modify_reason'];
2124 2227
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
2125 2228
 	}
2126
-	if (isset($msgOptions['smileys_enabled']))
2127
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2229
+	if (isset($msgOptions['smileys_enabled'])) {
2230
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2231
+	}
2128 2232
 
2129 2233
 	// Which columns need to be ints?
2130 2234
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -2142,23 +2246,27 @@  discard block
 block discarded – undo
2142 2246
 		{
2143 2247
 			preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match);
2144 2248
 
2145
-			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2]))
2146
-				foreach ($match[1] as $i => $oldID)
2249
+			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) {
2250
+							foreach ($match[1] as $i => $oldID)
2147 2251
 					$oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]);
2252
+			}
2148 2253
 
2149
-			if (empty($modSettings['search_custom_index_config']))
2150
-				unset($msgOptions['old_body']);
2254
+			if (empty($modSettings['search_custom_index_config'])) {
2255
+							unset($msgOptions['old_body']);
2256
+			}
2151 2257
 		}
2152 2258
 
2153 2259
 		$mentions = Mentions::getMentionedMembers($msgOptions['body']);
2154 2260
 		$messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions);
2155 2261
 
2156 2262
 		// Remove the poster.
2157
-		if (isset($mentions[$user_info['id']]))
2158
-			unset($mentions[$user_info['id']]);
2263
+		if (isset($mentions[$user_info['id']])) {
2264
+					unset($mentions[$user_info['id']]);
2265
+		}
2159 2266
 
2160
-		if (isset($oldmentions[$user_info['id']]))
2161
-			unset($oldmentions[$user_info['id']]);
2267
+		if (isset($oldmentions[$user_info['id']])) {
2268
+					unset($oldmentions[$user_info['id']]);
2269
+		}
2162 2270
 
2163 2271
 		if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions))
2164 2272
 		{
@@ -2188,8 +2296,9 @@  discard block
 block discarded – undo
2188 2296
 	}
2189 2297
 
2190 2298
 	// Nothing to do?
2191
-	if (empty($messages_columns))
2192
-		return true;
2299
+	if (empty($messages_columns)) {
2300
+			return true;
2301
+	}
2193 2302
 
2194 2303
 	// Change the post.
2195 2304
 	$smcFunc['db_query']('', '
@@ -2250,8 +2359,9 @@  discard block
 block discarded – undo
2250 2359
 	// If there's a custom search index, it needs to be modified...
2251 2360
 	require_once($sourcedir . '/Search.php');
2252 2361
 	$searchAPI = findSearchAPI();
2253
-	if (is_callable(array($searchAPI, 'postModified')))
2254
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2362
+	if (is_callable(array($searchAPI, 'postModified'))) {
2363
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2364
+	}
2255 2365
 
2256 2366
 	if (isset($msgOptions['subject']))
2257 2367
 	{
@@ -2265,14 +2375,16 @@  discard block
 block discarded – undo
2265 2375
 				'id_first_msg' => $msgOptions['id'],
2266 2376
 			)
2267 2377
 		);
2268
-		if ($smcFunc['db_num_rows']($request) == 1)
2269
-			updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2378
+		if ($smcFunc['db_num_rows']($request) == 1) {
2379
+					updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2380
+		}
2270 2381
 		$smcFunc['db_free_result']($request);
2271 2382
 	}
2272 2383
 
2273 2384
 	// Finally, if we are setting the approved state we need to do much more work :(
2274
-	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
2275
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
2385
+	if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
2386
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
2387
+	}
2276 2388
 
2277 2389
 	return true;
2278 2390
 }
@@ -2289,11 +2401,13 @@  discard block
 block discarded – undo
2289 2401
 {
2290 2402
 	global $smcFunc;
2291 2403
 
2292
-	if (!is_array($msgs))
2293
-		$msgs = array($msgs);
2404
+	if (!is_array($msgs)) {
2405
+			$msgs = array($msgs);
2406
+	}
2294 2407
 
2295
-	if (empty($msgs))
2296
-		return false;
2408
+	if (empty($msgs)) {
2409
+			return false;
2410
+	}
2297 2411
 
2298 2412
 	// May as well start at the beginning, working out *what* we need to change.
2299 2413
 	$request = $smcFunc['db_query']('', '
@@ -2325,20 +2439,22 @@  discard block
 block discarded – undo
2325 2439
 		$topics[] = $row['id_topic'];
2326 2440
 
2327 2441
 		// Ensure our change array exists already.
2328
-		if (!isset($topic_changes[$row['id_topic']]))
2329
-			$topic_changes[$row['id_topic']] = array(
2442
+		if (!isset($topic_changes[$row['id_topic']])) {
2443
+					$topic_changes[$row['id_topic']] = array(
2330 2444
 				'id_last_msg' => $row['id_last_msg'],
2331 2445
 				'approved' => $row['topic_approved'],
2332 2446
 				'replies' => 0,
2333 2447
 				'unapproved_posts' => 0,
2334 2448
 			);
2335
-		if (!isset($board_changes[$row['id_board']]))
2336
-			$board_changes[$row['id_board']] = array(
2449
+		}
2450
+		if (!isset($board_changes[$row['id_board']])) {
2451
+					$board_changes[$row['id_board']] = array(
2337 2452
 				'posts' => 0,
2338 2453
 				'topics' => 0,
2339 2454
 				'unapproved_posts' => 0,
2340 2455
 				'unapproved_topics' => 0,
2341 2456
 			);
2457
+		}
2342 2458
 
2343 2459
 		// If it's the first message then the topic state changes!
2344 2460
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -2359,14 +2475,13 @@  discard block
 block discarded – undo
2359 2475
 				'poster' => $row['id_member'],
2360 2476
 				'new_topic' => true,
2361 2477
 			);
2362
-		}
2363
-		else
2478
+		} else
2364 2479
 		{
2365 2480
 			$topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1;
2366 2481
 
2367 2482
 			// This will be a post... but don't notify unless it's not followed by approved ones.
2368
-			if ($row['id_msg'] > $row['id_last_msg'])
2369
-				$notification_posts[$row['id_topic']] = array(
2483
+			if ($row['id_msg'] > $row['id_last_msg']) {
2484
+							$notification_posts[$row['id_topic']] = array(
2370 2485
 					'id' => $row['id_msg'],
2371 2486
 					'body' => $row['body'],
2372 2487
 					'subject' => $row['subject'],
@@ -2377,28 +2492,33 @@  discard block
 block discarded – undo
2377 2492
 					'new_topic' => false,
2378 2493
 					'msg' => $row['id_msg'],
2379 2494
 				);
2495
+			}
2380 2496
 		}
2381 2497
 
2382 2498
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
2383
-		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
2384
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2499
+		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) {
2500
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2501
+		}
2385 2502
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
2386
-		elseif (!$approve)
2387
-			// Default to the first message and then we'll override in a bit ;)
2503
+		elseif (!$approve) {
2504
+					// Default to the first message and then we'll override in a bit ;)
2388 2505
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
2506
+		}
2389 2507
 
2390 2508
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
2391 2509
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
2392 2510
 		$board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1;
2393 2511
 
2394 2512
 		// Post count for the user?
2395
-		if ($row['id_member'] && empty($row['count_posts']))
2396
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2513
+		if ($row['id_member'] && empty($row['count_posts'])) {
2514
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2515
+		}
2397 2516
 	}
2398 2517
 	$smcFunc['db_free_result']($request);
2399 2518
 
2400
-	if (empty($msgs))
2401
-		return;
2519
+	if (empty($msgs)) {
2520
+			return;
2521
+	}
2402 2522
 
2403 2523
 	// Now we have the differences make the changes, first the easy one.
2404 2524
 	$smcFunc['db_query']('', '
@@ -2425,14 +2545,15 @@  discard block
 block discarded – undo
2425 2545
 				'approved' => 1,
2426 2546
 			)
2427 2547
 		);
2428
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2429
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2548
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2549
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2550
+		}
2430 2551
 		$smcFunc['db_free_result']($request);
2431 2552
 	}
2432 2553
 
2433 2554
 	// ... next the topics...
2434
-	foreach ($topic_changes as $id => $changes)
2435
-		$smcFunc['db_query']('', '
2555
+	foreach ($topic_changes as $id => $changes) {
2556
+			$smcFunc['db_query']('', '
2436 2557
 			UPDATE {db_prefix}topics
2437 2558
 			SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2438 2559
 				num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg}
@@ -2445,10 +2566,11 @@  discard block
 block discarded – undo
2445 2566
 				'id_topic' => $id,
2446 2567
 			)
2447 2568
 		);
2569
+	}
2448 2570
 
2449 2571
 	// ... finally the boards...
2450
-	foreach ($board_changes as $id => $changes)
2451
-		$smcFunc['db_query']('', '
2572
+	foreach ($board_changes as $id => $changes) {
2573
+			$smcFunc['db_query']('', '
2452 2574
 			UPDATE {db_prefix}boards
2453 2575
 			SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2454 2576
 				num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics}
@@ -2461,13 +2583,14 @@  discard block
 block discarded – undo
2461 2583
 				'id_board' => $id,
2462 2584
 			)
2463 2585
 		);
2586
+	}
2464 2587
 
2465 2588
 	// Finally, least importantly, notifications!
2466 2589
 	if ($approve)
2467 2590
 	{
2468 2591
 		$task_rows = array();
2469
-		foreach (array_merge($notification_topics, $notification_posts) as $topic)
2470
-			$task_rows[] = array(
2592
+		foreach (array_merge($notification_topics, $notification_posts) as $topic) {
2593
+					$task_rows[] = array(
2471 2594
 				'$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
2472 2595
 					'msgOptions' => array(
2473 2596
 						'id' => $topic['msg'],
@@ -2485,14 +2608,16 @@  discard block
 block discarded – undo
2485 2608
 					'type' => $topic['new_topic'] ? 'topic' : 'reply',
2486 2609
 				)), 0
2487 2610
 			);
2611
+		}
2488 2612
 
2489
-		if ($notify)
2490
-			$smcFunc['db_insert']('',
2613
+		if ($notify) {
2614
+					$smcFunc['db_insert']('',
2491 2615
 				'{db_prefix}background_tasks',
2492 2616
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2493 2617
 				$task_rows,
2494 2618
 				array('id_task')
2495 2619
 			);
2620
+		}
2496 2621
 
2497 2622
 		$smcFunc['db_query']('', '
2498 2623
 			DELETE FROM {db_prefix}approval_queue
@@ -2508,8 +2633,9 @@  discard block
 block discarded – undo
2508 2633
 	else
2509 2634
 	{
2510 2635
 		$msgInserts = array();
2511
-		foreach ($msgs as $msg)
2512
-			$msgInserts[] = array($msg);
2636
+		foreach ($msgs as $msg) {
2637
+					$msgInserts[] = array($msg);
2638
+		}
2513 2639
 
2514 2640
 		$smcFunc['db_insert']('ignore',
2515 2641
 			'{db_prefix}approval_queue',
@@ -2523,9 +2649,10 @@  discard block
 block discarded – undo
2523 2649
 	updateLastMessages(array_keys($board_changes));
2524 2650
 
2525 2651
 	// Post count for the members?
2526
-	if (!empty($member_post_changes))
2527
-		foreach ($member_post_changes as $id_member => $count_change)
2652
+	if (!empty($member_post_changes)) {
2653
+			foreach ($member_post_changes as $id_member => $count_change)
2528 2654
 			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
2655
+	}
2529 2656
 
2530 2657
 	return true;
2531 2658
 }
@@ -2542,11 +2669,13 @@  discard block
 block discarded – undo
2542 2669
 {
2543 2670
 	global $smcFunc;
2544 2671
 
2545
-	if (!is_array($topics))
2546
-		$topics = array($topics);
2672
+	if (!is_array($topics)) {
2673
+			$topics = array($topics);
2674
+	}
2547 2675
 
2548
-	if (empty($topics))
2549
-		return false;
2676
+	if (empty($topics)) {
2677
+			return false;
2678
+	}
2550 2679
 
2551 2680
 	$approve_type = $approve ? 0 : 1;
2552 2681
 
@@ -2562,8 +2691,9 @@  discard block
 block discarded – undo
2562 2691
 		)
2563 2692
 	);
2564 2693
 	$msgs = array();
2565
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2566
-		$msgs[] = $row['id_msg'];
2694
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2695
+			$msgs[] = $row['id_msg'];
2696
+	}
2567 2697
 	$smcFunc['db_free_result']($request);
2568 2698
 
2569 2699
 	return approvePosts($msgs, $approve);
@@ -2586,11 +2716,13 @@  discard block
 block discarded – undo
2586 2716
 	global $board_info, $board, $smcFunc;
2587 2717
 
2588 2718
 	// Please - let's be sane.
2589
-	if (empty($setboards))
2590
-		return false;
2719
+	if (empty($setboards)) {
2720
+			return false;
2721
+	}
2591 2722
 
2592
-	if (!is_array($setboards))
2593
-		$setboards = array($setboards);
2723
+	if (!is_array($setboards)) {
2724
+			$setboards = array($setboards);
2725
+	}
2594 2726
 
2595 2727
 	// If we don't know the id_msg we need to find it.
2596 2728
 	if (!$id_msg)
@@ -2608,15 +2740,16 @@  discard block
 block discarded – undo
2608 2740
 			)
2609 2741
 		);
2610 2742
 		$lastMsg = array();
2611
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2612
-			$lastMsg[$row['id_board']] = $row['id_msg'];
2743
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2744
+					$lastMsg[$row['id_board']] = $row['id_msg'];
2745
+		}
2613 2746
 		$smcFunc['db_free_result']($request);
2614
-	}
2615
-	else
2747
+	} else
2616 2748
 	{
2617 2749
 		// Just to note - there should only be one board passed if we are doing this.
2618
-		foreach ($setboards as $id_board)
2619
-			$lastMsg[$id_board] = $id_msg;
2750
+		foreach ($setboards as $id_board) {
2751
+					$lastMsg[$id_board] = $id_msg;
2752
+		}
2620 2753
 	}
2621 2754
 
2622 2755
 	$parent_boards = array();
@@ -2631,10 +2764,11 @@  discard block
 block discarded – undo
2631 2764
 			$lastModified[$id_board] = 0;
2632 2765
 		}
2633 2766
 
2634
-		if (!empty($board) && $id_board == $board)
2635
-			$parents = $board_info['parent_boards'];
2636
-		else
2637
-			$parents = getBoardParents($id_board);
2767
+		if (!empty($board) && $id_board == $board) {
2768
+					$parents = $board_info['parent_boards'];
2769
+		} else {
2770
+					$parents = getBoardParents($id_board);
2771
+		}
2638 2772
 
2639 2773
 		// Ignore any parents on the top child level.
2640 2774
 		// @todo Why?
@@ -2643,10 +2777,11 @@  discard block
 block discarded – undo
2643 2777
 			if ($parent['level'] != 0)
2644 2778
 			{
2645 2779
 				// If we're already doing this one as a board, is this a higher last modified?
2646
-				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
2647
-					$lastModified[$id] = $lastModified[$id_board];
2648
-				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
2649
-					$parent_boards[$id] = $lastModified[$id_board];
2780
+				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) {
2781
+									$lastModified[$id] = $lastModified[$id_board];
2782
+				} elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) {
2783
+									$parent_boards[$id] = $lastModified[$id_board];
2784
+				}
2650 2785
 			}
2651 2786
 		}
2652 2787
 	}
@@ -2659,23 +2794,24 @@  discard block
 block discarded – undo
2659 2794
 	// Finally, to save on queries make the changes...
2660 2795
 	foreach ($parent_boards as $id => $msg)
2661 2796
 	{
2662
-		if (!isset($parent_updates[$msg]))
2663
-			$parent_updates[$msg] = array($id);
2664
-		else
2665
-			$parent_updates[$msg][] = $id;
2797
+		if (!isset($parent_updates[$msg])) {
2798
+					$parent_updates[$msg] = array($id);
2799
+		} else {
2800
+					$parent_updates[$msg][] = $id;
2801
+		}
2666 2802
 	}
2667 2803
 
2668 2804
 	foreach ($lastMsg as $id => $msg)
2669 2805
 	{
2670
-		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
2671
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
2806
+		if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) {
2807
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
2672 2808
 				'id' => $msg,
2673 2809
 				'updated' => $lastModified[$id],
2674 2810
 				'boards' => array($id)
2675 2811
 			);
2676
-
2677
-		else
2678
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2812
+		} else {
2813
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2814
+		}
2679 2815
 	}
2680 2816
 
2681 2817
 	// Now commit the changes!
@@ -2767,11 +2903,13 @@  discard block
 block discarded – undo
2767 2903
 	global $txt, $mbname, $scripturl, $settings;
2768 2904
 
2769 2905
 	// First things first, load up the email templates language file, if we need to.
2770
-	if ($loadLang)
2771
-		loadLanguage('EmailTemplates', $lang);
2906
+	if ($loadLang) {
2907
+			loadLanguage('EmailTemplates', $lang);
2908
+	}
2772 2909
 
2773
-	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
2774
-		fatal_lang_error('email_no_template', 'template', array($template));
2910
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) {
2911
+			fatal_lang_error('email_no_template', 'template', array($template));
2912
+	}
2775 2913
 
2776 2914
 	$ret = array(
2777 2915
 		'subject' => $txt[$template . '_subject'],
@@ -2821,17 +2959,18 @@  discard block
 block discarded – undo
2821 2959
 function user_info_callback($matches)
2822 2960
 {
2823 2961
 	global $user_info;
2824
-	if (empty($matches[1]))
2825
-		return '';
2962
+	if (empty($matches[1])) {
2963
+			return '';
2964
+	}
2826 2965
 
2827 2966
 	$use_ref = true;
2828 2967
 	$ref = &$user_info;
2829 2968
 
2830 2969
 	foreach (explode('.', $matches[1]) as $index)
2831 2970
 	{
2832
-		if ($use_ref && isset($ref[$index]))
2833
-			$ref = &$ref[$index];
2834
-		else
2971
+		if ($use_ref && isset($ref[$index])) {
2972
+					$ref = &$ref[$index];
2973
+		} else
2835 2974
 		{
2836 2975
 			$use_ref = false;
2837 2976
 			break;
@@ -2868,8 +3007,7 @@  discard block
 block discarded – undo
2868 3007
 		if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
2869 3008
 		{
2870 3009
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
2871
-		}
2872
-		elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
3010
+		} elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2873 3011
 		{
2874 3012
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']);
2875 3013
 		}
@@ -2879,8 +3017,7 @@  discard block
 block discarded – undo
2879 3017
 		{
2880 3018
 			$context['provider'] = 'enchant';
2881 3019
 			return $enchant_link;
2882
-		}
2883
-		else
3020
+		} else
2884 3021
 		{
2885 3022
 			// Free up any resources used...
2886 3023
 			@enchant_broker_free($context['enchant_broker']);
@@ -2901,8 +3038,9 @@  discard block
 block discarded – undo
2901 3038
 		$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
2902 3039
 
2903 3040
 		// Most people don't have anything but English installed... So we use English as a last resort.
2904
-		if (!$pspell_link)
2905
-			$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3041
+		if (!$pspell_link) {
3042
+					$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3043
+		}
2906 3044
 
2907 3045
 		error_reporting($old);
2908 3046
 		ob_end_clean();
@@ -2942,8 +3080,7 @@  discard block
 block discarded – undo
2942 3080
 			$word = iconv($txt['lang_character_set'], 'UTF-8', $word);
2943 3081
 		}
2944 3082
 		return enchant_dict_check($dict, $word);
2945
-	}
2946
-	elseif ($context['provider'] == 'pspell')
3083
+	} elseif ($context['provider'] == 'pspell')
2947 3084
 	{
2948 3085
 		return pspell_check($dict, $word);
2949 3086
 	}
@@ -2979,13 +3116,11 @@  discard block
 block discarded – undo
2979 3116
 			}
2980 3117
 
2981 3118
 			return $suggestions;
2982
-		}
2983
-		else
3119
+		} else
2984 3120
 		{
2985 3121
 			return enchant_dict_suggest($dict, $word);
2986 3122
 		}
2987
-	}
2988
-	elseif ($context['provider'] == 'pspell')
3123
+	} elseif ($context['provider'] == 'pspell')
2989 3124
 	{
2990 3125
 		return pspell_suggest($dict, $word);
2991 3126
 	}
Please login to merge, or discard this patch.
Sources/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Load.php 1 patch
Braces   +796 added lines, -601 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('~(' . $ent_list . '|.)~' . ($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
 
@@ -392,9 +409,9 @@  discard block
 block discarded – undo
392 409
 				break;
393 410
 			}
394 411
 		}
412
+	} else {
413
+			$id_member = 0;
395 414
 	}
396
-	else
397
-		$id_member = 0;
398 415
 
399 416
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
400 417
 	{
@@ -402,8 +419,9 @@  discard block
 block discarded – undo
402 419
 		$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
403 420
 
404 421
 		// Legacy format (for recent 2.0 --> 2.1 upgrades)
405
-		if (empty($cookie_data))
406
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
422
+		if (empty($cookie_data)) {
423
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
424
+		}
407 425
 
408 426
 		list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, '');
409 427
 
@@ -411,16 +429,17 @@  discard block
 block discarded – undo
411 429
 
412 430
 		// Make sure the cookie is set to the correct domain and path
413 431
 		require_once($sourcedir . '/Subs-Auth.php');
414
-		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])))
415
-			setLoginCookie((int) $login_span - time(), $id_member);
416
-	}
417
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
432
+		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) {
433
+					setLoginCookie((int) $login_span - time(), $id_member);
434
+		}
435
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
418 436
 	{
419 437
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
420 438
 		$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true);
421 439
 
422
-		if (empty($cookie_data))
423
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
440
+		if (empty($cookie_data)) {
441
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
442
+		}
424 443
 
425 444
 		list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, '');
426 445
 		$id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0;
@@ -445,30 +464,34 @@  discard block
 block discarded – undo
445 464
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
446 465
 			$smcFunc['db_free_result']($request);
447 466
 
448
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
449
-				$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
467
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
468
+							$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
469
+			}
450 470
 
451
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
452
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
471
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
472
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
473
+			}
453 474
 		}
454 475
 
455 476
 		// Did we find 'im?  If not, junk it.
456 477
 		if (!empty($user_settings))
457 478
 		{
458 479
 			// As much as the password should be right, we can assume the integration set things up.
459
-			if (!empty($already_verified) && $already_verified === true)
460
-				$check = true;
480
+			if (!empty($already_verified) && $already_verified === true) {
481
+							$check = true;
482
+			}
461 483
 			// SHA-512 hash should be 128 characters long.
462
-			elseif (strlen($password) == 128)
463
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
464
-			else
465
-				$check = false;
484
+			elseif (strlen($password) == 128) {
485
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
486
+			} else {
487
+							$check = false;
488
+			}
466 489
 
467 490
 			// Wrong password or not activated - either way, you're going nowhere.
468 491
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
492
+		} else {
493
+					$id_member = 0;
469 494
 		}
470
-		else
471
-			$id_member = 0;
472 495
 
473 496
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
474 497
 		if (!$id_member)
@@ -497,8 +520,9 @@  discard block
 block discarded – undo
497 520
 
498 521
 					list ($tfamember, $tfasecret) = $tfa_data;
499 522
 
500
-					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member)
501
-						$tfasecret = null;
523
+					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) {
524
+											$tfasecret = null;
525
+					}
502 526
 				}
503 527
 
504 528
 				if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret)
@@ -518,10 +542,12 @@  discard block
 block discarded – undo
518 542
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
519 543
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
520 544
 		{
521
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
545
+			if ($modSettings['tfa_mode'] == 2) {
546
+				//only do this if we are just forcing SOME membergroups
522 547
 			{
523 548
 				//Build an array of ALL user membergroups.
524 549
 				$full_groups = array($user_settings['id_group']);
550
+			}
525 551
 				if (!empty($user_settings['additional_groups']))
526 552
 				{
527 553
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -541,15 +567,17 @@  discard block
 block discarded – undo
541 567
 				);
542 568
 				$row = $smcFunc['db_fetch_assoc']($request);
543 569
 				$smcFunc['db_free_result']($request);
570
+			} else {
571
+							$row['total'] = 1;
544 572
 			}
545
-			else
546
-				$row['total'] = 1; //simplifies logics in the next "if"
573
+			//simplifies logics in the next "if"
547 574
 
548 575
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
549 576
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
550 577
 
551
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
552
-				redirectexit('action=profile;area=tfasetup;forced');
578
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
579
+							redirectexit('action=profile;area=tfasetup;forced');
580
+			}
553 581
 		}
554 582
 	}
555 583
 
@@ -586,33 +614,37 @@  discard block
 block discarded – undo
586 614
 				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']));
587 615
 				$user_settings['last_login'] = time();
588 616
 
589
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
590
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
617
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
618
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
619
+				}
591 620
 
592
-				if (!empty($modSettings['cache_enable']))
593
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
621
+				if (!empty($modSettings['cache_enable'])) {
622
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
623
+				}
594 624
 			}
625
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
626
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
595 627
 		}
596
-		elseif (empty($_SESSION['id_msg_last_visit']))
597
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
598 628
 
599 629
 		$username = $user_settings['member_name'];
600 630
 
601
-		if (empty($user_settings['additional_groups']))
602
-			$user_info = array(
631
+		if (empty($user_settings['additional_groups'])) {
632
+					$user_info = array(
603 633
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
604 634
 			);
605
-		else
606
-			$user_info = array(
635
+		} else {
636
+					$user_info = array(
607 637
 				'groups' => array_merge(
608 638
 					array($user_settings['id_group'], $user_settings['id_post_group']),
609 639
 					explode(',', $user_settings['additional_groups'])
610 640
 				)
611 641
 			);
642
+		}
612 643
 
613 644
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
614
-		foreach ($user_info['groups'] as $k => $v)
615
-			$user_info['groups'][$k] = (int) $v;
645
+		foreach ($user_info['groups'] as $k => $v) {
646
+					$user_info['groups'][$k] = (int) $v;
647
+		}
616 648
 
617 649
 		// This is a logged in user, so definitely not a spider.
618 650
 		$user_info['possibly_robot'] = false;
@@ -626,8 +658,7 @@  discard block
 block discarded – undo
626 658
 			$time_system = new DateTime('now', $tz_system);
627 659
 			$time_user = new DateTime('now', $tz_user);
628 660
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
629
-		}
630
-		else
661
+		} else
631 662
 		{
632 663
 			// !!! Compatibility.
633 664
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
@@ -641,8 +672,9 @@  discard block
 block discarded – undo
641 672
 		$user_info = array('groups' => array(-1));
642 673
 		$user_settings = array();
643 674
 
644
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
645
-			$_COOKIE[$cookiename] = '';
675
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
676
+					$_COOKIE[$cookiename] = '';
677
+		}
646 678
 
647 679
 		// Expire the 2FA cookie
648 680
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
@@ -659,19 +691,20 @@  discard block
 block discarded – undo
659 691
 		}
660 692
 
661 693
 		// Create a login token if it doesn't exist yet.
662
-		if (!isset($_SESSION['token']['post-login']))
663
-			createToken('login');
664
-		else
665
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
694
+		if (!isset($_SESSION['token']['post-login'])) {
695
+					createToken('login');
696
+		} else {
697
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
698
+		}
666 699
 
667 700
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
668 701
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
669 702
 		{
670 703
 			require_once($sourcedir . '/ManageSearchEngines.php');
671 704
 			$user_info['possibly_robot'] = SpiderCheck();
705
+		} elseif (!empty($modSettings['spider_mode'])) {
706
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
672 707
 		}
673
-		elseif (!empty($modSettings['spider_mode']))
674
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
675 708
 		// If we haven't turned on proper spider hunts then have a guess!
676 709
 		else
677 710
 		{
@@ -719,8 +752,9 @@  discard block
 block discarded – undo
719 752
 	$user_info['groups'] = array_unique($user_info['groups']);
720 753
 
721 754
 	// 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.
722
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
723
-		unset($user_info['ignoreboards'][$tmp]);
755
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
756
+			unset($user_info['ignoreboards'][$tmp]);
757
+	}
724 758
 
725 759
 	// Allow the user to change their language.
726 760
 	if (!empty($modSettings['userLanguage']))
@@ -733,13 +767,14 @@  discard block
 block discarded – undo
733 767
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
734 768
 
735 769
 			// Make it permanent for members.
736
-			if (!empty($user_info['id']))
737
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
738
-			else
739
-				$_SESSION['language'] = $user_info['language'];
770
+			if (!empty($user_info['id'])) {
771
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
772
+			} else {
773
+							$_SESSION['language'] = $user_info['language'];
774
+			}
775
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
776
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
740 777
 		}
741
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
742
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
743 778
 	}
744 779
 
745 780
 	$temp = build_query_board($user_info['id']);
@@ -802,9 +837,9 @@  discard block
 block discarded – undo
802 837
 		}
803 838
 
804 839
 		// Remember redirection is the key to avoiding fallout from your bosses.
805
-		if (!empty($topic))
806
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
807
-		else
840
+		if (!empty($topic)) {
841
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
842
+		} else
808 843
 		{
809 844
 			loadPermissions();
810 845
 			loadTheme();
@@ -822,10 +857,11 @@  discard block
 block discarded – undo
822 857
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
823 858
 	{
824 859
 		// @todo SLOW?
825
-		if (!empty($topic))
826
-			$temp = cache_get_data('topic_board-' . $topic, 120);
827
-		else
828
-			$temp = cache_get_data('board-' . $board, 120);
860
+		if (!empty($topic)) {
861
+					$temp = cache_get_data('topic_board-' . $topic, 120);
862
+		} else {
863
+					$temp = cache_get_data('board-' . $board, 120);
864
+		}
829 865
 
830 866
 		if (!empty($temp))
831 867
 		{
@@ -863,8 +899,9 @@  discard block
 block discarded – undo
863 899
 			$row = $smcFunc['db_fetch_assoc']($request);
864 900
 
865 901
 			// Set the current board.
866
-			if (!empty($row['id_board']))
867
-				$board = $row['id_board'];
902
+			if (!empty($row['id_board'])) {
903
+							$board = $row['id_board'];
904
+			}
868 905
 
869 906
 			// Basic operating information. (globals... :/)
870 907
 			$board_info = array(
@@ -900,21 +937,23 @@  discard block
 block discarded – undo
900 937
 
901 938
 			do
902 939
 			{
903
-				if (!empty($row['id_moderator']))
904
-					$board_info['moderators'][$row['id_moderator']] = array(
940
+				if (!empty($row['id_moderator'])) {
941
+									$board_info['moderators'][$row['id_moderator']] = array(
905 942
 						'id' => $row['id_moderator'],
906 943
 						'name' => $row['real_name'],
907 944
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
908 945
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
909 946
 					);
947
+				}
910 948
 
911
-				if (!empty($row['id_moderator_group']))
912
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
949
+				if (!empty($row['id_moderator_group'])) {
950
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
913 951
 						'id' => $row['id_moderator_group'],
914 952
 						'name' => $row['group_name'],
915 953
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
916 954
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
917 955
 					);
956
+				}
918 957
 			}
919 958
 			while ($row = $smcFunc['db_fetch_assoc']($request));
920 959
 
@@ -946,12 +985,12 @@  discard block
 block discarded – undo
946 985
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
947 986
 			{
948 987
 				// @todo SLOW?
949
-				if (!empty($topic))
950
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
988
+				if (!empty($topic)) {
989
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
990
+				}
951 991
 				cache_put_data('board-' . $board, $board_info, 120);
952 992
 			}
953
-		}
954
-		else
993
+		} else
955 994
 		{
956 995
 			// Otherwise the topic is invalid, there are no moderators, etc.
957 996
 			$board_info = array(
@@ -965,8 +1004,9 @@  discard block
 block discarded – undo
965 1004
 		$smcFunc['db_free_result']($request);
966 1005
 	}
967 1006
 
968
-	if (!empty($topic))
969
-		$_GET['board'] = (int) $board;
1007
+	if (!empty($topic)) {
1008
+			$_GET['board'] = (int) $board;
1009
+	}
970 1010
 
971 1011
 	if (!empty($board))
972 1012
 	{
@@ -976,10 +1016,12 @@  discard block
 block discarded – undo
976 1016
 		// Now check if the user is a moderator.
977 1017
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
978 1018
 
979
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
980
-			$board_info['error'] = 'access';
981
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
982
-			$board_info['error'] = 'access';
1019
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1020
+					$board_info['error'] = 'access';
1021
+		}
1022
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1023
+					$board_info['error'] = 'access';
1024
+		}
983 1025
 
984 1026
 		// Build up the linktree.
985 1027
 		$context['linktree'] = array_merge(
@@ -1002,8 +1044,9 @@  discard block
 block discarded – undo
1002 1044
 	$context['current_board'] = $board;
1003 1045
 
1004 1046
 	// No posting in redirection boards!
1005
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
1006
-		$board_info['error'] == 'post_in_redirect';
1047
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1048
+			$board_info['error'] == 'post_in_redirect';
1049
+	}
1007 1050
 
1008 1051
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1009 1052
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1029,24 +1072,23 @@  discard block
 block discarded – undo
1029 1072
 			ob_end_clean();
1030 1073
 			header('HTTP/1.1 403 Forbidden');
1031 1074
 			die;
1032
-		}
1033
-		elseif ($board_info['error'] == 'post_in_redirect')
1075
+		} elseif ($board_info['error'] == 'post_in_redirect')
1034 1076
 		{
1035 1077
 			// Slightly different error message here...
1036 1078
 			fatal_lang_error('cannot_post_redirect', false);
1037
-		}
1038
-		elseif ($user_info['is_guest'])
1079
+		} elseif ($user_info['is_guest'])
1039 1080
 		{
1040 1081
 			loadLanguage('Errors');
1041 1082
 			is_not_guest($txt['topic_gone']);
1083
+		} else {
1084
+					fatal_lang_error('topic_gone', false);
1042 1085
 		}
1043
-		else
1044
-			fatal_lang_error('topic_gone', false);
1045 1086
 	}
1046 1087
 
1047
-	if ($user_info['is_mod'])
1048
-		$user_info['groups'][] = 3;
1049
-}
1088
+	if ($user_info['is_mod']) {
1089
+			$user_info['groups'][] = 3;
1090
+	}
1091
+	}
1050 1092
 
1051 1093
 /**
1052 1094
  * Load this user's permissions.
@@ -1067,8 +1109,9 @@  discard block
 block discarded – undo
1067 1109
 		asort($cache_groups);
1068 1110
 		$cache_groups = implode(',', $cache_groups);
1069 1111
 		// If it's a spider then cache it different.
1070
-		if ($user_info['possibly_robot'])
1071
-			$cache_groups .= '-spider';
1112
+		if ($user_info['possibly_robot']) {
1113
+					$cache_groups .= '-spider';
1114
+		}
1072 1115
 
1073 1116
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1074 1117
 		{
@@ -1076,9 +1119,9 @@  discard block
 block discarded – undo
1076 1119
 			banPermissions();
1077 1120
 
1078 1121
 			return;
1122
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1123
+					list ($user_info['permissions'], $removals) = $temp;
1079 1124
 		}
1080
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1081
-			list ($user_info['permissions'], $removals) = $temp;
1082 1125
 	}
1083 1126
 
1084 1127
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1100,23 +1143,26 @@  discard block
 block discarded – undo
1100 1143
 		$removals = array();
1101 1144
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1102 1145
 		{
1103
-			if (empty($row['add_deny']))
1104
-				$removals[] = $row['permission'];
1105
-			else
1106
-				$user_info['permissions'][] = $row['permission'];
1146
+			if (empty($row['add_deny'])) {
1147
+							$removals[] = $row['permission'];
1148
+			} else {
1149
+							$user_info['permissions'][] = $row['permission'];
1150
+			}
1107 1151
 		}
1108 1152
 		$smcFunc['db_free_result']($request);
1109 1153
 
1110
-		if (isset($cache_groups))
1111
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1154
+		if (isset($cache_groups)) {
1155
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1156
+		}
1112 1157
 	}
1113 1158
 
1114 1159
 	// Get the board permissions.
1115 1160
 	if (!empty($board))
1116 1161
 	{
1117 1162
 		// Make sure the board (if any) has been loaded by loadBoard().
1118
-		if (!isset($board_info['profile']))
1119
-			fatal_lang_error('no_board');
1163
+		if (!isset($board_info['profile'])) {
1164
+					fatal_lang_error('no_board');
1165
+		}
1120 1166
 
1121 1167
 		$request = $smcFunc['db_query']('', '
1122 1168
 			SELECT permission, add_deny
@@ -1132,20 +1178,23 @@  discard block
 block discarded – undo
1132 1178
 		);
1133 1179
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1134 1180
 		{
1135
-			if (empty($row['add_deny']))
1136
-				$removals[] = $row['permission'];
1137
-			else
1138
-				$user_info['permissions'][] = $row['permission'];
1181
+			if (empty($row['add_deny'])) {
1182
+							$removals[] = $row['permission'];
1183
+			} else {
1184
+							$user_info['permissions'][] = $row['permission'];
1185
+			}
1139 1186
 		}
1140 1187
 		$smcFunc['db_free_result']($request);
1141 1188
 	}
1142 1189
 
1143 1190
 	// Remove all the permissions they shouldn't have ;).
1144
-	if (!empty($modSettings['permission_enable_deny']))
1145
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1191
+	if (!empty($modSettings['permission_enable_deny'])) {
1192
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1193
+	}
1146 1194
 
1147
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1148
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1195
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1196
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1197
+	}
1149 1198
 
1150 1199
 	// Banned?  Watch, don't touch..
1151 1200
 	banPermissions();
@@ -1157,17 +1206,18 @@  discard block
 block discarded – undo
1157 1206
 		{
1158 1207
 			require_once($sourcedir . '/Subs-Auth.php');
1159 1208
 			rebuildModCache();
1209
+		} else {
1210
+					$user_info['mod_cache'] = $_SESSION['mc'];
1160 1211
 		}
1161
-		else
1162
-			$user_info['mod_cache'] = $_SESSION['mc'];
1163 1212
 
1164 1213
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1165 1214
 		// For example this drastically simplifies certain changes to the profile area.
1166 1215
 		$user_info['permissions'][] = 'is_not_guest';
1167 1216
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1168 1217
 		$user_info['permissions'][] = 'profile_view_own';
1169
-		if (in_array('profile_view', $user_info['permissions']))
1170
-			$user_info['permissions'][] = 'profile_view_any';
1218
+		if (in_array('profile_view', $user_info['permissions'])) {
1219
+					$user_info['permissions'][] = 'profile_view_any';
1220
+		}
1171 1221
 	}
1172 1222
 }
1173 1223
 
@@ -1185,8 +1235,9 @@  discard block
 block discarded – undo
1185 1235
 	global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info;
1186 1236
 
1187 1237
 	// Can't just look for no users :P.
1188
-	if (empty($users))
1189
-		return array();
1238
+	if (empty($users)) {
1239
+			return array();
1240
+	}
1190 1241
 
1191 1242
 	// Pass the set value
1192 1243
 	$context['loadMemberContext_set'] = $set;
@@ -1201,8 +1252,9 @@  discard block
 block discarded – undo
1201 1252
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1202 1253
 		{
1203 1254
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1204
-			if ($data == null)
1205
-				continue;
1255
+			if ($data == null) {
1256
+							continue;
1257
+			}
1206 1258
 
1207 1259
 			$loaded_ids[] = $data['id_member'];
1208 1260
 			$user_profile[$data['id_member']] = $data;
@@ -1269,16 +1321,19 @@  discard block
 block discarded – undo
1269 1321
 			$row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : '';
1270 1322
 
1271 1323
 			// Take care of proxying avatar if required, do this here for maximum reach
1272
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
1273
-				$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1324
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
1325
+							$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1326
+			}
1274 1327
 
1275 1328
 			// Keep track of the member's normal member group
1276 1329
 			$row['primary_group'] = $row['member_group'];
1277 1330
 
1278
-			if (isset($row['member_ip']))
1279
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1280
-			if (isset($row['member_ip2']))
1281
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1331
+			if (isset($row['member_ip'])) {
1332
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1333
+			}
1334
+			if (isset($row['member_ip2'])) {
1335
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1336
+			}
1282 1337
 			$new_loaded_ids[] = $row['id_member'];
1283 1338
 			$loaded_ids[] = $row['id_member'];
1284 1339
 			$row['options'] = array();
@@ -1297,8 +1352,9 @@  discard block
 block discarded – undo
1297 1352
 				'loaded_ids' => $new_loaded_ids,
1298 1353
 			)
1299 1354
 		);
1300
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1301
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1355
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1356
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1357
+		}
1302 1358
 		$smcFunc['db_free_result']($request);
1303 1359
 	}
1304 1360
 
@@ -1309,10 +1365,11 @@  discard block
 block discarded – undo
1309 1365
 	{
1310 1366
 		foreach ($loaded_ids as $a_member)
1311 1367
 		{
1312
-			if (!empty($user_profile[$a_member]['additional_groups']))
1313
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1314
-			else
1315
-				$groups = array($user_profile[$a_member]['id_group']);
1368
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1369
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1370
+			} else {
1371
+							$groups = array($user_profile[$a_member]['id_group']);
1372
+			}
1316 1373
 
1317 1374
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1318 1375
 
@@ -1325,8 +1382,9 @@  discard block
 block discarded – undo
1325 1382
 
1326 1383
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1327 1384
 	{
1328
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1329
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1385
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1386
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1387
+		}
1330 1388
 	}
1331 1389
 
1332 1390
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1352,14 +1410,17 @@  discard block
 block discarded – undo
1352 1410
 		foreach ($temp_mods as $id)
1353 1411
 		{
1354 1412
 			// By popular demand, don't show admins or global moderators as moderators.
1355
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1356
-				$user_profile[$id]['member_group'] = $row['member_group'];
1413
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1414
+							$user_profile[$id]['member_group'] = $row['member_group'];
1415
+			}
1357 1416
 
1358 1417
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1359
-			if (!empty($row['icons']))
1360
-				$user_profile[$id]['icons'] = $row['icons'];
1361
-			if (!empty($row['member_group_color']))
1362
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1418
+			if (!empty($row['icons'])) {
1419
+							$user_profile[$id]['icons'] = $row['icons'];
1420
+			}
1421
+			if (!empty($row['member_group_color'])) {
1422
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1423
+			}
1363 1424
 		}
1364 1425
 	}
1365 1426
 
@@ -1381,12 +1442,14 @@  discard block
 block discarded – undo
1381 1442
 	static $loadedLanguages = array();
1382 1443
 
1383 1444
 	// If this person's data is already loaded, skip it.
1384
-	if (isset($dataLoaded[$user]))
1385
-		return true;
1445
+	if (isset($dataLoaded[$user])) {
1446
+			return true;
1447
+	}
1386 1448
 
1387 1449
 	// We can't load guests or members not loaded by loadMemberData()!
1388
-	if ($user == 0)
1389
-		return false;
1450
+	if ($user == 0) {
1451
+			return false;
1452
+	}
1390 1453
 	if (!isset($user_profile[$user]))
1391 1454
 	{
1392 1455
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1412,12 +1475,16 @@  discard block
 block discarded – undo
1412 1475
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1413 1476
 
1414 1477
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1415
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1478
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1479
+		//icon is set and exists
1416 1480
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1417
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1481
+	} elseif (isset($profile['icons'][1])) {
1482
+		//icon is set and doesn't exist, fallback to default
1418 1483
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1419
-	else //not set, bye bye
1484
+	} else {
1485
+		//not set, bye bye
1420 1486
 		$group_icon_url = '';
1487
+	}
1421 1488
 
1422 1489
 	// These minimal values are always loaded
1423 1490
 	$memberContext[$user] = array(
@@ -1436,8 +1503,9 @@  discard block
 block discarded – undo
1436 1503
 	if ($context['loadMemberContext_set'] != 'minimal')
1437 1504
 	{
1438 1505
 		// Go the extra mile and load the user's native language name.
1439
-		if (empty($loadedLanguages))
1440
-			$loadedLanguages = getLanguages();
1506
+		if (empty($loadedLanguages)) {
1507
+					$loadedLanguages = getLanguages();
1508
+		}
1441 1509
 
1442 1510
 		$memberContext[$user] += array(
1443 1511
 			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
@@ -1492,31 +1560,33 @@  discard block
 block discarded – undo
1492 1560
 	{
1493 1561
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1494 1562
 		{
1495
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1496
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1497
-			else
1498
-				$image = get_gravatar_url($profile['email_address']);
1499
-		}
1500
-		else
1563
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1564
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1565
+			} else {
1566
+							$image = get_gravatar_url($profile['email_address']);
1567
+			}
1568
+		} else
1501 1569
 		{
1502 1570
 			// So it's stored in the member table?
1503 1571
 			if (!empty($profile['avatar']))
1504 1572
 			{
1505 1573
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1574
+			} elseif (!empty($profile['filename'])) {
1575
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1506 1576
 			}
1507
-			elseif (!empty($profile['filename']))
1508
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1509 1577
 			// Right... no avatar...use the default one
1510
-			else
1511
-				$image = $modSettings['avatar_url'] . '/default.png';
1578
+			else {
1579
+							$image = $modSettings['avatar_url'] . '/default.png';
1580
+			}
1512 1581
 		}
1513
-		if (!empty($image))
1514
-			$memberContext[$user]['avatar'] = array(
1582
+		if (!empty($image)) {
1583
+					$memberContext[$user]['avatar'] = array(
1515 1584
 				'name' => $profile['avatar'],
1516 1585
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1517 1586
 				'href' => $image,
1518 1587
 				'url' => $image,
1519 1588
 			);
1589
+		}
1520 1590
 	}
1521 1591
 
1522 1592
 	// Are we also loading the members custom fields into context?
@@ -1524,13 +1594,15 @@  discard block
 block discarded – undo
1524 1594
 	{
1525 1595
 		$memberContext[$user]['custom_fields'] = array();
1526 1596
 
1527
-		if (!isset($context['display_fields']))
1528
-			$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1597
+		if (!isset($context['display_fields'])) {
1598
+					$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1599
+		}
1529 1600
 
1530 1601
 		foreach ($context['display_fields'] as $custom)
1531 1602
 		{
1532
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1533
-				continue;
1603
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1604
+							continue;
1605
+			}
1534 1606
 
1535 1607
 			$value = $profile['options'][$custom['col_name']];
1536 1608
 
@@ -1538,31 +1610,36 @@  discard block
 block discarded – undo
1538 1610
 			$currentKey = 0;
1539 1611
 
1540 1612
 			// Create a key => value array for multiple options fields
1541
-			if (!empty($custom['options']))
1542
-				foreach ($custom['options'] as $k => $v)
1613
+			if (!empty($custom['options'])) {
1614
+							foreach ($custom['options'] as $k => $v)
1543 1615
 				{
1544 1616
 					$fieldOptions[] = $v;
1545
-					if (empty($currentKey))
1546
-						$currentKey = $v == $value ? $k : 0;
1617
+			}
1618
+					if (empty($currentKey)) {
1619
+											$currentKey = $v == $value ? $k : 0;
1620
+					}
1547 1621
 				}
1548 1622
 
1549 1623
 			// BBC?
1550
-			if ($custom['bbc'])
1551
-				$value = parse_bbc($value);
1624
+			if ($custom['bbc']) {
1625
+							$value = parse_bbc($value);
1626
+			}
1552 1627
 
1553 1628
 			// ... or checkbox?
1554
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1555
-				$value = $value ? $txt['yes'] : $txt['no'];
1629
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1630
+							$value = $value ? $txt['yes'] : $txt['no'];
1631
+			}
1556 1632
 
1557 1633
 			// Enclosing the user input within some other text?
1558
-			if (!empty($custom['enclose']))
1559
-				$value = strtr($custom['enclose'], array(
1634
+			if (!empty($custom['enclose'])) {
1635
+							$value = strtr($custom['enclose'], array(
1560 1636
 					'{SCRIPTURL}' => $scripturl,
1561 1637
 					'{IMAGES_URL}' => $settings['images_url'],
1562 1638
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1563 1639
 					'{INPUT}' => $value,
1564 1640
 					'{KEY}' => $currentKey,
1565 1641
 				));
1642
+			}
1566 1643
 
1567 1644
 			$memberContext[$user]['custom_fields'][] = array(
1568 1645
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1589,8 +1666,9 @@  discard block
 block discarded – undo
1589 1666
 	global $smcFunc, $txt, $scripturl, $settings;
1590 1667
 
1591 1668
 	// Do not waste my time...
1592
-	if (empty($users) || empty($params))
1593
-		return false;
1669
+	if (empty($users) || empty($params)) {
1670
+			return false;
1671
+	}
1594 1672
 
1595 1673
 	// Make sure it's an array.
1596 1674
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1617,41 +1695,48 @@  discard block
 block discarded – undo
1617 1695
 		$currentKey = 0;
1618 1696
 
1619 1697
 		// Create a key => value array for multiple options fields
1620
-		if (!empty($row['field_options']))
1621
-			foreach (explode(',', $row['field_options']) as $k => $v)
1698
+		if (!empty($row['field_options'])) {
1699
+					foreach (explode(',', $row['field_options']) as $k => $v)
1622 1700
 			{
1623 1701
 				$fieldOptions[] = $v;
1624
-				if (empty($currentKey))
1625
-					$currentKey = $v == $row['value'] ? $k : 0;
1702
+		}
1703
+				if (empty($currentKey)) {
1704
+									$currentKey = $v == $row['value'] ? $k : 0;
1705
+				}
1626 1706
 			}
1627 1707
 
1628 1708
 		// BBC?
1629
-		if (!empty($row['bbc']))
1630
-			$row['value'] = parse_bbc($row['value']);
1709
+		if (!empty($row['bbc'])) {
1710
+					$row['value'] = parse_bbc($row['value']);
1711
+		}
1631 1712
 
1632 1713
 		// ... or checkbox?
1633
-		elseif (isset($row['type']) && $row['type'] == 'check')
1634
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1714
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1715
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1716
+		}
1635 1717
 
1636 1718
 		// Enclosing the user input within some other text?
1637
-		if (!empty($row['enclose']))
1638
-			$row['value'] = strtr($row['enclose'], array(
1719
+		if (!empty($row['enclose'])) {
1720
+					$row['value'] = strtr($row['enclose'], array(
1639 1721
 				'{SCRIPTURL}' => $scripturl,
1640 1722
 				'{IMAGES_URL}' => $settings['images_url'],
1641 1723
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1642 1724
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1643 1725
 				'{KEY}' => $currentKey,
1644 1726
 			));
1727
+		}
1645 1728
 
1646 1729
 		// Send a simple array if there is just 1 param
1647
-		if (count($params) == 1)
1648
-			$return[$row['id_member']] = $row;
1730
+		if (count($params) == 1) {
1731
+					$return[$row['id_member']] = $row;
1732
+		}
1649 1733
 
1650 1734
 		// More than 1? knock yourself out...
1651 1735
 		else
1652 1736
 		{
1653
-			if (!isset($return[$row['id_member']]))
1654
-				$return[$row['id_member']] = array();
1737
+			if (!isset($return[$row['id_member']])) {
1738
+							$return[$row['id_member']] = array();
1739
+			}
1655 1740
 
1656 1741
 			$return[$row['id_member']][$row['variable']] = $row;
1657 1742
 		}
@@ -1685,8 +1770,9 @@  discard block
 block discarded – undo
1685 1770
 	global $context;
1686 1771
 
1687 1772
 	// Don't know any browser!
1688
-	if (empty($context['browser']))
1689
-		detectBrowser();
1773
+	if (empty($context['browser'])) {
1774
+			detectBrowser();
1775
+	}
1690 1776
 
1691 1777
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1692 1778
 }
@@ -1704,8 +1790,9 @@  discard block
 block discarded – undo
1704 1790
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1705 1791
 
1706 1792
 	// The theme was specified by parameter.
1707
-	if (!empty($id_theme))
1708
-		$id_theme = (int) $id_theme;
1793
+	if (!empty($id_theme)) {
1794
+			$id_theme = (int) $id_theme;
1795
+	}
1709 1796
 	// The theme was specified by REQUEST.
1710 1797
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1711 1798
 	{
@@ -1713,54 +1800,61 @@  discard block
 block discarded – undo
1713 1800
 		$_SESSION['id_theme'] = $id_theme;
1714 1801
 	}
1715 1802
 	// The theme was specified by REQUEST... previously.
1716
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1717
-		$id_theme = (int) $_SESSION['id_theme'];
1803
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1804
+			$id_theme = (int) $_SESSION['id_theme'];
1805
+	}
1718 1806
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1719
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1720
-		$id_theme = $user_info['theme'];
1807
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1808
+			$id_theme = $user_info['theme'];
1809
+	}
1721 1810
 	// The theme was specified by the board.
1722
-	elseif (!empty($board_info['theme']))
1723
-		$id_theme = $board_info['theme'];
1811
+	elseif (!empty($board_info['theme'])) {
1812
+			$id_theme = $board_info['theme'];
1813
+	}
1724 1814
 	// The theme is the forum's default.
1725
-	else
1726
-		$id_theme = $modSettings['theme_guests'];
1815
+	else {
1816
+			$id_theme = $modSettings['theme_guests'];
1817
+	}
1727 1818
 
1728 1819
 	// We already load the basic stuff?
1729 1820
 	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme )
1730 1821
 	{
1731 1822
 		// Verify the id_theme... no foul play.
1732 1823
 		// Always allow the board specific theme, if they are overriding.
1733
-		if (!empty($board_info['theme']) && $board_info['override_theme'])
1734
-			$id_theme = $board_info['theme'];
1824
+		if (!empty($board_info['theme']) && $board_info['override_theme']) {
1825
+					$id_theme = $board_info['theme'];
1826
+		}
1735 1827
 		// If they have specified a particular theme to use with SSI allow it to be used.
1736
-		elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1737
-			$id_theme = (int) $id_theme;
1738
-		elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1828
+		elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1829
+					$id_theme = (int) $id_theme;
1830
+		} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1739 1831
 		{
1740 1832
 			$themes = explode(',', $modSettings['enableThemes']);
1741
-			if (!in_array($id_theme, $themes))
1742
-				$id_theme = $modSettings['theme_guests'];
1743
-			else
1744
-				$id_theme = (int) $id_theme;
1833
+			if (!in_array($id_theme, $themes)) {
1834
+							$id_theme = $modSettings['theme_guests'];
1835
+			} else {
1836
+							$id_theme = (int) $id_theme;
1837
+			}
1838
+		} else {
1839
+					$id_theme = (int) $id_theme;
1745 1840
 		}
1746
-		else
1747
-			$id_theme = (int) $id_theme;
1748 1841
 
1749 1842
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1750 1843
 
1751 1844
 		// Disable image proxy if we don't have SSL enabled
1752
-		if (empty($modSettings['force_ssl']))
1753
-			$image_proxy_enabled = false;
1845
+		if (empty($modSettings['force_ssl'])) {
1846
+					$image_proxy_enabled = false;
1847
+		}
1754 1848
 
1755 1849
 		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'])
1756 1850
 		{
1757 1851
 			$themeData = $temp;
1758 1852
 			$flag = true;
1853
+		} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1854
+					$themeData = $temp + array($member => array());
1855
+		} else {
1856
+					$themeData = array(-1 => array(), 0 => array(), $member => array());
1759 1857
 		}
1760
-		elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1761
-			$themeData = $temp + array($member => array());
1762
-		else
1763
-			$themeData = array(-1 => array(), 0 => array(), $member => array());
1764 1858
 
1765 1859
 		if (empty($flag))
1766 1860
 		{
@@ -1779,31 +1873,37 @@  discard block
 block discarded – undo
1779 1873
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1780 1874
 			{
1781 1875
 				// There are just things we shouldn't be able to change as members.
1782
-				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')))
1783
-					continue;
1876
+				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'))) {
1877
+									continue;
1878
+				}
1784 1879
 
1785 1880
 				// If this is the theme_dir of the default theme, store it.
1786
-				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1787
-					$themeData[0]['default_' . $row['variable']] = $row['value'];
1881
+				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1882
+									$themeData[0]['default_' . $row['variable']] = $row['value'];
1883
+				}
1788 1884
 
1789 1885
 				// If this isn't set yet, is a theme option, or is not the default theme..
1790
-				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1791
-					$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1886
+				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1887
+									$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1888
+				}
1792 1889
 			}
1793 1890
 			$smcFunc['db_free_result']($result);
1794 1891
 
1795
-			if (!empty($themeData[-1]))
1796
-				foreach ($themeData[-1] as $k => $v)
1892
+			if (!empty($themeData[-1])) {
1893
+							foreach ($themeData[-1] as $k => $v)
1797 1894
 				{
1798 1895
 					if (!isset($themeData[$member][$k]))
1799 1896
 						$themeData[$member][$k] = $v;
1897
+			}
1800 1898
 				}
1801 1899
 
1802
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1803
-				cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1900
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1901
+							cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1902
+			}
1804 1903
 			// Only if we didn't already load that part of the cache...
1805
-			elseif (!isset($temp))
1806
-				cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1904
+			elseif (!isset($temp)) {
1905
+							cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1906
+			}
1807 1907
 		}
1808 1908
 
1809 1909
 		$settings = $themeData[0];
@@ -1820,17 +1920,20 @@  discard block
 block discarded – undo
1820 1920
 		$settings['template_dirs'][] = $settings['theme_dir'];
1821 1921
 
1822 1922
 		// Based on theme (if there is one).
1823
-		if (!empty($settings['base_theme_dir']))
1824
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1923
+		if (!empty($settings['base_theme_dir'])) {
1924
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1925
+		}
1825 1926
 
1826 1927
 		// Lastly the default theme.
1827
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1828
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1928
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1929
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1930
+		}
1829 1931
 	}
1830 1932
 
1831 1933
 
1832
-	if (!$initialize)
1833
-		return;
1934
+	if (!$initialize) {
1935
+			return;
1936
+	}
1834 1937
 
1835 1938
 	// Check to see if we're forcing SSL
1836 1939
 	if (!empty($modSettings['force_ssl']) && empty($maintenance) &&
@@ -1851,8 +1954,9 @@  discard block
 block discarded – undo
1851 1954
 		$detected_url = httpsOn() ? 'https://' : 'http://';
1852 1955
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1853 1956
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1854
-		if ($temp != '/')
1855
-			$detected_url .= $temp;
1957
+		if ($temp != '/') {
1958
+					$detected_url .= $temp;
1959
+		}
1856 1960
 	}
1857 1961
 	if (isset($detected_url) && $detected_url != $boardurl)
1858 1962
 	{
@@ -1864,8 +1968,9 @@  discard block
 block discarded – undo
1864 1968
 			foreach ($aliases as $alias)
1865 1969
 			{
1866 1970
 				// Rip off all the boring parts, spaces, etc.
1867
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1868
-					$do_fix = true;
1971
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1972
+									$do_fix = true;
1973
+				}
1869 1974
 			}
1870 1975
 		}
1871 1976
 
@@ -1873,21 +1978,23 @@  discard block
 block discarded – undo
1873 1978
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1874 1979
 		{
1875 1980
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1876
-			if (empty($_GET))
1877
-				redirectexit('wwwRedirect');
1878
-			else
1981
+			if (empty($_GET)) {
1982
+							redirectexit('wwwRedirect');
1983
+			} else
1879 1984
 			{
1880 1985
 				$k = key($_GET);
1881 1986
 				$v = current($_GET);
1882 1987
 
1883
-				if ($k != 'wwwRedirect')
1884
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1988
+				if ($k != 'wwwRedirect') {
1989
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1990
+				}
1885 1991
 			}
1886 1992
 		}
1887 1993
 
1888 1994
 		// #3 is just a check for SSL...
1889
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1890
-			$do_fix = true;
1995
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1996
+					$do_fix = true;
1997
+		}
1891 1998
 
1892 1999
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1893 2000
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1922,8 +2029,9 @@  discard block
 block discarded – undo
1922 2029
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1923 2030
 				}
1924 2031
 			}
1925
-			foreach ($context['linktree'] as $k => $dummy)
1926
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2032
+			foreach ($context['linktree'] as $k => $dummy) {
2033
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2034
+			}
1927 2035
 		}
1928 2036
 	}
1929 2037
 	// Set up the contextual user array.
@@ -1942,16 +2050,16 @@  discard block
 block discarded – undo
1942 2050
 			'email' => $user_info['email'],
1943 2051
 			'ignoreusers' => $user_info['ignoreusers'],
1944 2052
 		);
1945
-		if (!$context['user']['is_guest'])
1946
-			$context['user']['name'] = $user_info['name'];
1947
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1948
-			$context['user']['name'] = $txt['guest_title'];
2053
+		if (!$context['user']['is_guest']) {
2054
+					$context['user']['name'] = $user_info['name'];
2055
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2056
+					$context['user']['name'] = $txt['guest_title'];
2057
+		}
1949 2058
 
1950 2059
 		// Determine the current smiley set.
1951 2060
 		$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'];
1952 2061
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1953
-	}
1954
-	else
2062
+	} else
1955 2063
 	{
1956 2064
 		// What to do when there is no $user_info (e.g., an error very early in the login process)
1957 2065
 		$context['user'] = array(
@@ -1985,18 +2093,24 @@  discard block
 block discarded – undo
1985 2093
 	}
1986 2094
 
1987 2095
 	// Some basic information...
1988
-	if (!isset($context['html_headers']))
1989
-		$context['html_headers'] = '';
1990
-	if (!isset($context['javascript_files']))
1991
-		$context['javascript_files'] = array();
1992
-	if (!isset($context['css_files']))
1993
-		$context['css_files'] = array();
1994
-	if (!isset($context['css_header']))
1995
-		$context['css_header'] = array();
1996
-	if (!isset($context['javascript_inline']))
1997
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1998
-	if (!isset($context['javascript_vars']))
1999
-		$context['javascript_vars'] = array();
2096
+	if (!isset($context['html_headers'])) {
2097
+			$context['html_headers'] = '';
2098
+	}
2099
+	if (!isset($context['javascript_files'])) {
2100
+			$context['javascript_files'] = array();
2101
+	}
2102
+	if (!isset($context['css_files'])) {
2103
+			$context['css_files'] = array();
2104
+	}
2105
+	if (!isset($context['css_header'])) {
2106
+			$context['css_header'] = array();
2107
+	}
2108
+	if (!isset($context['javascript_inline'])) {
2109
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2110
+	}
2111
+	if (!isset($context['javascript_vars'])) {
2112
+			$context['javascript_vars'] = array();
2113
+	}
2000 2114
 
2001 2115
 	$context['login_url'] =  $scripturl . '?action=login2';
2002 2116
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -2008,16 +2122,18 @@  discard block
 block discarded – undo
2008 2122
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
2009 2123
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
2010 2124
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
2011
-	if (isset($modSettings['load_average']))
2012
-		$context['load_average'] = $modSettings['load_average'];
2125
+	if (isset($modSettings['load_average'])) {
2126
+			$context['load_average'] = $modSettings['load_average'];
2127
+	}
2013 2128
 
2014 2129
 	// Detect the browser. This is separated out because it's also used in attachment downloads
2015 2130
 	detectBrowser();
2016 2131
 
2017 2132
 	// Set the top level linktree up.
2018 2133
 	// Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet...
2019
-	if (empty($context['linktree']))
2020
-		$context['linktree'] = array();
2134
+	if (empty($context['linktree'])) {
2135
+			$context['linktree'] = array();
2136
+	}
2021 2137
 	array_unshift($context['linktree'], array(
2022 2138
 		'url' => $scripturl,
2023 2139
 		'name' => $context['forum_name_html_safe']
@@ -2026,8 +2142,9 @@  discard block
 block discarded – undo
2026 2142
 	// This allows sticking some HTML on the page output - useful for controls.
2027 2143
 	$context['insert_after_template'] = '';
2028 2144
 
2029
-	if (!isset($txt))
2030
-		$txt = array();
2145
+	if (!isset($txt)) {
2146
+			$txt = array();
2147
+	}
2031 2148
 
2032 2149
 	$simpleActions = array(
2033 2150
 		'findmember',
@@ -2073,9 +2190,10 @@  discard block
 block discarded – undo
2073 2190
 
2074 2191
 	// See if theres any extra param to check.
2075 2192
 	$requiresXML = false;
2076
-	foreach ($extraParams as $key => $extra)
2077
-		if (isset($_REQUEST[$extra]))
2193
+	foreach ($extraParams as $key => $extra) {
2194
+			if (isset($_REQUEST[$extra]))
2078 2195
 			$requiresXML = true;
2196
+	}
2079 2197
 
2080 2198
 	// Output is fully XML, so no need for the index template.
2081 2199
 	if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML))
@@ -2090,37 +2208,39 @@  discard block
 block discarded – undo
2090 2208
 	{
2091 2209
 		loadLanguage('index+Modifications');
2092 2210
 		$context['template_layers'] = array();
2093
-	}
2094
-
2095
-	else
2211
+	} else
2096 2212
 	{
2097 2213
 		// Custom templates to load, or just default?
2098
-		if (isset($settings['theme_templates']))
2099
-			$templates = explode(',', $settings['theme_templates']);
2100
-		else
2101
-			$templates = array('index');
2214
+		if (isset($settings['theme_templates'])) {
2215
+					$templates = explode(',', $settings['theme_templates']);
2216
+		} else {
2217
+					$templates = array('index');
2218
+		}
2102 2219
 
2103 2220
 		// Load each template...
2104
-		foreach ($templates as $template)
2105
-			loadTemplate($template);
2221
+		foreach ($templates as $template) {
2222
+					loadTemplate($template);
2223
+		}
2106 2224
 
2107 2225
 		// ...and attempt to load their associated language files.
2108 2226
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2109 2227
 		loadLanguage($required_files, '', false);
2110 2228
 
2111 2229
 		// Custom template layers?
2112
-		if (isset($settings['theme_layers']))
2113
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2114
-		else
2115
-			$context['template_layers'] = array('html', 'body');
2230
+		if (isset($settings['theme_layers'])) {
2231
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2232
+		} else {
2233
+					$context['template_layers'] = array('html', 'body');
2234
+		}
2116 2235
 	}
2117 2236
 
2118 2237
 	// Initialize the theme.
2119 2238
 	loadSubTemplate('init', 'ignore');
2120 2239
 
2121 2240
 	// Allow overriding the board wide time/number formats.
2122
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2123
-		$user_info['time_format'] = $txt['time_format'];
2241
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2242
+			$user_info['time_format'] = $txt['time_format'];
2243
+	}
2124 2244
 
2125 2245
 	// Set the character set from the template.
2126 2246
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2128,12 +2248,14 @@  discard block
 block discarded – undo
2128 2248
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2129 2249
 
2130 2250
 	// Guests may still need a name.
2131
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2132
-		$context['user']['name'] = $txt['guest_title'];
2251
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2252
+			$context['user']['name'] = $txt['guest_title'];
2253
+	}
2133 2254
 
2134 2255
 	// Any theme-related strings that need to be loaded?
2135
-	if (!empty($settings['require_theme_strings']))
2136
-		loadLanguage('ThemeStrings', '', false);
2256
+	if (!empty($settings['require_theme_strings'])) {
2257
+			loadLanguage('ThemeStrings', '', false);
2258
+	}
2137 2259
 
2138 2260
 	// Make a special URL for the language.
2139 2261
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2144,8 +2266,9 @@  discard block
 block discarded – undo
2144 2266
 	// Here is my luvly Responsive CSS
2145 2267
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive');
2146 2268
 
2147
-	if ($context['right_to_left'])
2148
-		loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2269
+	if ($context['right_to_left']) {
2270
+			loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2271
+	}
2149 2272
 
2150 2273
 	// We allow theme variants, because we're cool.
2151 2274
 	$context['theme_variant'] = '';
@@ -2153,14 +2276,17 @@  discard block
 block discarded – undo
2153 2276
 	if (!empty($settings['theme_variants']))
2154 2277
 	{
2155 2278
 		// Overriding - for previews and that ilk.
2156
-		if (!empty($_REQUEST['variant']))
2157
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2279
+		if (!empty($_REQUEST['variant'])) {
2280
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2281
+		}
2158 2282
 		// User selection?
2159
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2160
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2283
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2284
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2285
+		}
2161 2286
 		// If not a user variant, select the default.
2162
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2163
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2287
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2288
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2289
+		}
2164 2290
 
2165 2291
 		// Do this to keep things easier in the templates.
2166 2292
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2169,20 +2295,23 @@  discard block
 block discarded – undo
2169 2295
 		if (!empty($context['theme_variant']))
2170 2296
 		{
2171 2297
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']);
2172
-			if ($context['right_to_left'])
2173
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2298
+			if ($context['right_to_left']) {
2299
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2300
+			}
2174 2301
 		}
2175 2302
 	}
2176 2303
 
2177 2304
 	// Let's be compatible with old themes!
2178
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2179
-		$context['template_layers'] = array('main');
2305
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2306
+			$context['template_layers'] = array('main');
2307
+	}
2180 2308
 
2181 2309
 	$context['tabindex'] = 1;
2182 2310
 
2183 2311
 	// Compatibility.
2184
-	if (!isset($settings['theme_version']))
2185
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2312
+	if (!isset($settings['theme_version'])) {
2313
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2314
+	}
2186 2315
 
2187 2316
 	// Default JS variables for use in every theme
2188 2317
 	$context['javascript_vars'] = array(
@@ -2201,18 +2330,18 @@  discard block
 block discarded – undo
2201 2330
 	);
2202 2331
 
2203 2332
 	// Add the JQuery library to the list of files to load.
2204
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2205
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2206
-
2207
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2208
-		loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2209
-
2210
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2211
-		loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2333
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2334
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2335
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2336
+			loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2337
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2338
+			loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2339
+	}
2212 2340
 
2213 2341
 	// Auto loading? template_javascript() will take care of the local half of this.
2214
-	else
2215
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2342
+	else {
2343
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2344
+	}
2216 2345
 
2217 2346
 	// Queue our JQuery plugins!
2218 2347
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2235,12 +2364,12 @@  discard block
 block discarded – undo
2235 2364
 			require_once($sourcedir . '/ScheduledTasks.php');
2236 2365
 
2237 2366
 			// What to do, what to do?!
2238
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2239
-				AutoTask();
2240
-			else
2241
-				ReduceMailQueue();
2242
-		}
2243
-		else
2367
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2368
+							AutoTask();
2369
+			} else {
2370
+							ReduceMailQueue();
2371
+			}
2372
+		} else
2244 2373
 		{
2245 2374
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2246 2375
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2291,8 +2420,9 @@  discard block
 block discarded – undo
2291 2420
 		foreach ($theme_includes as $include)
2292 2421
 		{
2293 2422
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2294
-			if (file_exists($include))
2295
-				require_once($include);
2423
+			if (file_exists($include)) {
2424
+							require_once($include);
2425
+			}
2296 2426
 		}
2297 2427
 	}
2298 2428
 
@@ -2322,16 +2452,19 @@  discard block
 block discarded – undo
2322 2452
 	// Do any style sheets first, cause we're easy with those.
2323 2453
 	if (!empty($style_sheets))
2324 2454
 	{
2325
-		if (!is_array($style_sheets))
2326
-			$style_sheets = array($style_sheets);
2455
+		if (!is_array($style_sheets)) {
2456
+					$style_sheets = array($style_sheets);
2457
+		}
2327 2458
 
2328
-		foreach ($style_sheets as $sheet)
2329
-			loadCSSFile($sheet . '.css', array(), $sheet);
2459
+		foreach ($style_sheets as $sheet) {
2460
+					loadCSSFile($sheet . '.css', array(), $sheet);
2461
+		}
2330 2462
 	}
2331 2463
 
2332 2464
 	// No template to load?
2333
-	if ($template_name === false)
2334
-		return true;
2465
+	if ($template_name === false) {
2466
+			return true;
2467
+	}
2335 2468
 
2336 2469
 	$loaded = false;
2337 2470
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2346,12 +2479,14 @@  discard block
 block discarded – undo
2346 2479
 
2347 2480
 	if ($loaded)
2348 2481
 	{
2349
-		if ($db_show_debug === true)
2350
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2482
+		if ($db_show_debug === true) {
2483
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2484
+		}
2351 2485
 
2352 2486
 		// If they have specified an initialization function for this template, go ahead and call it now.
2353
-		if (function_exists('template_' . $template_name . '_init'))
2354
-			call_user_func('template_' . $template_name . '_init');
2487
+		if (function_exists('template_' . $template_name . '_init')) {
2488
+					call_user_func('template_' . $template_name . '_init');
2489
+		}
2355 2490
 	}
2356 2491
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2357 2492
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2371,13 +2506,14 @@  discard block
 block discarded – undo
2371 2506
 		loadTemplate($template_name);
2372 2507
 	}
2373 2508
 	// Cause an error otherwise.
2374
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2375
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2376
-	elseif ($fatal)
2377
-		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'));
2378
-	else
2379
-		return false;
2380
-}
2509
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2510
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2511
+	} elseif ($fatal) {
2512
+			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'));
2513
+	} else {
2514
+			return false;
2515
+	}
2516
+	}
2381 2517
 
2382 2518
 /**
2383 2519
  * Load a sub-template.
@@ -2395,17 +2531,19 @@  discard block
 block discarded – undo
2395 2531
 {
2396 2532
 	global $context, $txt, $db_show_debug;
2397 2533
 
2398
-	if ($db_show_debug === true)
2399
-		$context['debug']['sub_templates'][] = $sub_template_name;
2534
+	if ($db_show_debug === true) {
2535
+			$context['debug']['sub_templates'][] = $sub_template_name;
2536
+	}
2400 2537
 
2401 2538
 	// Figure out what the template function is named.
2402 2539
 	$theme_function = 'template_' . $sub_template_name;
2403
-	if (function_exists($theme_function))
2404
-		$theme_function();
2405
-	elseif ($fatal === false)
2406
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2407
-	elseif ($fatal !== 'ignore')
2408
-		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'));
2540
+	if (function_exists($theme_function)) {
2541
+			$theme_function();
2542
+	} elseif ($fatal === false) {
2543
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2544
+	} elseif ($fatal !== 'ignore') {
2545
+			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'));
2546
+	}
2409 2547
 
2410 2548
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2411 2549
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2435,8 +2573,9 @@  discard block
 block discarded – undo
2435 2573
 {
2436 2574
 	global $settings, $context, $modSettings;
2437 2575
 	
2438
-	if (empty($context['css_files_order'])) 
2439
-		$context['css_files_order'] = array();
2576
+	if (empty($context['css_files_order'])) {
2577
+			$context['css_files_order'] = array();
2578
+	}
2440 2579
 
2441 2580
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : '');
2442 2581
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
@@ -2447,8 +2586,9 @@  discard block
 block discarded – undo
2447 2586
 	$params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000;
2448 2587
 
2449 2588
 	// If this is an external file, automatically set this to false.
2450
-	if (!empty($params['external']))
2451
-		$params['minimize'] = false;
2589
+	if (!empty($params['external'])) {
2590
+			$params['minimize'] = false;
2591
+	}
2452 2592
 
2453 2593
 	// Account for shorthand like admin.css?alp21 filenames
2454 2594
 	$has_seed = strpos($fileName, '.css?');
@@ -2465,13 +2605,10 @@  discard block
 block discarded – undo
2465 2605
 			{
2466 2606
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2467 2607
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2608
+			} else {
2609
+							$fileUrl = false;
2468 2610
 			}
2469
-
2470
-			else
2471
-				$fileUrl = false;
2472
-		}
2473
-
2474
-		else
2611
+		} else
2475 2612
 		{
2476 2613
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2477 2614
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2489,16 +2626,18 @@  discard block
 block discarded – undo
2489 2626
 	if (!empty($fileName))
2490 2627
 	{
2491 2628
 		// find a free number/position
2492
-		while (isset($context['css_files_order'][$params['order_pos']]))
2493
-			$params['order_pos']++;
2629
+		while (isset($context['css_files_order'][$params['order_pos']])) {
2630
+					$params['order_pos']++;
2631
+		}
2494 2632
 		$context['css_files_order'][$params['order_pos']] = $id;
2495 2633
 
2496 2634
 		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2497 2635
 	}
2498 2636
 
2499
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2500
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2501
-}
2637
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2638
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2639
+	}
2640
+	}
2502 2641
 
2503 2642
 /**
2504 2643
  * Add a block of inline css code to be executed later
@@ -2515,8 +2654,9 @@  discard block
 block discarded – undo
2515 2654
 	global $context;
2516 2655
 
2517 2656
 	// Gotta add something...
2518
-	if (empty($css))
2519
-		return false;
2657
+	if (empty($css)) {
2658
+			return false;
2659
+	}
2520 2660
 
2521 2661
 	$context['css_header'][] = $css;
2522 2662
 }
@@ -2551,8 +2691,9 @@  discard block
 block discarded – undo
2551 2691
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2552 2692
 
2553 2693
 	// If this is an external file, automatically set this to false.
2554
-	if (!empty($params['external']))
2555
-		$params['minimize'] = false;
2694
+	if (!empty($params['external'])) {
2695
+			$params['minimize'] = false;
2696
+	}
2556 2697
 
2557 2698
 	// Account for shorthand like admin.js?alp21 filenames
2558 2699
 	$has_seed = strpos($fileName, '.js?');
@@ -2569,16 +2710,12 @@  discard block
 block discarded – undo
2569 2710
 			{
2570 2711
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2571 2712
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2572
-			}
2573
-
2574
-			else
2713
+			} else
2575 2714
 			{
2576 2715
 				$fileUrl = false;
2577 2716
 				$filePath = false;
2578 2717
 			}
2579
-		}
2580
-
2581
-		else
2718
+		} else
2582 2719
 		{
2583 2720
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2584 2721
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2593,9 +2730,10 @@  discard block
 block discarded – undo
2593 2730
 	}
2594 2731
 
2595 2732
 	// Add it to the array for use in the template
2596
-	if (!empty($fileName))
2597
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2598
-}
2733
+	if (!empty($fileName)) {
2734
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2735
+	}
2736
+	}
2599 2737
 
2600 2738
 /**
2601 2739
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2609,9 +2747,10 @@  discard block
 block discarded – undo
2609 2747
 {
2610 2748
 	global $context;
2611 2749
 
2612
-	if (!empty($key) && (!empty($value) || $value === '0'))
2613
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2614
-}
2750
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2751
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2752
+	}
2753
+	}
2615 2754
 
2616 2755
 /**
2617 2756
  * Add a block of inline Javascript code to be executed later
@@ -2628,8 +2767,9 @@  discard block
 block discarded – undo
2628 2767
 {
2629 2768
 	global $context;
2630 2769
 
2631
-	if (empty($javascript))
2632
-		return false;
2770
+	if (empty($javascript)) {
2771
+			return false;
2772
+	}
2633 2773
 
2634 2774
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2635 2775
 }
@@ -2650,15 +2790,18 @@  discard block
 block discarded – undo
2650 2790
 	static $already_loaded = array();
2651 2791
 
2652 2792
 	// Default to the user's language.
2653
-	if ($lang == '')
2654
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2793
+	if ($lang == '') {
2794
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2795
+	}
2655 2796
 
2656 2797
 	// Do we want the English version of language file as fallback?
2657
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2658
-		loadLanguage($template_name, 'english', false);
2798
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2799
+			loadLanguage($template_name, 'english', false);
2800
+	}
2659 2801
 
2660
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2661
-		return $lang;
2802
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2803
+			return $lang;
2804
+	}
2662 2805
 
2663 2806
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2664 2807
 	if (empty($settings['default_theme_dir']))
@@ -2669,8 +2812,9 @@  discard block
 block discarded – undo
2669 2812
 
2670 2813
 	// What theme are we in?
2671 2814
 	$theme_name = basename($settings['theme_url']);
2672
-	if (empty($theme_name))
2673
-		$theme_name = 'unknown';
2815
+	if (empty($theme_name)) {
2816
+			$theme_name = 'unknown';
2817
+	}
2674 2818
 
2675 2819
 	// For each file open it up and write it out!
2676 2820
 	foreach (explode('+', $template_name) as $template)
@@ -2712,8 +2856,9 @@  discard block
 block discarded – undo
2712 2856
 				$found = true;
2713 2857
 
2714 2858
 				// setlocale is required for basename() & pathinfo() to work properly on the selected language
2715
-				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set']))
2716
-					setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2859
+				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) {
2860
+									setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2861
+				}
2717 2862
 
2718 2863
 				break;
2719 2864
 			}
@@ -2753,8 +2898,9 @@  discard block
 block discarded – undo
2753 2898
 	}
2754 2899
 
2755 2900
 	// Keep track of what we're up to soldier.
2756
-	if ($db_show_debug === true)
2757
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2901
+	if ($db_show_debug === true) {
2902
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2903
+	}
2758 2904
 
2759 2905
 	// Remember what we have loaded, and in which language.
2760 2906
 	$already_loaded[$template_name] = $lang;
@@ -2800,8 +2946,9 @@  discard block
 block discarded – undo
2800 2946
 				)
2801 2947
 			);
2802 2948
 			// In the EXTREMELY unlikely event this happens, give an error message.
2803
-			if ($smcFunc['db_num_rows']($result) == 0)
2804
-				fatal_lang_error('parent_not_found', 'critical');
2949
+			if ($smcFunc['db_num_rows']($result) == 0) {
2950
+							fatal_lang_error('parent_not_found', 'critical');
2951
+			}
2805 2952
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2806 2953
 			{
2807 2954
 				if (!isset($boards[$row['id_board']]))
@@ -2818,8 +2965,8 @@  discard block
 block discarded – undo
2818 2965
 					);
2819 2966
 				}
2820 2967
 				// If a moderator exists for this board, add that moderator for all children too.
2821
-				if (!empty($row['id_moderator']))
2822
-					foreach ($boards as $id => $dummy)
2968
+				if (!empty($row['id_moderator'])) {
2969
+									foreach ($boards as $id => $dummy)
2823 2970
 					{
2824 2971
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2825 2972
 							'id' => $row['id_moderator'],
@@ -2827,11 +2974,12 @@  discard block
 block discarded – undo
2827 2974
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2828 2975
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2829 2976
 						);
2977
+				}
2830 2978
 					}
2831 2979
 
2832 2980
 				// If a moderator group exists for this board, add that moderator group for all children too
2833
-				if (!empty($row['id_moderator_group']))
2834
-					foreach ($boards as $id => $dummy)
2981
+				if (!empty($row['id_moderator_group'])) {
2982
+									foreach ($boards as $id => $dummy)
2835 2983
 					{
2836 2984
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2837 2985
 							'id' => $row['id_moderator_group'],
@@ -2839,6 +2987,7 @@  discard block
 block discarded – undo
2839 2987
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2840 2988
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2841 2989
 						);
2990
+				}
2842 2991
 					}
2843 2992
 			}
2844 2993
 			$smcFunc['db_free_result']($result);
@@ -2865,23 +3014,27 @@  discard block
 block discarded – undo
2865 3014
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2866 3015
 	{
2867 3016
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2868
-		if (empty($smcFunc['ucwords']))
2869
-			reloadSettings();
3017
+		if (empty($smcFunc['ucwords'])) {
3018
+					reloadSettings();
3019
+		}
2870 3020
 
2871 3021
 		// If we don't have our theme information yet, let's get it.
2872
-		if (empty($settings['default_theme_dir']))
2873
-			loadTheme(0, false);
3022
+		if (empty($settings['default_theme_dir'])) {
3023
+					loadTheme(0, false);
3024
+		}
2874 3025
 
2875 3026
 		// Default language directories to try.
2876 3027
 		$language_directories = array(
2877 3028
 			$settings['default_theme_dir'] . '/languages',
2878 3029
 		);
2879
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2880
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3030
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
3031
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3032
+		}
2881 3033
 
2882 3034
 		// We possibly have a base theme directory.
2883
-		if (!empty($settings['base_theme_dir']))
2884
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
3035
+		if (!empty($settings['base_theme_dir'])) {
3036
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
3037
+		}
2885 3038
 
2886 3039
 		// Remove any duplicates.
2887 3040
 		$language_directories = array_unique($language_directories);
@@ -2895,20 +3048,21 @@  discard block
 block discarded – undo
2895 3048
 		foreach ($language_directories as $language_dir)
2896 3049
 		{
2897 3050
 			// Can't look in here... doesn't exist!
2898
-			if (!file_exists($language_dir))
2899
-				continue;
3051
+			if (!file_exists($language_dir)) {
3052
+							continue;
3053
+			}
2900 3054
 
2901 3055
 			$dir = dir($language_dir);
2902 3056
 			while ($entry = $dir->read())
2903 3057
 			{
2904 3058
 				// Look for the index language file... For good measure skip any "index.language-utf8.php" files
2905
-				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches))
2906
-					continue;
2907
-
2908
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2909
-					$langName = $langList[$matches[1]];
3059
+				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) {
3060
+									continue;
3061
+				}
2910 3062
 
2911
-				else
3063
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
3064
+									$langName = $langList[$matches[1]];
3065
+				} else
2912 3066
 				{
2913 3067
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2914 3068
 
@@ -2949,12 +3103,14 @@  discard block
 block discarded – undo
2949 3103
 		}
2950 3104
 
2951 3105
 		// Do we need to store the lang list?
2952
-		if (empty($langList))
2953
-			updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3106
+		if (empty($langList)) {
3107
+					updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3108
+		}
2954 3109
 
2955 3110
 		// Let's cash in on this deal.
2956
-		if (!empty($modSettings['cache_enable']))
2957
-			cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3111
+		if (!empty($modSettings['cache_enable'])) {
3112
+					cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3113
+		}
2958 3114
 	}
2959 3115
 
2960 3116
 	return $context['languages'];
@@ -2977,8 +3133,9 @@  discard block
 block discarded – undo
2977 3133
 	global $modSettings, $options, $txt;
2978 3134
 	static $censor_vulgar = null, $censor_proper;
2979 3135
 
2980
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2981
-		return $text;
3136
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3137
+			return $text;
3138
+	}
2982 3139
 
2983 3140
 	// If they haven't yet been loaded, load them.
2984 3141
 	if ($censor_vulgar == null)
@@ -3009,9 +3166,9 @@  discard block
 block discarded – undo
3009 3166
 	{
3010 3167
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
3011 3168
 		$text = $func($censor_vulgar, $censor_proper, $text);
3169
+	} else {
3170
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
3012 3171
 	}
3013
-	else
3014
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
3015 3172
 
3016 3173
 	return $text;
3017 3174
 }
@@ -3037,38 +3194,42 @@  discard block
 block discarded – undo
3037 3194
 	@ini_set('track_errors', '1');
3038 3195
 
3039 3196
 	// Don't include the file more than once, if $once is true.
3040
-	if ($once && in_array($filename, $templates))
3041
-		return;
3197
+	if ($once && in_array($filename, $templates)) {
3198
+			return;
3199
+	}
3042 3200
 	// Add this file to the include list, whether $once is true or not.
3043
-	else
3044
-		$templates[] = $filename;
3201
+	else {
3202
+			$templates[] = $filename;
3203
+	}
3045 3204
 
3046 3205
 	// Are we going to use eval?
3047 3206
 	if (empty($modSettings['disableTemplateEval']))
3048 3207
 	{
3049 3208
 		$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
3050 3209
 		$settings['current_include_filename'] = $filename;
3051
-	}
3052
-	else
3210
+	} else
3053 3211
 	{
3054 3212
 		$file_found = file_exists($filename);
3055 3213
 
3056
-		if ($once && $file_found)
3057
-			require_once($filename);
3058
-		elseif ($file_found)
3059
-			require($filename);
3214
+		if ($once && $file_found) {
3215
+					require_once($filename);
3216
+		} elseif ($file_found) {
3217
+					require($filename);
3218
+		}
3060 3219
 	}
3061 3220
 
3062 3221
 	if ($file_found !== true)
3063 3222
 	{
3064 3223
 		ob_end_clean();
3065
-		if (!empty($modSettings['enableCompressedOutput']))
3066
-			@ob_start('ob_gzhandler');
3067
-		else
3068
-			ob_start();
3224
+		if (!empty($modSettings['enableCompressedOutput'])) {
3225
+					@ob_start('ob_gzhandler');
3226
+		} else {
3227
+					ob_start();
3228
+		}
3069 3229
 
3070
-		if (isset($_GET['debug']))
3071
-			header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3230
+		if (isset($_GET['debug'])) {
3231
+					header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3232
+		}
3072 3233
 
3073 3234
 		// Don't cache error pages!!
3074 3235
 		header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -3087,12 +3248,13 @@  discard block
 block discarded – undo
3087 3248
 		echo '<!DOCTYPE html>
3088 3249
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
3089 3250
 	<head>';
3090
-		if (isset($context['character_set']))
3091
-			echo '
3251
+		if (isset($context['character_set'])) {
3252
+					echo '
3092 3253
 		<meta charset="', $context['character_set'], '">';
3254
+		}
3093 3255
 
3094
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3095
-			echo '
3256
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3257
+					echo '
3096 3258
 		<title>', $mtitle, '</title>
3097 3259
 	</head>
3098 3260
 	<body>
@@ -3100,8 +3262,8 @@  discard block
 block discarded – undo
3100 3262
 		', $mmessage, '
3101 3263
 	</body>
3102 3264
 </html>';
3103
-		elseif (!allowedTo('admin_forum'))
3104
-			echo '
3265
+		} elseif (!allowedTo('admin_forum')) {
3266
+					echo '
3105 3267
 		<title>', $txt['template_parse_error'], '</title>
3106 3268
 	</head>
3107 3269
 	<body>
@@ -3109,16 +3271,18 @@  discard block
 block discarded – undo
3109 3271
 		', $txt['template_parse_error_message'], '
3110 3272
 	</body>
3111 3273
 </html>';
3112
-		else
3274
+		} else
3113 3275
 		{
3114 3276
 			require_once($sourcedir . '/Subs-Package.php');
3115 3277
 
3116 3278
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3117 3279
 			$error_array = error_get_last();
3118
-			if (empty($error) && ini_get('track_errors') && !empty($error_array))
3119
-				$error = $error_array['message'];
3120
-			if (empty($error))
3121
-				$error = $txt['template_parse_errmsg'];
3280
+			if (empty($error) && ini_get('track_errors') && !empty($error_array)) {
3281
+							$error = $error_array['message'];
3282
+			}
3283
+			if (empty($error)) {
3284
+							$error = $txt['template_parse_errmsg'];
3285
+			}
3122 3286
 
3123 3287
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3124 3288
 
@@ -3129,11 +3293,12 @@  discard block
 block discarded – undo
3129 3293
 		<h3>', $txt['template_parse_error'], '</h3>
3130 3294
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3131 3295
 
3132
-			if (!empty($error))
3133
-				echo '
3296
+			if (!empty($error)) {
3297
+							echo '
3134 3298
 		<hr>
3135 3299
 
3136 3300
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3301
+			}
3137 3302
 
3138 3303
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3139 3304
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3143,10 +3308,11 @@  discard block
 block discarded – undo
3143 3308
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3144 3309
 
3145 3310
 				// Fix the PHP code stuff...
3146
-				if (!isBrowser('gecko'))
3147
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3148
-				else
3149
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3311
+				if (!isBrowser('gecko')) {
3312
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3313
+				} else {
3314
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3315
+				}
3150 3316
 
3151 3317
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3152 3318
 				$j = -1;
@@ -3154,8 +3320,9 @@  discard block
 block discarded – undo
3154 3320
 				{
3155 3321
 					$j++;
3156 3322
 
3157
-					if (substr_count($line, '<br>') == 0)
3158
-						continue;
3323
+					if (substr_count($line, '<br>') == 0) {
3324
+											continue;
3325
+					}
3159 3326
 
3160 3327
 					$n = substr_count($line, '<br>');
3161 3328
 					for ($i = 0; $i < $n; $i++)
@@ -3174,38 +3341,42 @@  discard block
 block discarded – undo
3174 3341
 				// Figure out what the color coding was before...
3175 3342
 				$line = max($match[1] - 9, 1);
3176 3343
 				$last_line = '';
3177
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3178
-					if (strpos($data2[$line2], '<') !== false)
3344
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3345
+									if (strpos($data2[$line2], '<') !== false)
3179 3346
 					{
3180 3347
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3181 3348
 							$last_line = $color_match[1];
3349
+				}
3182 3350
 						break;
3183 3351
 					}
3184 3352
 
3185 3353
 				// Show the relevant lines...
3186 3354
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3187 3355
 				{
3188
-					if ($line == $match[1])
3189
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3356
+					if ($line == $match[1]) {
3357
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3358
+					}
3190 3359
 
3191 3360
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3192
-					if (isset($data2[$line]) && $data2[$line] != '')
3193
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3361
+					if (isset($data2[$line]) && $data2[$line] != '') {
3362
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3363
+					}
3194 3364
 
3195 3365
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3196 3366
 					{
3197 3367
 						$last_line = $color_match[1];
3198 3368
 						echo '</', substr($last_line, 1, 4), '>';
3369
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3370
+											$last_line = '';
3371
+					} elseif ($last_line != '' && $data2[$line] != '') {
3372
+											echo '</', substr($last_line, 1, 4), '>';
3199 3373
 					}
3200
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3201
-						$last_line = '';
3202
-					elseif ($last_line != '' && $data2[$line] != '')
3203
-						echo '</', substr($last_line, 1, 4), '>';
3204 3374
 
3205
-					if ($line == $match[1])
3206
-						echo '</pre></div><pre style="margin: 0;">';
3207
-					else
3208
-						echo "\n";
3375
+					if ($line == $match[1]) {
3376
+											echo '</pre></div><pre style="margin: 0;">';
3377
+					} else {
3378
+											echo "\n";
3379
+					}
3209 3380
 				}
3210 3381
 
3211 3382
 				echo '</pre></div>';
@@ -3229,8 +3400,9 @@  discard block
 block discarded – undo
3229 3400
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port;
3230 3401
 
3231 3402
 	// Figure out what type of database we are using.
3232
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3233
-		$db_type = 'mysql';
3403
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3404
+			$db_type = 'mysql';
3405
+	}
3234 3406
 
3235 3407
 	// Load the file for the database.
3236 3408
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3238,8 +3410,9 @@  discard block
 block discarded – undo
3238 3410
 	$db_options = array();
3239 3411
 
3240 3412
 	// Add in the port if needed
3241
-	if (!empty($db_port))
3242
-		$db_options['port'] = $db_port;
3413
+	if (!empty($db_port)) {
3414
+			$db_options['port'] = $db_port;
3415
+	}
3243 3416
 
3244 3417
 	// 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.
3245 3418
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3258,13 +3431,15 @@  discard block
 block discarded – undo
3258 3431
 	}
3259 3432
 
3260 3433
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3261
-	if (!$db_connection)
3262
-		display_db_error();
3434
+	if (!$db_connection) {
3435
+			display_db_error();
3436
+	}
3263 3437
 
3264 3438
 	// If in SSI mode fix up the prefix.
3265
-	if (SMF == 'SSI')
3266
-		db_fix_prefix($db_prefix, $db_name);
3267
-}
3439
+	if (SMF == 'SSI') {
3440
+			db_fix_prefix($db_prefix, $db_name);
3441
+	}
3442
+	}
3268 3443
 
3269 3444
 /**
3270 3445
  * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it.
@@ -3278,10 +3453,11 @@  discard block
 block discarded – undo
3278 3453
 	global $sourcedir, $cacheAPI, $cache_accelerator;
3279 3454
 
3280 3455
 	// Not overriding this and we have a cacheAPI, send it back.
3281
-	if (empty($overrideCache) && is_object($cacheAPI))
3282
-		return $cacheAPI;
3283
-	elseif (is_null($cacheAPI))
3284
-		$cacheAPI = false;
3456
+	if (empty($overrideCache) && is_object($cacheAPI)) {
3457
+			return $cacheAPI;
3458
+	} elseif (is_null($cacheAPI)) {
3459
+			$cacheAPI = false;
3460
+	}
3285 3461
 
3286 3462
 	// Make sure our class is in session.
3287 3463
 	require_once($sourcedir . '/Class-CacheAPI.php');
@@ -3302,8 +3478,9 @@  discard block
 block discarded – undo
3302 3478
 		if (!$testAPI->isSupported())
3303 3479
 		{
3304 3480
 			// Can we save ourselves?
3305
-			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf')
3306
-				return loadCacheAccelerator(null, false);
3481
+			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') {
3482
+							return loadCacheAccelerator(null, false);
3483
+			}
3307 3484
 			return false;
3308 3485
 		}
3309 3486
 
@@ -3315,9 +3492,9 @@  discard block
 block discarded – undo
3315 3492
 		{
3316 3493
 			$cacheAPI = $testAPI;
3317 3494
 			return $cacheAPI;
3495
+		} else {
3496
+					return $testAPI;
3318 3497
 		}
3319
-		else
3320
-			return $testAPI;
3321 3498
 	}
3322 3499
 }
3323 3500
 
@@ -3337,8 +3514,9 @@  discard block
 block discarded – undo
3337 3514
 
3338 3515
 	// @todo Why are we doing this if caching is disabled?
3339 3516
 
3340
-	if (function_exists('call_integration_hook'))
3341
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3517
+	if (function_exists('call_integration_hook')) {
3518
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3519
+	}
3342 3520
 
3343 3521
 	/* Refresh the cache if either:
3344 3522
 		1. Caching is disabled.
@@ -3352,16 +3530,19 @@  discard block
 block discarded – undo
3352 3530
 		require_once($sourcedir . '/' . $file);
3353 3531
 		$cache_block = call_user_func_array($function, $params);
3354 3532
 
3355
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3356
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3533
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3534
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3535
+		}
3357 3536
 	}
3358 3537
 
3359 3538
 	// Some cached data may need a freshening up after retrieval.
3360
-	if (!empty($cache_block['post_retri_eval']))
3361
-		eval($cache_block['post_retri_eval']);
3539
+	if (!empty($cache_block['post_retri_eval'])) {
3540
+			eval($cache_block['post_retri_eval']);
3541
+	}
3362 3542
 
3363
-	if (function_exists('call_integration_hook'))
3364
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3543
+	if (function_exists('call_integration_hook')) {
3544
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3545
+	}
3365 3546
 
3366 3547
 	return $cache_block['data'];
3367 3548
 }
@@ -3388,8 +3569,9 @@  discard block
 block discarded – undo
3388 3569
 	global $smcFunc, $cache_enable, $cacheAPI;
3389 3570
 	global $cache_hits, $cache_count, $db_show_debug;
3390 3571
 
3391
-	if (empty($cache_enable) || empty($cacheAPI))
3392
-		return;
3572
+	if (empty($cache_enable) || empty($cacheAPI)) {
3573
+			return;
3574
+	}
3393 3575
 
3394 3576
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3395 3577
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3402,12 +3584,14 @@  discard block
 block discarded – undo
3402 3584
 	$value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value));
3403 3585
 	$cacheAPI->putData($key, $value, $ttl);
3404 3586
 
3405
-	if (function_exists('call_integration_hook'))
3406
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3587
+	if (function_exists('call_integration_hook')) {
3588
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3589
+	}
3407 3590
 
3408
-	if (isset($db_show_debug) && $db_show_debug === true)
3409
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3410
-}
3591
+	if (isset($db_show_debug) && $db_show_debug === true) {
3592
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3593
+	}
3594
+	}
3411 3595
 
3412 3596
 /**
3413 3597
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3423,8 +3607,9 @@  discard block
 block discarded – undo
3423 3607
 	global $smcFunc, $cache_enable, $cacheAPI;
3424 3608
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
3425 3609
 
3426
-	if (empty($cache_enable) || empty($cacheAPI))
3427
-		return;
3610
+	if (empty($cache_enable) || empty($cacheAPI)) {
3611
+			return;
3612
+	}
3428 3613
 
3429 3614
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3430 3615
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3444,16 +3629,18 @@  discard block
 block discarded – undo
3444 3629
 
3445 3630
 		if (empty($value))
3446 3631
 		{
3447
-			if (!is_array($cache_misses))
3448
-				$cache_misses = array();
3632
+			if (!is_array($cache_misses)) {
3633
+							$cache_misses = array();
3634
+			}
3449 3635
 
3450 3636
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3451 3637
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3452 3638
 		}
3453 3639
 	}
3454 3640
 
3455
-	if (function_exists('call_integration_hook') && isset($value))
3456
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3641
+	if (function_exists('call_integration_hook') && isset($value)) {
3642
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3643
+	}
3457 3644
 
3458 3645
 	return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true));
3459 3646
 }
@@ -3475,8 +3662,9 @@  discard block
 block discarded – undo
3475 3662
 	global $cacheAPI;
3476 3663
 
3477 3664
 	// If we can't get to the API, can't do this.
3478
-	if (empty($cacheAPI))
3479
-		return;
3665
+	if (empty($cacheAPI)) {
3666
+			return;
3667
+	}
3480 3668
 
3481 3669
 	// Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure.
3482 3670
 	$cacheAPI->cleanCache($type);
@@ -3501,8 +3689,9 @@  discard block
 block discarded – undo
3501 3689
 	global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret, $user_info;
3502 3690
 
3503 3691
 	// Come on!
3504
-	if (empty($data))
3505
-		return array();
3692
+	if (empty($data)) {
3693
+			return array();
3694
+	}
3506 3695
 
3507 3696
 	// Set a nice default var.
3508 3697
 	$image = '';
@@ -3510,11 +3699,11 @@  discard block
 block discarded – undo
3510 3699
 	// Gravatar has been set as mandatory!
3511 3700
 	if (!empty($modSettings['gravatarOverride']))
3512 3701
 	{
3513
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3514
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3515
-
3516
-		else if (!empty($data['email']))
3517
-			$image = get_gravatar_url($data['email']);
3702
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3703
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3704
+		} else if (!empty($data['email'])) {
3705
+					$image = get_gravatar_url($data['email']);
3706
+		}
3518 3707
 	}
3519 3708
 
3520 3709
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3526,54 +3715,60 @@  discard block
 block discarded – undo
3526 3715
 			// Gravatar.
3527 3716
 			if (stristr($data['avatar'], 'gravatar://'))
3528 3717
 			{
3529
-				if ($data['avatar'] == 'gravatar://')
3530
-					$image = get_gravatar_url($data['email']);
3531
-
3532
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3533
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3718
+				if ($data['avatar'] == 'gravatar://') {
3719
+									$image = get_gravatar_url($data['email']);
3720
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3721
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3722
+				}
3534 3723
 			}
3535 3724
 
3536 3725
 			// External url.
3537 3726
 			else
3538 3727
 			{
3539 3728
 				// Using ssl?
3540
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
3541
-					$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3729
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
3730
+									$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3731
+				}
3542 3732
 
3543 3733
 				// Just a plain external url.
3544
-				else
3545
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3734
+				else {
3735
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3736
+				}
3546 3737
 			}
3547 3738
 		}
3548 3739
 
3549 3740
 		// Perhaps this user has an attachment as avatar...
3550
-		else if (!empty($data['filename']))
3551
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3741
+		else if (!empty($data['filename'])) {
3742
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3743
+		}
3552 3744
 
3553 3745
 		// Right... no avatar... use our default image.
3554
-		else
3555
-			$image = $modSettings['avatar_url'] . '/default.png';
3746
+		else {
3747
+					$image = $modSettings['avatar_url'] . '/default.png';
3748
+		}
3556 3749
 	}
3557 3750
 
3558 3751
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3559 3752
 
3560 3753
 	// 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.
3561
-	if (!empty($image))
3562
-		return array(
3754
+	if (!empty($image)) {
3755
+			return array(
3563 3756
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3564 3757
 			'image' => '<img class="avatar" src="' . $image . '" />',
3565 3758
 			'href' => $image,
3566 3759
 			'url' => $image,
3567 3760
 		);
3761
+	}
3568 3762
 
3569 3763
 	// Fallback to make life easier for everyone...
3570
-	else
3571
-		return array(
3764
+	else {
3765
+			return array(
3572 3766
 			'name' => '',
3573 3767
 			'image' => '',
3574 3768
 			'href' => '',
3575 3769
 			'url' => '',
3576 3770
 		);
3577
-}
3771
+	}
3772
+	}
3578 3773
 
3579 3774
 ?>
3580 3775
\ No newline at end of file
Please login to merge, or discard this patch.
avatars/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
attachments/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
custom_avatar/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Smileys/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
cache/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.