Completed
Branch release-2.1 (3c29ac)
by Mathias
08:54
created
Sources/Subs-Sound.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
  * Used by VerificationCode() (Register.php).
25 25
  *
26 26
  * @param string $word
27
- * @return boolean false on failure
27
+ * @return null|false false on failure
28 28
  */
29 29
 
30 30
 function createWaveFile($word)
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@
 block discarded – undo
66 66
 		$sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8);
67 67
 		switch ($word{$i} === 's' ? 0 : mt_rand(0, 2))
68 68
 		{
69
-			case 0:
70
-				for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
69
+			case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
71 70
 					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++)
72 71
 						$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
73 72
 			break;
Please login to merge, or discard this patch.
Braces   +32 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Creates a wave file that spells the letters of $word.
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	global $settings, $user_info;
33 34
 
34 35
 	// Allow max 2 requests per 20 seconds.
35
-	if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2)
36
-		die(header('HTTP/1.1 400 Bad Request'));
36
+	if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) {
37
+			die(header('HTTP/1.1 400 Bad Request'));
38
+	}
37 39
 	cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20);
38 40
 	cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20);
39 41
 
@@ -41,16 +43,19 @@  discard block
 block discarded – undo
41 43
 	mt_srand(end(unpack('n', md5($word . session_id()))));
42 44
 
43 45
 	// Try to see if there's a sound font in the user's language.
44
-	if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav'))
45
-		$sound_language = $user_info['language'];
46
+	if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) {
47
+			$sound_language = $user_info['language'];
48
+	}
46 49
 
47 50
 	// English should be there.
48
-	elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav'))
49
-		$sound_language = 'english';
51
+	elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) {
52
+			$sound_language = 'english';
53
+	}
50 54
 
51 55
 	// Guess not...
52
-	else
53
-		return false;
56
+	else {
57
+			return false;
58
+	}
54 59
 
55 60
 	// File names are in lower case so lets make sure that we are only using a lower case string
56 61
 	$word = strtolower($word);
@@ -60,21 +65,26 @@  discard block
 block discarded – undo
60 65
 	for ($i = 0; $i < strlen($word); $i++)
61 66
 	{
62 67
 		$sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav'));
63
-		if (strpos($sound_letter, 'data') === false)
64
-			return false;
68
+		if (strpos($sound_letter, 'data') === false) {
69
+					return false;
70
+		}
65 71
 
66 72
 		$sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8);
67 73
 		switch ($word{$i} === 's' ? 0 : mt_rand(0, 2))
68 74
 		{
69 75
 			case 0:
70
-				for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
71
-					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++)
72
-						$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
76
+				for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) {
77
+									for ($k = 0, $m = round(mt_rand(15, 25) / 10);
78
+				}
79
+				$k < $m; $k++) {
80
+											$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
81
+					}
73 82
 			break;
74 83
 
75 84
 			case 1:
76
-				for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2)
77
-					$sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : '');
85
+				for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) {
86
+									$sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : '');
87
+				}
78 88
 				$sound_word .= str_repeat($sound_letter{$n}, 2);
79 89
 			break;
80 90
 
@@ -82,10 +92,12 @@  discard block
 block discarded – undo
82 92
 				$shift = 0;
83 93
 				for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
84 94
 				{
85
-					if (mt_rand(0, 10) === 0)
86
-						$shift += mt_rand(-3, 3);
87
-					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++)
88
-						$sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF));
95
+					if (mt_rand(0, 10) === 0) {
96
+											$shift += mt_rand(-3, 3);
97
+					}
98
+					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) {
99
+											$sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF));
100
+					}
89 101
 				}
90 102
 			break;
91 103
 
Please login to merge, or discard this patch.
Sources/Subs-Themes.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -425,7 +425,7 @@
 block discarded – undo
425 425
  *
426 426
  * This is a recursive function, it will call itself if there are subdirs inside the main directory.
427 427
  * @param string $path The absolute path to the directory to be removed
428
- * @return bool true when success, false on error.
428
+ * @return false|null true when success, false on error.
429 429
  */
430 430
 function remove_dir($path)
431 431
 {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	);
55 55
 
56 56
 	// Make our known/enable themes a little easier to work with.
57
-	$knownThemes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
58
-	$enableThemes = !empty($modSettings['enableThemes']) ? explode(',',$modSettings['enableThemes']) : array();
57
+	$knownThemes = !empty($modSettings['knownThemes']) ? explode(',', $modSettings['knownThemes']) : array();
58
+	$enableThemes = !empty($modSettings['enableThemes']) ? explode(',', $modSettings['enableThemes']) : array();
59 59
 
60 60
 	$request = $smcFunc['db_query']('', '
61 61
 		SELECT id_theme, variable, value
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	global $modSettings, $context, $smcFunc;
103 103
 
104 104
 	// Make our known/enable themes a little easier to work with.
105
-	$knownThemes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
106
-	$enableThemes = !empty($modSettings['enableThemes']) ? explode(',',$modSettings['enableThemes']) : array();
105
+	$knownThemes = !empty($modSettings['knownThemes']) ? explode(',', $modSettings['knownThemes']) : array();
106
+	$enableThemes = !empty($modSettings['enableThemes']) ? explode(',', $modSettings['enableThemes']) : array();
107 107
 
108 108
 	// List of all possible themes values.
109 109
 	$themeValues = array(
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 				'no_member' => 0,
285 285
 				'name' => 'name',
286 286
 				'version' => 'version',
287
-				'name_value' => '%'. $context['to_install']['name'] .'%',
287
+				'name_value' => '%' . $context['to_install']['name'] . '%',
288 288
 			)
289 289
 		);
290 290
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 		foreach ($objects as $object)
440 440
 			if ($object != '.' && $object != '..')
441 441
 			{
442
-				if (filetype($path .'/'. $object) == 'dir')
443
-					remove_dir($path .'/'.$object);
442
+				if (filetype($path . '/' . $object) == 'dir')
443
+					remove_dir($path . '/' . $object);
444 444
 
445 445
 				else
446
-					unlink($path .'/'. $object);
446
+					unlink($path . '/' . $object);
447 447
 			}
448 448
 	}
449 449
 
Please login to merge, or discard this patch.
Braces   +67 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Gets a single theme's info.
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	global $smcFunc, $modSettings;
28 29
 
29 30
 	// No data, no fun!
30
-	if (empty($id))
31
-		return false;
31
+	if (empty($id)) {
32
+			return false;
33
+	}
32 34
 
33 35
 	// Make sure $id is an int.
34 36
 	$id = (int) $id;
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	global $sourcedir, $forum_version, $txt, $scripturl, $context;
172 174
 	global $explicit_images;
173 175
 
174
-	if (empty($path))
175
-		return false;
176
+	if (empty($path)) {
177
+			return false;
178
+	}
176 179
 
177 180
 	$xml_data = array();
178 181
 	$explicit_images = false;
@@ -229,9 +232,10 @@  discard block
 block discarded – undo
229 232
 	);
230 233
 
231 234
 	// Assign the values to be stored.
232
-	foreach ($xml_elements as $var => $name)
233
-		if (!empty($theme_info_xml[$name]))
235
+	foreach ($xml_elements as $var => $name) {
236
+			if (!empty($theme_info_xml[$name]))
234 237
 			$xml_data[$var] = $theme_info_xml[$name];
238
+	}
235 239
 
236 240
 	// Add the supported versions.
237 241
 	$xml_data['install_for'] = $install_versions;
@@ -243,8 +247,9 @@  discard block
 block discarded – undo
243 247
 		$explicit_images = true;
244 248
 	}
245 249
 
246
-	if (!empty($theme_info_xml['extra']))
247
-		$xml_data += smf_json_decode($theme_info_xml['extra'], true);
250
+	if (!empty($theme_info_xml['extra'])) {
251
+			$xml_data += smf_json_decode($theme_info_xml['extra'], true);
252
+	}
248 253
 
249 254
 	return $xml_data;
250 255
 }
@@ -262,12 +267,14 @@  discard block
 block discarded – undo
262 267
 	global $settings, $explicit_images;
263 268
 
264 269
 	// External use? no problem!
265
-	if ($to_install)
266
-		$context['to_install'] = $to_install;
270
+	if ($to_install) {
271
+			$context['to_install'] = $to_install;
272
+	}
267 273
 
268 274
 	// One last check.
269
-	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes')
270
-		fatal_lang_error('theme_install_invalid_dir', false);
275
+	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') {
276
+			fatal_lang_error('theme_install_invalid_dir', false);
277
+	}
271 278
 
272 279
 	// OK, is this a newer version of an already installed theme?
273 280
 	if (!empty($context['to_install']['version']))
@@ -292,8 +299,8 @@  discard block
 block discarded – undo
292 299
 		$smcFunc['db_free_result']($request);
293 300
 
294 301
 		// Got something, lets figure it out what to do next.
295
-		if (!empty($to_update) && !empty($to_update['version']))
296
-			switch (compareVersions($context['to_install']['version'], $to_update['version']))
302
+		if (!empty($to_update) && !empty($to_update['version'])) {
303
+					switch (compareVersions($context['to_install']['version'], $to_update['version']))
297 304
 			{
298 305
 				case 1: // Got a newer version, update the old entry.
299 306
 					$smcFunc['db_query']('', '
@@ -307,6 +314,7 @@  discard block
 block discarded – undo
307 314
 							'id_theme' => $to_update['id_theme'],
308 315
 						)
309 316
 					);
317
+		}
310 318
 
311 319
 					// Done with the update, tell the user about it.
312 320
 					$context['to_install']['updated'] = true;
@@ -372,13 +380,15 @@  discard block
 block discarded – undo
372 380
 				$context['to_install']['base_theme_url'] = $temp['theme_url'];
373 381
 				$context['to_install']['base_theme_dir'] = $temp['theme_dir'];
374 382
 
375
-				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url']))
376
-					$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
383
+				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) {
384
+									$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
385
+				}
377 386
 			}
378 387
 
379 388
 			// Nope, sorry, couldn't find any theme already installed.
380
-			else
381
-				fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
389
+			else {
390
+							fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
391
+			}
382 392
 		}
383 393
 
384 394
 		unset($context['to_install']['based_on']);
@@ -401,16 +411,18 @@  discard block
 block discarded – undo
401 411
 	call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme));
402 412
 
403 413
 	$inserts = array();
404
-	foreach ($context['to_install'] as $var => $val)
405
-		$inserts[] = array($id_theme, $var, $val);
414
+	foreach ($context['to_install'] as $var => $val) {
415
+			$inserts[] = array($id_theme, $var, $val);
416
+	}
406 417
 
407
-	if (!empty($inserts))
408
-		$smcFunc['db_insert']('insert',
418
+	if (!empty($inserts)) {
419
+			$smcFunc['db_insert']('insert',
409 420
 			'{db_prefix}themes',
410 421
 			array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
411 422
 			$inserts,
412 423
 			array('id_theme', 'variable')
413 424
 		);
425
+	}
414 426
 
415 427
 	// Update the known and enable Theme's settings.
416 428
 	$known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ','));
@@ -429,21 +441,24 @@  discard block
 block discarded – undo
429 441
  */
430 442
 function remove_dir($path)
431 443
 {
432
-	if (empty($path))
433
-		return false;
444
+	if (empty($path)) {
445
+			return false;
446
+	}
434 447
 
435 448
 	if (is_dir($path))
436 449
 	{
437 450
 		$objects = scandir($path);
438 451
 
439
-		foreach ($objects as $object)
440
-			if ($object != '.' && $object != '..')
452
+		foreach ($objects as $object) {
453
+					if ($object != '.' && $object != '..')
441 454
 			{
442 455
 				if (filetype($path .'/'. $object) == 'dir')
443 456
 					remove_dir($path .'/'.$object);
457
+		}
444 458
 
445
-				else
446
-					unlink($path .'/'. $object);
459
+				else {
460
+									unlink($path .'/'. $object);
461
+				}
447 462
 			}
448 463
 	}
449 464
 
@@ -462,8 +477,9 @@  discard block
 block discarded – undo
462 477
 	global $smcFunc, $modSettings;
463 478
 
464 479
 	// Can't delete the default theme, sorry!
465
-	if (empty($themeID) || $themeID == 1)
466
-		return false;
480
+	if (empty($themeID) || $themeID == 1) {
481
+			return false;
482
+	}
467 483
 
468 484
 	$known = explode(',', $modSettings['knownThemes']);
469 485
 	$enable = explode(',', $modSettings['enableThemes']);
@@ -513,8 +529,9 @@  discard block
 block discarded – undo
513 529
 	updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known));
514 530
 
515 531
 	// Fix it if the theme was the overall default theme.
516
-	if ($modSettings['theme_guests'] == $themeID)
517
-		updateSettings(array('theme_guests' => '1'));
532
+	if ($modSettings['theme_guests'] == $themeID) {
533
+			updateSettings(array('theme_guests' => '1'));
534
+	}
518 535
 
519 536
 	return true;
520 537
 }
@@ -531,13 +548,15 @@  discard block
 block discarded – undo
531 548
 	global $scripturl, $txt, $context;
532 549
 
533 550
 	// Is it even a directory?
534
-	if (!is_dir($path))
535
-		fatal_lang_error('error_invalid_dir', 'critical');
551
+	if (!is_dir($path)) {
552
+			fatal_lang_error('error_invalid_dir', 'critical');
553
+	}
536 554
 
537 555
 	$dir = dir($path);
538 556
 	$entries = array();
539
-	while ($entry = $dir->read())
540
-		$entries[] = $entry;
557
+	while ($entry = $dir->read()) {
558
+			$entries[] = $entry;
559
+	}
541 560
 	$dir->close();
542 561
 
543 562
 	natcasesort($entries);
@@ -548,11 +567,12 @@  discard block
 block discarded – undo
548 567
 	foreach ($entries as $entry)
549 568
 	{
550 569
 		// Skip all dot files, including .htaccess.
551
-		if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
552
-			continue;
570
+		if (substr($entry, 0, 1) == '.' || $entry == 'CVS') {
571
+					continue;
572
+		}
553 573
 
554
-		if (is_dir($path . '/' . $entry))
555
-			$listing1[] = array(
574
+		if (is_dir($path . '/' . $entry)) {
575
+					$listing1[] = array(
556 576
 				'filename' => $entry,
557 577
 				'is_writable' => is_writable($path . '/' . $entry),
558 578
 				'is_directory' => true,
@@ -562,13 +582,14 @@  discard block
 block discarded – undo
562 582
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry,
563 583
 				'size' => '',
564 584
 			);
565
-		else
585
+		} else
566 586
 		{
567 587
 			$size = filesize($path . '/' . $entry);
568
-			if ($size > 2048 || $size == 1024)
569
-				$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
570
-			else
571
-				$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
588
+			if ($size > 2048 || $size == 1024) {
589
+							$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
590
+			} else {
591
+							$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
592
+			}
572 593
 
573 594
 			$listing2[] = array(
574 595
 				'filename' => $entry,
Please login to merge, or discard this patch.
Sources/Subs.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
  * - caches the formatting data from the setting for optimization.
677 677
  *
678 678
  * @param float $number A number
679
- * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
679
+ * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
680 680
  * @return string A formatted number
681 681
  */
682 682
 function comma_format($number, $override_decimal_count = false)
@@ -5092,7 +5092,7 @@  discard block
 block discarded – undo
5092 5092
 
5093 5093
 /**
5094 5094
  * @param string $ip_address An IP address in IPv4, IPv6 or decimal notation
5095
- * @return binary The IP address in binary or false
5095
+ * @return string The IP address in binary or false
5096 5096
  */
5097 5097
 function inet_ptod($ip_address)
5098 5098
 {
@@ -5490,7 +5490,7 @@  discard block
 block discarded – undo
5490 5490
  * It assumes the data is already a string.
5491 5491
  * @param string $data The data to print
5492 5492
  * @param string $type The content type. Defaults to Json.
5493
- * @return void
5493
+ * @return false|null
5494 5494
  */
5495 5495
 function smf_serverResponse($data = '', $type = 'Content-Type: application/json')
5496 5496
 {
Please login to merge, or discard this patch.
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -5370,7 +5370,6 @@  discard block
 block discarded – undo
5370 5370
 
5371 5371
 /**
5372 5372
  * Tries different modes to make file/dirs writable. Wrapper function for chmod()
5373
-
5374 5373
  * @param string $file The file/dir full path.
5375 5374
  * @param int $value Not needed, added for legacy reasons.
5376 5375
  * @return boolean  true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable.
@@ -5410,7 +5409,6 @@  discard block
 block discarded – undo
5410 5409
 
5411 5410
 /**
5412 5411
  * Wrapper function for json_decode() with error handling.
5413
-
5414 5412
  * @param string $json The string to decode.
5415 5413
  * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default.
5416 5414
  * @param bool $logIt To specify if the error will be logged if theres any.
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1098 1098
 				),
1099 1099
 				'content' => '$1',
1100
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1100
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1101 1101
 				{
1102 1102
 					$returnContext = '';
1103 1103
 
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1147 1147
 							$returnContext .= '
1148
-													<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>';
1148
+													<a href="'. $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '" alt="' . $currentAttachment['name'] . '" id="thumb_' . $currentAttachment['id'] . '"></a>';
1149 1149
 						else
1150 1150
 							$returnContext .= '
1151 1151
 													<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>';
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 				'type' => 'unparsed_content',
1176 1176
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1177 1177
 				// @todo Maybe this can be simplified?
1178
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1178
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1179 1179
 				{
1180 1180
 					if (!isset($disabled['code']))
1181 1181
 					{
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 				'type' => 'unparsed_equals_content',
1213 1213
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1214 1214
 				// @todo Maybe this can be simplified?
1215
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1215
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1216 1216
 				{
1217 1217
 					if (!isset($disabled['code']))
1218 1218
 					{
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 				'type' => 'unparsed_content',
1257 1257
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1258 1258
 				// @todo Should this respect guest_hideContacts?
1259
-				'validate' => function (&$tag, &$data, $disabled)
1259
+				'validate' => function(&$tag, &$data, $disabled)
1260 1260
 				{
1261 1261
 					$data = strtr($data, array('<br>' => ''));
1262 1262
 				},
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 				'type' => 'unparsed_commas_content',
1276 1276
 				'test' => '\d+,\d+\]',
1277 1277
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1278
-				'validate' => function (&$tag, &$data, $disabled)
1278
+				'validate' => function(&$tag, &$data, $disabled)
1279 1279
 				{
1280 1280
 					if (isset($disabled['url']))
1281 1281
 						$tag['content'] = '$1';
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1321 1321
 				),
1322 1322
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1323
-				'validate' => function (&$tag, &$data, $disabled)
1323
+				'validate' => function(&$tag, &$data, $disabled)
1324 1324
 				{
1325 1325
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1326 1326
 
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 				'tag' => 'img',
1344 1344
 				'type' => 'unparsed_content',
1345 1345
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1346
-				'validate' => function (&$tag, &$data, $disabled)
1346
+				'validate' => function(&$tag, &$data, $disabled)
1347 1347
 				{
1348 1348
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1349 1349
 
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 				'tag' => 'iurl',
1367 1367
 				'type' => 'unparsed_content',
1368 1368
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1369
-				'validate' => function (&$tag, &$data, $disabled)
1369
+				'validate' => function(&$tag, &$data, $disabled)
1370 1370
 				{
1371 1371
 					$data = strtr($data, array('<br>' => ''));
1372 1372
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 				'quoted' => 'optional',
1381 1381
 				'before' => '<a href="$1" class="bbc_link">',
1382 1382
 				'after' => '</a>',
1383
-				'validate' => function (&$tag, &$data, $disabled)
1383
+				'validate' => function(&$tag, &$data, $disabled)
1384 1384
 				{
1385 1385
 					if (substr($data, 0, 1) == '#')
1386 1386
 						$data = '#post_' . substr($data, 1);
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
 				'tag' => 'php',
1461 1461
 				'type' => 'unparsed_content',
1462 1462
 				'content' => '<span class="phpcode">$1</span>',
1463
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1463
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1464 1464
 				{
1465 1465
 					if (!isset($disabled['php']))
1466 1466
 					{
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 				'test' => '[1-7]\]',
1559 1559
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1560 1560
 				'after' => '</span>',
1561
-				'validate' => function (&$tag, &$data, $disabled)
1561
+				'validate' => function(&$tag, &$data, $disabled)
1562 1562
 				{
1563 1563
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1564 1564
 					$data = $sizes[$data] . 'em';
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
 				'tag' => 'time',
1597 1597
 				'type' => 'unparsed_content',
1598 1598
 				'content' => '$1',
1599
-				'validate' => function (&$tag, &$data, $disabled)
1599
+				'validate' => function(&$tag, &$data, $disabled)
1600 1600
 				{
1601 1601
 					if (is_numeric($data))
1602 1602
 						$data = timeformat($data);
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 				'tag' => 'url',
1625 1625
 				'type' => 'unparsed_content',
1626 1626
 				'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',
1627
-				'validate' => function (&$tag, &$data, $disabled)
1627
+				'validate' => function(&$tag, &$data, $disabled)
1628 1628
 				{
1629 1629
 					$data = strtr($data, array('<br>' => ''));
1630 1630
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
 				'quoted' => 'optional',
1639 1639
 				'before' => '<a href="$1" class="bbc_link" target="_blank">',
1640 1640
 				'after' => '</a>',
1641
-				'validate' => function (&$tag, &$data, $disabled)
1641
+				'validate' => function(&$tag, &$data, $disabled)
1642 1642
 				{
1643 1643
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1644 1644
 					if (empty($scheme))
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 		{
1665 1665
 			if (isset($temp_bbc))
1666 1666
 				$bbc_codes = $temp_bbc;
1667
-			usort($codes, function ($a, $b) {
1667
+			usort($codes, function($a, $b) {
1668 1668
 				return strcmp($a['tag'], $b['tag']);
1669 1669
 			});
1670 1670
 			return $codes;
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 										# a run of Unicode domain name characters and a dot
1905 1905
 										[\p{L}\p{M}\p{N}\-.:@]+\.
1906 1906
 										# and then a TLD valid in the DNS or the reserved "local" TLD
1907
-										(?:'. $modSettings['tld_regex'] .'|local)
1907
+										(?:'. $modSettings['tld_regex'] . '|local)
1908 1908
 									)
1909 1909
 									# followed by a non-domain character or end of line
1910 1910
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 						)?
1973 1973
 						';
1974 1974
 
1975
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
1975
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
1976 1976
 							$url = array_shift($matches);
1977 1977
 
1978 1978
 							$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2702 2702
 		{
2703 2703
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2704
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2704
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2705 2705
 
2706 2706
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2707 2707
 
@@ -2718,7 +2718,7 @@  discard block
 block discarded – undo
2718 2718
 
2719 2719
 	// Replace away!
2720 2720
 	$message = preg_replace_callback($smileyPregSearch,
2721
-		function ($matches) use ($smileyPregReplacements)
2721
+		function($matches) use ($smileyPregReplacements)
2722 2722
 		{
2723 2723
 			return $smileyPregReplacements[$matches[1]];
2724 2724
 		}, $message);
@@ -2784,13 +2784,13 @@  discard block
 block discarded – undo
2784 2784
 	{
2785 2785
 		if (defined('SID') && SID != '')
2786 2786
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2787
-				function ($m) use ($scripturl)
2787
+				function($m) use ($scripturl)
2788 2788
 				{
2789
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2789
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2790 2790
 				}, $setLocation);
2791 2791
 		else
2792 2792
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2793
-				function ($m) use ($scripturl)
2793
+				function($m) use ($scripturl)
2794 2794
 				{
2795 2795
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2796 2796
 				}, $setLocation);
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 
3114 3114
 	// Add a generic "Are you sure?" confirmation message.
3115 3115
 	addInlineJavaScript('
3116
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3116
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3117 3117
 
3118 3118
 	// Now add the capping code for avatars.
3119 3119
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3477,7 +3477,7 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
 		else
3479 3479
 			echo '
3480
-	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3480
+	<script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>';
3481 3481
 	}
3482 3482
 
3483 3483
 	// Inline JavaScript - Actually useful some times!
@@ -3555,14 +3555,14 @@  discard block
 block discarded – undo
3555 3555
 
3556 3556
 		else
3557 3557
 			echo '
3558
-	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3558
+	<link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">';
3559 3559
 	}
3560 3560
 
3561 3561
 	// Print the rest after the minified files.
3562 3562
 	if (!empty($normal))
3563 3563
 		foreach ($normal as $nf)
3564 3564
 			echo '
3565
-	<link rel="stylesheet" href="', $nf ,'">';
3565
+	<link rel="stylesheet" href="', $nf, '">';
3566 3566
 
3567 3567
 	if ($db_show_debug === true)
3568 3568
 	{
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 	<style>';
3579 3579
 
3580 3580
 		foreach ($context['css_header'] as $css)
3581
-			echo $css .'
3581
+			echo $css . '
3582 3582
 	';
3583 3583
 
3584 3584
 		echo'
@@ -3608,7 +3608,7 @@  discard block
 block discarded – undo
3608 3608
 		return false;
3609 3609
 
3610 3610
 	// Did we already did this?
3611
-	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3611
+	$toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400);
3612 3612
 
3613 3613
 	// Already done?
3614 3614
 	if (!empty($toCache))
@@ -3616,25 +3616,25 @@  discard block
 block discarded – undo
3616 3616
 
3617 3617
 	// Yep, need a bunch of files.
3618 3618
 	require_once($sourcedir . '/minify/src/Minify.php');
3619
-	require_once($sourcedir . '/minify/src/'. strtoupper($type) .'.php');
3619
+	require_once($sourcedir . '/minify/src/' . strtoupper($type) . '.php');
3620 3620
 	require_once($sourcedir . '/minify/src/Exception.php');
3621 3621
 	require_once($sourcedir . '/minify/src/Converter.php');
3622 3622
 
3623 3623
 	// No namespaces, sorry!
3624
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3624
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3625 3625
 
3626 3626
 	// Temp path.
3627
-	$cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/';
3627
+	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
3628 3628
 
3629 3629
 	// What kind of file are we going to create?
3630
-	$toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type;
3630
+	$toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type;
3631 3631
 
3632 3632
 	// File has to exists, if it isn't try to create it.
3633 3633
 	if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate))
3634 3634
 	{
3635 3635
 		loadLanguage('Errors');
3636 3636
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3637
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3637
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3638 3638
 
3639 3639
 		// The process failed so roll back to print each individual file.
3640 3640
 		return $data;
@@ -3669,14 +3669,14 @@  discard block
 block discarded – undo
3669 3669
 	{
3670 3670
 		loadLanguage('Errors');
3671 3671
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3672
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3672
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3673 3673
 
3674 3674
 		// The process failed so roll back to print each individual file.
3675 3675
 		return $data;
3676 3676
 	}
3677 3677
 
3678 3678
 	// And create a long lived cache entry.
3679
-	cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400);
3679
+	cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400);
3680 3680
 
3681 3681
 	return true;
3682 3682
 }
@@ -3733,7 +3733,7 @@  discard block
 block discarded – undo
3733 3733
 	else
3734 3734
 		$path = $modSettings['attachmentUploadDir'];
3735 3735
 
3736
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3736
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3737 3737
 }
3738 3738
 
3739 3739
 /**
@@ -3777,10 +3777,10 @@  discard block
 block discarded – undo
3777 3777
 		$valid_low = isValidIP($ip_parts[0]);
3778 3778
 		$valid_high = isValidIP($ip_parts[1]);
3779 3779
 		$count = 0;
3780
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
3780
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
3781 3781
 		$max = ($mode == ':' ? 'ffff' : '255');
3782 3782
 		$min = 0;
3783
-		if(!$valid_low)
3783
+		if (!$valid_low)
3784 3784
 		{
3785 3785
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
3786 3786
 			$valid_low = isValidIP($ip_parts[0]);
@@ -3794,7 +3794,7 @@  discard block
 block discarded – undo
3794 3794
 		}
3795 3795
 
3796 3796
 		$count = 0;
3797
-		if(!$valid_high)
3797
+		if (!$valid_high)
3798 3798
 		{
3799 3799
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
3800 3800
 			$valid_high = isValidIP($ip_parts[1]);
@@ -3807,7 +3807,7 @@  discard block
 block discarded – undo
3807 3807
 			}
3808 3808
 		}
3809 3809
 
3810
-		if($valid_high && $valid_low)
3810
+		if ($valid_high && $valid_low)
3811 3811
 		{
3812 3812
 			$ip_array['low'] = $ip_parts[0];
3813 3813
 			$ip_array['high'] = $ip_parts[1];
@@ -4080,7 +4080,7 @@  discard block
 block discarded – undo
4080 4080
 		addInlineJavaScript('
4081 4081
 	var user_menus = new smc_PopupMenu();
4082 4082
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4083
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4083
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4084 4084
 		if ($context['allow_pm'])
4085 4085
 			addInlineJavaScript('
4086 4086
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4708,7 +4708,7 @@  discard block
 block discarded – undo
4708 4708
 		// No? try a fallback to $sourcedir
4709 4709
 		else
4710 4710
 		{
4711
-			$absPath = $sourcedir .'/'. $file;
4711
+			$absPath = $sourcedir . '/' . $file;
4712 4712
 
4713 4713
 			if (file_exists($absPath))
4714 4714
 				require_once($absPath);
@@ -4789,15 +4789,15 @@  discard block
 block discarded – undo
4789 4789
 
4790 4790
 	// UTF-8 occurences of MS special characters
4791 4791
 	$findchars_utf8 = array(
4792
-		"\xe2\80\x9a",	// single low-9 quotation mark
4793
-		"\xe2\80\x9e",	// double low-9 quotation mark
4794
-		"\xe2\80\xa6",	// horizontal ellipsis
4795
-		"\xe2\x80\x98",	// left single curly quote
4796
-		"\xe2\x80\x99",	// right single curly quote
4797
-		"\xe2\x80\x9c",	// left double curly quote
4798
-		"\xe2\x80\x9d",	// right double curly quote
4799
-		"\xe2\x80\x93",	// en dash
4800
-		"\xe2\x80\x94",	// em dash
4792
+		"\xe2\80\x9a", // single low-9 quotation mark
4793
+		"\xe2\80\x9e", // double low-9 quotation mark
4794
+		"\xe2\80\xa6", // horizontal ellipsis
4795
+		"\xe2\x80\x98", // left single curly quote
4796
+		"\xe2\x80\x99", // right single curly quote
4797
+		"\xe2\x80\x9c", // left double curly quote
4798
+		"\xe2\x80\x9d", // right double curly quote
4799
+		"\xe2\x80\x93", // en dash
4800
+		"\xe2\x80\x94", // em dash
4801 4801
 	);
4802 4802
 
4803 4803
 	// windows 1252 / iso equivalents
@@ -4815,15 +4815,15 @@  discard block
 block discarded – undo
4815 4815
 
4816 4816
 	// safe replacements
4817 4817
 	$replacechars = array(
4818
-		',',	// &sbquo;
4819
-		',,',	// &bdquo;
4820
-		'...',	// &hellip;
4821
-		"'",	// &lsquo;
4822
-		"'",	// &rsquo;
4823
-		'"',	// &ldquo;
4824
-		'"',	// &rdquo;
4825
-		'-',	// &ndash;
4826
-		'--',	// &mdash;
4818
+		',', // &sbquo;
4819
+		',,', // &bdquo;
4820
+		'...', // &hellip;
4821
+		"'", // &lsquo;
4822
+		"'", // &rsquo;
4823
+		'"', // &ldquo;
4824
+		'"', // &rdquo;
4825
+		'-', // &ndash;
4826
+		'--', // &mdash;
4827 4827
 	);
4828 4828
 
4829 4829
 	if ($context['utf8'])
@@ -5109,7 +5109,7 @@  discard block
 block discarded – undo
5109 5109
  */
5110 5110
 function inet_dtop($bin)
5111 5111
 {
5112
-	if(empty($bin))
5112
+	if (empty($bin))
5113 5113
 		return '';
5114 5114
 
5115 5115
 	global $db_type;
@@ -5140,28 +5140,28 @@  discard block
 block discarded – undo
5140 5140
  */
5141 5141
 function _safe_serialize($value)
5142 5142
 {
5143
-	if(is_null($value))
5143
+	if (is_null($value))
5144 5144
 		return 'N;';
5145 5145
 
5146
-	if(is_bool($value))
5147
-		return 'b:'. (int) $value .';';
5146
+	if (is_bool($value))
5147
+		return 'b:' . (int) $value . ';';
5148 5148
 
5149
-	if(is_int($value))
5150
-		return 'i:'. $value .';';
5149
+	if (is_int($value))
5150
+		return 'i:' . $value . ';';
5151 5151
 
5152
-	if(is_float($value))
5153
-		return 'd:'. str_replace(',', '.', $value) .';';
5152
+	if (is_float($value))
5153
+		return 'd:' . str_replace(',', '.', $value) . ';';
5154 5154
 
5155
-	if(is_string($value))
5156
-		return 's:'. strlen($value) .':"'. $value .'";';
5155
+	if (is_string($value))
5156
+		return 's:' . strlen($value) . ':"' . $value . '";';
5157 5157
 
5158
-	if(is_array($value))
5158
+	if (is_array($value))
5159 5159
 	{
5160 5160
 		$out = '';
5161
-		foreach($value as $k => $v)
5161
+		foreach ($value as $k => $v)
5162 5162
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5163 5163
 
5164
-		return 'a:'. count($value) .':{'. $out .'}';
5164
+		return 'a:' . count($value) . ':{' . $out . '}';
5165 5165
 	}
5166 5166
 
5167 5167
 	// safe_serialize cannot serialize resources or objects.
@@ -5203,7 +5203,7 @@  discard block
 block discarded – undo
5203 5203
 function _safe_unserialize($str)
5204 5204
 {
5205 5205
 	// Input  is not a string.
5206
-	if(empty($str) || !is_string($str))
5206
+	if (empty($str) || !is_string($str))
5207 5207
 		return false;
5208 5208
 
5209 5209
 	$stack = array();
@@ -5217,40 +5217,40 @@  discard block
 block discarded – undo
5217 5217
 	 *   3 - in array, expecting value or another array
5218 5218
 	 */
5219 5219
 	$state = 0;
5220
-	while($state != 1)
5220
+	while ($state != 1)
5221 5221
 	{
5222 5222
 		$type = isset($str[0]) ? $str[0] : '';
5223
-		if($type == '}')
5223
+		if ($type == '}')
5224 5224
 			$str = substr($str, 1);
5225 5225
 
5226
-		else if($type == 'N' && $str[1] == ';')
5226
+		else if ($type == 'N' && $str[1] == ';')
5227 5227
 		{
5228 5228
 			$value = null;
5229 5229
 			$str = substr($str, 2);
5230 5230
 		}
5231
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5231
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5232 5232
 		{
5233 5233
 			$value = $matches[1] == '1' ? true : false;
5234 5234
 			$str = substr($str, 4);
5235 5235
 		}
5236
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5236
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5237 5237
 		{
5238
-			$value = (int)$matches[1];
5238
+			$value = (int) $matches[1];
5239 5239
 			$str = $matches[2];
5240 5240
 		}
5241
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5241
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5242 5242
 		{
5243
-			$value = (float)$matches[1];
5243
+			$value = (float) $matches[1];
5244 5244
 			$str = $matches[3];
5245 5245
 		}
5246
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5246
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5247 5247
 		{
5248
-			$value = substr($matches[2], 0, (int)$matches[1]);
5249
-			$str = substr($matches[2], (int)$matches[1] + 2);
5248
+			$value = substr($matches[2], 0, (int) $matches[1]);
5249
+			$str = substr($matches[2], (int) $matches[1] + 2);
5250 5250
 		}
5251
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5251
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5252 5252
 		{
5253
-			$expectedLength = (int)$matches[1];
5253
+			$expectedLength = (int) $matches[1];
5254 5254
 			$str = $matches[2];
5255 5255
 		}
5256 5256
 
@@ -5258,10 +5258,10 @@  discard block
 block discarded – undo
5258 5258
 		else
5259 5259
 			return false;
5260 5260
 
5261
-		switch($state)
5261
+		switch ($state)
5262 5262
 		{
5263 5263
 			case 3: // In array, expecting value or another array.
5264
-				if($type == 'a')
5264
+				if ($type == 'a')
5265 5265
 				{
5266 5266
 					$stack[] = &$list;
5267 5267
 					$list[$key] = array();
@@ -5270,7 +5270,7 @@  discard block
 block discarded – undo
5270 5270
 					$state = 2;
5271 5271
 					break;
5272 5272
 				}
5273
-				if($type != '}')
5273
+				if ($type != '}')
5274 5274
 				{
5275 5275
 					$list[$key] = $value;
5276 5276
 					$state = 2;
@@ -5281,29 +5281,29 @@  discard block
 block discarded – undo
5281 5281
 				return false;
5282 5282
 
5283 5283
 			case 2: // in array, expecting end of array or a key
5284
-				if($type == '}')
5284
+				if ($type == '}')
5285 5285
 				{
5286 5286
 					// Array size is less than expected.
5287
-					if(count($list) < end($expected))
5287
+					if (count($list) < end($expected))
5288 5288
 						return false;
5289 5289
 
5290 5290
 					unset($list);
5291
-					$list = &$stack[count($stack)-1];
5291
+					$list = &$stack[count($stack) - 1];
5292 5292
 					array_pop($stack);
5293 5293
 
5294 5294
 					// Go to terminal state if we're at the end of the root array.
5295 5295
 					array_pop($expected);
5296 5296
 
5297
-					if(count($expected) == 0)
5297
+					if (count($expected) == 0)
5298 5298
 						$state = 1;
5299 5299
 
5300 5300
 					break;
5301 5301
 				}
5302 5302
 
5303
-				if($type == 'i' || $type == 's')
5303
+				if ($type == 'i' || $type == 's')
5304 5304
 				{
5305 5305
 					// Array size exceeds expected length.
5306
-					if(count($list) >= end($expected))
5306
+					if (count($list) >= end($expected))
5307 5307
 						return false;
5308 5308
 
5309 5309
 					$key = $value;
@@ -5316,7 +5316,7 @@  discard block
 block discarded – undo
5316 5316
 
5317 5317
 			// Expecting array or value.
5318 5318
 			case 0:
5319
-				if($type == 'a')
5319
+				if ($type == 'a')
5320 5320
 				{
5321 5321
 					$data = array();
5322 5322
 					$list = &$data;
@@ -5325,7 +5325,7 @@  discard block
 block discarded – undo
5325 5325
 					break;
5326 5326
 				}
5327 5327
 
5328
-				if($type != '}')
5328
+				if ($type != '}')
5329 5329
 				{
5330 5330
 					$data = $value;
5331 5331
 					$state = 1;
@@ -5338,7 +5338,7 @@  discard block
 block discarded – undo
5338 5338
 	}
5339 5339
 
5340 5340
 	// Trailing data in input.
5341
-	if(!empty($str))
5341
+	if (!empty($str))
5342 5342
 		return false;
5343 5343
 
5344 5344
 	return $data;
@@ -5392,7 +5392,7 @@  discard block
 block discarded – undo
5392 5392
 	// Set different modes.
5393 5393
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5394 5394
 
5395
-	foreach($chmodValues as $val)
5395
+	foreach ($chmodValues as $val)
5396 5396
 	{
5397 5397
 		// If it's writable, break out of the loop.
5398 5398
 		if (is_writable($file))
@@ -5430,13 +5430,13 @@  discard block
 block discarded – undo
5430 5430
 	$returnArray = @json_decode($json, $returnAsArray);
5431 5431
 
5432 5432
 	// PHP 5.3 so no json_last_error_msg()
5433
-	switch(json_last_error())
5433
+	switch (json_last_error())
5434 5434
 	{
5435 5435
 		case JSON_ERROR_NONE:
5436 5436
 			$jsonError = false;
5437 5437
 			break;
5438 5438
 		case JSON_ERROR_DEPTH:
5439
-			$jsonError =  'JSON_ERROR_DEPTH';
5439
+			$jsonError = 'JSON_ERROR_DEPTH';
5440 5440
 			break;
5441 5441
 		case JSON_ERROR_STATE_MISMATCH:
5442 5442
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5464,10 +5464,10 @@  discard block
 block discarded – undo
5464 5464
 		loadLanguage('Errors');
5465 5465
 
5466 5466
 		if (!empty($jsonDebug))
5467
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5467
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5468 5468
 
5469 5469
 		else
5470
-			log_error($txt['json_'. $jsonError], 'critical');
5470
+			log_error($txt['json_' . $jsonError], 'critical');
5471 5471
 
5472 5472
 		// Everyone expects an array.
5473 5473
 		return array();
@@ -5571,7 +5571,7 @@  discard block
 block discarded – undo
5571 5571
 		});
5572 5572
 
5573 5573
 		// Convert Punycode to Unicode
5574
-		$tlds = array_map(function ($input) {
5574
+		$tlds = array_map(function($input) {
5575 5575
 			$prefix = 'xn--';
5576 5576
 			$safe_char = 0xFFFC;
5577 5577
 			$base = 36;
@@ -5587,7 +5587,7 @@  discard block
 block discarded – undo
5587 5587
 
5588 5588
 			foreach ($enco_parts as $encoded)
5589 5589
 			{
5590
-				if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0)
5590
+				if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0)
5591 5591
 				{
5592 5592
 					$output_parts[] = $encoded;
5593 5593
 					continue;
@@ -5598,7 +5598,7 @@  discard block
 block discarded – undo
5598 5598
 				$idx = 0;
5599 5599
 				$char = 0x80;
5600 5600
 				$decoded = array();
5601
-				$output='';
5601
+				$output = '';
5602 5602
 				$delim_pos = strrpos($encoded, '-');
5603 5603
 
5604 5604
 				if ($delim_pos > strlen($prefix))
@@ -5614,7 +5614,7 @@  discard block
 block discarded – undo
5614 5614
 
5615 5615
 				for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len)
5616 5616
 				{
5617
-					for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base)
5617
+					for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base)
5618 5618
 					{
5619 5619
 						$cp = ord($encoded{$enco_idx++});
5620 5620
 						$digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base));
@@ -5655,15 +5655,15 @@  discard block
 block discarded – undo
5655 5655
 
5656 5656
 					// 2 bytes
5657 5657
 					elseif ($v < (1 << 11))
5658
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5658
+						$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
5659 5659
 
5660 5660
 					// 3 bytes
5661 5661
 					elseif ($v < (1 << 16))
5662
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5662
+						$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5663 5663
 
5664 5664
 					// 4 bytes
5665 5665
 					elseif ($v < (1 << 21))
5666
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5666
+						$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5667 5667
 
5668 5668
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5669 5669
 					else
@@ -5770,7 +5770,7 @@  discard block
 block discarded – undo
5770 5770
 	}
5771 5771
 
5772 5772
 	// This recursive function creates the index array from the strings
5773
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5773
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5774 5774
 	{
5775 5775
 		static $depth = 0;
5776 5776
 		$depth++;
@@ -5797,7 +5797,7 @@  discard block
 block discarded – undo
5797 5797
 	};
5798 5798
 
5799 5799
 	// This recursive function turns the index array into a regular expression
5800
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
5800
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
5801 5801
 	{
5802 5802
 		static $depth = 0;
5803 5803
 		$depth++;
@@ -5820,9 +5820,9 @@  discard block
 block discarded – undo
5820 5820
 				$sub_regex = $index_to_regex($value, $delim);
5821 5821
 
5822 5822
 				if (count(array_keys($value)) == 1)
5823
-					$new_key .= explode('(?'.'>', $sub_regex)[0];
5823
+					$new_key .= explode('(?' . '>', $sub_regex)[0];
5824 5824
 				else
5825
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5825
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
5826 5826
 			}
5827 5827
 
5828 5828
 			if ($depth > 1)
@@ -5862,7 +5862,7 @@  discard block
 block discarded – undo
5862 5862
 		$index = $add_string_to_index($string, $index);
5863 5863
 
5864 5864
 	while (!empty($index))
5865
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5865
+		$regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
5866 5866
 
5867 5867
 	// Restore PHP's internal character encoding to whatever it was originally
5868 5868
 	if (!empty($current_encoding))
Please login to merge, or discard this patch.
Braces   +1272 added lines, -949 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Update some basic statistics.
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
 						$smcFunc['db_free_result']($result);
123 124
 
124 125
 						// Add this to the number of unapproved members
125
-						if (!empty($changes['unapprovedMembers']))
126
-							$changes['unapprovedMembers'] += $coppa_approvals;
127
-						else
128
-							$changes['unapprovedMembers'] = $coppa_approvals;
126
+						if (!empty($changes['unapprovedMembers'])) {
127
+													$changes['unapprovedMembers'] += $coppa_approvals;
128
+						} else {
129
+													$changes['unapprovedMembers'] = $coppa_approvals;
130
+						}
129 131
 					}
130 132
 				}
131 133
 			}
@@ -133,9 +135,9 @@  discard block
 block discarded – undo
133 135
 			break;
134 136
 
135 137
 		case 'message':
136
-			if ($parameter1 === true && $parameter2 !== null)
137
-				updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
138
-			else
138
+			if ($parameter1 === true && $parameter2 !== null) {
139
+							updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
140
+			} else
139 141
 			{
140 142
 				// SUM and MAX on a smaller table is better for InnoDB tables.
141 143
 				$result = $smcFunc['db_query']('', '
@@ -175,23 +177,25 @@  discard block
 block discarded – undo
175 177
 				$parameter2 = text2words($parameter2);
176 178
 
177 179
 				$inserts = array();
178
-				foreach ($parameter2 as $word)
179
-					$inserts[] = array($word, $parameter1);
180
+				foreach ($parameter2 as $word) {
181
+									$inserts[] = array($word, $parameter1);
182
+				}
180 183
 
181
-				if (!empty($inserts))
182
-					$smcFunc['db_insert']('ignore',
184
+				if (!empty($inserts)) {
185
+									$smcFunc['db_insert']('ignore',
183 186
 						'{db_prefix}log_search_subjects',
184 187
 						array('word' => 'string', 'id_topic' => 'int'),
185 188
 						$inserts,
186 189
 						array('word', 'id_topic')
187 190
 					);
191
+				}
188 192
 			}
189 193
 			break;
190 194
 
191 195
 		case 'topic':
192
-			if ($parameter1 === true)
193
-				updateSettings(array('totalTopics' => true), true);
194
-			else
196
+			if ($parameter1 === true) {
197
+							updateSettings(array('totalTopics' => true), true);
198
+			} else
195 199
 			{
196 200
 				// Get the number of topics - a SUM is better for InnoDB tables.
197 201
 				// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
 		case 'postgroups':
214 218
 			// Parameter two is the updated columns: we should check to see if we base groups off any of these.
215
-			if ($parameter2 !== null && !in_array('posts', $parameter2))
216
-				return;
219
+			if ($parameter2 !== null && !in_array('posts', $parameter2)) {
220
+							return;
221
+			}
217 222
 
218 223
 			$postgroups = cache_get_data('updateStats:postgroups', 360);
219 224
 			if ($postgroups == null || $parameter1 == null)
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
 					)
229 234
 				);
230 235
 				$postgroups = array();
231
-				while ($row = $smcFunc['db_fetch_assoc']($request))
232
-					$postgroups[$row['id_group']] = $row['min_posts'];
236
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+									$postgroups[$row['id_group']] = $row['min_posts'];
238
+				}
233 239
 				$smcFunc['db_free_result']($request);
234 240
 
235 241
 				// Sort them this way because if it's done with MySQL it causes a filesort :(.
@@ -239,8 +245,9 @@  discard block
 block discarded – undo
239 245
 			}
240 246
 
241 247
 			// Oh great, they've screwed their post groups.
242
-			if (empty($postgroups))
243
-				return;
248
+			if (empty($postgroups)) {
249
+							return;
250
+			}
244 251
 
245 252
 			// Set all membergroups from most posts to least posts.
246 253
 			$conditions = '';
@@ -298,10 +305,9 @@  discard block
 block discarded – undo
298 305
 	{
299 306
 		$condition = 'id_member IN ({array_int:members})';
300 307
 		$parameters['members'] = $members;
301
-	}
302
-	elseif ($members === null)
303
-		$condition = '1=1';
304
-	else
308
+	} elseif ($members === null) {
309
+			$condition = '1=1';
310
+	} else
305 311
 	{
306 312
 		$condition = 'id_member = {int:member}';
307 313
 		$parameters['member'] = $members;
@@ -341,9 +347,9 @@  discard block
 block discarded – undo
341 347
 		if (count($vars_to_integrate) != 0)
342 348
 		{
343 349
 			// Fetch a list of member_names if necessary
344
-			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
345
-				$member_names = array($user_info['username']);
346
-			else
350
+			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) {
351
+							$member_names = array($user_info['username']);
352
+			} else
347 353
 			{
348 354
 				$member_names = array();
349 355
 				$request = $smcFunc['db_query']('', '
@@ -352,14 +358,16 @@  discard block
 block discarded – undo
352 358
 					WHERE ' . $condition,
353 359
 					$parameters
354 360
 				);
355
-				while ($row = $smcFunc['db_fetch_assoc']($request))
356
-					$member_names[] = $row['member_name'];
361
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
362
+									$member_names[] = $row['member_name'];
363
+				}
357 364
 				$smcFunc['db_free_result']($request);
358 365
 			}
359 366
 
360
-			if (!empty($member_names))
361
-				foreach ($vars_to_integrate as $var)
367
+			if (!empty($member_names)) {
368
+							foreach ($vars_to_integrate as $var)
362 369
 					call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats));
370
+			}
363 371
 		}
364 372
 	}
365 373
 
@@ -367,16 +375,17 @@  discard block
 block discarded – undo
367 375
 	foreach ($data as $var => $val)
368 376
 	{
369 377
 		$type = 'string';
370
-		if (in_array($var, $knownInts))
371
-			$type = 'int';
372
-		elseif (in_array($var, $knownFloats))
373
-			$type = 'float';
374
-		elseif ($var == 'birthdate')
375
-			$type = 'date';
376
-		elseif ($var == 'member_ip')
377
-			$type = 'inet';
378
-		elseif ($var == 'member_ip2')
379
-			$type = 'inet';
378
+		if (in_array($var, $knownInts)) {
379
+					$type = 'int';
380
+		} elseif (in_array($var, $knownFloats)) {
381
+					$type = 'float';
382
+		} elseif ($var == 'birthdate') {
383
+					$type = 'date';
384
+		} elseif ($var == 'member_ip') {
385
+					$type = 'inet';
386
+		} elseif ($var == 'member_ip2') {
387
+					$type = 'inet';
388
+		}
380 389
 
381 390
 		// Doing an increment?
382 391
 		if ($type == 'int' && ($val === '+' || $val === '-'))
@@ -390,8 +399,9 @@  discard block
 block discarded – undo
390 399
 		{
391 400
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
392 401
 			{
393
-				if ($match[1] != '+ ')
394
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
402
+				if ($match[1] != '+ ') {
403
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
404
+				}
395 405
 				$type = 'raw';
396 406
 			}
397 407
 		}
@@ -412,8 +422,9 @@  discard block
 block discarded – undo
412 422
 	// Clear any caching?
413 423
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members))
414 424
 	{
415
-		if (!is_array($members))
416
-			$members = array($members);
425
+		if (!is_array($members)) {
426
+					$members = array($members);
427
+		}
417 428
 
418 429
 		foreach ($members as $member)
419 430
 		{
@@ -446,29 +457,32 @@  discard block
 block discarded – undo
446 457
 {
447 458
 	global $modSettings, $smcFunc;
448 459
 
449
-	if (empty($changeArray) || !is_array($changeArray))
450
-		return;
460
+	if (empty($changeArray) || !is_array($changeArray)) {
461
+			return;
462
+	}
451 463
 
452 464
 	$toRemove = array();
453 465
 
454 466
 	// Go check if there is any setting to be removed.
455
-	foreach ($changeArray as $k => $v)
456
-		if ($v === null)
467
+	foreach ($changeArray as $k => $v) {
468
+			if ($v === null)
457 469
 		{
458 470
 			// Found some, remove them from the original array and add them to ours.
459 471
 			unset($changeArray[$k]);
472
+	}
460 473
 			$toRemove[] = $k;
461 474
 		}
462 475
 
463 476
 	// Proceed with the deletion.
464
-	if (!empty($toRemove))
465
-		$smcFunc['db_query']('', '
477
+	if (!empty($toRemove)) {
478
+			$smcFunc['db_query']('', '
466 479
 			DELETE FROM {db_prefix}settings
467 480
 			WHERE variable IN ({array_string:remove})',
468 481
 			array(
469 482
 				'remove' => $toRemove,
470 483
 			)
471 484
 		);
485
+	}
472 486
 
473 487
 	// In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.
474 488
 	if ($update)
@@ -497,19 +511,22 @@  discard block
 block discarded – undo
497 511
 	foreach ($changeArray as $variable => $value)
498 512
 	{
499 513
 		// Don't bother if it's already like that ;).
500
-		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value)
501
-			continue;
514
+		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) {
515
+					continue;
516
+		}
502 517
 		// If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it.
503
-		elseif (!isset($modSettings[$variable]) && empty($value))
504
-			continue;
518
+		elseif (!isset($modSettings[$variable]) && empty($value)) {
519
+					continue;
520
+		}
505 521
 
506 522
 		$replaceArray[] = array($variable, $value);
507 523
 
508 524
 		$modSettings[$variable] = $value;
509 525
 	}
510 526
 
511
-	if (empty($replaceArray))
512
-		return;
527
+	if (empty($replaceArray)) {
528
+			return;
529
+	}
513 530
 
514 531
 	$smcFunc['db_insert']('replace',
515 532
 		'{db_prefix}settings',
@@ -555,14 +572,17 @@  discard block
 block discarded – undo
555 572
 	$start_invalid = $start < 0;
556 573
 
557 574
 	// Make sure $start is a proper variable - not less than 0.
558
-	if ($start_invalid)
559
-		$start = 0;
575
+	if ($start_invalid) {
576
+			$start = 0;
577
+	}
560 578
 	// Not greater than the upper bound.
561
-	elseif ($start >= $max_value)
562
-		$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
579
+	elseif ($start >= $max_value) {
580
+			$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
581
+	}
563 582
 	// And it has to be a multiple of $num_per_page!
564
-	else
565
-		$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
583
+	else {
584
+			$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
585
+	}
566 586
 
567 587
 	$context['current_page'] = $start / $num_per_page;
568 588
 
@@ -592,77 +612,87 @@  discard block
 block discarded – undo
592 612
 
593 613
 		// Show all the pages.
594 614
 		$display_page = 1;
595
-		for ($counter = 0; $counter < $max_value; $counter += $num_per_page)
596
-			$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
615
+		for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
616
+					$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
617
+		}
597 618
 
598 619
 		// Show the right arrow.
599 620
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
600
-		if ($start != $counter - $max_value && !$start_invalid)
601
-			$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
602
-	}
603
-	else
621
+		if ($start != $counter - $max_value && !$start_invalid) {
622
+					$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
623
+		}
624
+	} else
604 625
 	{
605 626
 		// If they didn't enter an odd value, pretend they did.
606 627
 		$PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2;
607 628
 
608 629
 		// Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page)
609
-		if (!empty($start) && $show_prevnext)
610
-			$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
611
-		else
612
-			$pageindex .= '';
630
+		if (!empty($start) && $show_prevnext) {
631
+					$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
632
+		} else {
633
+					$pageindex .= '';
634
+		}
613 635
 
614 636
 		// Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15)
615
-		if ($start > $num_per_page * $PageContiguous)
616
-			$pageindex .= sprintf($base_link, 0, '1');
637
+		if ($start > $num_per_page * $PageContiguous) {
638
+					$pageindex .= sprintf($base_link, 0, '1');
639
+		}
617 640
 
618 641
 		// Show the ... after the first page.  (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page)
619
-		if ($start > $num_per_page * ($PageContiguous + 1))
620
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
642
+		if ($start > $num_per_page * ($PageContiguous + 1)) {
643
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
621 644
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
622 645
 				'{FIRST_PAGE}' => $num_per_page,
623 646
 				'{LAST_PAGE}' => $start - $num_per_page * $PageContiguous,
624 647
 				'{PER_PAGE}' => $num_per_page,
625 648
 			));
649
+		}
626 650
 
627 651
 		// Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page)
628
-		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
629
-			if ($start >= $num_per_page * $nCont)
652
+		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) {
653
+					if ($start >= $num_per_page * $nCont)
630 654
 			{
631 655
 				$tmpStart = $start - $num_per_page * $nCont;
656
+		}
632 657
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
633 658
 			}
634 659
 
635 660
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
636
-		if (!$start_invalid)
637
-			$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
638
-		else
639
-			$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
661
+		if (!$start_invalid) {
662
+					$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
663
+		} else {
664
+					$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
665
+		}
640 666
 
641 667
 		// Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page)
642 668
 		$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
643
-		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
644
-			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
669
+		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) {
670
+					if ($start + $num_per_page * $nCont <= $tmpMaxPages)
645 671
 			{
646 672
 				$tmpStart = $start + $num_per_page * $nCont;
673
+		}
647 674
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
648 675
 			}
649 676
 
650 677
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
651
-		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
652
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
678
+		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) {
679
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
653 680
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
654 681
 				'{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1),
655 682
 				'{LAST_PAGE}' => $tmpMaxPages,
656 683
 				'{PER_PAGE}' => $num_per_page,
657 684
 			));
685
+		}
658 686
 
659 687
 		// Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15<  next page)
660
-		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
661
-			$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
688
+		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) {
689
+					$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
690
+		}
662 691
 
663 692
 		// Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<)
664
-		if ($start != $tmpMaxPages && $show_prevnext)
665
-			$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
693
+		if ($start != $tmpMaxPages && $show_prevnext) {
694
+					$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
695
+		}
666 696
 	}
667 697
 	$pageindex .= $settings['page_index']['extra_after'];
668 698
 
@@ -688,8 +718,9 @@  discard block
 block discarded – undo
688 718
 	if ($decimal_separator === null)
689 719
 	{
690 720
 		// Not set for whatever reason?
691
-		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1)
692
-			return $number;
721
+		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) {
722
+					return $number;
723
+		}
693 724
 
694 725
 		// Cache these each load...
695 726
 		$thousands_separator = $matches[1];
@@ -721,17 +752,20 @@  discard block
 block discarded – undo
721 752
 	static $non_twelve_hour;
722 753
 
723 754
 	// Offset the time.
724
-	if (!$offset_type)
725
-		$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
755
+	if (!$offset_type) {
756
+			$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
757
+	}
726 758
 	// Just the forum offset?
727
-	elseif ($offset_type == 'forum')
728
-		$time = $log_time + $modSettings['time_offset'] * 3600;
729
-	else
730
-		$time = $log_time;
759
+	elseif ($offset_type == 'forum') {
760
+			$time = $log_time + $modSettings['time_offset'] * 3600;
761
+	} else {
762
+			$time = $log_time;
763
+	}
731 764
 
732 765
 	// We can't have a negative date (on Windows, at least.)
733
-	if ($log_time < 0)
734
-		$log_time = 0;
766
+	if ($log_time < 0) {
767
+			$log_time = 0;
768
+	}
735 769
 
736 770
 	// Today and Yesterday?
737 771
 	if ($modSettings['todayMod'] >= 1 && $show_today === true)
@@ -748,46 +782,53 @@  discard block
 block discarded – undo
748 782
 		{
749 783
 			$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
750 784
 			$today_fmt = $h . ':%M' . $s . ' %p';
785
+		} else {
786
+					$today_fmt = '%H:%M' . $s;
751 787
 		}
752
-		else
753
-			$today_fmt = '%H:%M' . $s;
754 788
 
755 789
 		// Same day of the year, same year.... Today!
756
-		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
757
-			return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
790
+		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
791
+					return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
792
+		}
758 793
 
759 794
 		// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
760
-		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
761
-			return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
795
+		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) {
796
+					return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
797
+		}
762 798
 	}
763 799
 
764 800
 	$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];
765 801
 
766 802
 	if (setlocale(LC_TIME, $txt['lang_locale']))
767 803
 	{
768
-		if (!isset($non_twelve_hour))
769
-			$non_twelve_hour = trim(strftime('%p')) === '';
770
-		if ($non_twelve_hour && strpos($str, '%p') !== false)
771
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
804
+		if (!isset($non_twelve_hour)) {
805
+					$non_twelve_hour = trim(strftime('%p')) === '';
806
+		}
807
+		if ($non_twelve_hour && strpos($str, '%p') !== false) {
808
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
809
+		}
772 810
 
773
-		foreach (array('%a', '%A', '%b', '%B') as $token)
774
-			if (strpos($str, $token) !== false)
811
+		foreach (array('%a', '%A', '%b', '%B') as $token) {
812
+					if (strpos($str, $token) !== false)
775 813
 				$str = str_replace($token, strftime($token, $time), $str);
776
-	}
777
-	else
814
+		}
815
+	} else
778 816
 	{
779 817
 		// Do-it-yourself time localization.  Fun.
780
-		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
781
-			if (strpos($str, $token) !== false)
818
+		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
819
+					if (strpos($str, $token) !== false)
782 820
 				$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
821
+		}
783 822
 
784
-		if (strpos($str, '%p') !== false)
785
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
823
+		if (strpos($str, '%p') !== false) {
824
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
825
+		}
786 826
 	}
787 827
 
788 828
 	// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
789
-	if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
790
-		$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);
829
+	if ($context['server']['is_windows'] && strpos($str, '%e') !== false) {
830
+			$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);
831
+	}
791 832
 
792 833
 	// Format any other characters..
793 834
 	return strftime($str, $time);
@@ -809,16 +850,19 @@  discard block
 block discarded – undo
809 850
 	static $translation = array();
810 851
 
811 852
 	// Determine the character set... Default to UTF-8
812
-	if (empty($context['character_set']))
813
-		$charset = 'UTF-8';
853
+	if (empty($context['character_set'])) {
854
+			$charset = 'UTF-8';
855
+	}
814 856
 	// Use ISO-8859-1 in place of non-supported ISO-8859 charsets...
815
-	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15')))
816
-		$charset = 'ISO-8859-1';
817
-	else
818
-		$charset = $context['character_set'];
857
+	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) {
858
+			$charset = 'ISO-8859-1';
859
+	} else {
860
+			$charset = $context['character_set'];
861
+	}
819 862
 
820
-	if (empty($translation))
821
-		$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
863
+	if (empty($translation)) {
864
+			$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
865
+	}
822 866
 
823 867
 	return strtr($string, $translation);
824 868
 }
@@ -840,8 +884,9 @@  discard block
 block discarded – undo
840 884
 	global $smcFunc;
841 885
 
842 886
 	// It was already short enough!
843
-	if ($smcFunc['strlen']($subject) <= $len)
844
-		return $subject;
887
+	if ($smcFunc['strlen']($subject) <= $len) {
888
+			return $subject;
889
+	}
845 890
 
846 891
 	// Shorten it by the length it was too long, and strip off junk from the end.
847 892
 	return $smcFunc['substr']($subject, 0, $len) . '...';
@@ -860,10 +905,11 @@  discard block
 block discarded – undo
860 905
 {
861 906
 	global $user_info, $modSettings;
862 907
 
863
-	if ($timestamp === null)
864
-		$timestamp = time();
865
-	elseif ($timestamp == 0)
866
-		return 0;
908
+	if ($timestamp === null) {
909
+			$timestamp = time();
910
+	} elseif ($timestamp == 0) {
911
+			return 0;
912
+	}
867 913
 
868 914
 	return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
869 915
 }
@@ -892,8 +938,9 @@  discard block
 block discarded – undo
892 938
 		$array[$i] = $array[$j];
893 939
 		$array[$j] = $temp;
894 940
 
895
-		for ($i = 1; $p[$i] == 0; $i++)
896
-			$p[$i] = 1;
941
+		for ($i = 1; $p[$i] == 0; $i++) {
942
+					$p[$i] = 1;
943
+		}
897 944
 
898 945
 		$orders[] = $array;
899 946
 	}
@@ -925,12 +972,14 @@  discard block
 block discarded – undo
925 972
 	static $disabled;
926 973
 
927 974
 	// Don't waste cycles
928
-	if ($message === '')
929
-		return '';
975
+	if ($message === '') {
976
+			return '';
977
+	}
930 978
 
931 979
 	// Just in case it wasn't determined yet whether UTF-8 is enabled.
932
-	if (!isset($context['utf8']))
933
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
980
+	if (!isset($context['utf8'])) {
981
+			$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
982
+	}
934 983
 
935 984
 	// Clean up any cut/paste issues we may have
936 985
 	$message = sanitizeMSCutPaste($message);
@@ -942,13 +991,15 @@  discard block
 block discarded – undo
942 991
 		return $message;
943 992
 	}
944 993
 
945
-	if ($smileys !== null && ($smileys == '1' || $smileys == '0'))
946
-		$smileys = (bool) $smileys;
994
+	if ($smileys !== null && ($smileys == '1' || $smileys == '0')) {
995
+			$smileys = (bool) $smileys;
996
+	}
947 997
 
948 998
 	if (empty($modSettings['enableBBC']) && $message !== false)
949 999
 	{
950
-		if ($smileys === true)
951
-			parsesmileys($message);
1000
+		if ($smileys === true) {
1001
+					parsesmileys($message);
1002
+		}
952 1003
 
953 1004
 		return $message;
954 1005
 	}
@@ -961,8 +1012,9 @@  discard block
 block discarded – undo
961 1012
 	}
962 1013
 
963 1014
 	// Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker
964
-	if (!empty($modSettings['autoLinkUrls']))
965
-		set_tld_regex();
1015
+	if (!empty($modSettings['autoLinkUrls'])) {
1016
+			set_tld_regex();
1017
+	}
966 1018
 
967 1019
 	// Allow mods access before entering the main parse_bbc loop
968 1020
 	call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
@@ -976,12 +1028,14 @@  discard block
 block discarded – undo
976 1028
 
977 1029
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
978 1030
 
979
-			foreach ($temp as $tag)
980
-				$disabled[trim($tag)] = true;
1031
+			foreach ($temp as $tag) {
1032
+							$disabled[trim($tag)] = true;
1033
+			}
981 1034
 		}
982 1035
 
983
-		if (empty($modSettings['enableEmbeddedFlash']))
984
-			$disabled['flash'] = true;
1036
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1037
+					$disabled['flash'] = true;
1038
+		}
985 1039
 
986 1040
 		/* The following bbc are formatted as an array, with keys as follows:
987 1041
 
@@ -1102,8 +1156,9 @@  discard block
 block discarded – undo
1102 1156
 					$returnContext = '';
1103 1157
 
1104 1158
 					// BBC or the entire attachments feature is disabled
1105
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1106
-						return $data;
1159
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1160
+											return $data;
1161
+					}
1107 1162
 
1108 1163
 					// Save the attach ID.
1109 1164
 					$attachID = $data;
@@ -1114,8 +1169,9 @@  discard block
 block discarded – undo
1114 1169
 					$currentAttachment = parseAttachBBC($attachID);
1115 1170
 
1116 1171
 					// parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do.
1117
-					if (is_string($currentAttachment))
1118
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1172
+					if (is_string($currentAttachment)) {
1173
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1174
+					}
1119 1175
 
1120 1176
 					if (!empty($currentAttachment['is_image']))
1121 1177
 					{
@@ -1126,34 +1182,33 @@  discard block
 block discarded – undo
1126 1182
 						{
1127 1183
 							$width = ' width="' . $params['{width}'] . '"';
1128 1184
 							$height = ' height="' . $params['{height}'] . '"';
1129
-						}
1130
-						elseif (!empty($params['{width}']) && empty($params['{height}']))
1185
+						} elseif (!empty($params['{width}']) && empty($params['{height}']))
1131 1186
 						{
1132 1187
 							$width = ' width="' . $params['{width}'] . '"';
1133 1188
 							$height = '';
1134
-						}
1135
-						elseif (empty($params['{width}']) && !empty($params['{height}']))
1189
+						} elseif (empty($params['{width}']) && !empty($params['{height}']))
1136 1190
 						{
1137 1191
 							$width = '';
1138 1192
 							$height = ' height="' . $params['{height}'] . '"';
1139
-						}
1140
-						else
1193
+						} else
1141 1194
 						{
1142 1195
 							$width = ' width="' . $currentAttachment['width'] . '"';
1143 1196
 							$height = ' height="' . $currentAttachment['height'] . '"';
1144 1197
 						}
1145 1198
 
1146
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1147
-							$returnContext .= '
1199
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1200
+													$returnContext .= '
1148 1201
 													<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>';
1149
-						else
1150
-							$returnContext .= '
1202
+						} else {
1203
+													$returnContext .= '
1151 1204
 													<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>';
1205
+						}
1152 1206
 					}
1153 1207
 
1154 1208
 					// No image. Show a link.
1155
-					else
1156
-						$returnContext .= $currentAttachment['link'];
1209
+					else {
1210
+											$returnContext .= $currentAttachment['link'];
1211
+					}
1157 1212
 
1158 1213
 					// Gotta append what we just did.
1159 1214
 					$data = $returnContext;
@@ -1184,8 +1239,9 @@  discard block
 block discarded – undo
1184 1239
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1185 1240
 						{
1186 1241
 							// Do PHP code coloring?
1187
-							if ($php_parts[$php_i] != '&lt;?php')
1188
-								continue;
1242
+							if ($php_parts[$php_i] != '&lt;?php') {
1243
+															continue;
1244
+							}
1189 1245
 
1190 1246
 							$php_string = '';
1191 1247
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1201,8 +1257,9 @@  discard block
 block discarded – undo
1201 1257
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1202 1258
 
1203 1259
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1204
-						if ($context['browser']['is_opera'])
1205
-							$data .= '&nbsp;';
1260
+						if ($context['browser']['is_opera']) {
1261
+													$data .= '&nbsp;';
1262
+						}
1206 1263
 					}
1207 1264
 				},
1208 1265
 				'block_level' => true,
@@ -1221,8 +1278,9 @@  discard block
 block discarded – undo
1221 1278
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1222 1279
 						{
1223 1280
 							// Do PHP code coloring?
1224
-							if ($php_parts[$php_i] != '&lt;?php')
1225
-								continue;
1281
+							if ($php_parts[$php_i] != '&lt;?php') {
1282
+															continue;
1283
+							}
1226 1284
 
1227 1285
 							$php_string = '';
1228 1286
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1238,8 +1296,9 @@  discard block
 block discarded – undo
1238 1296
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1239 1297
 
1240 1298
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1241
-						if ($context['browser']['is_opera'])
1242
-							$data[0] .= '&nbsp;';
1299
+						if ($context['browser']['is_opera']) {
1300
+													$data[0] .= '&nbsp;';
1301
+						}
1243 1302
 					}
1244 1303
 				},
1245 1304
 				'block_level' => true,
@@ -1277,11 +1336,13 @@  discard block
 block discarded – undo
1277 1336
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1278 1337
 				'validate' => function (&$tag, &$data, $disabled)
1279 1338
 				{
1280
-					if (isset($disabled['url']))
1281
-						$tag['content'] = '$1';
1339
+					if (isset($disabled['url'])) {
1340
+											$tag['content'] = '$1';
1341
+					}
1282 1342
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1283
-					if (empty($scheme))
1284
-						$data[0] = '//' . ltrim($data[0], ':/');
1343
+					if (empty($scheme)) {
1344
+											$data[0] = '//' . ltrim($data[0], ':/');
1345
+					}
1285 1346
 				},
1286 1347
 				'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>',
1287 1348
 			),
@@ -1328,14 +1389,16 @@  discard block
 block discarded – undo
1328 1389
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1329 1390
 					if ($image_proxy_enabled)
1330 1391
 					{
1331
-						if (empty($scheme))
1332
-							$data = 'http://' . ltrim($data, ':/');
1392
+						if (empty($scheme)) {
1393
+													$data = 'http://' . ltrim($data, ':/');
1394
+						}
1333 1395
 
1334
-						if ($scheme != 'https')
1335
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1396
+						if ($scheme != 'https') {
1397
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1398
+						}
1399
+					} elseif (empty($scheme)) {
1400
+											$data = '//' . ltrim($data, ':/');
1336 1401
 					}
1337
-					elseif (empty($scheme))
1338
-						$data = '//' . ltrim($data, ':/');
1339 1402
 				},
1340 1403
 				'disabled_content' => '($1)',
1341 1404
 			),
@@ -1351,14 +1414,16 @@  discard block
 block discarded – undo
1351 1414
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1352 1415
 					if ($image_proxy_enabled)
1353 1416
 					{
1354
-						if (empty($scheme))
1355
-							$data = 'http://' . ltrim($data, ':/');
1417
+						if (empty($scheme)) {
1418
+													$data = 'http://' . ltrim($data, ':/');
1419
+						}
1356 1420
 
1357
-						if ($scheme != 'https')
1358
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1421
+						if ($scheme != 'https') {
1422
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1423
+						}
1424
+					} elseif (empty($scheme)) {
1425
+											$data = '//' . ltrim($data, ':/');
1359 1426
 					}
1360
-					elseif (empty($scheme))
1361
-						$data = '//' . ltrim($data, ':/');
1362 1427
 				},
1363 1428
 				'disabled_content' => '($1)',
1364 1429
 			),
@@ -1370,8 +1435,9 @@  discard block
 block discarded – undo
1370 1435
 				{
1371 1436
 					$data = strtr($data, array('<br>' => ''));
1372 1437
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1373
-					if (empty($scheme))
1374
-						$data = '//' . ltrim($data, ':/');
1438
+					if (empty($scheme)) {
1439
+											$data = '//' . ltrim($data, ':/');
1440
+					}
1375 1441
 				},
1376 1442
 			),
1377 1443
 			array(
@@ -1382,13 +1448,14 @@  discard block
 block discarded – undo
1382 1448
 				'after' => '</a>',
1383 1449
 				'validate' => function (&$tag, &$data, $disabled)
1384 1450
 				{
1385
-					if (substr($data, 0, 1) == '#')
1386
-						$data = '#post_' . substr($data, 1);
1387
-					else
1451
+					if (substr($data, 0, 1) == '#') {
1452
+											$data = '#post_' . substr($data, 1);
1453
+					} else
1388 1454
 					{
1389 1455
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1390
-						if (empty($scheme))
1391
-							$data = '//' . ltrim($data, ':/');
1456
+						if (empty($scheme)) {
1457
+													$data = '//' . ltrim($data, ':/');
1458
+						}
1392 1459
 					}
1393 1460
 				},
1394 1461
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1466,8 +1533,9 @@  discard block
 block discarded – undo
1466 1533
 					{
1467 1534
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1468 1535
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1469
-						if ($add_begin)
1470
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1536
+						if ($add_begin) {
1537
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1538
+						}
1471 1539
 					}
1472 1540
 				},
1473 1541
 				'block_level' => false,
@@ -1598,10 +1666,11 @@  discard block
 block discarded – undo
1598 1666
 				'content' => '$1',
1599 1667
 				'validate' => function (&$tag, &$data, $disabled)
1600 1668
 				{
1601
-					if (is_numeric($data))
1602
-						$data = timeformat($data);
1603
-					else
1604
-						$tag['content'] = '[time]$1[/time]';
1669
+					if (is_numeric($data)) {
1670
+											$data = timeformat($data);
1671
+					} else {
1672
+											$tag['content'] = '[time]$1[/time]';
1673
+					}
1605 1674
 				},
1606 1675
 			),
1607 1676
 			array(
@@ -1628,8 +1697,9 @@  discard block
 block discarded – undo
1628 1697
 				{
1629 1698
 					$data = strtr($data, array('<br>' => ''));
1630 1699
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1631
-					if (empty($scheme))
1632
-						$data = '//' . ltrim($data, ':/');
1700
+					if (empty($scheme)) {
1701
+											$data = '//' . ltrim($data, ':/');
1702
+					}
1633 1703
 				},
1634 1704
 			),
1635 1705
 			array(
@@ -1641,8 +1711,9 @@  discard block
 block discarded – undo
1641 1711
 				'validate' => function (&$tag, &$data, $disabled)
1642 1712
 				{
1643 1713
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1644
-					if (empty($scheme))
1645
-						$data = '//' . ltrim($data, ':/');
1714
+					if (empty($scheme)) {
1715
+											$data = '//' . ltrim($data, ':/');
1716
+					}
1646 1717
 				},
1647 1718
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1648 1719
 				'disabled_after' => ' ($1)',
@@ -1662,8 +1733,9 @@  discard block
 block discarded – undo
1662 1733
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1663 1734
 		if ($message === false)
1664 1735
 		{
1665
-			if (isset($temp_bbc))
1666
-				$bbc_codes = $temp_bbc;
1736
+			if (isset($temp_bbc)) {
1737
+							$bbc_codes = $temp_bbc;
1738
+			}
1667 1739
 			usort($codes, function ($a, $b) {
1668 1740
 				return strcmp($a['tag'], $b['tag']);
1669 1741
 			});
@@ -1683,8 +1755,9 @@  discard block
 block discarded – undo
1683 1755
 		);
1684 1756
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1685 1757
 		{
1686
-			foreach ($itemcodes as $c => $dummy)
1687
-				$bbc_codes[$c] = array();
1758
+			foreach ($itemcodes as $c => $dummy) {
1759
+							$bbc_codes[$c] = array();
1760
+			}
1688 1761
 		}
1689 1762
 
1690 1763
 		// Shhhh!
@@ -1705,12 +1778,14 @@  discard block
 block discarded – undo
1705 1778
 		foreach ($codes as $code)
1706 1779
 		{
1707 1780
 			// Make it easier to process parameters later
1708
-			if (!empty($code['parameters']))
1709
-				ksort($code['parameters'], SORT_STRING);
1781
+			if (!empty($code['parameters'])) {
1782
+							ksort($code['parameters'], SORT_STRING);
1783
+			}
1710 1784
 
1711 1785
 			// If we are not doing every tag only do ones we are interested in.
1712
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1713
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1786
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
1787
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1788
+			}
1714 1789
 		}
1715 1790
 		$codes = null;
1716 1791
 	}
@@ -1721,8 +1796,9 @@  discard block
 block discarded – undo
1721 1796
 		// It's likely this will change if the message is modified.
1722 1797
 		$cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']);
1723 1798
 
1724
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1725
-			return $temp;
1799
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
1800
+					return $temp;
1801
+		}
1726 1802
 
1727 1803
 		$cache_t = microtime();
1728 1804
 	}
@@ -1754,8 +1830,9 @@  discard block
 block discarded – undo
1754 1830
 		$disabled['flash'] = true;
1755 1831
 
1756 1832
 		// @todo Change maybe?
1757
-		if (!isset($_GET['images']))
1758
-			$disabled['img'] = true;
1833
+		if (!isset($_GET['images'])) {
1834
+					$disabled['img'] = true;
1835
+		}
1759 1836
 
1760 1837
 		// @todo Interface/setting to add more?
1761 1838
 	}
@@ -1781,8 +1858,9 @@  discard block
 block discarded – undo
1781 1858
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
1782 1859
 
1783 1860
 		// Failsafe.
1784
-		if ($pos === false || $last_pos > $pos)
1785
-			$pos = strlen($message) + 1;
1861
+		if ($pos === false || $last_pos > $pos) {
1862
+					$pos = strlen($message) + 1;
1863
+		}
1786 1864
 
1787 1865
 		// Can't have a one letter smiley, URL, or email! (sorry.)
1788 1866
 		if ($last_pos < $pos - 1)
@@ -1801,8 +1879,9 @@  discard block
 block discarded – undo
1801 1879
 
1802 1880
 				// <br> should be empty.
1803 1881
 				$empty_tags = array('br', 'hr');
1804
-				foreach ($empty_tags as $tag)
1805
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1882
+				foreach ($empty_tags as $tag) {
1883
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1884
+				}
1806 1885
 
1807 1886
 				// b, u, i, s, pre... basic tags.
1808 1887
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote');
@@ -1811,8 +1890,9 @@  discard block
 block discarded – undo
1811 1890
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
1812 1891
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
1813 1892
 
1814
-					if ($diff > 0)
1815
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1893
+					if ($diff > 0) {
1894
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1895
+					}
1816 1896
 				}
1817 1897
 
1818 1898
 				// Do <img ...> - with security... action= -> action-.
@@ -1825,8 +1905,9 @@  discard block
 block discarded – undo
1825 1905
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
1826 1906
 
1827 1907
 						// Remove action= from the URL - no funny business, now.
1828
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
1829
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1908
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
1909
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1910
+						}
1830 1911
 
1831 1912
 						// Check if the image is larger than allowed.
1832 1913
 						if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
@@ -1847,9 +1928,9 @@  discard block
 block discarded – undo
1847 1928
 
1848 1929
 							// Set the new image tag.
1849 1930
 							$replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]';
1931
+						} else {
1932
+													$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1850 1933
 						}
1851
-						else
1852
-							$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1853 1934
 					}
1854 1935
 
1855 1936
 					$data = strtr($data, $replaces);
@@ -1862,16 +1943,18 @@  discard block
 block discarded – undo
1862 1943
 				$no_autolink_area = false;
1863 1944
 				if (!empty($open_tags))
1864 1945
 				{
1865
-					foreach ($open_tags as $open_tag)
1866
-						if (in_array($open_tag['tag'], $no_autolink_tags))
1946
+					foreach ($open_tags as $open_tag) {
1947
+											if (in_array($open_tag['tag'], $no_autolink_tags))
1867 1948
 							$no_autolink_area = true;
1949
+					}
1868 1950
 				}
1869 1951
 
1870 1952
 				// Don't go backwards.
1871 1953
 				// @todo Don't think is the real solution....
1872 1954
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
1873
-				if ($pos < $lastAutoPos)
1874
-					$no_autolink_area = true;
1955
+				if ($pos < $lastAutoPos) {
1956
+									$no_autolink_area = true;
1957
+				}
1875 1958
 				$lastAutoPos = $pos;
1876 1959
 
1877 1960
 				if (!$no_autolink_area)
@@ -1980,17 +2063,19 @@  discard block
 block discarded – undo
1980 2063
 							if ($scheme == 'mailto')
1981 2064
 							{
1982 2065
 								$email_address = str_replace('mailto:', '', $url);
1983
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
1984
-									return '[email=' . $email_address . ']' . $url . '[/email]';
1985
-								else
1986
-									return $url;
2066
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2067
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2068
+								} else {
2069
+																	return $url;
2070
+								}
1987 2071
 							}
1988 2072
 
1989 2073
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
1990
-							if (empty($scheme))
1991
-								$fullUrl = '//' . ltrim($url, ':/');
1992
-							else
1993
-								$fullUrl = $url;
2074
+							if (empty($scheme)) {
2075
+															$fullUrl = '//' . ltrim($url, ':/');
2076
+							} else {
2077
+															$fullUrl = $url;
2078
+							}
1994 2079
 
1995 2080
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
1996 2081
 						}, $data);
@@ -2039,16 +2124,18 @@  discard block
 block discarded – undo
2039 2124
 		}
2040 2125
 
2041 2126
 		// Are we there yet?  Are we there yet?
2042
-		if ($pos >= strlen($message) - 1)
2043
-			break;
2127
+		if ($pos >= strlen($message) - 1) {
2128
+					break;
2129
+		}
2044 2130
 
2045 2131
 		$tags = strtolower($message[$pos + 1]);
2046 2132
 
2047 2133
 		if ($tags == '/' && !empty($open_tags))
2048 2134
 		{
2049 2135
 			$pos2 = strpos($message, ']', $pos + 1);
2050
-			if ($pos2 == $pos + 2)
2051
-				continue;
2136
+			if ($pos2 == $pos + 2) {
2137
+							continue;
2138
+			}
2052 2139
 
2053 2140
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2054 2141
 
@@ -2058,8 +2145,9 @@  discard block
 block discarded – undo
2058 2145
 			do
2059 2146
 			{
2060 2147
 				$tag = array_pop($open_tags);
2061
-				if (!$tag)
2062
-					break;
2148
+				if (!$tag) {
2149
+									break;
2150
+				}
2063 2151
 
2064 2152
 				if (!empty($tag['block_level']))
2065 2153
 				{
@@ -2073,10 +2161,11 @@  discard block
 block discarded – undo
2073 2161
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2074 2162
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2075 2163
 					{
2076
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2077
-							if ($temp['tag'] == $look_for)
2164
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2165
+													if ($temp['tag'] == $look_for)
2078 2166
 							{
2079 2167
 								$block_level = !empty($temp['block_level']);
2168
+						}
2080 2169
 								break;
2081 2170
 							}
2082 2171
 					}
@@ -2098,15 +2187,15 @@  discard block
 block discarded – undo
2098 2187
 			{
2099 2188
 				$open_tags = $to_close;
2100 2189
 				continue;
2101
-			}
2102
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2190
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2103 2191
 			{
2104 2192
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2105 2193
 				{
2106
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2107
-						if ($temp['tag'] == $look_for)
2194
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2195
+											if ($temp['tag'] == $look_for)
2108 2196
 						{
2109 2197
 							$block_level = !empty($temp['block_level']);
2198
+					}
2110 2199
 							break;
2111 2200
 						}
2112 2201
 				}
@@ -2114,8 +2203,9 @@  discard block
 block discarded – undo
2114 2203
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2115 2204
 				if (!$block_level)
2116 2205
 				{
2117
-					foreach ($to_close as $tag)
2118
-						array_push($open_tags, $tag);
2206
+					foreach ($to_close as $tag) {
2207
+											array_push($open_tags, $tag);
2208
+					}
2119 2209
 					continue;
2120 2210
 				}
2121 2211
 			}
@@ -2127,10 +2217,12 @@  discard block
 block discarded – undo
2127 2217
 				$pos2 = $pos - 1;
2128 2218
 
2129 2219
 				// See the comment at the end of the big loop - just eating whitespace ;).
2130
-				if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>')
2131
-					$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2132
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
2133
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2220
+				if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') {
2221
+									$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2222
+				}
2223
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0) {
2224
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2225
+				}
2134 2226
 			}
2135 2227
 
2136 2228
 			if (!empty($to_close))
@@ -2143,8 +2235,9 @@  discard block
 block discarded – undo
2143 2235
 		}
2144 2236
 
2145 2237
 		// No tags for this character, so just keep going (fastest possible course.)
2146
-		if (!isset($bbc_codes[$tags]))
2147
-			continue;
2238
+		if (!isset($bbc_codes[$tags])) {
2239
+					continue;
2240
+		}
2148 2241
 
2149 2242
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2150 2243
 		$tag = null;
@@ -2153,44 +2246,52 @@  discard block
 block discarded – undo
2153 2246
 			$pt_strlen = strlen($possible['tag']);
2154 2247
 
2155 2248
 			// Not a match?
2156
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2157
-				continue;
2249
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2250
+							continue;
2251
+			}
2158 2252
 
2159 2253
 			$next_c = $message[$pos + 1 + $pt_strlen];
2160 2254
 
2161 2255
 			// A test validation?
2162
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2163
-				continue;
2256
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2257
+							continue;
2258
+			}
2164 2259
 			// Do we want parameters?
2165 2260
 			elseif (!empty($possible['parameters']))
2166 2261
 			{
2167
-				if ($next_c != ' ')
2168
-					continue;
2169
-			}
2170
-			elseif (isset($possible['type']))
2262
+				if ($next_c != ' ') {
2263
+									continue;
2264
+				}
2265
+			} elseif (isset($possible['type']))
2171 2266
 			{
2172 2267
 				// Do we need an equal sign?
2173
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2174
-					continue;
2268
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2269
+									continue;
2270
+				}
2175 2271
 				// Maybe we just want a /...
2176
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2177
-					continue;
2272
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2273
+									continue;
2274
+				}
2178 2275
 				// An immediate ]?
2179
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2180
-					continue;
2276
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2277
+									continue;
2278
+				}
2181 2279
 			}
2182 2280
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2183
-			elseif ($next_c != ']')
2184
-				continue;
2281
+			elseif ($next_c != ']') {
2282
+							continue;
2283
+			}
2185 2284
 
2186 2285
 			// Check allowed tree?
2187
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2188
-				continue;
2189
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2190
-				continue;
2286
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2287
+							continue;
2288
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2289
+							continue;
2290
+			}
2191 2291
 			// If this is in the list of disallowed child tags, don't parse it.
2192
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2193
-				continue;
2292
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2293
+							continue;
2294
+			}
2194 2295
 
2195 2296
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2196 2297
 
@@ -2202,8 +2303,9 @@  discard block
 block discarded – undo
2202 2303
 				foreach ($open_tags as $open_quote)
2203 2304
 				{
2204 2305
 					// Every parent quote this quote has flips the styling
2205
-					if ($open_quote['tag'] == 'quote')
2206
-						$quote_alt = !$quote_alt;
2306
+					if ($open_quote['tag'] == 'quote') {
2307
+											$quote_alt = !$quote_alt;
2308
+					}
2207 2309
 				}
2208 2310
 				// Add a class to the quote to style alternating blockquotes
2209 2311
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2214,8 +2316,9 @@  discard block
 block discarded – undo
2214 2316
 			{
2215 2317
 				// Build a regular expression for each parameter for the current tag.
2216 2318
 				$preg = array();
2217
-				foreach ($possible['parameters'] as $p => $info)
2218
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2319
+				foreach ($possible['parameters'] as $p => $info) {
2320
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2321
+				}
2219 2322
 
2220 2323
 				// Extract the string that potentially holds our parameters.
2221 2324
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2235,24 +2338,27 @@  discard block
 block discarded – undo
2235 2338
 
2236 2339
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2237 2340
 
2238
-					if ($match)
2239
-						$blob_counter = count($blobs) + 1;
2341
+					if ($match) {
2342
+											$blob_counter = count($blobs) + 1;
2343
+					}
2240 2344
 				}
2241 2345
 
2242 2346
 				// Didn't match our parameter list, try the next possible.
2243
-				if (!$match)
2244
-					continue;
2347
+				if (!$match) {
2348
+									continue;
2349
+				}
2245 2350
 
2246 2351
 				$params = array();
2247 2352
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2248 2353
 				{
2249 2354
 					$key = strtok(ltrim($matches[$i]), '=');
2250
-					if (isset($possible['parameters'][$key]['value']))
2251
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2252
-					elseif (isset($possible['parameters'][$key]['validate']))
2253
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2254
-					else
2255
-						$params['{' . $key . '}'] = $matches[$i + 1];
2355
+					if (isset($possible['parameters'][$key]['value'])) {
2356
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2357
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2358
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2359
+					} else {
2360
+											$params['{' . $key . '}'] = $matches[$i + 1];
2361
+					}
2256 2362
 
2257 2363
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2258 2364
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2260,23 +2366,26 @@  discard block
 block discarded – undo
2260 2366
 
2261 2367
 				foreach ($possible['parameters'] as $p => $info)
2262 2368
 				{
2263
-					if (!isset($params['{' . $p . '}']))
2264
-						$params['{' . $p . '}'] = '';
2369
+					if (!isset($params['{' . $p . '}'])) {
2370
+											$params['{' . $p . '}'] = '';
2371
+					}
2265 2372
 				}
2266 2373
 
2267 2374
 				$tag = $possible;
2268 2375
 
2269 2376
 				// Put the parameters into the string.
2270
-				if (isset($tag['before']))
2271
-					$tag['before'] = strtr($tag['before'], $params);
2272
-				if (isset($tag['after']))
2273
-					$tag['after'] = strtr($tag['after'], $params);
2274
-				if (isset($tag['content']))
2275
-					$tag['content'] = strtr($tag['content'], $params);
2377
+				if (isset($tag['before'])) {
2378
+									$tag['before'] = strtr($tag['before'], $params);
2379
+				}
2380
+				if (isset($tag['after'])) {
2381
+									$tag['after'] = strtr($tag['after'], $params);
2382
+				}
2383
+				if (isset($tag['content'])) {
2384
+									$tag['content'] = strtr($tag['content'], $params);
2385
+				}
2276 2386
 
2277 2387
 				$pos1 += strlen($given_param_string);
2278
-			}
2279
-			else
2388
+			} else
2280 2389
 			{
2281 2390
 				$tag = $possible;
2282 2391
 				$params = array();
@@ -2287,8 +2396,9 @@  discard block
 block discarded – undo
2287 2396
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2288 2397
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2289 2398
 		{
2290
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2291
-				continue;
2399
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2400
+							continue;
2401
+			}
2292 2402
 
2293 2403
 			$tag = $itemcodes[$message[$pos + 1]];
2294 2404
 
@@ -2309,9 +2419,9 @@  discard block
 block discarded – undo
2309 2419
 			{
2310 2420
 				array_pop($open_tags);
2311 2421
 				$code = '</li>';
2422
+			} else {
2423
+							$code = '';
2312 2424
 			}
2313
-			else
2314
-				$code = '';
2315 2425
 
2316 2426
 			// Now we open a new tag.
2317 2427
 			$open_tags[] = array(
@@ -2358,12 +2468,14 @@  discard block
 block discarded – undo
2358 2468
 		}
2359 2469
 
2360 2470
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2361
-		if ($tag === null)
2362
-			continue;
2471
+		if ($tag === null) {
2472
+					continue;
2473
+		}
2363 2474
 
2364 2475
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2365
-		if (isset($inside['disallow_children']))
2366
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2476
+		if (isset($inside['disallow_children'])) {
2477
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2478
+		}
2367 2479
 
2368 2480
 		// Is this tag disabled?
2369 2481
 		if (isset($disabled[$tag['tag']]))
@@ -2373,14 +2485,13 @@  discard block
 block discarded – undo
2373 2485
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2374 2486
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2375 2487
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2376
-			}
2377
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2488
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2378 2489
 			{
2379 2490
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2380 2491
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2492
+			} else {
2493
+							$tag['content'] = $tag['disabled_content'];
2381 2494
 			}
2382
-			else
2383
-				$tag['content'] = $tag['disabled_content'];
2384 2495
 		}
2385 2496
 
2386 2497
 		// we use this a lot
@@ -2390,8 +2501,9 @@  discard block
 block discarded – undo
2390 2501
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2391 2502
 		{
2392 2503
 			$n = count($open_tags) - 1;
2393
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2394
-				$n--;
2504
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2505
+							$n--;
2506
+			}
2395 2507
 
2396 2508
 			// Close all the non block level tags so this tag isn't surrounded by them.
2397 2509
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2402,10 +2514,12 @@  discard block
 block discarded – undo
2402 2514
 				$pos1 += $ot_strlen + 2;
2403 2515
 
2404 2516
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2405
-				if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>')
2406
-					$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2407
-				if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
2408
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2517
+				if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') {
2518
+									$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2519
+				}
2520
+				if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0) {
2521
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2522
+				}
2409 2523
 
2410 2524
 				array_pop($open_tags);
2411 2525
 			}
@@ -2423,16 +2537,19 @@  discard block
 block discarded – undo
2423 2537
 		elseif ($tag['type'] == 'unparsed_content')
2424 2538
 		{
2425 2539
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2426
-			if ($pos2 === false)
2427
-				continue;
2540
+			if ($pos2 === false) {
2541
+							continue;
2542
+			}
2428 2543
 
2429 2544
 			$data = substr($message, $pos1, $pos2 - $pos1);
2430 2545
 
2431
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2432
-				$data = substr($data, 4);
2546
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2547
+							$data = substr($data, 4);
2548
+			}
2433 2549
 
2434
-			if (isset($tag['validate']))
2435
-				$tag['validate']($tag, $data, $disabled, $params);
2550
+			if (isset($tag['validate'])) {
2551
+							$tag['validate']($tag, $data, $disabled, $params);
2552
+			}
2436 2553
 
2437 2554
 			$code = strtr($tag['content'], array('$1' => $data));
2438 2555
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2448,34 +2565,40 @@  discard block
 block discarded – undo
2448 2565
 			if (isset($tag['quoted']))
2449 2566
 			{
2450 2567
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2451
-				if ($tag['quoted'] != 'optional' && !$quoted)
2452
-					continue;
2568
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2569
+									continue;
2570
+				}
2453 2571
 
2454
-				if ($quoted)
2455
-					$pos1 += 6;
2572
+				if ($quoted) {
2573
+									$pos1 += 6;
2574
+				}
2575
+			} else {
2576
+							$quoted = false;
2456 2577
 			}
2457
-			else
2458
-				$quoted = false;
2459 2578
 
2460 2579
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2461
-			if ($pos2 === false)
2462
-				continue;
2580
+			if ($pos2 === false) {
2581
+							continue;
2582
+			}
2463 2583
 
2464 2584
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2465
-			if ($pos3 === false)
2466
-				continue;
2585
+			if ($pos3 === false) {
2586
+							continue;
2587
+			}
2467 2588
 
2468 2589
 			$data = array(
2469 2590
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2470 2591
 				substr($message, $pos1, $pos2 - $pos1)
2471 2592
 			);
2472 2593
 
2473
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2474
-				$data[0] = substr($data[0], 4);
2594
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2595
+							$data[0] = substr($data[0], 4);
2596
+			}
2475 2597
 
2476 2598
 			// Validation for my parking, please!
2477
-			if (isset($tag['validate']))
2478
-				$tag['validate']($tag, $data, $disabled, $params);
2599
+			if (isset($tag['validate'])) {
2600
+							$tag['validate']($tag, $data, $disabled, $params);
2601
+			}
2479 2602
 
2480 2603
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2481 2604
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2492,23 +2615,27 @@  discard block
 block discarded – undo
2492 2615
 		elseif ($tag['type'] == 'unparsed_commas_content')
2493 2616
 		{
2494 2617
 			$pos2 = strpos($message, ']', $pos1);
2495
-			if ($pos2 === false)
2496
-				continue;
2618
+			if ($pos2 === false) {
2619
+							continue;
2620
+			}
2497 2621
 
2498 2622
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2499
-			if ($pos3 === false)
2500
-				continue;
2623
+			if ($pos3 === false) {
2624
+							continue;
2625
+			}
2501 2626
 
2502 2627
 			// We want $1 to be the content, and the rest to be csv.
2503 2628
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2504 2629
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2505 2630
 
2506
-			if (isset($tag['validate']))
2507
-				$tag['validate']($tag, $data, $disabled, $params);
2631
+			if (isset($tag['validate'])) {
2632
+							$tag['validate']($tag, $data, $disabled, $params);
2633
+			}
2508 2634
 
2509 2635
 			$code = $tag['content'];
2510
-			foreach ($data as $k => $d)
2511
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2636
+			foreach ($data as $k => $d) {
2637
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2638
+			}
2512 2639
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2513 2640
 			$pos += strlen($code) - 1 + 2;
2514 2641
 		}
@@ -2516,24 +2643,28 @@  discard block
 block discarded – undo
2516 2643
 		elseif ($tag['type'] == 'unparsed_commas')
2517 2644
 		{
2518 2645
 			$pos2 = strpos($message, ']', $pos1);
2519
-			if ($pos2 === false)
2520
-				continue;
2646
+			if ($pos2 === false) {
2647
+							continue;
2648
+			}
2521 2649
 
2522 2650
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2523 2651
 
2524
-			if (isset($tag['validate']))
2525
-				$tag['validate']($tag, $data, $disabled, $params);
2652
+			if (isset($tag['validate'])) {
2653
+							$tag['validate']($tag, $data, $disabled, $params);
2654
+			}
2526 2655
 
2527 2656
 			// Fix after, for disabled code mainly.
2528
-			foreach ($data as $k => $d)
2529
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2657
+			foreach ($data as $k => $d) {
2658
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2659
+			}
2530 2660
 
2531 2661
 			$open_tags[] = $tag;
2532 2662
 
2533 2663
 			// Replace them out, $1, $2, $3, $4, etc.
2534 2664
 			$code = $tag['before'];
2535
-			foreach ($data as $k => $d)
2536
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2665
+			foreach ($data as $k => $d) {
2666
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2667
+			}
2537 2668
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2538 2669
 			$pos += strlen($code) - 1 + 2;
2539 2670
 		}
@@ -2544,28 +2675,33 @@  discard block
 block discarded – undo
2544 2675
 			if (isset($tag['quoted']))
2545 2676
 			{
2546 2677
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2547
-				if ($tag['quoted'] != 'optional' && !$quoted)
2548
-					continue;
2678
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2679
+									continue;
2680
+				}
2549 2681
 
2550
-				if ($quoted)
2551
-					$pos1 += 6;
2682
+				if ($quoted) {
2683
+									$pos1 += 6;
2684
+				}
2685
+			} else {
2686
+							$quoted = false;
2552 2687
 			}
2553
-			else
2554
-				$quoted = false;
2555 2688
 
2556 2689
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2557
-			if ($pos2 === false)
2558
-				continue;
2690
+			if ($pos2 === false) {
2691
+							continue;
2692
+			}
2559 2693
 
2560 2694
 			$data = substr($message, $pos1, $pos2 - $pos1);
2561 2695
 
2562 2696
 			// Validation for my parking, please!
2563
-			if (isset($tag['validate']))
2564
-				$tag['validate']($tag, $data, $disabled, $params);
2697
+			if (isset($tag['validate'])) {
2698
+							$tag['validate']($tag, $data, $disabled, $params);
2699
+			}
2565 2700
 
2566 2701
 			// For parsed content, we must recurse to avoid security problems.
2567
-			if ($tag['type'] != 'unparsed_equals')
2568
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2702
+			if ($tag['type'] != 'unparsed_equals') {
2703
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2704
+			}
2569 2705
 
2570 2706
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2571 2707
 
@@ -2577,34 +2713,40 @@  discard block
 block discarded – undo
2577 2713
 		}
2578 2714
 
2579 2715
 		// If this is block level, eat any breaks after it.
2580
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2581
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2716
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2717
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2718
+		}
2582 2719
 
2583 2720
 		// Are we trimming outside this tag?
2584
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2585
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2721
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2722
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2723
+		}
2586 2724
 	}
2587 2725
 
2588 2726
 	// Close any remaining tags.
2589
-	while ($tag = array_pop($open_tags))
2590
-		$message .= "\n" . $tag['after'] . "\n";
2727
+	while ($tag = array_pop($open_tags)) {
2728
+			$message .= "\n" . $tag['after'] . "\n";
2729
+	}
2591 2730
 
2592 2731
 	// Parse the smileys within the parts where it can be done safely.
2593 2732
 	if ($smileys === true)
2594 2733
 	{
2595 2734
 		$message_parts = explode("\n", $message);
2596
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2597
-			parsesmileys($message_parts[$i]);
2735
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2736
+					parsesmileys($message_parts[$i]);
2737
+		}
2598 2738
 
2599 2739
 		$message = implode('', $message_parts);
2600 2740
 	}
2601 2741
 
2602 2742
 	// No smileys, just get rid of the markers.
2603
-	else
2604
-		$message = strtr($message, array("\n" => ''));
2743
+	else {
2744
+			$message = strtr($message, array("\n" => ''));
2745
+	}
2605 2746
 
2606
-	if ($message !== '' && $message[0] === ' ')
2607
-		$message = '&nbsp;' . substr($message, 1);
2747
+	if ($message !== '' && $message[0] === ' ') {
2748
+			$message = '&nbsp;' . substr($message, 1);
2749
+	}
2608 2750
 
2609 2751
 	// Cleanup whitespace.
2610 2752
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2613,15 +2755,16 @@  discard block
 block discarded – undo
2613 2755
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2614 2756
 
2615 2757
 	// Cache the output if it took some time...
2616
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2617
-		cache_put_data($cache_key, $message, 240);
2758
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
2759
+			cache_put_data($cache_key, $message, 240);
2760
+	}
2618 2761
 
2619 2762
 	// If this was a force parse revert if needed.
2620 2763
 	if (!empty($parse_tags))
2621 2764
 	{
2622
-		if (empty($temp_bbc))
2623
-			$bbc_codes = array();
2624
-		else
2765
+		if (empty($temp_bbc)) {
2766
+					$bbc_codes = array();
2767
+		} else
2625 2768
 		{
2626 2769
 			$bbc_codes = $temp_bbc;
2627 2770
 			unset($temp_bbc);
@@ -2648,8 +2791,9 @@  discard block
 block discarded – undo
2648 2791
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2649 2792
 
2650 2793
 	// No smiley set at all?!
2651
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2652
-		return;
2794
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
2795
+			return;
2796
+	}
2653 2797
 
2654 2798
 	// If smileyPregSearch hasn't been set, do it now.
2655 2799
 	if (empty($smileyPregSearch))
@@ -2660,8 +2804,7 @@  discard block
 block discarded – undo
2660 2804
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2661 2805
 			$smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
2662 2806
 			$smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
2663
-		}
2664
-		else
2807
+		} else
2665 2808
 		{
2666 2809
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2667 2810
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2685,9 +2828,9 @@  discard block
 block discarded – undo
2685 2828
 				$smcFunc['db_free_result']($result);
2686 2829
 
2687 2830
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
2831
+			} else {
2832
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2688 2833
 			}
2689
-			else
2690
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2691 2834
 		}
2692 2835
 
2693 2836
 		// The non-breaking-space is a complex thing...
@@ -2764,35 +2907,41 @@  discard block
 block discarded – undo
2764 2907
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
2765 2908
 
2766 2909
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
2767
-	if (!empty($context['flush_mail']))
2768
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2910
+	if (!empty($context['flush_mail'])) {
2911
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2769 2912
 		AddMailQueue(true);
2913
+	}
2770 2914
 
2771 2915
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
2772 2916
 
2773
-	if ($add)
2774
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2917
+	if ($add) {
2918
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2919
+	}
2775 2920
 
2776 2921
 	// Put the session ID in.
2777
-	if (defined('SID') && SID != '')
2778
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2922
+	if (defined('SID') && SID != '') {
2923
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2924
+	}
2779 2925
 	// Keep that debug in their for template debugging!
2780
-	elseif (isset($_GET['debug']))
2781
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2926
+	elseif (isset($_GET['debug'])) {
2927
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2928
+	}
2782 2929
 
2783 2930
 	if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
2784 2931
 	{
2785
-		if (defined('SID') && SID != '')
2786
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2932
+		if (defined('SID') && SID != '') {
2933
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2787 2934
 				function ($m) use ($scripturl)
2788 2935
 				{
2789 2936
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2937
+		}
2790 2938
 				}, $setLocation);
2791
-		else
2792
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2939
+		else {
2940
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2793 2941
 				function ($m) use ($scripturl)
2794 2942
 				{
2795 2943
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2944
+		}
2796 2945
 				}, $setLocation);
2797 2946
 	}
2798 2947
 
@@ -2803,8 +2952,9 @@  discard block
 block discarded – undo
2803 2952
 	header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
2804 2953
 
2805 2954
 	// Debugging.
2806
-	if (isset($db_show_debug) && $db_show_debug === true)
2807
-		$_SESSION['debug_redirect'] = $db_cache;
2955
+	if (isset($db_show_debug) && $db_show_debug === true) {
2956
+			$_SESSION['debug_redirect'] = $db_cache;
2957
+	}
2808 2958
 
2809 2959
 	obExit(false);
2810 2960
 }
@@ -2823,51 +2973,60 @@  discard block
 block discarded – undo
2823 2973
 
2824 2974
 	// Attempt to prevent a recursive loop.
2825 2975
 	++$level;
2826
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
2827
-		exit;
2828
-	if ($from_fatal_error)
2829
-		$has_fatal_error = true;
2976
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
2977
+			exit;
2978
+	}
2979
+	if ($from_fatal_error) {
2980
+			$has_fatal_error = true;
2981
+	}
2830 2982
 
2831 2983
 	// Clear out the stat cache.
2832 2984
 	trackStats();
2833 2985
 
2834 2986
 	// If we have mail to send, send it.
2835
-	if (!empty($context['flush_mail']))
2836
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2987
+	if (!empty($context['flush_mail'])) {
2988
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2837 2989
 		AddMailQueue(true);
2990
+	}
2838 2991
 
2839 2992
 	$do_header = $header === null ? !$header_done : $header;
2840
-	if ($do_footer === null)
2841
-		$do_footer = $do_header;
2993
+	if ($do_footer === null) {
2994
+			$do_footer = $do_header;
2995
+	}
2842 2996
 
2843 2997
 	// Has the template/header been done yet?
2844 2998
 	if ($do_header)
2845 2999
 	{
2846 3000
 		// Was the page title set last minute? Also update the HTML safe one.
2847
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
2848
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3001
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3002
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3003
+		}
2849 3004
 
2850 3005
 		// Start up the session URL fixer.
2851 3006
 		ob_start('ob_sessrewrite');
2852 3007
 
2853
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
2854
-			$buffers = explode(',', $settings['output_buffers']);
2855
-		elseif (!empty($settings['output_buffers']))
2856
-			$buffers = $settings['output_buffers'];
2857
-		else
2858
-			$buffers = array();
3008
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3009
+					$buffers = explode(',', $settings['output_buffers']);
3010
+		} elseif (!empty($settings['output_buffers'])) {
3011
+					$buffers = $settings['output_buffers'];
3012
+		} else {
3013
+					$buffers = array();
3014
+		}
2859 3015
 
2860
-		if (isset($modSettings['integrate_buffer']))
2861
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3016
+		if (isset($modSettings['integrate_buffer'])) {
3017
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3018
+		}
2862 3019
 
2863
-		if (!empty($buffers))
2864
-			foreach ($buffers as $function)
3020
+		if (!empty($buffers)) {
3021
+					foreach ($buffers as $function)
2865 3022
 			{
2866 3023
 				$call = call_helper($function, true);
3024
+		}
2867 3025
 
2868 3026
 				// Is it valid?
2869
-				if (!empty($call))
2870
-					ob_start($call);
3027
+				if (!empty($call)) {
3028
+									ob_start($call);
3029
+				}
2871 3030
 			}
2872 3031
 
2873 3032
 		// Display the screen in the logical order.
@@ -2879,8 +3038,9 @@  discard block
 block discarded – undo
2879 3038
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
2880 3039
 
2881 3040
 		// Anything special to put out?
2882
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
2883
-			echo $context['insert_after_template'];
3041
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3042
+					echo $context['insert_after_template'];
3043
+		}
2884 3044
 
2885 3045
 		// Just so we don't get caught in an endless loop of errors from the footer...
2886 3046
 		if (!$footer_done)
@@ -2889,14 +3049,16 @@  discard block
 block discarded – undo
2889 3049
 			template_footer();
2890 3050
 
2891 3051
 			// (since this is just debugging... it's okay that it's after </html>.)
2892
-			if (!isset($_REQUEST['xml']))
2893
-				displayDebug();
3052
+			if (!isset($_REQUEST['xml'])) {
3053
+							displayDebug();
3054
+			}
2894 3055
 		}
2895 3056
 	}
2896 3057
 
2897 3058
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
2898
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
2899
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3059
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3060
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3061
+	}
2900 3062
 
2901 3063
 	// For session check verification.... don't switch browsers...
2902 3064
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -2905,9 +3067,10 @@  discard block
 block discarded – undo
2905 3067
 	call_integration_hook('integrate_exit', array($do_footer));
2906 3068
 
2907 3069
 	// Don't exit if we're coming from index.php; that will pass through normally.
2908
-	if (!$from_index)
2909
-		exit;
2910
-}
3070
+	if (!$from_index) {
3071
+			exit;
3072
+	}
3073
+	}
2911 3074
 
2912 3075
 /**
2913 3076
  * Get the size of a specified image with better error handling.
@@ -2926,8 +3089,9 @@  discard block
 block discarded – undo
2926 3089
 	$url = str_replace(' ', '%20', $url);
2927 3090
 
2928 3091
 	// Can we pull this from the cache... please please?
2929
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
2930
-		return $temp;
3092
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3093
+			return $temp;
3094
+	}
2931 3095
 	$t = microtime();
2932 3096
 
2933 3097
 	// Get the host to pester...
@@ -2937,12 +3101,10 @@  discard block
 block discarded – undo
2937 3101
 	if ($url == '' || $url == 'http://' || $url == 'https://')
2938 3102
 	{
2939 3103
 		return false;
2940
-	}
2941
-	elseif (!isset($match[1]))
3104
+	} elseif (!isset($match[1]))
2942 3105
 	{
2943 3106
 		$size = @getimagesize($url);
2944
-	}
2945
-	else
3107
+	} else
2946 3108
 	{
2947 3109
 		// Try to connect to the server... give it half a second.
2948 3110
 		$temp = 0;
@@ -2981,12 +3143,14 @@  discard block
 block discarded – undo
2981 3143
 	}
2982 3144
 
2983 3145
 	// If we didn't get it, we failed.
2984
-	if (!isset($size))
2985
-		$size = false;
3146
+	if (!isset($size)) {
3147
+			$size = false;
3148
+	}
2986 3149
 
2987 3150
 	// If this took a long time, we may never have to do it again, but then again we might...
2988
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
2989
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3151
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3152
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3153
+	}
2990 3154
 
2991 3155
 	// Didn't work.
2992 3156
 	return $size;
@@ -3004,8 +3168,9 @@  discard block
 block discarded – undo
3004 3168
 
3005 3169
 	// Under SSI this function can be called more then once.  That can cause some problems.
3006 3170
 	//   So only run the function once unless we are forced to run it again.
3007
-	if ($loaded && !$forceload)
3008
-		return;
3171
+	if ($loaded && !$forceload) {
3172
+			return;
3173
+	}
3009 3174
 
3010 3175
 	$loaded = true;
3011 3176
 
@@ -3017,14 +3182,16 @@  discard block
 block discarded – undo
3017 3182
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3018 3183
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3019 3184
 	{
3020
-		if (trim($context['news_lines'][$i]) == '')
3021
-			continue;
3185
+		if (trim($context['news_lines'][$i]) == '') {
3186
+					continue;
3187
+		}
3022 3188
 
3023 3189
 		// Clean it up for presentation ;).
3024 3190
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3025 3191
 	}
3026
-	if (!empty($context['news_lines']))
3027
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3192
+	if (!empty($context['news_lines'])) {
3193
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3194
+	}
3028 3195
 
3029 3196
 	if (!$user_info['is_guest'])
3030 3197
 	{
@@ -3033,40 +3200,48 @@  discard block
 block discarded – undo
3033 3200
 		$context['user']['alerts'] = &$user_info['alerts'];
3034 3201
 
3035 3202
 		// Personal message popup...
3036
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3037
-			$context['user']['popup_messages'] = true;
3038
-		else
3039
-			$context['user']['popup_messages'] = false;
3203
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3204
+					$context['user']['popup_messages'] = true;
3205
+		} else {
3206
+					$context['user']['popup_messages'] = false;
3207
+		}
3040 3208
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3041 3209
 
3042
-		if (allowedTo('moderate_forum'))
3043
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3210
+		if (allowedTo('moderate_forum')) {
3211
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3212
+		}
3044 3213
 
3045 3214
 		$context['user']['avatar'] = array();
3046 3215
 
3047 3216
 		// Check for gravatar first since we might be forcing them...
3048 3217
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3049 3218
 		{
3050
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3051
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3052
-			else
3053
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3219
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3220
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3221
+			} else {
3222
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3223
+			}
3054 3224
 		}
3055 3225
 		// Uploaded?
3056
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3057
-			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3226
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3227
+					$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3228
+		}
3058 3229
 		// Full URL?
3059
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3060
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3230
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3231
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3232
+		}
3061 3233
 		// Otherwise we assume it's server stored.
3062
-		elseif ($user_info['avatar']['url'] != '')
3063
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3234
+		elseif ($user_info['avatar']['url'] != '') {
3235
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3236
+		}
3064 3237
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3065
-		else
3066
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3238
+		else {
3239
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3240
+		}
3067 3241
 
3068
-		if (!empty($context['user']['avatar']))
3069
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3242
+		if (!empty($context['user']['avatar'])) {
3243
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3244
+		}
3070 3245
 
3071 3246
 		// Figure out how long they've been logged in.
3072 3247
 		$context['user']['total_time_logged_in'] = array(
@@ -3074,8 +3249,7 @@  discard block
 block discarded – undo
3074 3249
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3075 3250
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3076 3251
 		);
3077
-	}
3078
-	else
3252
+	} else
3079 3253
 	{
3080 3254
 		$context['user']['messages'] = 0;
3081 3255
 		$context['user']['unread_messages'] = 0;
@@ -3083,12 +3257,14 @@  discard block
 block discarded – undo
3083 3257
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3084 3258
 		$context['user']['popup_messages'] = false;
3085 3259
 
3086
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3087
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3260
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3261
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3262
+		}
3088 3263
 
3089 3264
 		// If we've upgraded recently, go easy on the passwords.
3090
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3091
-			$context['disable_login_hashing'] = true;
3265
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3266
+					$context['disable_login_hashing'] = true;
3267
+		}
3092 3268
 	}
3093 3269
 
3094 3270
 	// Setup the main menu items.
@@ -3101,8 +3277,8 @@  discard block
 block discarded – undo
3101 3277
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3102 3278
 
3103 3279
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3104
-	if ($context['show_pm_popup'])
3105
-		addInlineJavaScript('
3280
+	if ($context['show_pm_popup']) {
3281
+			addInlineJavaScript('
3106 3282
 		jQuery(document).ready(function($) {
3107 3283
 			new smc_Popup({
3108 3284
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3110,15 +3286,17 @@  discard block
 block discarded – undo
3110 3286
 				icon_class: \'generic_icons mail_new\'
3111 3287
 			});
3112 3288
 		});');
3289
+	}
3113 3290
 
3114 3291
 	// Add a generic "Are you sure?" confirmation message.
3115 3292
 	addInlineJavaScript('
3116 3293
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3117 3294
 
3118 3295
 	// Now add the capping code for avatars.
3119
-	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
3120
-		addInlineCss('
3296
+	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') {
3297
+			addInlineCss('
3121 3298
 img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3299
+	}
3122 3300
 
3123 3301
 	// This looks weird, but it's because BoardIndex.php references the variable.
3124 3302
 	$context['common_stats']['latest_member'] = array(
@@ -3135,11 +3313,13 @@  discard block
 block discarded – undo
3135 3313
 	);
3136 3314
 	$context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']);
3137 3315
 
3138
-	if (empty($settings['theme_version']))
3139
-		addJavaScriptVar('smf_scripturl', $scripturl);
3316
+	if (empty($settings['theme_version'])) {
3317
+			addJavaScriptVar('smf_scripturl', $scripturl);
3318
+	}
3140 3319
 
3141
-	if (!isset($context['page_title']))
3142
-		$context['page_title'] = '';
3320
+	if (!isset($context['page_title'])) {
3321
+			$context['page_title'] = '';
3322
+	}
3143 3323
 
3144 3324
 	// Set some specific vars.
3145 3325
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3149,21 +3329,23 @@  discard block
 block discarded – undo
3149 3329
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3150 3330
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3151 3331
 
3152
-	if (!empty($context['meta_keywords']))
3153
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3332
+	if (!empty($context['meta_keywords'])) {
3333
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3334
+	}
3154 3335
 
3155
-	if (!empty($context['canonical_url']))
3156
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3336
+	if (!empty($context['canonical_url'])) {
3337
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3338
+	}
3157 3339
 
3158
-	if (!empty($settings['og_image']))
3159
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3340
+	if (!empty($settings['og_image'])) {
3341
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3342
+	}
3160 3343
 
3161 3344
 	if (!empty($context['meta_description']))
3162 3345
 	{
3163 3346
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3164 3347
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3165
-	}
3166
-	else
3348
+	} else
3167 3349
 	{
3168 3350
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3169 3351
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3189,8 +3371,9 @@  discard block
 block discarded – undo
3189 3371
 	$memory_needed = memoryReturnBytes($needed);
3190 3372
 
3191 3373
 	// should we account for how much is currently being used?
3192
-	if ($in_use)
3193
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3374
+	if ($in_use) {
3375
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3376
+	}
3194 3377
 
3195 3378
 	// if more is needed, request it
3196 3379
 	if ($memory_current < $memory_needed)
@@ -3213,8 +3396,9 @@  discard block
 block discarded – undo
3213 3396
  */
3214 3397
 function memoryReturnBytes($val)
3215 3398
 {
3216
-	if (is_integer($val))
3217
-		return $val;
3399
+	if (is_integer($val)) {
3400
+			return $val;
3401
+	}
3218 3402
 
3219 3403
 	// Separate the number from the designator
3220 3404
 	$val = trim($val);
@@ -3250,10 +3434,11 @@  discard block
 block discarded – undo
3250 3434
 		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3251 3435
 
3252 3436
 		// Are we debugging the template/html content?
3253
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3254
-			header('Content-Type: application/xhtml+xml');
3255
-		elseif (!isset($_REQUEST['xml']))
3256
-			header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3437
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3438
+					header('Content-Type: application/xhtml+xml');
3439
+		} elseif (!isset($_REQUEST['xml'])) {
3440
+					header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3441
+		}
3257 3442
 	}
3258 3443
 
3259 3444
 	header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3262,8 +3447,9 @@  discard block
 block discarded – undo
3262 3447
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3263 3448
 	{
3264 3449
 		$position = array_search('body', $context['template_layers']);
3265
-		if ($position === false)
3266
-			$position = array_search('main', $context['template_layers']);
3450
+		if ($position === false) {
3451
+					$position = array_search('main', $context['template_layers']);
3452
+		}
3267 3453
 
3268 3454
 		if ($position !== false)
3269 3455
 		{
@@ -3291,15 +3477,15 @@  discard block
 block discarded – undo
3291 3477
 
3292 3478
 			foreach ($securityFiles as $i => $securityFile)
3293 3479
 			{
3294
-				if (!file_exists($boarddir . '/' . $securityFile))
3295
-					unset($securityFiles[$i]);
3480
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3481
+									unset($securityFiles[$i]);
3482
+				}
3296 3483
 			}
3297 3484
 
3298 3485
 			// We are already checking so many files...just few more doesn't make any difference! :P
3299
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3300
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3301
-
3302
-			else
3486
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3487
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3488
+			} else
3303 3489
 			{
3304 3490
 				$path = $modSettings['attachmentUploadDir'];
3305 3491
 				$id_folder_thumb = 1;
@@ -3308,8 +3494,9 @@  discard block
 block discarded – undo
3308 3494
 			secureDirectory($cachedir);
3309 3495
 
3310 3496
 			// If agreement is enabled, at least the english version shall exists
3311
-			if ($modSettings['requireAgreement'])
3312
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3497
+			if ($modSettings['requireAgreement']) {
3498
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3499
+			}
3313 3500
 
3314 3501
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3315 3502
 			{
@@ -3324,18 +3511,21 @@  discard block
 block discarded – undo
3324 3511
 					echo '
3325 3512
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3326 3513
 
3327
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3328
-						echo '
3514
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3515
+											echo '
3329 3516
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3517
+					}
3330 3518
 				}
3331 3519
 
3332
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3333
-					echo '
3520
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3521
+									echo '
3334 3522
 				<strong>', $txt['cache_writable'], '</strong><br>';
3523
+				}
3335 3524
 
3336
-				if (!empty($agreement))
3337
-					echo '
3525
+				if (!empty($agreement)) {
3526
+									echo '
3338 3527
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3528
+				}
3339 3529
 
3340 3530
 				echo '
3341 3531
 			</p>
@@ -3350,16 +3540,18 @@  discard block
 block discarded – undo
3350 3540
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3351 3541
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3352 3542
 
3353
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3354
-				echo '
3543
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3544
+							echo '
3355 3545
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3546
+			}
3356 3547
 
3357
-			if (!empty($_SESSION['ban']['expire_time']))
3358
-				echo '
3548
+			if (!empty($_SESSION['ban']['expire_time'])) {
3549
+							echo '
3359 3550
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3360
-			else
3361
-				echo '
3551
+			} else {
3552
+							echo '
3362 3553
 					<div>', $txt['your_ban_expires_never'], '</div>';
3554
+			}
3363 3555
 
3364 3556
 			echo '
3365 3557
 				</div>';
@@ -3375,8 +3567,9 @@  discard block
 block discarded – undo
3375 3567
 	global $forum_copyright, $software_year, $forum_version;
3376 3568
 
3377 3569
 	// Don't display copyright for things like SSI.
3378
-	if (!isset($forum_version) || !isset($software_year))
3379
-		return;
3570
+	if (!isset($forum_version) || !isset($software_year)) {
3571
+			return;
3572
+	}
3380 3573
 
3381 3574
 	// Put in the version...
3382 3575
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3394,9 +3587,10 @@  discard block
 block discarded – undo
3394 3587
 	$context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3));
3395 3588
 	$context['load_queries'] = $db_count;
3396 3589
 
3397
-	foreach (array_reverse($context['template_layers']) as $layer)
3398
-		loadSubTemplate($layer . '_below', true);
3399
-}
3590
+	foreach (array_reverse($context['template_layers']) as $layer) {
3591
+			loadSubTemplate($layer . '_below', true);
3592
+	}
3593
+	}
3400 3594
 
3401 3595
 /**
3402 3596
  * Output the Javascript files
@@ -3427,8 +3621,7 @@  discard block
 block discarded – undo
3427 3621
 			{
3428 3622
 				echo '
3429 3623
 		var ', $key, ';';
3430
-			}
3431
-			else
3624
+			} else
3432 3625
 			{
3433 3626
 				echo '
3434 3627
 		var ', $key, ' = ', $value, ';';
@@ -3443,26 +3636,27 @@  discard block
 block discarded – undo
3443 3636
 	foreach ($context['javascript_files'] as $id => $js_file)
3444 3637
 	{
3445 3638
 		// Last minute call! allow theme authors to disable single files.
3446
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3447
-			continue;
3639
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3640
+					continue;
3641
+		}
3448 3642
 
3449 3643
 		// By default all files don't get minimized unless the file explicitly says so!
3450 3644
 		if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3451 3645
 		{
3452
-			if ($do_deferred && !empty($js_file['options']['defer']))
3453
-				$toMinifyDefer[] = $js_file;
3454
-
3455
-			elseif (!$do_deferred && empty($js_file['options']['defer']))
3456
-				$toMinify[] = $js_file;
3646
+			if ($do_deferred && !empty($js_file['options']['defer'])) {
3647
+							$toMinifyDefer[] = $js_file;
3648
+			} elseif (!$do_deferred && empty($js_file['options']['defer'])) {
3649
+							$toMinify[] = $js_file;
3650
+			}
3457 3651
 
3458 3652
 			// Grab a random seed.
3459
-			if (!isset($minSeed))
3460
-				$minSeed = $js_file['options']['seed'];
3461
-		}
3462
-
3463
-		elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer'])))
3464
-			echo '
3653
+			if (!isset($minSeed)) {
3654
+							$minSeed = $js_file['options']['seed'];
3655
+			}
3656
+		} elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) {
3657
+					echo '
3465 3658
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
3659
+		}
3466 3660
 	}
3467 3661
 
3468 3662
 	if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer)))
@@ -3470,14 +3664,14 @@  discard block
 block discarded – undo
3470 3664
 		$result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred);
3471 3665
 
3472 3666
 		// Minify process couldn't work, print each individual files.
3473
-		if (!empty($result) && is_array($result))
3474
-			foreach ($result as $minFailedFile)
3667
+		if (!empty($result) && is_array($result)) {
3668
+					foreach ($result as $minFailedFile)
3475 3669
 				echo '
3476 3670
 	<script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>';
3477
-
3478
-		else
3479
-			echo '
3671
+		} else {
3672
+					echo '
3480 3673
 	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3674
+		}
3481 3675
 	}
3482 3676
 
3483 3677
 	// Inline JavaScript - Actually useful some times!
@@ -3488,8 +3682,9 @@  discard block
 block discarded – undo
3488 3682
 			echo '
3489 3683
 <script>';
3490 3684
 
3491
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3492
-				echo $js_code;
3685
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
3686
+							echo $js_code;
3687
+			}
3493 3688
 
3494 3689
 			echo '
3495 3690
 </script>';
@@ -3500,8 +3695,9 @@  discard block
 block discarded – undo
3500 3695
 			echo '
3501 3696
 	<script>';
3502 3697
 
3503
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3504
-				echo $js_code;
3698
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
3699
+							echo $js_code;
3700
+			}
3505 3701
 
3506 3702
 			echo '
3507 3703
 	</script>';
@@ -3526,8 +3722,9 @@  discard block
 block discarded – undo
3526 3722
 	foreach ($context['css_files'] as $id => $file)
3527 3723
 	{
3528 3724
 		// Last minute call! allow theme authors to disable single files.
3529
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3530
-			continue;
3725
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3726
+					continue;
3727
+		}
3531 3728
 
3532 3729
 		// By default all files don't get minimized unless the file explicitly says so!
3533 3730
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
@@ -3535,12 +3732,12 @@  discard block
 block discarded – undo
3535 3732
 			$toMinify[] = $file;
3536 3733
 
3537 3734
 			// Grab a random seed.
3538
-			if (!isset($minSeed))
3539
-				$minSeed = $file['options']['seed'];
3735
+			if (!isset($minSeed)) {
3736
+							$minSeed = $file['options']['seed'];
3737
+			}
3738
+		} else {
3739
+					$normal[] = $file['fileUrl'];
3540 3740
 		}
3541
-
3542
-		else
3543
-			$normal[] = $file['fileUrl'];
3544 3741
 	}
3545 3742
 
3546 3743
 	if (!empty($toMinify))
@@ -3548,28 +3745,30 @@  discard block
 block discarded – undo
3548 3745
 		$result = custMinify($toMinify, 'css');
3549 3746
 
3550 3747
 		// Minify process couldn't work, print each individual files.
3551
-		if (!empty($result) && is_array($result))
3552
-			foreach ($result as $minFailedFile)
3748
+		if (!empty($result) && is_array($result)) {
3749
+					foreach ($result as $minFailedFile)
3553 3750
 				echo '
3554 3751
 	<link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">';
3555
-
3556
-		else
3557
-			echo '
3752
+		} else {
3753
+					echo '
3558 3754
 	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3755
+		}
3559 3756
 	}
3560 3757
 
3561 3758
 	// Print the rest after the minified files.
3562
-	if (!empty($normal))
3563
-		foreach ($normal as $nf)
3759
+	if (!empty($normal)) {
3760
+			foreach ($normal as $nf)
3564 3761
 			echo '
3565 3762
 	<link rel="stylesheet" href="', $nf ,'">';
3763
+	}
3566 3764
 
3567 3765
 	if ($db_show_debug === true)
3568 3766
 	{
3569 3767
 		// Try to keep only what's useful.
3570 3768
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3571
-		foreach ($context['css_files'] as $file)
3572
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3769
+		foreach ($context['css_files'] as $file) {
3770
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3771
+		}
3573 3772
 	}
3574 3773
 
3575 3774
 	if (!empty($context['css_header']))
@@ -3577,9 +3776,10 @@  discard block
 block discarded – undo
3577 3776
 		echo '
3578 3777
 	<style>';
3579 3778
 
3580
-		foreach ($context['css_header'] as $css)
3581
-			echo $css .'
3779
+		foreach ($context['css_header'] as $css) {
3780
+					echo $css .'
3582 3781
 	';
3782
+		}
3583 3783
 
3584 3784
 		echo'
3585 3785
 	</style>';
@@ -3604,15 +3804,17 @@  discard block
 block discarded – undo
3604 3804
 	$data = !empty($data) ? $data : false;
3605 3805
 	$minFailed = array();
3606 3806
 
3607
-	if (empty($type) || empty($data))
3608
-		return false;
3807
+	if (empty($type) || empty($data)) {
3808
+			return false;
3809
+	}
3609 3810
 
3610 3811
 	// Did we already did this?
3611 3812
 	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3612 3813
 
3613 3814
 	// Already done?
3614
-	if (!empty($toCache))
3615
-		return true;
3815
+	if (!empty($toCache)) {
3816
+			return true;
3817
+	}
3616 3818
 
3617 3819
 	// Yep, need a bunch of files.
3618 3820
 	require_once($sourcedir . '/minify/src/Minify.php');
@@ -3700,8 +3902,9 @@  discard block
 block discarded – undo
3700 3902
 	global $modSettings, $smcFunc;
3701 3903
 
3702 3904
 	// Just make up a nice hash...
3703
-	if ($new)
3704
-		return sha1(md5($filename . time()) . mt_rand());
3905
+	if ($new) {
3906
+			return sha1(md5($filename . time()) . mt_rand());
3907
+	}
3705 3908
 
3706 3909
 	// Grab the file hash if it wasn't added.
3707 3910
 	// Left this for legacy.
@@ -3715,23 +3918,25 @@  discard block
 block discarded – undo
3715 3918
 				'id_attach' => $attachment_id,
3716 3919
 			));
3717 3920
 
3718
-		if ($smcFunc['db_num_rows']($request) === 0)
3719
-			return false;
3921
+		if ($smcFunc['db_num_rows']($request) === 0) {
3922
+					return false;
3923
+		}
3720 3924
 
3721 3925
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
3722 3926
 		$smcFunc['db_free_result']($request);
3723 3927
 	}
3724 3928
 
3725 3929
 	// Still no hash? mmm...
3726
-	if (empty($file_hash))
3727
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
3930
+	if (empty($file_hash)) {
3931
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
3932
+	}
3728 3933
 
3729 3934
 	// Are we using multiple directories?
3730
-	if (!empty($modSettings['currentAttachmentUploadDir']))
3731
-		$path = $modSettings['attachmentUploadDir'][$dir];
3732
-
3733
-	else
3734
-		$path = $modSettings['attachmentUploadDir'];
3935
+	if (!empty($modSettings['currentAttachmentUploadDir'])) {
3936
+			$path = $modSettings['attachmentUploadDir'][$dir];
3937
+	} else {
3938
+			$path = $modSettings['attachmentUploadDir'];
3939
+	}
3735 3940
 
3736 3941
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3737 3942
 }
@@ -3746,8 +3951,9 @@  discard block
 block discarded – undo
3746 3951
 function ip2range($fullip)
3747 3952
 {
3748 3953
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
3749
-	if ($fullip == 'unknown')
3750
-		$fullip = '255.255.255.255';
3954
+	if ($fullip == 'unknown') {
3955
+			$fullip = '255.255.255.255';
3956
+	}
3751 3957
 
3752 3958
 	$ip_parts = explode('-', $fullip);
3753 3959
 	$ip_array = array();
@@ -3771,10 +3977,11 @@  discard block
 block discarded – undo
3771 3977
 		$ip_array['low'] = $ip_parts[0];
3772 3978
 		$ip_array['high'] = $ip_parts[1];
3773 3979
 		return $ip_array;
3774
-	}
3775
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
3980
+	} elseif (count($ip_parts) == 2) {
3981
+		// if ip 22.22.*-22.22.*
3776 3982
 	{
3777 3983
 		$valid_low = isValidIP($ip_parts[0]);
3984
+	}
3778 3985
 		$valid_high = isValidIP($ip_parts[1]);
3779 3986
 		$count = 0;
3780 3987
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -3789,7 +3996,9 @@  discard block
 block discarded – undo
3789 3996
 				$ip_parts[0] .= $mode . $min;
3790 3997
 				$valid_low = isValidIP($ip_parts[0]);
3791 3998
 				$count++;
3792
-				if ($count > 9) break;
3999
+				if ($count > 9) {
4000
+					break;
4001
+				}
3793 4002
 			}
3794 4003
 		}
3795 4004
 
@@ -3803,7 +4012,9 @@  discard block
 block discarded – undo
3803 4012
 				$ip_parts[1] .= $mode . $max;
3804 4013
 				$valid_high = isValidIP($ip_parts[1]);
3805 4014
 				$count++;
3806
-				if ($count > 9) break;
4015
+				if ($count > 9) {
4016
+					break;
4017
+				}
3807 4018
 			}
3808 4019
 		}
3809 4020
 
@@ -3828,46 +4039,54 @@  discard block
 block discarded – undo
3828 4039
 {
3829 4040
 	global $modSettings;
3830 4041
 
3831
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
3832
-		return $host;
4042
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4043
+			return $host;
4044
+	}
3833 4045
 	$t = microtime();
3834 4046
 
3835 4047
 	// Try the Linux host command, perhaps?
3836 4048
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
3837 4049
 	{
3838
-		if (!isset($modSettings['host_to_dis']))
3839
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3840
-		else
3841
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4050
+		if (!isset($modSettings['host_to_dis'])) {
4051
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4052
+		} else {
4053
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4054
+		}
3842 4055
 
3843 4056
 		// Did host say it didn't find anything?
3844
-		if (strpos($test, 'not found') !== false)
3845
-			$host = '';
4057
+		if (strpos($test, 'not found') !== false) {
4058
+					$host = '';
4059
+		}
3846 4060
 		// Invalid server option?
3847
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
3848
-			updateSettings(array('host_to_dis' => 1));
4061
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4062
+					updateSettings(array('host_to_dis' => 1));
4063
+		}
3849 4064
 		// Maybe it found something, after all?
3850
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
3851
-			$host = $match[1];
4065
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4066
+					$host = $match[1];
4067
+		}
3852 4068
 	}
3853 4069
 
3854 4070
 	// This is nslookup; usually only Windows, but possibly some Unix?
3855 4071
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
3856 4072
 	{
3857 4073
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
3858
-		if (strpos($test, 'Non-existent domain') !== false)
3859
-			$host = '';
3860
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
3861
-			$host = $match[1];
4074
+		if (strpos($test, 'Non-existent domain') !== false) {
4075
+					$host = '';
4076
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4077
+					$host = $match[1];
4078
+		}
3862 4079
 	}
3863 4080
 
3864 4081
 	// This is the last try :/.
3865
-	if (!isset($host) || $host === false)
3866
-		$host = @gethostbyaddr($ip);
4082
+	if (!isset($host) || $host === false) {
4083
+			$host = @gethostbyaddr($ip);
4084
+	}
3867 4085
 
3868 4086
 	// It took a long time, so let's cache it!
3869
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
3870
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4087
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4088
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4089
+	}
3871 4090
 
3872 4091
 	return $host;
3873 4092
 }
@@ -3903,20 +4122,21 @@  discard block
 block discarded – undo
3903 4122
 			{
3904 4123
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
3905 4124
 				$total = 0;
3906
-				for ($i = 0; $i < $max_chars; $i++)
3907
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4125
+				for ($i = 0; $i < $max_chars; $i++) {
4126
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4127
+				}
3908 4128
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
3909 4129
 			}
3910 4130
 		}
3911 4131
 		return array_unique($returned_ints);
3912
-	}
3913
-	else
4132
+	} else
3914 4133
 	{
3915 4134
 		// Trim characters before and after and add slashes for database insertion.
3916 4135
 		$returned_words = array();
3917
-		foreach ($words as $word)
3918
-			if (($word = trim($word, '-_\'')) !== '')
4136
+		foreach ($words as $word) {
4137
+					if (($word = trim($word, '-_\'')) !== '')
3919 4138
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4139
+		}
3920 4140
 
3921 4141
 		// Filter out all words that occur more than once.
3922 4142
 		return array_unique($returned_words);
@@ -3938,16 +4158,18 @@  discard block
 block discarded – undo
3938 4158
 	global $settings, $txt;
3939 4159
 
3940 4160
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
3941
-	if (function_exists('template_create_button') && !$force_use)
3942
-		return template_create_button($name, $alt, $label = '', $custom = '');
4161
+	if (function_exists('template_create_button') && !$force_use) {
4162
+			return template_create_button($name, $alt, $label = '', $custom = '');
4163
+	}
3943 4164
 
3944
-	if (!$settings['use_image_buttons'])
3945
-		return $txt[$alt];
3946
-	elseif (!empty($settings['use_buttons']))
3947
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
3948
-	else
3949
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
3950
-}
4165
+	if (!$settings['use_image_buttons']) {
4166
+			return $txt[$alt];
4167
+	} elseif (!empty($settings['use_buttons'])) {
4168
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4169
+	} else {
4170
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4171
+	}
4172
+	}
3951 4173
 
3952 4174
 /**
3953 4175
  * Empty out the cache in use as best it can
@@ -3971,16 +4193,19 @@  discard block
 block discarded – undo
3971 4193
 			if (function_exists('memcache_flush') || function_exists('memcached_flush') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
3972 4194
 			{
3973 4195
 				// Not connected yet?
3974
-				if (empty($memcached))
3975
-					get_memcached_server();
3976
-				if (!$memcached)
3977
-					return;
4196
+				if (empty($memcached)) {
4197
+									get_memcached_server();
4198
+				}
4199
+				if (!$memcached) {
4200
+									return;
4201
+				}
3978 4202
 
3979 4203
 				// clear it out
3980
-				if (function_exists('memcache_flush'))
3981
-					memcache_flush($memcached);
3982
-				else
3983
-					memcached_flush($memcached);
4204
+				if (function_exists('memcache_flush')) {
4205
+									memcache_flush($memcached);
4206
+				} else {
4207
+									memcached_flush($memcached);
4208
+				}
3984 4209
 			}
3985 4210
 			break;
3986 4211
 		case 'apc':
@@ -3991,14 +4216,15 @@  discard block
 block discarded – undo
3991 4216
 				{
3992 4217
 					apc_clear_cache('user');
3993 4218
 					apc_clear_cache('system');
4219
+				} elseif ($type === 'user') {
4220
+									apc_clear_cache('user');
3994 4221
 				}
3995
-				elseif ($type === 'user')
3996
-					apc_clear_cache('user');
3997 4222
 			}
3998 4223
 			break;
3999 4224
 		case 'zend':
4000
-			if (function_exists('zend_shm_cache_clear'))
4001
-				zend_shm_cache_clear('SMF');
4225
+			if (function_exists('zend_shm_cache_clear')) {
4226
+							zend_shm_cache_clear('SMF');
4227
+			}
4002 4228
 			break;
4003 4229
 		case 'xcache':
4004 4230
 			if (function_exists('xcache_clear_cache'))
@@ -4009,23 +4235,27 @@  discard block
 block discarded – undo
4009 4235
 					xcache_clear_cache(XC_TYPE_VAR, 0);
4010 4236
 					xcache_clear_cache(XC_TYPE_PHP, 0);
4011 4237
 				}
4012
-				if ($type === 'user')
4013
-					xcache_clear_cache(XC_TYPE_VAR, 0);
4014
-				if ($type === 'data')
4015
-					xcache_clear_cache(XC_TYPE_PHP, 0);
4238
+				if ($type === 'user') {
4239
+									xcache_clear_cache(XC_TYPE_VAR, 0);
4240
+				}
4241
+				if ($type === 'data') {
4242
+									xcache_clear_cache(XC_TYPE_PHP, 0);
4243
+				}
4016 4244
 			}
4017 4245
 			break;
4018 4246
 		default:
4019 4247
 			// No directory = no game.
4020
-			if (!is_dir($cachedir))
4021
-				return;
4248
+			if (!is_dir($cachedir)) {
4249
+							return;
4250
+			}
4022 4251
 
4023 4252
 			// Remove the files in SMF's own disk cache, if any
4024 4253
 			$dh = opendir($cachedir);
4025 4254
 			while ($file = readdir($dh))
4026 4255
 			{
4027
-				if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
4028
-					@unlink($cachedir . '/' . $file);
4256
+				if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
4257
+									@unlink($cachedir . '/' . $file);
4258
+				}
4029 4259
 			}
4030 4260
 			closedir($dh);
4031 4261
 			break;
@@ -4033,8 +4263,9 @@  discard block
 block discarded – undo
4033 4263
 
4034 4264
 	// Invalidate cache, to be sure!
4035 4265
 	// ... as long as index.php can be modified, anyway.
4036
-	if (empty($type))
4037
-		@touch($cachedir . '/' . 'index.php');
4266
+	if (empty($type)) {
4267
+			@touch($cachedir . '/' . 'index.php');
4268
+	}
4038 4269
 
4039 4270
 	call_integration_hook('integrate_clean_cache');
4040 4271
 	clearstatcache();
@@ -4081,9 +4312,10 @@  discard block
 block discarded – undo
4081 4312
 	var user_menus = new smc_PopupMenu();
4082 4313
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4083 4314
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4084
-		if ($context['allow_pm'])
4085
-			addInlineJavaScript('
4315
+		if ($context['allow_pm']) {
4316
+					addInlineJavaScript('
4086 4317
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4318
+		}
4087 4319
 
4088 4320
 		if (!empty($modSettings['enable_ajax_alerts']))
4089 4321
 		{
@@ -4243,88 +4475,96 @@  discard block
 block discarded – undo
4243 4475
 
4244 4476
 		// Now we put the buttons in the context so the theme can use them.
4245 4477
 		$menu_buttons = array();
4246
-		foreach ($buttons as $act => $button)
4247
-			if (!empty($button['show']))
4478
+		foreach ($buttons as $act => $button) {
4479
+					if (!empty($button['show']))
4248 4480
 			{
4249 4481
 				$button['active_button'] = false;
4482
+		}
4250 4483
 
4251 4484
 				// This button needs some action.
4252
-				if (isset($button['action_hook']))
4253
-					$needs_action_hook = true;
4485
+				if (isset($button['action_hook'])) {
4486
+									$needs_action_hook = true;
4487
+				}
4254 4488
 
4255 4489
 				// Make sure the last button truly is the last button.
4256 4490
 				if (!empty($button['is_last']))
4257 4491
 				{
4258
-					if (isset($last_button))
4259
-						unset($menu_buttons[$last_button]['is_last']);
4492
+					if (isset($last_button)) {
4493
+											unset($menu_buttons[$last_button]['is_last']);
4494
+					}
4260 4495
 					$last_button = $act;
4261 4496
 				}
4262 4497
 
4263 4498
 				// Go through the sub buttons if there are any.
4264
-				if (!empty($button['sub_buttons']))
4265
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4499
+				if (!empty($button['sub_buttons'])) {
4500
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4266 4501
 					{
4267 4502
 						if (empty($subbutton['show']))
4268 4503
 							unset($button['sub_buttons'][$key]);
4504
+				}
4269 4505
 
4270 4506
 						// 2nd level sub buttons next...
4271 4507
 						if (!empty($subbutton['sub_buttons']))
4272 4508
 						{
4273 4509
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4274 4510
 							{
4275
-								if (empty($sub_button2['show']))
4276
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4511
+								if (empty($sub_button2['show'])) {
4512
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4513
+								}
4277 4514
 							}
4278 4515
 						}
4279 4516
 					}
4280 4517
 
4281 4518
 				// Does this button have its own icon?
4282
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4283
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4284
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4285
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4286
-				elseif (isset($button['icon']))
4287
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4288
-				else
4289
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4519
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4520
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4521
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4522
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4523
+				} elseif (isset($button['icon'])) {
4524
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4525
+				} else {
4526
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4527
+				}
4290 4528
 
4291 4529
 				$menu_buttons[$act] = $button;
4292 4530
 			}
4293 4531
 
4294
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4295
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4532
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4533
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4534
+		}
4296 4535
 	}
4297 4536
 
4298 4537
 	$context['menu_buttons'] = $menu_buttons;
4299 4538
 
4300 4539
 	// Logging out requires the session id in the url.
4301
-	if (isset($context['menu_buttons']['logout']))
4302
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4540
+	if (isset($context['menu_buttons']['logout'])) {
4541
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4542
+	}
4303 4543
 
4304 4544
 	// Figure out which action we are doing so we can set the active tab.
4305 4545
 	// Default to home.
4306 4546
 	$current_action = 'home';
4307 4547
 
4308
-	if (isset($context['menu_buttons'][$context['current_action']]))
4309
-		$current_action = $context['current_action'];
4310
-	elseif ($context['current_action'] == 'search2')
4311
-		$current_action = 'search';
4312
-	elseif ($context['current_action'] == 'theme')
4313
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4314
-	elseif ($context['current_action'] == 'register2')
4315
-		$current_action = 'register';
4316
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4317
-		$current_action = 'login';
4318
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4319
-		$current_action = 'moderate';
4548
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4549
+			$current_action = $context['current_action'];
4550
+	} elseif ($context['current_action'] == 'search2') {
4551
+			$current_action = 'search';
4552
+	} elseif ($context['current_action'] == 'theme') {
4553
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4554
+	} elseif ($context['current_action'] == 'register2') {
4555
+			$current_action = 'register';
4556
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4557
+			$current_action = 'login';
4558
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4559
+			$current_action = 'moderate';
4560
+	}
4320 4561
 
4321 4562
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4322 4563
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4323 4564
 	{
4324 4565
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4325 4566
 		$context[$current_action] = true;
4326
-	}
4327
-	elseif ($context['current_action'] == 'pm')
4567
+	} elseif ($context['current_action'] == 'pm')
4328 4568
 	{
4329 4569
 		$current_action = 'self_pm';
4330 4570
 		$context['self_pm'] = true;
@@ -4367,12 +4607,14 @@  discard block
 block discarded – undo
4367 4607
 	}
4368 4608
 
4369 4609
 	// Not all actions are simple.
4370
-	if (!empty($needs_action_hook))
4371
-		call_integration_hook('integrate_current_action', array(&$current_action));
4610
+	if (!empty($needs_action_hook)) {
4611
+			call_integration_hook('integrate_current_action', array(&$current_action));
4612
+	}
4372 4613
 
4373
-	if (isset($context['menu_buttons'][$current_action]))
4374
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4375
-}
4614
+	if (isset($context['menu_buttons'][$current_action])) {
4615
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4616
+	}
4617
+	}
4376 4618
 
4377 4619
 /**
4378 4620
  * Generate a random seed and ensure it's stored in settings.
@@ -4396,16 +4638,19 @@  discard block
 block discarded – undo
4396 4638
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4397 4639
 	global $context, $txt;
4398 4640
 
4399
-	if ($db_show_debug === true)
4400
-		$context['debug']['hooks'][] = $hook;
4641
+	if ($db_show_debug === true) {
4642
+			$context['debug']['hooks'][] = $hook;
4643
+	}
4401 4644
 
4402 4645
 	// Need to have some control.
4403
-	if (!isset($context['instances']))
4404
-		$context['instances'] = array();
4646
+	if (!isset($context['instances'])) {
4647
+			$context['instances'] = array();
4648
+	}
4405 4649
 
4406 4650
 	$results = array();
4407
-	if (empty($modSettings[$hook]))
4408
-		return $results;
4651
+	if (empty($modSettings[$hook])) {
4652
+			return $results;
4653
+	}
4409 4654
 
4410 4655
 	// Define some needed vars.
4411 4656
 	$function = false;
@@ -4415,14 +4660,16 @@  discard block
 block discarded – undo
4415 4660
 	foreach ($functions as $function)
4416 4661
 	{
4417 4662
 		// Hook has been marked as "disabled". Skip it!
4418
-		if (strpos($function, '!') !== false)
4419
-			continue;
4663
+		if (strpos($function, '!') !== false) {
4664
+					continue;
4665
+		}
4420 4666
 
4421 4667
 		$call = call_helper($function, true);
4422 4668
 
4423 4669
 		// Is it valid?
4424
-		if (!empty($call))
4425
-			$results[$function] = call_user_func_array($call, $parameters);
4670
+		if (!empty($call)) {
4671
+					$results[$function] = call_user_func_array($call, $parameters);
4672
+		}
4426 4673
 
4427 4674
 		// Whatever it was suppose to call, it failed :(
4428 4675
 		elseif (!empty($function))
@@ -4438,8 +4685,9 @@  discard block
 block discarded – undo
4438 4685
 			}
4439 4686
 
4440 4687
 			// "Assume" the file resides on $boarddir somewhere...
4441
-			else
4442
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4688
+			else {
4689
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4690
+			}
4443 4691
 		}
4444 4692
 	}
4445 4693
 
@@ -4461,12 +4709,14 @@  discard block
 block discarded – undo
4461 4709
 	global $smcFunc, $modSettings;
4462 4710
 
4463 4711
 	// Any objects?
4464
-	if ($object)
4465
-		$function = $function . '#';
4712
+	if ($object) {
4713
+			$function = $function . '#';
4714
+	}
4466 4715
 
4467 4716
 	// Any files  to load?
4468
-	if (!empty($file) && is_string($file))
4469
-		$function = $file . (!empty($function) ? '|' . $function : '');
4717
+	if (!empty($file) && is_string($file)) {
4718
+			$function = $file . (!empty($function) ? '|' . $function : '');
4719
+	}
4470 4720
 
4471 4721
 	// Get the correct string.
4472 4722
 	$integration_call = $function;
@@ -4488,13 +4738,14 @@  discard block
 block discarded – undo
4488 4738
 		if (!empty($current_functions))
4489 4739
 		{
4490 4740
 			$current_functions = explode(',', $current_functions);
4491
-			if (in_array($integration_call, $current_functions))
4492
-				return;
4741
+			if (in_array($integration_call, $current_functions)) {
4742
+							return;
4743
+			}
4493 4744
 
4494 4745
 			$permanent_functions = array_merge($current_functions, array($integration_call));
4746
+		} else {
4747
+					$permanent_functions = array($integration_call);
4495 4748
 		}
4496
-		else
4497
-			$permanent_functions = array($integration_call);
4498 4749
 
4499 4750
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4500 4751
 	}
@@ -4503,8 +4754,9 @@  discard block
 block discarded – undo
4503 4754
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4504 4755
 
4505 4756
 	// Do nothing, if it's already there.
4506
-	if (in_array($integration_call, $functions))
4507
-		return;
4757
+	if (in_array($integration_call, $functions)) {
4758
+			return;
4759
+	}
4508 4760
 
4509 4761
 	$functions[] = $integration_call;
4510 4762
 	$modSettings[$hook] = implode(',', $functions);
@@ -4527,12 +4779,14 @@  discard block
 block discarded – undo
4527 4779
 	global $smcFunc, $modSettings;
4528 4780
 
4529 4781
 	// Any objects?
4530
-	if ($object)
4531
-		$function = $function . '#';
4782
+	if ($object) {
4783
+			$function = $function . '#';
4784
+	}
4532 4785
 
4533 4786
 	// Any files  to load?
4534
-	if (!empty($file) && is_string($file))
4535
-		$function = $file . '|' . $function;
4787
+	if (!empty($file) && is_string($file)) {
4788
+			$function = $file . '|' . $function;
4789
+	}
4536 4790
 
4537 4791
 	// Get the correct string.
4538 4792
 	$integration_call = $function;
@@ -4553,16 +4807,18 @@  discard block
 block discarded – undo
4553 4807
 	{
4554 4808
 		$current_functions = explode(',', $current_functions);
4555 4809
 
4556
-		if (in_array($integration_call, $current_functions))
4557
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4810
+		if (in_array($integration_call, $current_functions)) {
4811
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4812
+		}
4558 4813
 	}
4559 4814
 
4560 4815
 	// Turn the function list into something usable.
4561 4816
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4562 4817
 
4563 4818
 	// You can only remove it if it's available.
4564
-	if (!in_array($integration_call, $functions))
4565
-		return;
4819
+	if (!in_array($integration_call, $functions)) {
4820
+			return;
4821
+	}
4566 4822
 
4567 4823
 	$functions = array_diff($functions, array($integration_call));
4568 4824
 	$modSettings[$hook] = implode(',', $functions);
@@ -4583,17 +4839,20 @@  discard block
 block discarded – undo
4583 4839
 	global $context, $smcFunc, $txt, $db_show_debug;
4584 4840
 
4585 4841
 	// Really?
4586
-	if (empty($string))
4587
-		return false;
4842
+	if (empty($string)) {
4843
+			return false;
4844
+	}
4588 4845
 
4589 4846
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4590 4847
 	// A closure? should be a callable one.
4591
-	if (is_array($string) || $string instanceof Closure)
4592
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4848
+	if (is_array($string) || $string instanceof Closure) {
4849
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4850
+	}
4593 4851
 
4594 4852
 	// No full objects, sorry! pass a method or a property instead!
4595
-	if (is_object($string))
4596
-		return false;
4853
+	if (is_object($string)) {
4854
+			return false;
4855
+	}
4597 4856
 
4598 4857
 	// Stay vitaminized my friends...
4599 4858
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4605,8 +4864,9 @@  discard block
 block discarded – undo
4605 4864
 	$string = load_file($string);
4606 4865
 
4607 4866
 	// Loaded file failed
4608
-	if (empty($string))
4609
-		return false;
4867
+	if (empty($string)) {
4868
+			return false;
4869
+	}
4610 4870
 
4611 4871
 	// Found a method.
4612 4872
 	if (strpos($string, '::') !== false)
@@ -4627,8 +4887,9 @@  discard block
 block discarded – undo
4627 4887
 				// Add another one to the list.
4628 4888
 				if ($db_show_debug === true)
4629 4889
 				{
4630
-					if (!isset($context['debug']['instances']))
4631
-						$context['debug']['instances'] = array();
4890
+					if (!isset($context['debug']['instances'])) {
4891
+											$context['debug']['instances'] = array();
4892
+					}
4632 4893
 
4633 4894
 					$context['debug']['instances'][$class] = $class;
4634 4895
 				}
@@ -4638,13 +4899,15 @@  discard block
 block discarded – undo
4638 4899
 		}
4639 4900
 
4640 4901
 		// Right then. This is a call to a static method.
4641
-		else
4642
-			$func = array($class, $method);
4902
+		else {
4903
+					$func = array($class, $method);
4904
+		}
4643 4905
 	}
4644 4906
 
4645 4907
 	// Nope! just a plain regular function.
4646
-	else
4647
-		$func = $string;
4908
+	else {
4909
+			$func = $string;
4910
+	}
4648 4911
 
4649 4912
 	// Right, we got what we need, time to do some checks.
4650 4913
 	if (!is_callable($func, false, $callable_name))
@@ -4660,17 +4923,18 @@  discard block
 block discarded – undo
4660 4923
 	else
4661 4924
 	{
4662 4925
 		// What are we gonna do about it?
4663
-		if ($return)
4664
-			return $func;
4926
+		if ($return) {
4927
+					return $func;
4928
+		}
4665 4929
 
4666 4930
 		// If this is a plain function, avoid the heat of calling call_user_func().
4667 4931
 		else
4668 4932
 		{
4669
-			if (is_array($func))
4670
-				call_user_func($func);
4671
-
4672
-			else
4673
-				$func();
4933
+			if (is_array($func)) {
4934
+							call_user_func($func);
4935
+			} else {
4936
+							$func();
4937
+			}
4674 4938
 		}
4675 4939
 	}
4676 4940
 }
@@ -4687,31 +4951,34 @@  discard block
 block discarded – undo
4687 4951
 {
4688 4952
 	global $sourcedir, $txt, $boarddir, $settings;
4689 4953
 
4690
-	if (empty($string))
4691
-		return false;
4954
+	if (empty($string)) {
4955
+			return false;
4956
+	}
4692 4957
 
4693 4958
 	if (strpos($string, '|') !== false)
4694 4959
 	{
4695 4960
 		list ($file, $string) = explode('|', $string);
4696 4961
 
4697 4962
 		// Match the wildcards to their regular vars.
4698
-		if (empty($settings['theme_dir']))
4699
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4700
-
4701
-		else
4702
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4963
+		if (empty($settings['theme_dir'])) {
4964
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4965
+		} else {
4966
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4967
+		}
4703 4968
 
4704 4969
 		// Load the file if it can be loaded.
4705
-		if (file_exists($absPath))
4706
-			require_once($absPath);
4970
+		if (file_exists($absPath)) {
4971
+					require_once($absPath);
4972
+		}
4707 4973
 
4708 4974
 		// No? try a fallback to $sourcedir
4709 4975
 		else
4710 4976
 		{
4711 4977
 			$absPath = $sourcedir .'/'. $file;
4712 4978
 
4713
-			if (file_exists($absPath))
4714
-				require_once($absPath);
4979
+			if (file_exists($absPath)) {
4980
+							require_once($absPath);
4981
+			}
4715 4982
 
4716 4983
 			// Sorry, can't do much for you at this point.
4717 4984
 			else
@@ -4738,8 +5005,9 @@  discard block
 block discarded – undo
4738 5005
 	global $user_info, $smcFunc;
4739 5006
 
4740 5007
 	// Make sure we have something to work with.
4741
-	if (empty($topic))
4742
-		return array();
5008
+	if (empty($topic)) {
5009
+			return array();
5010
+	}
4743 5011
 
4744 5012
 
4745 5013
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -4762,8 +5030,9 @@  discard block
 block discarded – undo
4762 5030
 				'topic' => $topic,
4763 5031
 			)
4764 5032
 		);
4765
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4766
-			$temp[] = (int) $row['content_id'];
5033
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5034
+					$temp[] = (int) $row['content_id'];
5035
+		}
4767 5036
 
4768 5037
 		cache_put_data($cache_key, $temp, $ttl);
4769 5038
 	}
@@ -4784,8 +5053,9 @@  discard block
 block discarded – undo
4784 5053
 {
4785 5054
 	global $context;
4786 5055
 
4787
-	if (empty($string))
4788
-		return $string;
5056
+	if (empty($string)) {
5057
+			return $string;
5058
+	}
4789 5059
 
4790 5060
 	// UTF-8 occurences of MS special characters
4791 5061
 	$findchars_utf8 = array(
@@ -4826,10 +5096,11 @@  discard block
 block discarded – undo
4826 5096
 		'--',	// &mdash;
4827 5097
 	);
4828 5098
 
4829
-	if ($context['utf8'])
4830
-		$string = str_replace($findchars_utf8, $replacechars, $string);
4831
-	else
4832
-		$string = str_replace($findchars_iso, $replacechars, $string);
5099
+	if ($context['utf8']) {
5100
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5101
+	} else {
5102
+			$string = str_replace($findchars_iso, $replacechars, $string);
5103
+	}
4833 5104
 
4834 5105
 	return $string;
4835 5106
 }
@@ -4848,49 +5119,59 @@  discard block
 block discarded – undo
4848 5119
 {
4849 5120
 	global $context;
4850 5121
 
4851
-	if (!isset($matches[2]))
4852
-		return '';
5122
+	if (!isset($matches[2])) {
5123
+			return '';
5124
+	}
4853 5125
 
4854 5126
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4855 5127
 
4856 5128
 	// remove left to right / right to left overrides
4857
-	if ($num === 0x202D || $num === 0x202E)
4858
-		return '';
5129
+	if ($num === 0x202D || $num === 0x202E) {
5130
+			return '';
5131
+	}
4859 5132
 
4860 5133
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
4861
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
4862
-		return '&#' . $num . ';';
5134
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5135
+			return '&#' . $num . ';';
5136
+	}
4863 5137
 
4864 5138
 	if (empty($context['utf8']))
4865 5139
 	{
4866 5140
 		// no control characters
4867
-		if ($num < 0x20)
4868
-			return '';
5141
+		if ($num < 0x20) {
5142
+					return '';
5143
+		}
4869 5144
 		// text is text
4870
-		elseif ($num < 0x80)
4871
-			return chr($num);
5145
+		elseif ($num < 0x80) {
5146
+					return chr($num);
5147
+		}
4872 5148
 		// all others get html-ised
4873
-		else
4874
-			return '&#' . $matches[2] . ';';
4875
-	}
4876
-	else
5149
+		else {
5150
+					return '&#' . $matches[2] . ';';
5151
+		}
5152
+	} else
4877 5153
 	{
4878 5154
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
4879 5155
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
4880
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
4881
-			return '';
5156
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5157
+					return '';
5158
+		}
4882 5159
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4883
-		elseif ($num < 0x80)
4884
-			return chr($num);
5160
+		elseif ($num < 0x80) {
5161
+					return chr($num);
5162
+		}
4885 5163
 		// <0x800 (2048)
4886
-		elseif ($num < 0x800)
4887
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5164
+		elseif ($num < 0x800) {
5165
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5166
+		}
4888 5167
 		// < 0x10000 (65536)
4889
-		elseif ($num < 0x10000)
4890
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5168
+		elseif ($num < 0x10000) {
5169
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5170
+		}
4891 5171
 		// <= 0x10FFFF (1114111)
4892
-		else
4893
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5172
+		else {
5173
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5174
+		}
4894 5175
 	}
4895 5176
 }
4896 5177
 
@@ -4906,28 +5187,34 @@  discard block
 block discarded – undo
4906 5187
  */
4907 5188
 function fixchar__callback($matches)
4908 5189
 {
4909
-	if (!isset($matches[1]))
4910
-		return '';
5190
+	if (!isset($matches[1])) {
5191
+			return '';
5192
+	}
4911 5193
 
4912 5194
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
4913 5195
 
4914 5196
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
4915 5197
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
4916
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
4917
-		return '';
5198
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5199
+			return '';
5200
+	}
4918 5201
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4919
-	elseif ($num < 0x80)
4920
-		return chr($num);
5202
+	elseif ($num < 0x80) {
5203
+			return chr($num);
5204
+	}
4921 5205
 	// <0x800 (2048)
4922
-	elseif ($num < 0x800)
4923
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5206
+	elseif ($num < 0x800) {
5207
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5208
+	}
4924 5209
 	// < 0x10000 (65536)
4925
-	elseif ($num < 0x10000)
4926
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5210
+	elseif ($num < 0x10000) {
5211
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5212
+	}
4927 5213
 	// <= 0x10FFFF (1114111)
4928
-	else
4929
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4930
-}
5214
+	else {
5215
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5216
+	}
5217
+	}
4931 5218
 
4932 5219
 /**
4933 5220
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -4940,17 +5227,19 @@  discard block
 block discarded – undo
4940 5227
  */
4941 5228
 function entity_fix__callback($matches)
4942 5229
 {
4943
-	if (!isset($matches[2]))
4944
-		return '';
5230
+	if (!isset($matches[2])) {
5231
+			return '';
5232
+	}
4945 5233
 
4946 5234
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4947 5235
 
4948 5236
 	// we don't allow control characters, characters out of range, byte markers, etc
4949
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
4950
-		return '';
4951
-	else
4952
-		return '&#' . $num . ';';
4953
-}
5237
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5238
+			return '';
5239
+	} else {
5240
+			return '&#' . $num . ';';
5241
+	}
5242
+	}
4954 5243
 
4955 5244
 /**
4956 5245
  * Return a Gravatar URL based on
@@ -4974,18 +5263,23 @@  discard block
 block discarded – undo
4974 5263
 		$ratings = array('G', 'PG', 'R', 'X');
4975 5264
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
4976 5265
 		$url_params = array();
4977
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
4978
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
4979
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
4980
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
4981
-		if (!empty($modSettings['avatar_max_width_external']))
4982
-			$size_string = (int) $modSettings['avatar_max_width_external'];
4983
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
4984
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5266
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5267
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5268
+		}
5269
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5270
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5271
+		}
5272
+		if (!empty($modSettings['avatar_max_width_external'])) {
5273
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5274
+		}
5275
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5276
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
4985 5277
 				$size_string = $modSettings['avatar_max_height_external'];
5278
+		}
4986 5279
 
4987
-		if (!empty($size_string))
4988
-			$url_params[] = 's=' . $size_string;
5280
+		if (!empty($size_string)) {
5281
+					$url_params[] = 's=' . $size_string;
5282
+		}
4989 5283
 	}
4990 5284
 	$http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www';
4991 5285
 
@@ -5096,8 +5390,9 @@  discard block
 block discarded – undo
5096 5390
  */
5097 5391
 function inet_ptod($ip_address)
5098 5392
 {
5099
-	if (!isValidIP($ip_address))
5100
-		return $ip_address;
5393
+	if (!isValidIP($ip_address)) {
5394
+			return $ip_address;
5395
+	}
5101 5396
 
5102 5397
 	$bin = inet_pton($ip_address);
5103 5398
 	return $bin;
@@ -5109,13 +5404,15 @@  discard block
 block discarded – undo
5109 5404
  */
5110 5405
 function inet_dtop($bin)
5111 5406
 {
5112
-	if(empty($bin))
5113
-		return '';
5407
+	if(empty($bin)) {
5408
+			return '';
5409
+	}
5114 5410
 
5115 5411
 	global $db_type;
5116 5412
 
5117
-	if ($db_type == 'postgresql')
5118
-		return $bin;
5413
+	if ($db_type == 'postgresql') {
5414
+			return $bin;
5415
+	}
5119 5416
 
5120 5417
 	$ip_address = inet_ntop($bin);
5121 5418
 
@@ -5140,26 +5437,32 @@  discard block
 block discarded – undo
5140 5437
  */
5141 5438
 function _safe_serialize($value)
5142 5439
 {
5143
-	if(is_null($value))
5144
-		return 'N;';
5440
+	if(is_null($value)) {
5441
+			return 'N;';
5442
+	}
5145 5443
 
5146
-	if(is_bool($value))
5147
-		return 'b:'. (int) $value .';';
5444
+	if(is_bool($value)) {
5445
+			return 'b:'. (int) $value .';';
5446
+	}
5148 5447
 
5149
-	if(is_int($value))
5150
-		return 'i:'. $value .';';
5448
+	if(is_int($value)) {
5449
+			return 'i:'. $value .';';
5450
+	}
5151 5451
 
5152
-	if(is_float($value))
5153
-		return 'd:'. str_replace(',', '.', $value) .';';
5452
+	if(is_float($value)) {
5453
+			return 'd:'. str_replace(',', '.', $value) .';';
5454
+	}
5154 5455
 
5155
-	if(is_string($value))
5156
-		return 's:'. strlen($value) .':"'. $value .'";';
5456
+	if(is_string($value)) {
5457
+			return 's:'. strlen($value) .':"'. $value .'";';
5458
+	}
5157 5459
 
5158 5460
 	if(is_array($value))
5159 5461
 	{
5160 5462
 		$out = '';
5161
-		foreach($value as $k => $v)
5162
-			$out .= _safe_serialize($k) . _safe_serialize($v);
5463
+		foreach($value as $k => $v) {
5464
+					$out .= _safe_serialize($k) . _safe_serialize($v);
5465
+		}
5163 5466
 
5164 5467
 		return 'a:'. count($value) .':{'. $out .'}';
5165 5468
 	}
@@ -5185,8 +5488,9 @@  discard block
 block discarded – undo
5185 5488
 
5186 5489
 	$out = _safe_serialize($value);
5187 5490
 
5188
-	if (isset($mbIntEnc))
5189
-		mb_internal_encoding($mbIntEnc);
5491
+	if (isset($mbIntEnc)) {
5492
+			mb_internal_encoding($mbIntEnc);
5493
+	}
5190 5494
 
5191 5495
 	return $out;
5192 5496
 }
@@ -5203,8 +5507,9 @@  discard block
 block discarded – undo
5203 5507
 function _safe_unserialize($str)
5204 5508
 {
5205 5509
 	// Input  is not a string.
5206
-	if(empty($str) || !is_string($str))
5207
-		return false;
5510
+	if(empty($str) || !is_string($str)) {
5511
+			return false;
5512
+	}
5208 5513
 
5209 5514
 	$stack = array();
5210 5515
 	$expected = array();
@@ -5220,43 +5525,38 @@  discard block
 block discarded – undo
5220 5525
 	while($state != 1)
5221 5526
 	{
5222 5527
 		$type = isset($str[0]) ? $str[0] : '';
5223
-		if($type == '}')
5224
-			$str = substr($str, 1);
5225
-
5226
-		else if($type == 'N' && $str[1] == ';')
5528
+		if($type == '}') {
5529
+					$str = substr($str, 1);
5530
+		} else if($type == 'N' && $str[1] == ';')
5227 5531
 		{
5228 5532
 			$value = null;
5229 5533
 			$str = substr($str, 2);
5230
-		}
5231
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5534
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5232 5535
 		{
5233 5536
 			$value = $matches[1] == '1' ? true : false;
5234 5537
 			$str = substr($str, 4);
5235
-		}
5236
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5538
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5237 5539
 		{
5238 5540
 			$value = (int)$matches[1];
5239 5541
 			$str = $matches[2];
5240
-		}
5241
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5542
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5242 5543
 		{
5243 5544
 			$value = (float)$matches[1];
5244 5545
 			$str = $matches[3];
5245
-		}
5246
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5546
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5247 5547
 		{
5248 5548
 			$value = substr($matches[2], 0, (int)$matches[1]);
5249 5549
 			$str = substr($matches[2], (int)$matches[1] + 2);
5250
-		}
5251
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5550
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5252 5551
 		{
5253 5552
 			$expectedLength = (int)$matches[1];
5254 5553
 			$str = $matches[2];
5255 5554
 		}
5256 5555
 
5257 5556
 		// Object or unknown/malformed type.
5258
-		else
5259
-			return false;
5557
+		else {
5558
+					return false;
5559
+		}
5260 5560
 
5261 5561
 		switch($state)
5262 5562
 		{
@@ -5284,8 +5584,9 @@  discard block
 block discarded – undo
5284 5584
 				if($type == '}')
5285 5585
 				{
5286 5586
 					// Array size is less than expected.
5287
-					if(count($list) < end($expected))
5288
-						return false;
5587
+					if(count($list) < end($expected)) {
5588
+											return false;
5589
+					}
5289 5590
 
5290 5591
 					unset($list);
5291 5592
 					$list = &$stack[count($stack)-1];
@@ -5294,8 +5595,9 @@  discard block
 block discarded – undo
5294 5595
 					// Go to terminal state if we're at the end of the root array.
5295 5596
 					array_pop($expected);
5296 5597
 
5297
-					if(count($expected) == 0)
5298
-						$state = 1;
5598
+					if(count($expected) == 0) {
5599
+											$state = 1;
5600
+					}
5299 5601
 
5300 5602
 					break;
5301 5603
 				}
@@ -5303,8 +5605,9 @@  discard block
 block discarded – undo
5303 5605
 				if($type == 'i' || $type == 's')
5304 5606
 				{
5305 5607
 					// Array size exceeds expected length.
5306
-					if(count($list) >= end($expected))
5307
-						return false;
5608
+					if(count($list) >= end($expected)) {
5609
+											return false;
5610
+					}
5308 5611
 
5309 5612
 					$key = $value;
5310 5613
 					$state = 3;
@@ -5338,8 +5641,9 @@  discard block
 block discarded – undo
5338 5641
 	}
5339 5642
 
5340 5643
 	// Trailing data in input.
5341
-	if(!empty($str))
5342
-		return false;
5644
+	if(!empty($str)) {
5645
+			return false;
5646
+	}
5343 5647
 
5344 5648
 	return $data;
5345 5649
 }
@@ -5362,8 +5666,9 @@  discard block
 block discarded – undo
5362 5666
 
5363 5667
 	$out = _safe_unserialize($str);
5364 5668
 
5365
-	if (isset($mbIntEnc))
5366
-		mb_internal_encoding($mbIntEnc);
5669
+	if (isset($mbIntEnc)) {
5670
+			mb_internal_encoding($mbIntEnc);
5671
+	}
5367 5672
 
5368 5673
 	return $out;
5369 5674
 }
@@ -5378,12 +5683,14 @@  discard block
 block discarded – undo
5378 5683
 function smf_chmod($file, $value = 0)
5379 5684
 {
5380 5685
 	// No file? no checks!
5381
-	if (empty($file))
5382
-		return false;
5686
+	if (empty($file)) {
5687
+			return false;
5688
+	}
5383 5689
 
5384 5690
 	// Already writable?
5385
-	if (is_writable($file))
5386
-		return true;
5691
+	if (is_writable($file)) {
5692
+			return true;
5693
+	}
5387 5694
 
5388 5695
 	// Do we have a file or a dir?
5389 5696
 	$isDir = is_dir($file);
@@ -5399,10 +5706,9 @@  discard block
 block discarded – undo
5399 5706
 		{
5400 5707
 			$isWritable = true;
5401 5708
 			break;
5709
+		} else {
5710
+					@chmod($file, $val);
5402 5711
 		}
5403
-
5404
-		else
5405
-			@chmod($file, $val);
5406 5712
 	}
5407 5713
 
5408 5714
 	return $isWritable;
@@ -5421,8 +5727,9 @@  discard block
 block discarded – undo
5421 5727
 	global $txt;
5422 5728
 
5423 5729
 	// Come on...
5424
-	if (empty($json) || !is_string($json))
5425
-		return array();
5730
+	if (empty($json) || !is_string($json)) {
5731
+			return array();
5732
+	}
5426 5733
 
5427 5734
 	$returnArray = array();
5428 5735
 	$jsonError = false;
@@ -5463,11 +5770,11 @@  discard block
 block discarded – undo
5463 5770
 		$jsonDebug = $jsonDebug[0];
5464 5771
 		loadLanguage('Errors');
5465 5772
 
5466
-		if (!empty($jsonDebug))
5467
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5468
-
5469
-		else
5470
-			log_error($txt['json_'. $jsonError], 'critical');
5773
+		if (!empty($jsonDebug)) {
5774
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5775
+		} else {
5776
+					log_error($txt['json_'. $jsonError], 'critical');
5777
+		}
5471 5778
 
5472 5779
 		// Everyone expects an array.
5473 5780
 		return array();
@@ -5497,8 +5804,9 @@  discard block
 block discarded – undo
5497 5804
 	global $db_show_debug, $modSettings;
5498 5805
 
5499 5806
 	// Defensive programming anyone?
5500
-	if (empty($data))
5501
-		return false;
5807
+	if (empty($data)) {
5808
+			return false;
5809
+	}
5502 5810
 
5503 5811
 	// Don't need extra stuff...
5504 5812
 	$db_show_debug = false;
@@ -5506,11 +5814,11 @@  discard block
 block discarded – undo
5506 5814
 	// Kill anything else.
5507 5815
 	ob_end_clean();
5508 5816
 
5509
-	if (!empty($modSettings['CompressedOutput']))
5510
-		@ob_start('ob_gzhandler');
5511
-
5512
-	else
5513
-		ob_start();
5817
+	if (!empty($modSettings['CompressedOutput'])) {
5818
+			@ob_start('ob_gzhandler');
5819
+	} else {
5820
+			ob_start();
5821
+	}
5514 5822
 
5515 5823
 	// Set the header.
5516 5824
 	header($type);
@@ -5542,8 +5850,9 @@  discard block
 block discarded – undo
5542 5850
 	static $done = false;
5543 5851
 
5544 5852
 	// If we don't need to do anything, don't
5545
-	if (!$update && $done)
5546
-		return;
5853
+	if (!$update && $done) {
5854
+			return;
5855
+	}
5547 5856
 
5548 5857
 	// Should we get a new copy of the official list of TLDs?
5549 5858
 	if ($update)
@@ -5564,10 +5873,11 @@  discard block
 block discarded – undo
5564 5873
 		// Clean $tlds and convert it to an array
5565 5874
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
5566 5875
 			$line = trim($line);
5567
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
5568
-				return false;
5569
-			else
5570
-				return true;
5876
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
5877
+							return false;
5878
+			} else {
5879
+							return true;
5880
+			}
5571 5881
 		});
5572 5882
 
5573 5883
 		// Convert Punycode to Unicode
@@ -5621,8 +5931,9 @@  discard block
 block discarded – undo
5621 5931
 						$idx += $digit * $w;
5622 5932
 						$t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias));
5623 5933
 
5624
-						if ($digit < $t)
5625
-							break;
5934
+						if ($digit < $t) {
5935
+													break;
5936
+						}
5626 5937
 
5627 5938
 						$w = (int) ($w * ($base - $t));
5628 5939
 					}
@@ -5631,8 +5942,9 @@  discard block
 block discarded – undo
5631 5942
 					$delta = intval($is_first ? ($delta / $damp) : ($delta / 2));
5632 5943
 					$delta += intval($delta / ($deco_len + 1));
5633 5944
 
5634
-					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base)
5635
-						$delta = intval($delta / ($base - $tmin));
5945
+					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) {
5946
+											$delta = intval($delta / ($base - $tmin));
5947
+					}
5636 5948
 
5637 5949
 					$bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew));
5638 5950
 					$is_first = false;
@@ -5641,8 +5953,9 @@  discard block
 block discarded – undo
5641 5953
 
5642 5954
 					if ($deco_len > 0)
5643 5955
 					{
5644
-						for ($i = $deco_len; $i > $idx; $i--)
5645
-							$decoded[$i] = $decoded[($i - 1)];
5956
+						for ($i = $deco_len; $i > $idx; $i--) {
5957
+													$decoded[$i] = $decoded[($i - 1)];
5958
+						}
5646 5959
 					}
5647 5960
 					$decoded[$idx++] = $char;
5648 5961
 				}
@@ -5650,24 +5963,29 @@  discard block
 block discarded – undo
5650 5963
 				foreach ($decoded as $k => $v)
5651 5964
 				{
5652 5965
 					// 7bit are transferred literally
5653
-					if ($v < 128)
5654
-						$output .= chr($v);
5966
+					if ($v < 128) {
5967
+											$output .= chr($v);
5968
+					}
5655 5969
 
5656 5970
 					// 2 bytes
5657
-					elseif ($v < (1 << 11))
5658
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5971
+					elseif ($v < (1 << 11)) {
5972
+											$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5973
+					}
5659 5974
 
5660 5975
 					// 3 bytes
5661
-					elseif ($v < (1 << 16))
5662
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5976
+					elseif ($v < (1 << 16)) {
5977
+											$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5978
+					}
5663 5979
 
5664 5980
 					// 4 bytes
5665
-					elseif ($v < (1 << 21))
5666
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5981
+					elseif ($v < (1 << 21)) {
5982
+											$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5983
+					}
5667 5984
 
5668 5985
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5669
-					else
5670
-						$output .= $safe_char;
5986
+					else {
5987
+											$output .= $safe_char;
5988
+					}
5671 5989
 				}
5672 5990
 
5673 5991
 				$output_parts[] = $output;
@@ -5762,8 +6080,7 @@  discard block
 block discarded – undo
5762 6080
 
5763 6081
 		$strlen = 'mb_strlen';
5764 6082
 		$substr = 'mb_substr';
5765
-	}
5766
-	else
6083
+	} else
5767 6084
 	{
5768 6085
 		$strlen = $smcFunc['strlen'];
5769 6086
 		$substr = $smcFunc['substr'];
@@ -5777,20 +6094,21 @@  discard block
 block discarded – undo
5777 6094
 
5778 6095
 		$first = $substr($string, 0, 1);
5779 6096
 
5780
-		if (empty($index[$first]))
5781
-			$index[$first] = array();
6097
+		if (empty($index[$first])) {
6098
+					$index[$first] = array();
6099
+		}
5782 6100
 
5783 6101
 		if ($strlen($string) > 1)
5784 6102
 		{
5785 6103
 			// Sanity check on recursion
5786
-			if ($depth > 99)
5787
-				$index[$first][$substr($string, 1)] = '';
5788
-
5789
-			else
5790
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6104
+			if ($depth > 99) {
6105
+							$index[$first][$substr($string, 1)] = '';
6106
+			} else {
6107
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6108
+			}
6109
+		} else {
6110
+					$index[$first][''] = '';
5791 6111
 		}
5792
-		else
5793
-			$index[$first][''] = '';
5794 6112
 
5795 6113
 		$depth--;
5796 6114
 		return $index;
@@ -5813,29 +6131,30 @@  discard block
 block discarded – undo
5813 6131
 			$key_regex = preg_quote($key, $delim);
5814 6132
 			$new_key = $key;
5815 6133
 
5816
-			if (empty($value))
5817
-				$sub_regex = '';
5818
-			else
6134
+			if (empty($value)) {
6135
+							$sub_regex = '';
6136
+			} else
5819 6137
 			{
5820 6138
 				$sub_regex = $index_to_regex($value, $delim);
5821 6139
 
5822
-				if (count(array_keys($value)) == 1)
5823
-					$new_key .= explode('(?'.'>', $sub_regex)[0];
5824
-				else
5825
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6140
+				if (count(array_keys($value)) == 1) {
6141
+									$new_key .= explode('(?'.'>', $sub_regex)[0];
6142
+				} else {
6143
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
6144
+				}
5826 6145
 			}
5827 6146
 
5828
-			if ($depth > 1)
5829
-				$regex[$new_key] = $key_regex . $sub_regex;
5830
-			else
6147
+			if ($depth > 1) {
6148
+							$regex[$new_key] = $key_regex . $sub_regex;
6149
+			} else
5831 6150
 			{
5832 6151
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
5833 6152
 				{
5834 6153
 					$regex[$new_key] = $key_regex . $sub_regex;
5835 6154
 					unset($index[$key]);
6155
+				} else {
6156
+									break;
5836 6157
 				}
5837
-				else
5838
-					break;
5839 6158
 			}
5840 6159
 		}
5841 6160
 
@@ -5844,10 +6163,11 @@  discard block
 block discarded – undo
5844 6163
 			$l1 = $strlen($k1);
5845 6164
 			$l2 = $strlen($k2);
5846 6165
 
5847
-			if ($l1 == $l2)
5848
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
5849
-			else
5850
-				return $l1 > $l2 ? -1 : 1;
6166
+			if ($l1 == $l2) {
6167
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6168
+			} else {
6169
+							return $l1 > $l2 ? -1 : 1;
6170
+			}
5851 6171
 		});
5852 6172
 
5853 6173
 		$depth--;
@@ -5858,15 +6178,18 @@  discard block
 block discarded – undo
5858 6178
 	$index = array();
5859 6179
 	$regexes = array();
5860 6180
 
5861
-	foreach ($strings as $string)
5862
-		$index = $add_string_to_index($string, $index);
6181
+	foreach ($strings as $string) {
6182
+			$index = $add_string_to_index($string, $index);
6183
+	}
5863 6184
 
5864
-	while (!empty($index))
5865
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6185
+	while (!empty($index)) {
6186
+			$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6187
+	}
5866 6188
 
5867 6189
 	// Restore PHP's internal character encoding to whatever it was originally
5868
-	if (!empty($current_encoding))
5869
-		mb_internal_encoding($current_encoding);
6190
+	if (!empty($current_encoding)) {
6191
+			mb_internal_encoding($current_encoding);
6192
+	}
5870 6193
 
5871 6194
 	return $regexes;
5872 6195
 }
Please login to merge, or discard this patch.
Sources/Subscriptions-PayPal.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -402,7 +402,7 @@
 block discarded – undo
402 402
 	 * A private function to find out the subscription details.
403 403
 	 *
404 404
 	 * @access private
405
-	 * @return boolean|void False on failure, otherwise just sets $_POST['item_number']
405
+	 * @return false|null False on failure, otherwise just sets $_POST['item_number']
406 406
 	 */
407 407
 	private function _findSubscription()
408 408
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@
 block discarded – undo
236 236
 			$header = 'POST /cgi-bin/webscr HTTP/1.1' . "\r\n";
237 237
 			$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
238 238
 			$header .= 'Host: www.' . (!empty($modSettings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com' . "\r\n";
239
-			$header .= 'Content-Length: ' . strlen ($requestString) . "\r\n";
239
+			$header .= 'Content-Length: ' . strlen($requestString) . "\r\n";
240 240
 			$header .= 'Connection: close' . "\r\n\r\n";
241 241
 
242 242
 			// Open the connection.
Please login to merge, or discard this patch.
Braces   +83 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 // This won't be dedicated without this - this must exist in each gateway!
15 15
 // SMF Payment Gateway: paypal
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Class for returning available form data for this gateway
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 		{
119 120
 			$return_data['hidden']['p3'] = 1;
120 121
 			$return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1));
121
-		}
122
-		else
122
+		} else
123 123
 		{
124 124
 			preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match);
125 125
 			$unit = $match[1];
@@ -130,14 +130,15 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// If it's repeatable do some javascript to respect this idea.
133
-		if (!empty($sub_data['repeatable']))
134
-			$return_data['javascript'] = '
133
+		if (!empty($sub_data['repeatable'])) {
134
+					$return_data['javascript'] = '
135 135
 				document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\');
136 136
 
137 137
 				function switchPaypalRecur()
138 138
 				{
139 139
 					document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick";
140 140
 				}';
141
+		}
141 142
 
142 143
 		return $return_data;
143 144
 	}
@@ -160,20 +161,24 @@  discard block
 block discarded – undo
160 161
 		global $modSettings;
161 162
 
162 163
 		// Has the user set up an email address?
163
-		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email'])))
164
-			return false;
164
+		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) {
165
+					return false;
166
+		}
165 167
 		// Check the correct transaction types are even here.
166
-		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email'])))
167
-			return false;
168
+		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) {
169
+					return false;
170
+		}
168 171
 		// Correct email address?
169
-		if (!isset($_POST['business']))
170
-			$_POST['business'] = $_POST['receiver_email'];
172
+		if (!isset($_POST['business'])) {
173
+					$_POST['business'] = $_POST['receiver_email'];
174
+		}
171 175
 
172 176
 		// Are we testing?
173
-		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
174
-			return false;
175
-		elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails']))))
176
-			return false;
177
+		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
178
+					return false;
179
+		} elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) {
180
+					return false;
181
+		}
177 182
 		return true;
178 183
 	}
179 184
 
@@ -192,15 +197,17 @@  discard block
 block discarded – undo
192 197
 		global $modSettings, $txt;
193 198
 
194 199
 		// Put this to some default value.
195
-		if (!isset($_POST['txn_type']))
196
-			$_POST['txn_type'] = '';
200
+		if (!isset($_POST['txn_type'])) {
201
+					$_POST['txn_type'] = '';
202
+		}
197 203
 
198 204
 		// Build the request string - starting with the minimum requirement.
199 205
 		$requestString = 'cmd=_notify-validate';
200 206
 
201 207
 		// Now my dear, add all the posted bits in the order we got them
202
-		foreach ($_POST as $k => $v)
203
-			$requestString .= '&' . $k . '=' . urlencode($v);
208
+		foreach ($_POST as $k => $v) {
209
+					$requestString .= '&' . $k . '=' . urlencode($v);
210
+		}
204 211
 
205 212
 		// Can we use curl?
206 213
 		if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr'))
@@ -240,14 +247,16 @@  discard block
 block discarded – undo
240 247
 			$header .= 'Connection: close' . "\r\n\r\n";
241 248
 
242 249
 			// Open the connection.
243
-			if (!empty($modSettings['paidsubs_test']))
244
-				$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
245
-			else
246
-				$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
250
+			if (!empty($modSettings['paidsubs_test'])) {
251
+							$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
252
+			} else {
253
+							$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
254
+			}
247 255
 
248 256
 			// Did it work?
249
-			if (!$fp)
250
-				generateSubscriptionError($txt['paypal_could_not_connect']);
257
+			if (!$fp) {
258
+							generateSubscriptionError($txt['paypal_could_not_connect']);
259
+			}
251 260
 
252 261
 			// Put the data to the port.
253 262
 			fputs($fp, $header . $requestString);
@@ -256,8 +265,9 @@  discard block
 block discarded – undo
256 265
 			while (!feof($fp))
257 266
 			{
258 267
 				$this->return_data = fgets($fp, 1024);
259
-				if (strcmp(trim($this->return_data), 'VERIFIED') === 0)
260
-					break;
268
+				if (strcmp(trim($this->return_data), 'VERIFIED') === 0) {
269
+									break;
270
+				}
261 271
 			}
262 272
 
263 273
 			// Clean up.
@@ -265,28 +275,34 @@  discard block
 block discarded – undo
265 275
 		}
266 276
 
267 277
 		// If this isn't verified then give up...
268
-		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0)
269
-			exit;
278
+		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) {
279
+					exit;
280
+		}
270 281
 
271 282
 		// Check that this is intended for us.
272
-		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
273
-			exit;
283
+		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
284
+					exit;
285
+		}
274 286
 
275 287
 		// Is this a subscription - and if so is it a secondary payment that we need to process?
276 288
 		// If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding.
277
-		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false)
278
-			$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
279
-		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false))
280
-			// Calculate the subscription it relates to!
289
+		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) {
290
+					$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
291
+		}
292
+		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) {
293
+					// Calculate the subscription it relates to!
281 294
 			$this->_findSubscription();
295
+		}
282 296
 
283 297
 		// Verify the currency!
284
-		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code']))
285
-			exit;
298
+		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) {
299
+					exit;
300
+		}
286 301
 
287 302
 		// Can't exist if it doesn't contain anything.
288
-		if (empty($_POST['item_number']))
289
-			exit;
303
+		if (empty($_POST['item_number'])) {
304
+					exit;
305
+		}
290 306
 
291 307
 		// Return the id_sub and id_member
292 308
 		return explode('+', $_POST['item_number']);
@@ -299,10 +315,11 @@  discard block
 block discarded – undo
299 315
 	 */
300 316
 	public function isRefund()
301 317
 	{
302
-		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed'))
303
-			return true;
304
-		else
305
-			return false;
318
+		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) {
319
+					return true;
320
+		} else {
321
+					return false;
322
+		}
306 323
 	}
307 324
 
308 325
 	/**
@@ -312,10 +329,11 @@  discard block
 block discarded – undo
312 329
 	 */
313 330
 	public function isSubscription()
314 331
 	{
315
-		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed')
316
-			return true;
317
-		else
318
-			return false;
332
+		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') {
333
+					return true;
334
+		} else {
335
+					return false;
336
+		}
319 337
 	}
320 338
 
321 339
 	/**
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 	 */
326 344
 	public function isPayment()
327 345
 	{
328
-		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept')
329
-			return true;
330
-		else
331
-			return false;
346
+		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') {
347
+					return true;
348
+		} else {
349
+					return false;
350
+		}
332 351
 	}
333 352
 
334 353
 	/**
@@ -341,10 +360,11 @@  discard block
 block discarded – undo
341 360
 		// subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment
342 361
 		// Neither require us to *do* anything as per performCancel().
343 362
 		// subscr_eot, if sent, indicates an end of payments term.
344
-		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot')
345
-			return true;
346
-		else
347
-			return false;
363
+		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') {
364
+					return true;
365
+		} else {
366
+					return false;
367
+		}
348 368
 	}
349 369
 
350 370
 	/**
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		global $smcFunc;
410 430
 
411 431
 		// Assume we have this?
412
-		if (empty($_POST['subscr_id']))
413
-			return false;
432
+		if (empty($_POST['subscr_id'])) {
433
+					return false;
434
+		}
414 435
 
415 436
 		// Do we have this in the database?
416 437
 		$request = $smcFunc['db_query']('', '
@@ -439,11 +460,12 @@  discard block
 block discarded – undo
439 460
 						'payer_email' => $_POST['payer_email'],
440 461
 					)
441 462
 				);
442
-				if ($smcFunc['db_num_rows']($request) === 0)
443
-					return false;
463
+				if ($smcFunc['db_num_rows']($request) === 0) {
464
+									return false;
465
+				}
466
+			} else {
467
+							return false;
444 468
 			}
445
-			else
446
-				return false;
447 469
 		}
448 470
 		list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request);
449 471
 		$_POST['item_number'] = $member_id . '+' . $subscription_id;
Please login to merge, or discard this patch.
Sources/tasks/EventNew-Notify.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 {
22 22
 	/**
23 23
      * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24
-	 * @return bool Always returns true
24
+	 * @return boolean|null Always returns true
25 25
 	 */
26 26
 	public function execute()
27 27
  	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 class EventNew_Notify_Background extends SMF_BackgroundTask
21 21
 {
22 22
 	/**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24 24
 	 * @return bool Always returns true
25 25
 	 */
26 26
 	public function execute()
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@  discard block
 block discarded – undo
32 32
 		$members = membersAllowedTo('calendar_view');
33 33
 
34 34
 		// Don't alert the event creator
35
-		if (!empty($this->_details['sender_id']))
36
-			$members = array_diff($members, array($this->_details['sender_id']));
35
+		if (!empty($this->_details['sender_id'])) {
36
+					$members = array_diff($members, array($this->_details['sender_id']));
37
+		}
37 38
 
38 39
 		// Having successfully figured this out, now let's get the preferences of everyone.
39 40
 		require_once($sourcedir . '/Subs-Notify.php');
@@ -44,10 +45,11 @@  discard block
 block discarded – undo
44 45
 		if (!empty($this->_details['sender_id']) && empty($this->_details['sender_name']))
45 46
 		{
46 47
 			loadMemberData($this->_details['sender_id'], 'minimal');
47
-			if (!empty($user_profile[$this->_details['sender_id']]))
48
-				$this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name'];
49
-			else
50
-				$this->_details['sender_id'] = 0;
48
+			if (!empty($user_profile[$this->_details['sender_id']])) {
49
+							$this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name'];
50
+			} else {
51
+							$this->_details['sender_id'] = 0;
52
+			}
51 53
 		}
52 54
 
53 55
 		// So now we find out who wants what.
@@ -59,9 +61,10 @@  discard block
 block discarded – undo
59 61
 
60 62
 		foreach ($prefs as $member => $pref_option)
61 63
 		{
62
-			foreach ($alert_bits as $type => $bitvalue)
63
-				if ($pref_option['event_new'] & $bitvalue)
64
+			foreach ($alert_bits as $type => $bitvalue) {
65
+							if ($pref_option['event_new'] & $bitvalue)
64 66
 					$notifies[$type][] = $member;
67
+			}
65 68
 		}
66 69
 
67 70
 		// Firstly, anyone who wants alerts.
Please login to merge, or discard this patch.
Sources/Xml.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 /**
81 81
  * Handles retrieving previews of news items, newsletters, signatures and warnings.
82 82
  * Calls the appropriate function based on $_POST['item']
83
- * @return void|bool Returns false if $_POST['item'] isn't set or isn't valid
83
+ * @return false|null Returns false if $_POST['item'] isn't set or isn't valid
84 84
  */
85 85
 function RetrievePreview()
86 86
 {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -272,13 +272,13 @@
 block discarded – undo
272 272
 				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
273 273
 			// Add in few replacements.
274 274
 			/**
275
-			* These are the defaults:
276
-			* - {MEMBER} - Member Name. => current user for review
277
-			* - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
-			* - {FORUMNAME} - Forum Name.
279
-			* - {SCRIPTURL} - Web address of forum.
280
-			* - {REGARDS} - Standard email sign-off.
281
-			*/
275
+			 * These are the defaults:
276
+			 * - {MEMBER} - Member Name. => current user for review
277
+			 * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
+			 * - {FORUMNAME} - Forum Name.
279
+			 * - {SCRIPTURL} - Web address of forum.
280
+			 * - {REGARDS} - Standard email sign-off.
281
+			 */
282 282
 			$find = array(
283 283
 				'{MEMBER}',
284 284
 				'{FORUMNAME}',
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
 	require_once($sourcedir . '/Subs-Post.php');
112 112
 
113 113
 	$errors = array();
114
-	$news = !isset($_POST['news'])? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
114
+	$news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
115 115
 	if (empty($news))
116 116
 		$errors[] = array('value' => 'no_news');
117 117
 	else
Please login to merge, or discard this patch.
Braces   +55 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main handler and designator for AJAX stuff - jumpto, message icons and previews
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	// Easy adding of sub actions.
33 34
 	call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions));
34 35
 
35
-	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']]))
36
-		fatal_lang_error('no_access', false);
36
+	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	call_helper($subActions[$_REQUEST['sa']]);
39 41
 }
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 	foreach ($context['jump_to'] as $id_cat => $cat)
58 60
 	{
59 61
 		$context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name']));
60
-		foreach ($cat['boards'] as $id_board => $board)
61
-			$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
62
+		foreach ($cat['boards'] as $id_board => $board) {
63
+					$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
64
+		}
62 65
 	}
63 66
 
64 67
 	$context['sub_template'] = 'jump_to';
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 
96 99
 	$context['sub_template'] = 'generic_xml';
97 100
 
98
-	if (!isset($_POST['item']) || !in_array($_POST['item'], $items))
99
-		return false;
101
+	if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) {
102
+			return false;
103
+	}
100 104
 
101 105
 	$_POST['item']();
102 106
 }
@@ -112,10 +116,11 @@  discard block
 block discarded – undo
112 116
 
113 117
 	$errors = array();
114 118
 	$news = !isset($_POST['news'])? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
115
-	if (empty($news))
116
-		$errors[] = array('value' => 'no_news');
117
-	else
118
-		preparsecode($news);
119
+	if (empty($news)) {
120
+			$errors[] = array('value' => 'no_news');
121
+	} else {
122
+			preparsecode($news);
123
+	}
119 124
 
120 125
 	$context['xml_data'] = array(
121 126
 		'news' => array(
@@ -148,10 +153,12 @@  discard block
 block discarded – undo
148 153
 	$context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0;
149 154
 	$context['send_html'] = !empty($_POST['send_html']) ? 1 : 0;
150 155
 
151
-	if (empty($_POST['subject']))
152
-		$context['post_error']['messages'][] = $txt['error_no_subject'];
153
-	if (empty($_POST['message']))
154
-		$context['post_error']['messages'][] = $txt['error_no_message'];
156
+	if (empty($_POST['subject'])) {
157
+			$context['post_error']['messages'][] = $txt['error_no_subject'];
158
+	}
159
+	if (empty($_POST['message'])) {
160
+			$context['post_error']['messages'][] = $txt['error_no_message'];
161
+	}
155 162
 
156 163
 	prepareMailingForPreview();
157 164
 
@@ -196,38 +203,41 @@  discard block
 block discarded – undo
196 203
 		$preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview'];
197 204
 		$validation = profileValidateSignature($preview_signature);
198 205
 
199
-		if ($validation !== true && $validation !== false)
200
-			$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
206
+		if ($validation !== true && $validation !== false) {
207
+					$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
208
+		}
201 209
 
202 210
 		censorText($preview_signature);
203 211
 		$preview_signature = parse_bbc($preview_signature, true, 'sig' . $user);
204
-	}
205
-	elseif (!$can_change)
212
+	} elseif (!$can_change)
206 213
 	{
207
-		if ($is_owner)
208
-			$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
209
-		else
210
-			$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
214
+		if ($is_owner) {
215
+					$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
216
+		} else {
217
+					$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
218
+		}
219
+	} else {
220
+			$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
211 221
 	}
212
-	else
213
-		$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
214 222
 
215 223
 	$context['xml_data']['signatures'] = array(
216 224
 			'identifier' => 'signature',
217 225
 			'children' => array()
218 226
 		);
219
-	if (isset($current_signature))
220
-		$context['xml_data']['signatures']['children'][] = array(
227
+	if (isset($current_signature)) {
228
+			$context['xml_data']['signatures']['children'][] = array(
221 229
 					'value' => $current_signature,
222 230
 					'attributes' => array('type' => 'current'),
223 231
 				);
224
-	if (isset($preview_signature))
225
-		$context['xml_data']['signatures']['children'][] = array(
232
+	}
233
+	if (isset($preview_signature)) {
234
+			$context['xml_data']['signatures']['children'][] = array(
226 235
 					'value' => $preview_signature,
227 236
 					'attributes' => array('type' => 'preview'),
228 237
 				);
229
-	if (!empty($errors))
230
-		$context['xml_data']['errors'] = array(
238
+	}
239
+	if (!empty($errors)) {
240
+			$context['xml_data']['errors'] = array(
231 241
 			'identifier' => 'error',
232 242
 			'children' => array_merge(
233 243
 				array(
@@ -239,7 +249,8 @@  discard block
 block discarded – undo
239 249
 				$errors
240 250
 			),
241 251
 		);
242
-}
252
+	}
253
+	}
243 254
 
244 255
 /**
245 256
  * Handles previewing user warnings
@@ -261,15 +272,17 @@  discard block
 block discarded – undo
261 272
 		$context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : '';
262 273
 		if (isset($_POST['issuing']))
263 274
 		{
264
-			if (empty($_POST['title']) || empty($_POST['body']))
265
-				$context['post_error']['messages'][] = $txt['warning_notify_blank'];
266
-		}
267
-		else
275
+			if (empty($_POST['title']) || empty($_POST['body'])) {
276
+							$context['post_error']['messages'][] = $txt['warning_notify_blank'];
277
+			}
278
+		} else
268 279
 		{
269
-			if (empty($_POST['title']))
270
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
271
-			if (empty($_POST['body']))
272
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
280
+			if (empty($_POST['title'])) {
281
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
282
+			}
283
+			if (empty($_POST['body'])) {
284
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
285
+			}
273 286
 			// Add in few replacements.
274 287
 			/**
275 288
 			* These are the defaults:
@@ -300,9 +313,9 @@  discard block
 block discarded – undo
300 313
 			$warning_body = parse_bbc($warning_body, true);
301 314
 		}
302 315
 		$context['preview_message'] = $warning_body;
316
+	} else {
317
+			$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
303 318
 	}
304
-	else
305
-		$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
306 319
 
307 320
 	$context['sub_template'] = 'warning';
308 321
 }
Please login to merge, or discard this patch.
SSI.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 /**
1718 1718
  * Show today's birthdays.
1719 1719
  * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them.
1720
- * @return void|array Displays a list of users or returns an array of info about them depending on output_method.
1720
+ * @return null|string Displays a list of users or returns an array of info about them depending on output_method.
1721 1721
  */
1722 1722
 function ssi_todaysBirthdays($output_method = 'echo')
1723 1723
 {
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 /**
1747 1747
  * Shows today's holidays.
1748 1748
  * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them.
1749
- * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method
1749
+ * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method
1750 1750
  */
1751 1751
 function ssi_todaysHolidays($output_method = 'echo')
1752 1752
 {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 
1774 1774
 /**
1775 1775
  * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them.
1776
- * @return void|array Displays a list of events or returns an array of info about them depending on output_method
1776
+ * @return null|string Displays a list of events or returns an array of info about them depending on output_method
1777 1777
  */
1778 1778
 function ssi_todaysEvents($output_method = 'echo')
1779 1779
 {
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 /**
1808 1808
  * Shows today's calendar items (events, birthdays and holidays)
1809 1809
  * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them.
1810
- * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method
1810
+ * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method
1811 1811
  */
1812 1812
 function ssi_todaysCalendar($output_method = 'echo')
1813 1813
 {
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
  * @param int|string $id The ID or username of a user
2199 2199
  * @param string $password The password to check
2200 2200
  * @param bool $is_username If true, treats $id as a username rather than a user ID
2201
- * @return bool Whether or not the password is correct.
2201
+ * @return null|boolean Whether or not the password is correct.
2202 2202
  */
2203 2203
 function ssi_checkPassword($id = null, $password = null, $is_username = false)
2204 2204
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 
1558 1558
 		echo '
1559 1559
 				</dl>', ($return['allow_view_results'] ? '
1560
-				<strong>'. $txt['poll_total_voters'] .': '. $return['total_votes'] .'</strong>' : ''), '
1560
+				<strong>'. $txt['poll_total_voters'] . ': ' . $return['total_votes'] . '</strong>' : ''), '
1561 1561
 			</div>';
1562 1562
 	}
1563 1563
 }
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
 				$base .= (isset($txt[$base . $count])) ? $count : 'n';
2084 2084
 
2085 2085
 				echo '
2086
-						<li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=msg;like=' . $news['message_id'] .';'. $context['session_var'] .'='. $context['session_id'], comma_format($count)), '</li>';
2086
+						<li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=msg;like=' . $news['message_id'] . ';' . $context['session_var'] . '=' . $context['session_id'], comma_format($count)), '</li>';
2087 2087
 			}
2088 2088
 
2089 2089
 			echo '
@@ -2287,7 +2287,7 @@  discard block
 block discarded – undo
2287 2287
 			),
2288 2288
 			'file' => array(
2289 2289
 				'filename' => $filename,
2290
-				'filesize' => round($row['filesize'] /1024, 2) . $txt['kilobyte'],
2290
+				'filesize' => round($row['filesize'] / 1024, 2) . $txt['kilobyte'],
2291 2291
 				'downloads' => $row['downloads'],
2292 2292
 				'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'],
2293 2293
 				'link' => '<img src="' . $settings['images_url'] . '/icons/clip.png" alt=""> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>',
Please login to merge, or discard this patch.
Braces   +428 added lines, -304 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -26,21 +27,24 @@  discard block
 block discarded – undo
26 27
 
27 28
 // Remember the current configuration so it can be set back.
28 29
 $ssi_magic_quotes_runtime = function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime();
29
-if (function_exists('set_magic_quotes_runtime'))
30
+if (function_exists('set_magic_quotes_runtime')) {
30 31
 	@set_magic_quotes_runtime(0);
32
+}
31 33
 $time_start = microtime();
32 34
 
33 35
 // Just being safe...
34
-foreach (array('db_character_set', 'cachedir') as $variable)
36
+foreach (array('db_character_set', 'cachedir') as $variable) {
35 37
 	if (isset($GLOBALS[$variable]))
36 38
 		unset($GLOBALS[$variable]);
39
+}
37 40
 
38 41
 // Get the forum's settings for database and file paths.
39 42
 require_once(dirname(__FILE__) . '/Settings.php');
40 43
 
41 44
 // Make absolutely sure the cache directory is defined.
42
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
45
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
43 46
 	$cachedir = $boarddir . '/cache';
47
+}
44 48
 
45 49
 $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
46 50
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -51,12 +55,14 @@  discard block
 block discarded – undo
51 55
 $ssi_on_error_method = false;
52 56
 
53 57
 // Don't do john didley if the forum's been shut down completely.
54
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
58
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
55 59
 	die($mmessage);
60
+}
56 61
 
57 62
 // Fix for using the current directory as a path.
58
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
63
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
59 64
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
65
+}
60 66
 
61 67
 // Load the important includes.
62 68
 require_once($sourcedir . '/QueryString.php');
@@ -81,34 +87,38 @@  discard block
 block discarded – undo
81 87
 cleanRequest();
82 88
 
83 89
 // Seed the random generator?
84
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
90
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
85 91
 	smf_seed_generator();
92
+}
86 93
 
87 94
 // Check on any hacking attempts.
88
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
95
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
89 96
 	die('No direct access...');
90
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
97
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
91 98
 	die('No direct access...');
92
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
99
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
93 100
 	die('No direct access...');
94
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
101
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
95 102
 	die('No direct access...');
96
-if (isset($_REQUEST['context']))
103
+}
104
+if (isset($_REQUEST['context'])) {
97 105
 	die('No direct access...');
106
+}
98 107
 
99 108
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
100
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
109
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
101 110
 	ob_start('ob_gzhandler');
102
-else
111
+} else {
103 112
 	$modSettings['enableCompressedOutput'] = '0';
113
+}
104 114
 
105 115
 // Primarily, this is to fix the URLs...
106 116
 ob_start('ob_sessrewrite');
107 117
 
108 118
 // Start the session... known to scramble SSI includes in cases...
109
-if (!headers_sent())
119
+if (!headers_sent()) {
110 120
 	loadSession();
111
-else
121
+} else
112 122
 {
113 123
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
114 124
 	{
@@ -142,12 +152,14 @@  discard block
 block discarded – undo
142 152
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
143 153
 
144 154
 // @todo: probably not the best place, but somewhere it should be set...
145
-if (!headers_sent())
155
+if (!headers_sent()) {
146 156
 	header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
157
+}
147 158
 
148 159
 // Take care of any banning that needs to be done.
149
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
160
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
150 161
 	is_not_banned();
162
+}
151 163
 
152 164
 // Do we allow guests in here?
153 165
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -162,17 +174,19 @@  discard block
 block discarded – undo
162 174
 {
163 175
 	$context['template_layers'] = $ssi_layers;
164 176
 	template_header();
165
-}
166
-else
177
+} else {
167 178
 	setupThemeContext();
179
+}
168 180
 
169 181
 // Make sure they didn't muss around with the settings... but only if it's not cli.
170
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
182
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
171 183
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
184
+}
172 185
 
173 186
 // Without visiting the forum this session variable might not be set on submit.
174
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
187
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
175 188
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
189
+}
176 190
 
177 191
 // Have the ability to easily add functions to SSI.
178 192
 call_integration_hook('integrate_SSI');
@@ -183,15 +197,18 @@  discard block
 block discarded – undo
183 197
 	call_user_func('ssi_' . $_GET['ssi_function']);
184 198
 	exit;
185 199
 }
186
-if (isset($_GET['ssi_function']))
200
+if (isset($_GET['ssi_function'])) {
187 201
 	exit;
202
+}
188 203
 // You shouldn't just access SSI.php directly by URL!!
189
-elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php')
204
+elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') {
190 205
 	die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
206
+}
191 207
 
192 208
 error_reporting($ssi_error_reporting);
193
-if (function_exists('set_magic_quotes_runtime'))
209
+if (function_exists('set_magic_quotes_runtime')) {
194 210
 	@set_magic_quotes_runtime($ssi_magic_quotes_runtime);
211
+}
195 212
 
196 213
 return true;
197 214
 
@@ -201,9 +218,10 @@  discard block
 block discarded – undo
201 218
  */
202 219
 function ssi_shutdown()
203 220
 {
204
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
205
-		template_footer();
206
-}
221
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
222
+			template_footer();
223
+	}
224
+	}
207 225
 
208 226
 /**
209 227
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -216,15 +234,17 @@  discard block
 block discarded – undo
216 234
 
217 235
 	if ($output_method == 'echo')
218 236
 	{
219
-		if ($context['user']['is_guest'])
220
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
221
-		else
222
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
237
+		if ($context['user']['is_guest']) {
238
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
239
+		} else {
240
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
241
+		}
223 242
 	}
224 243
 	// Don't echo... then do what?!
225
-	else
226
-		return $context['user'];
227
-}
244
+	else {
245
+			return $context['user'];
246
+	}
247
+	}
228 248
 
229 249
 /**
230 250
  * Display a menu bar, like is displayed at the top of the forum.
@@ -235,12 +255,14 @@  discard block
 block discarded – undo
235 255
 {
236 256
 	global $context;
237 257
 
238
-	if ($output_method == 'echo')
239
-		template_menu();
258
+	if ($output_method == 'echo') {
259
+			template_menu();
260
+	}
240 261
 	// What else could this do?
241
-	else
242
-		return $context['menu_buttons'];
243
-}
262
+	else {
263
+			return $context['menu_buttons'];
264
+	}
265
+	}
244 266
 
245 267
 /**
246 268
  * Show a logout link.
@@ -252,20 +274,23 @@  discard block
 block discarded – undo
252 274
 {
253 275
 	global $context, $txt, $scripturl;
254 276
 
255
-	if ($redirect_to != '')
256
-		$_SESSION['logout_url'] = $redirect_to;
277
+	if ($redirect_to != '') {
278
+			$_SESSION['logout_url'] = $redirect_to;
279
+	}
257 280
 
258 281
 	// Guests can't log out.
259
-	if ($context['user']['is_guest'])
260
-		return false;
282
+	if ($context['user']['is_guest']) {
283
+			return false;
284
+	}
261 285
 
262 286
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
263 287
 
264
-	if ($output_method == 'echo')
265
-		echo $link;
266
-	else
267
-		return $link;
268
-}
288
+	if ($output_method == 'echo') {
289
+			echo $link;
290
+	} else {
291
+			return $link;
292
+	}
293
+	}
269 294
 
270 295
 /**
271 296
  * Recent post list:   [board] Subject by Poster    Date
@@ -281,17 +306,17 @@  discard block
 block discarded – undo
281 306
 	global $modSettings, $context;
282 307
 
283 308
 	// Excluding certain boards...
284
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
285
-		$exclude_boards = array($modSettings['recycle_board']);
286
-	else
287
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
309
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
310
+			$exclude_boards = array($modSettings['recycle_board']);
311
+	} else {
312
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
313
+	}
288 314
 
289 315
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
290 316
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
291 317
 	{
292 318
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
293
-	}
294
-	elseif ($include_boards != null)
319
+	} elseif ($include_boards != null)
295 320
 	{
296 321
 		$include_boards = array();
297 322
 	}
@@ -328,8 +353,9 @@  discard block
 block discarded – undo
328 353
 {
329 354
 	global $modSettings;
330 355
 
331
-	if (empty($post_ids))
332
-		return;
356
+	if (empty($post_ids)) {
357
+			return;
358
+	}
333 359
 
334 360
 	// Allow the user to request more than one - why not?
335 361
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -364,8 +390,9 @@  discard block
 block discarded – undo
364 390
 	global $scripturl, $txt, $user_info;
365 391
 	global $modSettings, $smcFunc, $context;
366 392
 
367
-	if (!empty($modSettings['enable_likes']))
368
-		$context['can_like'] = allowedTo('likes_like');
393
+	if (!empty($modSettings['enable_likes'])) {
394
+			$context['can_like'] = allowedTo('likes_like');
395
+	}
369 396
 
370 397
 	// Find all the posts. Newer ones will have higher IDs.
371 398
 	$request = $smcFunc['db_query']('substring', '
@@ -431,12 +458,13 @@  discard block
 block discarded – undo
431 458
 		);
432 459
 
433 460
 		// Get the likes for each message.
434
-		if (!empty($modSettings['enable_likes']))
435
-			$posts[$row['id_msg']]['likes'] = array(
461
+		if (!empty($modSettings['enable_likes'])) {
462
+					$posts[$row['id_msg']]['likes'] = array(
436 463
 				'count' => $row['likes'],
437 464
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
438 465
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
439 466
 			);
467
+		}
440 468
 	}
441 469
 	$smcFunc['db_free_result']($request);
442 470
 
@@ -444,13 +472,14 @@  discard block
 block discarded – undo
444 472
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
445 473
 
446 474
 	// Just return it.
447
-	if ($output_method != 'echo' || empty($posts))
448
-		return $posts;
475
+	if ($output_method != 'echo' || empty($posts)) {
476
+			return $posts;
477
+	}
449 478
 
450 479
 	echo '
451 480
 		<table style="border: none" class="ssi_table">';
452
-	foreach ($posts as $post)
453
-		echo '
481
+	foreach ($posts as $post) {
482
+			echo '
454 483
 			<tr>
455 484
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
456 485
 					[', $post['board']['link'], ']
@@ -464,6 +493,7 @@  discard block
 block discarded – undo
464 493
 					', $post['time'], '
465 494
 				</td>
466 495
 			</tr>';
496
+	}
467 497
 	echo '
468 498
 		</table>';
469 499
 }
@@ -481,25 +511,26 @@  discard block
 block discarded – undo
481 511
 	global $settings, $scripturl, $txt, $user_info;
482 512
 	global $modSettings, $smcFunc, $context;
483 513
 
484
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
485
-		$exclude_boards = array($modSettings['recycle_board']);
486
-	else
487
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
514
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
515
+			$exclude_boards = array($modSettings['recycle_board']);
516
+	} else {
517
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
518
+	}
488 519
 
489 520
 	// Only some boards?.
490 521
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
491 522
 	{
492 523
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
493
-	}
494
-	elseif ($include_boards != null)
524
+	} elseif ($include_boards != null)
495 525
 	{
496 526
 		$output_method = $include_boards;
497 527
 		$include_boards = array();
498 528
 	}
499 529
 
500 530
 	$icon_sources = array();
501
-	foreach ($context['stable_icons'] as $icon)
502
-		$icon_sources[$icon] = 'images_url';
531
+	foreach ($context['stable_icons'] as $icon) {
532
+			$icon_sources[$icon] = 'images_url';
533
+	}
503 534
 
504 535
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
505 536
 	$request = $smcFunc['db_query']('substring', '
@@ -524,13 +555,15 @@  discard block
 block discarded – undo
524 555
 		)
525 556
 	);
526 557
 	$topics = array();
527
-	while ($row = $smcFunc['db_fetch_assoc']($request))
528
-		$topics[$row['id_topic']] = $row;
558
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
559
+			$topics[$row['id_topic']] = $row;
560
+	}
529 561
 	$smcFunc['db_free_result']($request);
530 562
 
531 563
 	// Did we find anything? If not, bail.
532
-	if (empty($topics))
533
-		return array();
564
+	if (empty($topics)) {
565
+			return array();
566
+	}
534 567
 
535 568
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
536 569
 
@@ -558,19 +591,22 @@  discard block
 block discarded – undo
558 591
 	while ($row = $smcFunc['db_fetch_assoc']($request))
559 592
 	{
560 593
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
561
-		if ($smcFunc['strlen']($row['body']) > 128)
562
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
594
+		if ($smcFunc['strlen']($row['body']) > 128) {
595
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
596
+		}
563 597
 
564 598
 		// Censor the subject.
565 599
 		censorText($row['subject']);
566 600
 		censorText($row['body']);
567 601
 
568 602
 		// Recycled icon
569
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
570
-			$row['icon'] = 'recycled';
603
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
604
+					$row['icon'] = 'recycled';
605
+		}
571 606
 
572
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
573
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
607
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
608
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
609
+		}
574 610
 
575 611
 		// Build the array.
576 612
 		$posts[] = array(
@@ -609,13 +645,14 @@  discard block
 block discarded – undo
609 645
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
610 646
 
611 647
 	// Just return it.
612
-	if ($output_method != 'echo' || empty($posts))
613
-		return $posts;
648
+	if ($output_method != 'echo' || empty($posts)) {
649
+			return $posts;
650
+	}
614 651
 
615 652
 	echo '
616 653
 		<table style="border: none" class="ssi_table">';
617
-	foreach ($posts as $post)
618
-		echo '
654
+	foreach ($posts as $post) {
655
+			echo '
619 656
 			<tr>
620 657
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
621 658
 					[', $post['board']['link'], ']
@@ -629,6 +666,7 @@  discard block
 block discarded – undo
629 666
 					', $post['time'], '
630 667
 				</td>
631 668
 			</tr>';
669
+	}
632 670
 	echo '
633 671
 		</table>';
634 672
 }
@@ -653,27 +691,30 @@  discard block
 block discarded – undo
653 691
 		)
654 692
 	);
655 693
 	$return = array();
656
-	while ($row = $smcFunc['db_fetch_assoc']($request))
657
-		$return[] = array(
694
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
695
+			$return[] = array(
658 696
 			'id' => $row['id_member'],
659 697
 			'name' => $row['real_name'],
660 698
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
661 699
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
662 700
 			'posts' => $row['posts']
663 701
 		);
702
+	}
664 703
 	$smcFunc['db_free_result']($request);
665 704
 
666 705
 	// If mods want to do somthing with this list of members, let them do that now.
667 706
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
668 707
 
669 708
 	// Just return all the top posters.
670
-	if ($output_method != 'echo')
671
-		return $return;
709
+	if ($output_method != 'echo') {
710
+			return $return;
711
+	}
672 712
 
673 713
 	// Make a quick array to list the links in.
674 714
 	$temp_array = array();
675
-	foreach ($return as $member)
676
-		$temp_array[] = $member['link'];
715
+	foreach ($return as $member) {
716
+			$temp_array[] = $member['link'];
717
+	}
677 718
 
678 719
 	echo implode(', ', $temp_array);
679 720
 }
@@ -705,8 +746,8 @@  discard block
 block discarded – undo
705 746
 		)
706 747
 	);
707 748
 	$boards = array();
708
-	while ($row = $smcFunc['db_fetch_assoc']($request))
709
-		$boards[] = array(
749
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
750
+			$boards[] = array(
710 751
 			'id' => $row['id_board'],
711 752
 			'num_posts' => $row['num_posts'],
712 753
 			'num_topics' => $row['num_topics'],
@@ -715,14 +756,16 @@  discard block
 block discarded – undo
715 756
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
716 757
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
717 758
 		);
759
+	}
718 760
 	$smcFunc['db_free_result']($request);
719 761
 
720 762
 	// If mods want to do somthing with this list of boards, let them do that now.
721 763
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
722 764
 
723 765
 	// If we shouldn't output or have nothing to output, just jump out.
724
-	if ($output_method != 'echo' || empty($boards))
725
-		return $boards;
766
+	if ($output_method != 'echo' || empty($boards)) {
767
+			return $boards;
768
+	}
726 769
 
727 770
 	echo '
728 771
 		<table class="ssi_table">
@@ -731,13 +774,14 @@  discard block
 block discarded – undo
731 774
 				<th style="text-align: left">', $txt['board_topics'], '</th>
732 775
 				<th style="text-align: left">', $txt['posts'], '</th>
733 776
 			</tr>';
734
-	foreach ($boards as $sBoard)
735
-		echo '
777
+	foreach ($boards as $sBoard) {
778
+			echo '
736 779
 			<tr>
737 780
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
738 781
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
739 782
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
740 783
 			</tr>';
784
+	}
741 785
 	echo '
742 786
 		</table>';
743 787
 }
@@ -770,12 +814,13 @@  discard block
 block discarded – undo
770 814
 			)
771 815
 		);
772 816
 		$topic_ids = array();
773
-		while ($row = $smcFunc['db_fetch_assoc']($request))
774
-			$topic_ids[] = $row['id_topic'];
817
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
818
+					$topic_ids[] = $row['id_topic'];
819
+		}
775 820
 		$smcFunc['db_free_result']($request);
821
+	} else {
822
+			$topic_ids = array();
776 823
 	}
777
-	else
778
-		$topic_ids = array();
779 824
 
780 825
 	$request = $smcFunc['db_query']('', '
781 826
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -814,8 +859,9 @@  discard block
 block discarded – undo
814 859
 	// If mods want to do somthing with this list of topics, let them do that now.
815 860
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
816 861
 
817
-	if ($output_method != 'echo' || empty($topics))
818
-		return $topics;
862
+	if ($output_method != 'echo' || empty($topics)) {
863
+			return $topics;
864
+	}
819 865
 
820 866
 	echo '
821 867
 		<table class="ssi_table">
@@ -824,8 +870,8 @@  discard block
 block discarded – undo
824 870
 				<th style="text-align: left">', $txt['views'], '</th>
825 871
 				<th style="text-align: left">', $txt['replies'], '</th>
826 872
 			</tr>';
827
-	foreach ($topics as $sTopic)
828
-		echo '
873
+	foreach ($topics as $sTopic) {
874
+			echo '
829 875
 			<tr>
830 876
 				<td style="text-align: left">
831 877
 					', $sTopic['link'], '
@@ -833,6 +879,7 @@  discard block
 block discarded – undo
833 879
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
834 880
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
835 881
 			</tr>';
882
+	}
836 883
 	echo '
837 884
 		</table>';
838 885
 }
@@ -868,12 +915,13 @@  discard block
 block discarded – undo
868 915
 {
869 916
 	global $txt, $context;
870 917
 
871
-	if ($output_method == 'echo')
872
-		echo '
918
+	if ($output_method == 'echo') {
919
+			echo '
873 920
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
874
-	else
875
-		return $context['common_stats']['latest_member'];
876
-}
921
+	} else {
922
+			return $context['common_stats']['latest_member'];
923
+	}
924
+	}
877 925
 
878 926
 /**
879 927
  * Fetches a random member.
@@ -922,8 +970,9 @@  discard block
 block discarded – undo
922 970
 	}
923 971
 
924 972
 	// Just to be sure put the random generator back to something... random.
925
-	if ($random_type != '')
926
-		mt_srand(time());
973
+	if ($random_type != '') {
974
+			mt_srand(time());
975
+	}
927 976
 
928 977
 	return $result;
929 978
 }
@@ -936,8 +985,9 @@  discard block
 block discarded – undo
936 985
  */
937 986
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
938 987
 {
939
-	if (empty($member_ids))
940
-		return;
988
+	if (empty($member_ids)) {
989
+			return;
990
+	}
941 991
 
942 992
 	// Can have more than one member if you really want...
943 993
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -962,8 +1012,9 @@  discard block
 block discarded – undo
962 1012
  */
963 1013
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
964 1014
 {
965
-	if ($group_id === null)
966
-		return;
1015
+	if ($group_id === null) {
1016
+			return;
1017
+	}
967 1018
 
968 1019
 	$query_where = '
969 1020
 		id_group = {int:id_group}
@@ -990,8 +1041,9 @@  discard block
 block discarded – undo
990 1041
 {
991 1042
 	global $smcFunc, $memberContext;
992 1043
 
993
-	if ($query_where === null)
994
-		return;
1044
+	if ($query_where === null) {
1045
+			return;
1046
+	}
995 1047
 
996 1048
 	// Fetch the members in question.
997 1049
 	$request = $smcFunc['db_query']('', '
@@ -1004,12 +1056,14 @@  discard block
 block discarded – undo
1004 1056
 		))
1005 1057
 	);
1006 1058
 	$members = array();
1007
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1008
-		$members[] = $row['id_member'];
1059
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1060
+			$members[] = $row['id_member'];
1061
+	}
1009 1062
 	$smcFunc['db_free_result']($request);
1010 1063
 
1011
-	if (empty($members))
1012
-		return array();
1064
+	if (empty($members)) {
1065
+			return array();
1066
+	}
1013 1067
 
1014 1068
 	// If mods want to do somthing with this list of members, let them do that now.
1015 1069
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1018,23 +1072,25 @@  discard block
 block discarded – undo
1018 1072
 	loadMemberData($members);
1019 1073
 
1020 1074
 	// Draw the table!
1021
-	if ($output_method == 'echo')
1022
-		echo '
1075
+	if ($output_method == 'echo') {
1076
+			echo '
1023 1077
 		<table style="border: none" class="ssi_table">';
1078
+	}
1024 1079
 
1025 1080
 	$query_members = array();
1026 1081
 	foreach ($members as $member)
1027 1082
 	{
1028 1083
 		// Load their context data.
1029
-		if (!loadMemberContext($member))
1030
-			continue;
1084
+		if (!loadMemberContext($member)) {
1085
+					continue;
1086
+		}
1031 1087
 
1032 1088
 		// Store this member's information.
1033 1089
 		$query_members[$member] = $memberContext[$member];
1034 1090
 
1035 1091
 		// Only do something if we're echo'ing.
1036
-		if ($output_method == 'echo')
1037
-			echo '
1092
+		if ($output_method == 'echo') {
1093
+					echo '
1038 1094
 			<tr>
1039 1095
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1040 1096
 					', $query_members[$member]['link'], '
@@ -1042,12 +1098,14 @@  discard block
 block discarded – undo
1042 1098
 					<br>', $query_members[$member]['avatar']['image'], '
1043 1099
 				</td>
1044 1100
 			</tr>';
1101
+		}
1045 1102
 	}
1046 1103
 
1047 1104
 	// End the table if appropriate.
1048
-	if ($output_method == 'echo')
1049
-		echo '
1105
+	if ($output_method == 'echo') {
1106
+			echo '
1050 1107
 		</table>';
1108
+	}
1051 1109
 
1052 1110
 	// Send back the data.
1053 1111
 	return $query_members;
@@ -1062,8 +1120,9 @@  discard block
 block discarded – undo
1062 1120
 {
1063 1121
 	global $txt, $scripturl, $modSettings, $smcFunc;
1064 1122
 
1065
-	if (!allowedTo('view_stats'))
1066
-		return;
1123
+	if (!allowedTo('view_stats')) {
1124
+			return;
1125
+	}
1067 1126
 
1068 1127
 	$totals = array(
1069 1128
 		'members' => $modSettings['totalMembers'],
@@ -1092,8 +1151,9 @@  discard block
 block discarded – undo
1092 1151
 	// If mods want to do somthing with the board stats, let them do that now.
1093 1152
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1094 1153
 
1095
-	if ($output_method != 'echo')
1096
-		return $totals;
1154
+	if ($output_method != 'echo') {
1155
+			return $totals;
1156
+	}
1097 1157
 
1098 1158
 	echo '
1099 1159
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1122,8 +1182,8 @@  discard block
 block discarded – undo
1122 1182
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1123 1183
 
1124 1184
 	// Add some redundancy for backwards compatibility reasons.
1125
-	if ($output_method != 'echo')
1126
-		return $return + array(
1185
+	if ($output_method != 'echo') {
1186
+			return $return + array(
1127 1187
 			'users' => $return['users_online'],
1128 1188
 			'guests' => $return['num_guests'],
1129 1189
 			'hidden' => $return['num_users_hidden'],
@@ -1131,29 +1191,35 @@  discard block
 block discarded – undo
1131 1191
 			'num_users' => $return['num_users_online'],
1132 1192
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1133 1193
 		);
1194
+	}
1134 1195
 
1135 1196
 	echo '
1136 1197
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1137 1198
 
1138 1199
 	$bracketList = array();
1139
-	if (!empty($user_info['buddies']))
1140
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1141
-	if (!empty($return['num_spiders']))
1142
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1143
-	if (!empty($return['num_users_hidden']))
1144
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1200
+	if (!empty($user_info['buddies'])) {
1201
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1202
+	}
1203
+	if (!empty($return['num_spiders'])) {
1204
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1205
+	}
1206
+	if (!empty($return['num_users_hidden'])) {
1207
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1208
+	}
1145 1209
 
1146
-	if (!empty($bracketList))
1147
-		echo ' (' . implode(', ', $bracketList) . ')';
1210
+	if (!empty($bracketList)) {
1211
+			echo ' (' . implode(', ', $bracketList) . ')';
1212
+	}
1148 1213
 
1149 1214
 	echo '<br>
1150 1215
 			', implode(', ', $return['list_users_online']);
1151 1216
 
1152 1217
 	// Showing membergroups?
1153
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1154
-		echo '<br>
1218
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1219
+			echo '<br>
1155 1220
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1156
-}
1221
+	}
1222
+	}
1157 1223
 
1158 1224
 /**
1159 1225
  * Just like whosOnline except it also logs the online presence.
@@ -1164,11 +1230,12 @@  discard block
 block discarded – undo
1164 1230
 {
1165 1231
 	writeLog();
1166 1232
 
1167
-	if ($output_method != 'echo')
1168
-		return ssi_whosOnline($output_method);
1169
-	else
1170
-		ssi_whosOnline($output_method);
1171
-}
1233
+	if ($output_method != 'echo') {
1234
+			return ssi_whosOnline($output_method);
1235
+	} else {
1236
+			ssi_whosOnline($output_method);
1237
+	}
1238
+	}
1172 1239
 
1173 1240
 // Shows a login box.
1174 1241
 /**
@@ -1181,11 +1248,13 @@  discard block
 block discarded – undo
1181 1248
 {
1182 1249
 	global $scripturl, $txt, $user_info, $context;
1183 1250
 
1184
-	if ($redirect_to != '')
1185
-		$_SESSION['login_url'] = $redirect_to;
1251
+	if ($redirect_to != '') {
1252
+			$_SESSION['login_url'] = $redirect_to;
1253
+	}
1186 1254
 
1187
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1188
-		return $user_info['is_guest'];
1255
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1256
+			return $user_info['is_guest'];
1257
+	}
1189 1258
 
1190 1259
 	// Create a login token
1191 1260
 	createToken('login');
@@ -1237,8 +1306,9 @@  discard block
 block discarded – undo
1237 1306
 
1238 1307
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1239 1308
 
1240
-	if (empty($boardsAllowed))
1241
-		return array();
1309
+	if (empty($boardsAllowed)) {
1310
+			return array();
1311
+	}
1242 1312
 
1243 1313
 	$request = $smcFunc['db_query']('', '
1244 1314
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1271,12 +1341,14 @@  discard block
 block discarded – undo
1271 1341
 	$smcFunc['db_free_result']($request);
1272 1342
 
1273 1343
 	// This user has voted on all the polls.
1274
-	if (empty($row) || !is_array($row))
1275
-		return array();
1344
+	if (empty($row) || !is_array($row)) {
1345
+			return array();
1346
+	}
1276 1347
 
1277 1348
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1278
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1279
-		return ssi_showPoll($row['id_topic'], $output_method);
1349
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1350
+			return ssi_showPoll($row['id_topic'], $output_method);
1351
+	}
1280 1352
 
1281 1353
 	$request = $smcFunc['db_query']('', '
1282 1354
 		SELECT COUNT(DISTINCT id_member)
@@ -1340,8 +1412,9 @@  discard block
 block discarded – undo
1340 1412
 	// If mods want to do somthing with this list of polls, let them do that now.
1341 1413
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1342 1414
 
1343
-	if ($output_method != 'echo')
1344
-		return $return;
1415
+	if ($output_method != 'echo') {
1416
+			return $return;
1417
+	}
1345 1418
 
1346 1419
 	if ($allow_view_results)
1347 1420
 	{
@@ -1350,19 +1423,20 @@  discard block
 block discarded – undo
1350 1423
 			<strong>', $return['question'], '</strong><br>
1351 1424
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1352 1425
 
1353
-		foreach ($return['options'] as $option)
1354
-			echo '
1426
+		foreach ($return['options'] as $option) {
1427
+					echo '
1355 1428
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1429
+		}
1356 1430
 
1357 1431
 		echo '
1358 1432
 			<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1359 1433
 			<input type="hidden" name="poll" value="', $return['id'], '">
1360 1434
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1361 1435
 		</form>';
1436
+	} else {
1437
+			echo $txt['poll_cannot_see'];
1438
+	}
1362 1439
 	}
1363
-	else
1364
-		echo $txt['poll_cannot_see'];
1365
-}
1366 1440
 
1367 1441
 /**
1368 1442
  * Shows the poll from the specified topic
@@ -1376,13 +1450,15 @@  discard block
 block discarded – undo
1376 1450
 
1377 1451
 	$boardsAllowed = boardsAllowedTo('poll_view');
1378 1452
 
1379
-	if (empty($boardsAllowed))
1380
-		return array();
1453
+	if (empty($boardsAllowed)) {
1454
+			return array();
1455
+	}
1381 1456
 
1382
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1383
-		$topic = (int) $_REQUEST['ssi_topic'];
1384
-	else
1385
-		$topic = (int) $topic;
1457
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1458
+			$topic = (int) $_REQUEST['ssi_topic'];
1459
+	} else {
1460
+			$topic = (int) $topic;
1461
+	}
1386 1462
 
1387 1463
 	$request = $smcFunc['db_query']('', '
1388 1464
 		SELECT
@@ -1403,17 +1479,18 @@  discard block
 block discarded – undo
1403 1479
 	);
1404 1480
 
1405 1481
 	// Either this topic has no poll, or the user cannot view it.
1406
-	if ($smcFunc['db_num_rows']($request) == 0)
1407
-		return array();
1482
+	if ($smcFunc['db_num_rows']($request) == 0) {
1483
+			return array();
1484
+	}
1408 1485
 
1409 1486
 	$row = $smcFunc['db_fetch_assoc']($request);
1410 1487
 	$smcFunc['db_free_result']($request);
1411 1488
 
1412 1489
 	// Check if they can vote.
1413 1490
 	$already_voted = false;
1414
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1415
-		$allow_vote = false;
1416
-	elseif ($user_info['is_guest'])
1491
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1492
+			$allow_vote = false;
1493
+	} elseif ($user_info['is_guest'])
1417 1494
 	{
1418 1495
 		// There's a difference between "allowed to vote" and "already voted"...
1419 1496
 		$allow_vote = $row['guest_vote'];
@@ -1423,10 +1500,9 @@  discard block
 block discarded – undo
1423 1500
 		{
1424 1501
 			$already_voted = true;
1425 1502
 		}
1426
-	}
1427
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1428
-		$allow_vote = false;
1429
-	else
1503
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1504
+			$allow_vote = false;
1505
+	} else
1430 1506
 	{
1431 1507
 		$request = $smcFunc['db_query']('', '
1432 1508
 			SELECT id_member
@@ -1508,8 +1584,9 @@  discard block
 block discarded – undo
1508 1584
 	// If mods want to do somthing with this poll, let them do that now.
1509 1585
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1510 1586
 
1511
-	if ($output_method != 'echo')
1512
-		return $return;
1587
+	if ($output_method != 'echo') {
1588
+			return $return;
1589
+	}
1513 1590
 
1514 1591
 	if ($return['allow_vote'])
1515 1592
 	{
@@ -1518,17 +1595,17 @@  discard block
 block discarded – undo
1518 1595
 				<strong>', $return['question'], '</strong><br>
1519 1596
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1520 1597
 
1521
-		foreach ($return['options'] as $option)
1522
-			echo '
1598
+		foreach ($return['options'] as $option) {
1599
+					echo '
1523 1600
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1601
+		}
1524 1602
 
1525 1603
 		echo '
1526 1604
 				<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1527 1605
 				<input type="hidden" name="poll" value="', $return['id'], '">
1528 1606
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1529 1607
 			</form>';
1530
-	}
1531
-	else
1608
+	} else
1532 1609
 	{
1533 1610
 		echo '
1534 1611
 			<div class="ssi_poll">
@@ -1608,27 +1685,32 @@  discard block
 block discarded – undo
1608 1685
 			'is_approved' => 1,
1609 1686
 		)
1610 1687
 	);
1611
-	if ($smcFunc['db_num_rows']($request) == 0)
1612
-		die;
1688
+	if ($smcFunc['db_num_rows']($request) == 0) {
1689
+			die;
1690
+	}
1613 1691
 	$row = $smcFunc['db_fetch_assoc']($request);
1614 1692
 	$smcFunc['db_free_result']($request);
1615 1693
 
1616
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1617
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1694
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1695
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1696
+	}
1618 1697
 
1619 1698
 	// Too many options checked?
1620
-	if (count($_REQUEST['options']) > $row['max_votes'])
1621
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1699
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1700
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1701
+	}
1622 1702
 
1623 1703
 	// It's a guest who has already voted?
1624 1704
 	if ($user_info['is_guest'])
1625 1705
 	{
1626 1706
 		// Guest voting disabled?
1627
-		if (!$row['guest_vote'])
1628
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1707
+		if (!$row['guest_vote']) {
1708
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1709
+		}
1629 1710
 		// Already voted?
1630
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1631
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1711
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1712
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1713
+		}
1632 1714
 	}
1633 1715
 
1634 1716
 	$sOptions = array();
@@ -1682,11 +1764,13 @@  discard block
 block discarded – undo
1682 1764
 {
1683 1765
 	global $scripturl, $txt, $context;
1684 1766
 
1685
-	if (!allowedTo('search_posts'))
1686
-		return;
1767
+	if (!allowedTo('search_posts')) {
1768
+			return;
1769
+	}
1687 1770
 
1688
-	if ($output_method != 'echo')
1689
-		return $scripturl . '?action=search';
1771
+	if ($output_method != 'echo') {
1772
+			return $scripturl . '?action=search';
1773
+	}
1690 1774
 
1691 1775
 	echo '
1692 1776
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1708,8 +1792,9 @@  discard block
 block discarded – undo
1708 1792
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1709 1793
 	call_integration_hook('integrate_ssi_news');
1710 1794
 
1711
-	if ($output_method != 'echo')
1712
-		return $context['random_news_line'];
1795
+	if ($output_method != 'echo') {
1796
+			return $context['random_news_line'];
1797
+	}
1713 1798
 
1714 1799
 	echo $context['random_news_line'];
1715 1800
 }
@@ -1723,8 +1808,9 @@  discard block
 block discarded – undo
1723 1808
 {
1724 1809
 	global $scripturl, $modSettings, $user_info;
1725 1810
 
1726
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1727
-		return;
1811
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1812
+			return;
1813
+	}
1728 1814
 
1729 1815
 	$eventOptions = array(
1730 1816
 		'include_birthdays' => true,
@@ -1735,13 +1821,15 @@  discard block
 block discarded – undo
1735 1821
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1736 1822
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1737 1823
 
1738
-	if ($output_method != 'echo')
1739
-		return $return['calendar_birthdays'];
1824
+	if ($output_method != 'echo') {
1825
+			return $return['calendar_birthdays'];
1826
+	}
1740 1827
 
1741
-	foreach ($return['calendar_birthdays'] as $member)
1742
-		echo '
1828
+	foreach ($return['calendar_birthdays'] as $member) {
1829
+			echo '
1743 1830
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1744
-}
1831
+	}
1832
+	}
1745 1833
 
1746 1834
 /**
1747 1835
  * Shows today's holidays.
@@ -1752,8 +1840,9 @@  discard block
 block discarded – undo
1752 1840
 {
1753 1841
 	global $modSettings, $user_info;
1754 1842
 
1755
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1756
-		return;
1843
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1844
+			return;
1845
+	}
1757 1846
 
1758 1847
 	$eventOptions = array(
1759 1848
 		'include_holidays' => true,
@@ -1764,8 +1853,9 @@  discard block
 block discarded – undo
1764 1853
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1765 1854
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1766 1855
 
1767
-	if ($output_method != 'echo')
1768
-		return $return['calendar_holidays'];
1856
+	if ($output_method != 'echo') {
1857
+			return $return['calendar_holidays'];
1858
+	}
1769 1859
 
1770 1860
 	echo '
1771 1861
 		', implode(', ', $return['calendar_holidays']);
@@ -1779,8 +1869,9 @@  discard block
 block discarded – undo
1779 1869
 {
1780 1870
 	global $modSettings, $user_info;
1781 1871
 
1782
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1783
-		return;
1872
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1873
+			return;
1874
+	}
1784 1875
 
1785 1876
 	$eventOptions = array(
1786 1877
 		'include_events' => true,
@@ -1791,14 +1882,16 @@  discard block
 block discarded – undo
1791 1882
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1792 1883
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1793 1884
 
1794
-	if ($output_method != 'echo')
1795
-		return $return['calendar_events'];
1885
+	if ($output_method != 'echo') {
1886
+			return $return['calendar_events'];
1887
+	}
1796 1888
 
1797 1889
 	foreach ($return['calendar_events'] as $event)
1798 1890
 	{
1799
-		if ($event['can_edit'])
1800
-			echo '
1891
+		if ($event['can_edit']) {
1892
+					echo '
1801 1893
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1894
+		}
1802 1895
 		echo '
1803 1896
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1804 1897
 	}
@@ -1813,8 +1906,9 @@  discard block
 block discarded – undo
1813 1906
 {
1814 1907
 	global $modSettings, $txt, $scripturl, $user_info;
1815 1908
 
1816
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1817
-		return;
1909
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1910
+			return;
1911
+	}
1818 1912
 
1819 1913
 	$eventOptions = array(
1820 1914
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1827,19 +1921,22 @@  discard block
 block discarded – undo
1827 1921
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1828 1922
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1829 1923
 
1830
-	if ($output_method != 'echo')
1831
-		return $return;
1924
+	if ($output_method != 'echo') {
1925
+			return $return;
1926
+	}
1832 1927
 
1833
-	if (!empty($return['calendar_holidays']))
1834
-		echo '
1928
+	if (!empty($return['calendar_holidays'])) {
1929
+			echo '
1835 1930
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1931
+	}
1836 1932
 	if (!empty($return['calendar_birthdays']))
1837 1933
 	{
1838 1934
 		echo '
1839 1935
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1840
-		foreach ($return['calendar_birthdays'] as $member)
1841
-			echo '
1936
+		foreach ($return['calendar_birthdays'] as $member) {
1937
+					echo '
1842 1938
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1939
+		}
1843 1940
 		echo '
1844 1941
 			<br>';
1845 1942
 	}
@@ -1849,9 +1946,10 @@  discard block
 block discarded – undo
1849 1946
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1850 1947
 		foreach ($return['calendar_events'] as $event)
1851 1948
 		{
1852
-			if ($event['can_edit'])
1853
-				echo '
1949
+			if ($event['can_edit']) {
1950
+							echo '
1854 1951
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1952
+			}
1855 1953
 			echo '
1856 1954
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1857 1955
 		}
@@ -1875,25 +1973,29 @@  discard block
 block discarded – undo
1875 1973
 	loadLanguage('Stats');
1876 1974
 
1877 1975
 	// Must be integers....
1878
-	if ($limit === null)
1879
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1880
-	else
1881
-		$limit = (int) $limit;
1882
-
1883
-	if ($start === null)
1884
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1885
-	else
1886
-		$start = (int) $start;
1887
-
1888
-	if ($board !== null)
1889
-		$board = (int) $board;
1890
-	elseif (isset($_GET['board']))
1891
-		$board = (int) $_GET['board'];
1892
-
1893
-	if ($length === null)
1894
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1895
-	else
1896
-		$length = (int) $length;
1976
+	if ($limit === null) {
1977
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1978
+	} else {
1979
+			$limit = (int) $limit;
1980
+	}
1981
+
1982
+	if ($start === null) {
1983
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1984
+	} else {
1985
+			$start = (int) $start;
1986
+	}
1987
+
1988
+	if ($board !== null) {
1989
+			$board = (int) $board;
1990
+	} elseif (isset($_GET['board'])) {
1991
+			$board = (int) $_GET['board'];
1992
+	}
1993
+
1994
+	if ($length === null) {
1995
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1996
+	} else {
1997
+			$length = (int) $length;
1998
+	}
1897 1999
 
1898 2000
 	$limit = max(0, $limit);
1899 2001
 	$start = max(0, $start);
@@ -1911,17 +2013,19 @@  discard block
 block discarded – undo
1911 2013
 	);
1912 2014
 	if ($smcFunc['db_num_rows']($request) == 0)
1913 2015
 	{
1914
-		if ($output_method == 'echo')
1915
-			die($txt['ssi_no_guests']);
1916
-		else
1917
-			return array();
2016
+		if ($output_method == 'echo') {
2017
+					die($txt['ssi_no_guests']);
2018
+		} else {
2019
+					return array();
2020
+		}
1918 2021
 	}
1919 2022
 	list ($board) = $smcFunc['db_fetch_row']($request);
1920 2023
 	$smcFunc['db_free_result']($request);
1921 2024
 
1922 2025
 	$icon_sources = array();
1923
-	foreach ($context['stable_icons'] as $icon)
1924
-		$icon_sources[$icon] = 'images_url';
2026
+	foreach ($context['stable_icons'] as $icon) {
2027
+			$icon_sources[$icon] = 'images_url';
2028
+	}
1925 2029
 
1926 2030
 	if (!empty($modSettings['enable_likes']))
1927 2031
 	{
@@ -1945,12 +2049,14 @@  discard block
 block discarded – undo
1945 2049
 		)
1946 2050
 	);
1947 2051
 	$posts = array();
1948
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1949
-		$posts[] = $row['id_first_msg'];
2052
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2053
+			$posts[] = $row['id_first_msg'];
2054
+	}
1950 2055
 	$smcFunc['db_free_result']($request);
1951 2056
 
1952
-	if (empty($posts))
1953
-		return array();
2057
+	if (empty($posts)) {
2058
+			return array();
2059
+	}
1954 2060
 
1955 2061
 	// Find the posts.
1956 2062
 	$request = $smcFunc['db_query']('', '
@@ -1980,24 +2086,28 @@  discard block
 block discarded – undo
1980 2086
 			$last_space = strrpos($row['body'], ' ');
1981 2087
 			$last_open = strrpos($row['body'], '<');
1982 2088
 			$last_close = strrpos($row['body'], '>');
1983
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
1984
-				$cutoff = $last_open;
1985
-			elseif (empty($last_close) || $last_close < $last_open)
1986
-				$cutoff = $last_space;
2089
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2090
+							$cutoff = $last_open;
2091
+			} elseif (empty($last_close) || $last_close < $last_open) {
2092
+							$cutoff = $last_space;
2093
+			}
1987 2094
 
1988
-			if ($cutoff !== false)
1989
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2095
+			if ($cutoff !== false) {
2096
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2097
+			}
1990 2098
 			$row['body'] .= '...';
1991 2099
 		}
1992 2100
 
1993 2101
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1994 2102
 
1995
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
1996
-			$row['icon'] = 'recycled';
2103
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2104
+					$row['icon'] = 'recycled';
2105
+		}
1997 2106
 
1998 2107
 		// Check that this message icon is there...
1999
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
2000
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2108
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2109
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2110
+		}
2001 2111
 
2002 2112
 		censorText($row['subject']);
2003 2113
 		censorText($row['body']);
@@ -2034,16 +2144,18 @@  discard block
 block discarded – undo
2034 2144
 	}
2035 2145
 	$smcFunc['db_free_result']($request);
2036 2146
 
2037
-	if (empty($return))
2038
-		return $return;
2147
+	if (empty($return)) {
2148
+			return $return;
2149
+	}
2039 2150
 
2040 2151
 	$return[count($return) - 1]['is_last'] = true;
2041 2152
 
2042 2153
 	// If mods want to do somthing with this list of posts, let them do that now.
2043 2154
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2044 2155
 
2045
-	if ($output_method != 'echo')
2046
-		return $return;
2156
+	if ($output_method != 'echo') {
2157
+			return $return;
2158
+	}
2047 2159
 
2048 2160
 	foreach ($return as $news)
2049 2161
 	{
@@ -2095,9 +2207,10 @@  discard block
 block discarded – undo
2095 2207
 		echo '
2096 2208
 			</div>';
2097 2209
 
2098
-		if (!$news['is_last'])
2099
-			echo '
2210
+		if (!$news['is_last']) {
2211
+					echo '
2100 2212
 			<hr>';
2213
+		}
2101 2214
 	}
2102 2215
 }
2103 2216
 
@@ -2111,8 +2224,9 @@  discard block
 block discarded – undo
2111 2224
 {
2112 2225
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2113 2226
 
2114
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2115
-		return;
2227
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2228
+			return;
2229
+	}
2116 2230
 
2117 2231
 	// Find all events which are happening in the near future that the member can see.
2118 2232
 	$request = $smcFunc['db_query']('', '
@@ -2137,20 +2251,23 @@  discard block
 block discarded – undo
2137 2251
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2138 2252
 	{
2139 2253
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2140
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2141
-			continue;
2254
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2255
+					continue;
2256
+		}
2142 2257
 
2143 2258
 		// Censor the title.
2144 2259
 		censorText($row['title']);
2145 2260
 
2146
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2147
-			$date = strftime('%Y-%m-%d', forum_time(false));
2148
-		else
2149
-			$date = $row['start_date'];
2261
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2262
+					$date = strftime('%Y-%m-%d', forum_time(false));
2263
+		} else {
2264
+					$date = $row['start_date'];
2265
+		}
2150 2266
 
2151 2267
 		// If the topic it is attached to is not approved then don't link it.
2152
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2153
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2268
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2269
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2270
+		}
2154 2271
 
2155 2272
 		$return[$date][] = array(
2156 2273
 			'id' => $row['id_event'],
@@ -2169,24 +2286,27 @@  discard block
 block discarded – undo
2169 2286
 	}
2170 2287
 	$smcFunc['db_free_result']($request);
2171 2288
 
2172
-	foreach ($return as $mday => $array)
2173
-		$return[$mday][count($array) - 1]['is_last'] = true;
2289
+	foreach ($return as $mday => $array) {
2290
+			$return[$mday][count($array) - 1]['is_last'] = true;
2291
+	}
2174 2292
 
2175 2293
 	// If mods want to do somthing with this list of events, let them do that now.
2176 2294
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2177 2295
 
2178
-	if ($output_method != 'echo' || empty($return))
2179
-		return $return;
2296
+	if ($output_method != 'echo' || empty($return)) {
2297
+			return $return;
2298
+	}
2180 2299
 
2181 2300
 	// Well the output method is echo.
2182 2301
 	echo '
2183 2302
 			<span class="event">' . $txt['events'] . '</span> ';
2184
-	foreach ($return as $mday => $array)
2185
-		foreach ($array as $event)
2303
+	foreach ($return as $mday => $array) {
2304
+			foreach ($array as $event)
2186 2305
 		{
2187 2306
 			if ($event['can_edit'])
2188 2307
 				echo '
2189 2308
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2309
+	}
2190 2310
 
2191 2311
 			echo '
2192 2312
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2205,8 +2325,9 @@  discard block
 block discarded – undo
2205 2325
 	global $smcFunc;
2206 2326
 
2207 2327
 	// If $id is null, this was most likely called from a query string and should do nothing.
2208
-	if ($id === null)
2209
-		return;
2328
+	if ($id === null) {
2329
+			return;
2330
+	}
2210 2331
 
2211 2332
 	$request = $smcFunc['db_query']('', '
2212 2333
 		SELECT passwd, member_name, is_activated
@@ -2238,8 +2359,9 @@  discard block
 block discarded – undo
2238 2359
 	$attachments_boards = boardsAllowedTo('view_attachments');
2239 2360
 
2240 2361
 	// No boards?  Adios amigo.
2241
-	if (empty($attachments_boards))
2242
-		return array();
2362
+	if (empty($attachments_boards)) {
2363
+			return array();
2364
+	}
2243 2365
 
2244 2366
 	// Is it an array?
2245 2367
 	$attachment_ext = (array) $attachment_ext;
@@ -2323,8 +2445,9 @@  discard block
 block discarded – undo
2323 2445
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2324 2446
 
2325 2447
 	// So you just want an array?  Here you can have it.
2326
-	if ($output_method == 'array' || empty($attachments))
2327
-		return $attachments;
2448
+	if ($output_method == 'array' || empty($attachments)) {
2449
+			return $attachments;
2450
+	}
2328 2451
 
2329 2452
 	// Give them the default.
2330 2453
 	echo '
@@ -2335,14 +2458,15 @@  discard block
 block discarded – undo
2335 2458
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2336 2459
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2337 2460
 			</tr>';
2338
-	foreach ($attachments as $attach)
2339
-		echo '
2461
+	foreach ($attachments as $attach) {
2462
+			echo '
2340 2463
 			<tr>
2341 2464
 				<td>', $attach['file']['link'], '</td>
2342 2465
 				<td>', $attach['member']['link'], '</td>
2343 2466
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2344 2467
 				<td>', $attach['file']['filesize'], '</td>
2345 2468
 			</tr>';
2469
+	}
2346 2470
 	echo '
2347 2471
 		</table>';
2348 2472
 }
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @param string $grid_name The grid name
62 62
  * @param bool $is_mini Is this a mini grid?
63
- * @return void|bool Returns false if the grid doesn't exist.
63
+ * @return false|null Returns false if the grid doesn't exist.
64 64
  */
65 65
 function template_show_month_grid($grid_name, $is_mini = false)
66 66
 {
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
  * Shows a weekly grid
313 313
  *
314 314
  * @param string $grid_name The name of the grid
315
- * @return void|bool Returns false if the grid doesn't exist
315
+ * @return false|null Returns false if the grid doesn't exist
316 316
  */
317 317
 function template_show_week_grid($grid_name)
318 318
 {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 				// Additional classes are given for events, holidays, and birthdays.
173 173
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
174 174
 				{
175
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1,3)))
175
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
176 176
 						$classes[] = 'events';
177
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2,3)))
177
+					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
178 178
 						$classes[] = 'events';
179 179
 				}
180 180
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
181 181
 				{
182
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1,3)))
182
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
183 183
 						$classes[] = 'holidays';
184
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2,3)))
184
+					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
185 185
 						$classes[] = 'holidays';
186 186
 				}
187 187
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
188 188
 				{
189
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1,3)))
189
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
190 190
 						$classes[] = 'birthdays';
191
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2,3)))
191
+					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
192 192
 						$classes[] = 'birthdays';
193 193
 				}
194 194
 			}
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 			elseif ($is_mini === false)
288 288
 			{
289 289
 				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
290
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- + 1, '</a>';
290
+					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
291 291
 				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
292 292
 					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
293 293
 			}
Please login to merge, or discard this patch.
Braces   +115 added lines, -85 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 				', template_show_week_grid('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	else
43
+	} else
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
@@ -67,17 +66,19 @@  discard block
 block discarded – undo
67 66
 	global $context, $settings, $txt, $scripturl, $modSettings;
68 67
 
69 68
 	// If the grid doesn't exist, no point in proceeding.
70
-	if (!isset($context['calendar_grid_' . $grid_name]))
71
-		return false;
69
+	if (!isset($context['calendar_grid_' . $grid_name])) {
70
+			return false;
71
+	}
72 72
 
73 73
 	// A handy little pointer variable.
74 74
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
75 75
 
76 76
 	// Some conditions for whether or not we should show the week links *here*.
77
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
78
-		$show_week_links = true;
79
-	else
80
-		$show_week_links = false;
77
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
78
+			$show_week_links = true;
79
+	} else {
80
+			$show_week_links = false;
81
+	}
81 82
 
82 83
 	// Assuming that we've not disabled it, show the title block!
83 84
 	if (empty($calendar_data['disable_title']))
@@ -124,8 +125,9 @@  discard block
 block discarded – undo
124 125
 		echo '<tr>';
125 126
 
126 127
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
127
-		if ($show_week_links === true)
128
-			echo '<th>&nbsp;</th>';
128
+		if ($show_week_links === true) {
129
+					echo '<th>&nbsp;</th>';
130
+		}
129 131
 
130 132
 		// Now, loop through each actual day of the week.
131 133
 		foreach ($calendar_data['week_days'] as $day)
@@ -172,29 +174,32 @@  discard block
 block discarded – undo
172 174
 				// Additional classes are given for events, holidays, and birthdays.
173 175
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
174 176
 				{
175
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1,3)))
176
-						$classes[] = 'events';
177
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2,3)))
178
-						$classes[] = 'events';
177
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1,3))) {
178
+											$classes[] = 'events';
179
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2,3))) {
180
+											$classes[] = 'events';
181
+					}
179 182
 				}
180 183
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
181 184
 				{
182
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1,3)))
183
-						$classes[] = 'holidays';
184
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2,3)))
185
-						$classes[] = 'holidays';
185
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1,3))) {
186
+											$classes[] = 'holidays';
187
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2,3))) {
188
+											$classes[] = 'holidays';
189
+					}
186 190
 				}
187 191
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
188 192
 				{
189
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1,3)))
190
-						$classes[] = 'birthdays';
191
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2,3)))
192
-						$classes[] = 'birthdays';
193
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1,3))) {
194
+											$classes[] = 'birthdays';
195
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2,3))) {
196
+											$classes[] = 'birthdays';
197
+					}
193 198
 				}
194
-			}
195
-			else
196
-				// Default Classes (either compact or comfortable and disabled).
199
+			} else {
200
+							// Default Classes (either compact or comfortable and disabled).
197 201
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
202
+			}
198 203
 				$classes[] = 'disabled';
199 204
 
200 205
 			// Now, implode the classes for each day.
@@ -208,17 +213,19 @@  discard block
 block discarded – undo
208 213
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
209 214
 
210 215
 				// The actual day number - be it a link, or just plain old text!
211
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
212
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
213
-				else
214
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
216
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
217
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
218
+				} else {
219
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
220
+				}
215 221
 
216 222
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
217 223
 				if ($is_mini === false)
218 224
 				{
219 225
 					// Holidays are always fun, let's show them!
220
-					if (!empty($day['holidays']))
221
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
226
+					if (!empty($day['holidays'])) {
227
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
228
+					}
222 229
 
223 230
 					// Happy Birthday Dear, Member!
224 231
 					if (!empty($day['birthdays']))
@@ -236,14 +243,16 @@  discard block
 block discarded – undo
236 243
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
237 244
 
238 245
 							// 9...10! Let's stop there.
239
-							if ($birthday_count == 10 && $use_js_hide)
240
-								// !!TODO - Inline CSS and JavaScript should be moved.
246
+							if ($birthday_count == 10 && $use_js_hide) {
247
+															// !!TODO - Inline CSS and JavaScript should be moved.
241 248
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
249
+							}
242 250
 
243 251
 							++$birthday_count;
244 252
 						}
245
-						if ($use_js_hide)
246
-							echo '</span>';
253
+						if ($use_js_hide) {
254
+													echo '</span>';
255
+						}
247 256
 
248 257
 						echo '</div>';
249 258
 					}
@@ -286,10 +295,11 @@  discard block
 block discarded – undo
286 295
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
287 296
 			elseif ($is_mini === false)
288 297
 			{
289
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
290
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- + 1, '</a>';
291
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
292
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
298
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
299
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- + 1, '</a>';
300
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
301
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
302
+				}
293 303
 			}
294 304
 
295 305
 			// Close this day and increase var count.
@@ -301,8 +311,9 @@  discard block
 block discarded – undo
301 311
 	}
302 312
 
303 313
 	// Quick Month Navigation + Post Event Link on Main Grids!
304
-	if ($is_mini === false)
305
-		template_calendar_base($show_week_links === true ? 8 : 7);
314
+	if ($is_mini === false) {
315
+			template_calendar_base($show_week_links === true ? 8 : 7);
316
+	}
306 317
 
307 318
 	// The end of our main table.
308 319
 	echo '</table>';
@@ -319,8 +330,9 @@  discard block
 block discarded – undo
319 330
 	global $context, $settings, $txt, $scripturl, $modSettings;
320 331
 
321 332
 	// We might have no reason to proceed, if the variable isn't there.
322
-	if (!isset($context['calendar_grid_' . $grid_name]))
323
-		return false;
333
+	if (!isset($context['calendar_grid_' . $grid_name])) {
334
+			return false;
335
+	}
324 336
 
325 337
 	// Handy pointer.
326 338
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -356,8 +368,9 @@  discard block
 block discarded – undo
356 368
 					}
357 369
 
358 370
 					// The Month Title + Week Number...
359
-					if (!empty($calendar_data['week_title']))
360
-							echo $calendar_data['week_title'];
371
+					if (!empty($calendar_data['week_title'])) {
372
+												echo $calendar_data['week_title'];
373
+					}
361 374
 
362 375
 					echo '
363 376
 					</h3>
@@ -393,10 +406,11 @@  discard block
 block discarded – undo
393 406
 						<tr class="days_wrapper">
394 407
 							<td class="', implode(' ', $classes), ' act_day">';
395 408
 							// Should the day number be a link?
396
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
397
-								echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
398
-							else
399
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
409
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
410
+															echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
411
+							} else {
412
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
413
+							}
400 414
 
401 415
 							echo '</td>
402 416
 							<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col">';
@@ -432,8 +446,7 @@  discard block
 block discarded – undo
432 446
 										</a>
433 447
 									</div>
434 448
 									<br class="clear">';
435
-							}
436
-							else
449
+							} else
437 450
 							{
438 451
 								if (!empty($context['can_post']))
439 452
 								{
@@ -446,8 +459,9 @@  discard block
 block discarded – undo
446 459
 							echo '</td>
447 460
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col">';
448 461
 							// Show any holidays!
449
-							if (!empty($day['holidays']))
450
-								echo implode('<br>', $day['holidays']);
462
+							if (!empty($day['holidays'])) {
463
+															echo implode('<br>', $day['holidays']);
464
+							}
451 465
 
452 466
 							echo '</td>
453 467
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col">';
@@ -467,8 +481,9 @@  discard block
 block discarded – undo
467 481
 				}
468 482
 
469 483
 				// We'll show the lower column after our last month is shown.
470
-				if ($iteration == $num_months)
471
-					template_calendar_base(4);
484
+				if ($iteration == $num_months) {
485
+									template_calendar_base(4);
486
+				}
472 487
 
473 488
 				// Increase iteration for loop counting.
474 489
 				++$iteration;
@@ -524,8 +539,9 @@  discard block
 block discarded – undo
524 539
 	echo '
525 540
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">';
526 541
 
527
-	if (!empty($context['event']['new']))
528
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
542
+	if (!empty($context['event']['new'])) {
543
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
544
+	}
529 545
 
530 546
 	// Start the main table.
531 547
 	echo '
@@ -561,9 +577,10 @@  discard block
 block discarded – undo
561 577
 						<select name="year" id="year" onchange="generateDays();">';
562 578
 
563 579
 	// Show a list of all the years we allow...
564
-	for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++)
565
-		echo '
580
+	for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) {
581
+			echo '
566 582
 							<option value="', $year, '"', $year == $context['event']['year'] ? ' selected' : '', '>', $year, '&nbsp;</option>';
583
+	}
567 584
 
568 585
 	echo '
569 586
 						</select>
@@ -571,9 +588,10 @@  discard block
 block discarded – undo
571 588
 						<select name="month" id="month" onchange="generateDays();">';
572 589
 
573 590
 	// There are 12 months per year - ensure that they all get listed.
574
-	for ($month = 1; $month <= 12; $month++)
575
-		echo '
591
+	for ($month = 1; $month <= 12; $month++) {
592
+			echo '
576 593
 							<option value="', $month, '"', $month == $context['event']['month'] ? ' selected' : '', '>', $txt['months'][$month], '&nbsp;</option>';
594
+	}
577 595
 
578 596
 	echo '
579 597
 						</select>
@@ -581,21 +599,23 @@  discard block
 block discarded – undo
581 599
 						<select name="day" id="day">';
582 600
 
583 601
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
584
-	for ($day = 1; $day <= $context['event']['last_day']; $day++)
585
-		echo '
602
+	for ($day = 1; $day <= $context['event']['last_day']; $day++) {
603
+			echo '
586 604
 							<option value="', $day, '"', $day == $context['event']['day'] ? ' selected' : '', '>', $day, '&nbsp;</option>';
605
+	}
587 606
 
588 607
 	echo '
589 608
 						</select>
590 609
 					</div>
591 610
 				</fieldset>';
592 611
 
593
-	if (!empty($modSettings['cal_allowspan']) || $context['event']['new'])
594
-		echo '
612
+	if (!empty($modSettings['cal_allowspan']) || $context['event']['new']) {
613
+			echo '
595 614
 				<fieldset id="event_options">
596 615
 					<legend>', $txt['calendar_event_options'], '</legend>
597 616
 					<div class="event_options smalltext">
598 617
 						<ul class="event_options">';
618
+	}
599 619
 
600 620
 	// If events can span more than one day then allow the user to select how long it should last.
601 621
 	if (!empty($modSettings['cal_allowspan']))
@@ -605,9 +625,10 @@  discard block
 block discarded – undo
605 625
 								', $txt['calendar_numb_days'], '
606 626
 								<select name="span">';
607 627
 
608
-		for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++)
609
-			echo '
628
+		for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++) {
629
+					echo '
610 630
 									<option value="', $days, '"', $context['event']['span'] == $days ? ' selected' : '', '>', $days, '&nbsp;</option>';
631
+		}
611 632
 
612 633
 		echo '
613 634
 								</select>
@@ -629,9 +650,10 @@  discard block
 block discarded – undo
629 650
 		{
630 651
 			echo '
631 652
 									<optgroup label="', $category['name'], '">';
632
-			foreach ($category['boards'] as $board)
633
-				echo '
653
+			foreach ($category['boards'] as $board) {
654
+							echo '
634 655
 										<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
656
+			}
635 657
 			echo '
636 658
 									</optgroup>';
637 659
 		}
@@ -640,18 +662,20 @@  discard block
 block discarded – undo
640 662
 							</li>';
641 663
 	}
642 664
 
643
-	if (!empty($modSettings['cal_allowspan']) || $context['event']['new'])
644
-		echo '
665
+	if (!empty($modSettings['cal_allowspan']) || $context['event']['new']) {
666
+			echo '
645 667
 						</ul>
646 668
 					</div>
647 669
 				</fieldset>';
670
+	}
648 671
 
649 672
 	echo '
650 673
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
651 674
 	// Delete button?
652
-	if (empty($context['event']['new']))
653
-		echo '
675
+	if (empty($context['event']['new'])) {
676
+			echo '
654 677
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
678
+	}
655 679
 
656 680
 	echo '
657 681
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -695,9 +719,10 @@  discard block
 block discarded – undo
695 719
 
696 720
 		foreach ($context['clockicons'] as $t => $v)
697 721
 		{
698
-			foreach ($v as $i)
699
-				echo '
722
+			foreach ($v as $i) {
723
+							echo '
700 724
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
725
+			}
701 726
 		}
702 727
 
703 728
 		echo '
@@ -722,13 +747,14 @@  discard block
 block discarded – undo
722 747
 
723 748
 		foreach ($context['clockicons'] as $t => $v)
724 749
 		{
725
-			foreach ($v as $i)
726
-				echo '
750
+			foreach ($v as $i) {
751
+							echo '
727 752
 			if (', $t, ' >= ', $i, ')
728 753
 			{
729 754
 				turnon.push("', $t, '_', $i, '");
730 755
 				', $t, ' -= ', $i, ';
731 756
 			}';
757
+			}
732 758
 		}
733 759
 
734 760
 		echo '
@@ -792,9 +818,10 @@  discard block
 block discarded – undo
792 818
 
793 819
 	foreach ($context['clockicons'] as $t => $v)
794 820
 	{
795
-		foreach ($v as $i)
796
-			echo '
821
+		foreach ($v as $i) {
822
+					echo '
797 823
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
824
+		}
798 825
 	}
799 826
 
800 827
 	echo '
@@ -811,13 +838,14 @@  discard block
 block discarded – undo
811 838
 
812 839
 	foreach ($context['clockicons'] as $t => $v)
813 840
 	{
814
-		foreach ($v as $i)
815
-			echo '
841
+		foreach ($v as $i) {
842
+					echo '
816 843
 		if (', $t, ' >= ', $i, ')
817 844
 		{
818 845
 			turnon.push("', $t, '_', $i, '");
819 846
 			', $t, ' -= ', $i, ';
820 847
 		}';
848
+		}
821 849
 	}
822 850
 
823 851
 	echo '
@@ -876,9 +904,10 @@  discard block
 block discarded – undo
876 904
 
877 905
 	foreach ($context['clockicons'] as $t => $v)
878 906
 	{
879
-		foreach ($v as $i)
880
-			echo '
907
+		foreach ($v as $i) {
908
+					echo '
881 909
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
910
+		}
882 911
 	}
883 912
 
884 913
 	echo '
@@ -899,13 +928,14 @@  discard block
 block discarded – undo
899 928
 
900 929
 	foreach ($context['clockicons'] as $t => $v)
901 930
 	{
902
-		foreach ($v as $i)
903
-		echo '
931
+		foreach ($v as $i) {
932
+				echo '
904 933
 		if (', $t, ' >= ', $i, ')
905 934
 		{
906 935
 			turnon.push("', $t, '_', $i, '");
907 936
 			', $t, ' -= ', $i, ';
908 937
 		}';
938
+		}
909 939
 	}
910 940
 
911 941
 	echo '
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
  * @param int|string $verify_id The verification control ID
228 228
  * @param string $display_type What type to display. Can be 'single' to only show one verification option or 'all' to show all of them
229 229
  * @param bool $reset Whether to reset the internal tracking counter
230
- * @return bool False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
230
+ * @return boolean|null False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
231 231
  */
232 232
 function template_control_verification($verify_id, $display_type = 'all', $reset = false)
233 233
 {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 				', !empty($context['bbcodes_handlers']) ? $context['bbcodes_handlers'] : '', '
33 33
 
34 34
 				$("#', $editor_id, '").sceditor({
35
-					',( $editor_id != 'quickReply' ? 'autofocus : true,' : '' ),'
35
+					',($editor_id != 'quickReply' ? 'autofocus : true,' : ''), '
36 36
 					style: "', $settings['default_theme_url'], '/css/jquery.sceditor.default.css",
37 37
 					emoticonsCompat: true,', !empty($editor_context['locale']) ? '
38 38
 					locale: \'' . $editor_context['locale'] . '\',' : '', !empty($context['right_to_left']) ? '
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 	if (!empty($context['drafts_pm_save']))
161 161
 		echo '
162
-		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="',  --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit">
162
+		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit">
163 163
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
164 164
 
165 165
 	if (!empty($context['drafts_save']))
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
187 187
 			<span id="draft_lastautosave" ></span>
188 188
 		</span>
189
-		<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $modSettings['browser_cache'] ,'"></script>
189
+		<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $modSettings['browser_cache'], '"></script>
190 190
 		<script>
191 191
 			var oDraftAutoSave = new smf_DraftAutoSave({
192 192
 				sSelf: \'oDraftAutoSave\',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
208 208
 			<span id="draft_lastautosave" ></span>
209 209
 		</span>
210
-		<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $modSettings['browser_cache'] ,'"></script>
210
+		<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $modSettings['browser_cache'], '"></script>
211 211
 		<script>
212 212
 			var oDraftAutoSave = new smf_DraftAutoSave({
213 213
 				sSelf: \'oDraftAutoSave\',
Please login to merge, or discard this patch.
Braces   +76 added lines, -58 removed lines patch added patch discarded remove patch
@@ -53,14 +53,15 @@  discard block
 block discarded – undo
53 53
 			foreach ($context['smileys'] as $location => $smileyRows)
54 54
 			{
55 55
 				$countLocations--;
56
-				if ($location == 'postform')
57
-					echo '
56
+				if ($location == 'postform') {
57
+									echo '
58 58
 						dropdown:
59 59
 						{';
60
-				elseif ($location == 'popup')
61
-					echo '
60
+				} elseif ($location == 'popup') {
61
+									echo '
62 62
 						popup:
63 63
 						{';
64
+				}
64 65
 
65 66
 				$numRows = count($smileyRows);
66 67
 				// This is needed because otherwise the editor will remove all the duplicate (empty) keys and leave only 1 additional line
@@ -72,20 +73,21 @@  discard block
 block discarded – undo
72 73
 						echo '
73 74
 								', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : '';
74 75
 					}
75
-					if (empty($smileyRow['isLast']) && $numRows != 1)
76
-						echo ',
76
+					if (empty($smileyRow['isLast']) && $numRows != 1) {
77
+											echo ',
77 78
 						\'-', $emptyPlaceholder++, '\': \'\',';
79
+					}
78 80
 				}
79 81
 				echo '
80 82
 						}', $countLocations != 0 ? ',' : '';
81 83
 			}
82 84
 			echo '
83 85
 					}';
84
-		}
85
-		else
86
-			echo ',
86
+		} else {
87
+					echo ',
87 88
 					emoticons:
88 89
 					{}';
90
+		}
89 91
 
90 92
 		if ($context['show_bbc'] && $bbcContainer !== null)
91 93
 		{
@@ -96,15 +98,16 @@  discard block
 block discarded – undo
96 98
 			{
97 99
 				echo implode('|', $buttonRow);
98 100
 				$count_tags--;
99
-				if (!empty($count_tags))
100
-					echo '||';
101
+				if (!empty($count_tags)) {
102
+									echo '||';
103
+				}
101 104
 			}
102 105
 
103 106
 			echo '",';
104
-		}
105
-		else
106
-			echo ',
107
+		} else {
108
+					echo ',
107 109
 					toolbar: "",';
110
+		}
108 111
 
109 112
 		echo '
110 113
 				});
@@ -145,43 +148,48 @@  discard block
 block discarded – undo
145 148
 		</span>';
146 149
 
147 150
 	$tempTab = $context['tabindex'];
148
-	if (!empty($context['drafts_pm_save']))
149
-		$tempTab++;
150
-	elseif (!empty($context['drafts_save']))
151
-		$tempTab++;
152
-	elseif ($editor_context['preview_type'])
153
-		$tempTab++;
154
-	elseif ($context['show_spellchecking'])
155
-		$tempTab++;
151
+	if (!empty($context['drafts_pm_save'])) {
152
+			$tempTab++;
153
+	} elseif (!empty($context['drafts_save'])) {
154
+			$tempTab++;
155
+	} elseif ($editor_context['preview_type']) {
156
+			$tempTab++;
157
+	} elseif ($context['show_spellchecking']) {
158
+			$tempTab++;
159
+	}
156 160
 
157 161
 	$tempTab++;
158 162
 	$context['tabindex'] = $tempTab;
159 163
 
160
-	if (!empty($context['drafts_pm_save']))
161
-		echo '
164
+	if (!empty($context['drafts_pm_save'])) {
165
+			echo '
162 166
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="',  --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit">
163 167
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
168
+	}
164 169
 
165
-	if (!empty($context['drafts_save']))
166
-		echo '
170
+	if (!empty($context['drafts_save'])) {
171
+			echo '
167 172
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button_submit">
168 173
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
174
+	}
169 175
 
170
-	if ($context['show_spellchecking'])
171
-		echo '
176
+	if ($context['show_spellchecking']) {
177
+			echo '
172 178
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button_submit">';
179
+	}
173 180
 
174
-	if ($editor_context['preview_type'])
175
-		echo '
181
+	if ($editor_context['preview_type']) {
182
+			echo '
176 183
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button_submit">';
184
+	}
177 185
 
178 186
 
179 187
 	echo '
180 188
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit">';
181 189
 
182 190
 	// Load in the PM autosaver if it's enabled
183
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
184
-		echo '
191
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
192
+			echo '
185 193
 		<span class="righttext padding" style="display: block">
186 194
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
187 195
 			<span id="draft_lastautosave" ></span>
@@ -199,10 +207,11 @@  discard block
 block discarded – undo
199 207
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
200 208
 			});
201 209
 		</script>';
210
+	}
202 211
 
203 212
 	// Start an instance of the auto saver if its enabled
204
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
205
-		echo '
213
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
214
+			echo '
206 215
 		<span class="righttext padding" style="display: block">
207 216
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
208 217
 			<span id="draft_lastautosave" ></span>
@@ -219,7 +228,8 @@  discard block
 block discarded – undo
219 228
 				iFreq: ', $context['drafts_autosave_frequency'], '
220 229
 			});
221 230
 		</script>';
222
-}
231
+	}
232
+	}
223 233
 
224 234
 /**
225 235
  * This template displays a verification form
@@ -236,50 +246,56 @@  discard block
 block discarded – undo
236 246
 	$verify_context = &$context['controls']['verification'][$verify_id];
237 247
 
238 248
 	// Keep track of where we are.
239
-	if (empty($verify_context['tracking']) || $reset)
240
-		$verify_context['tracking'] = 0;
249
+	if (empty($verify_context['tracking']) || $reset) {
250
+			$verify_context['tracking'] = 0;
251
+	}
241 252
 
242 253
 	// How many items are there to display in total.
243 254
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] ? 1 : 0);
244 255
 
245 256
 	// If we've gone too far, stop.
246
-	if ($verify_context['tracking'] > $total_items)
247
-		return false;
257
+	if ($verify_context['tracking'] > $total_items) {
258
+			return false;
259
+	}
248 260
 
249 261
 	// Loop through each item to show them.
250 262
 	for ($i = 0; $i < $total_items; $i++)
251 263
 	{
252 264
 		// If we're after a single item only show it if we're in the right place.
253
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
254
-			continue;
265
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
266
+					continue;
267
+		}
255 268
 
256
-		if ($display_type != 'single')
257
-			echo '
269
+		if ($display_type != 'single') {
270
+					echo '
258 271
 			<div id="verification_control_', $i, '" class="verification_control">';
272
+		}
259 273
 
260 274
 		// Display empty field, but only if we have one, and it's the first time.
261
-		if ($verify_context['empty_field'] && empty($i))
262
-			echo '
275
+		if ($verify_context['empty_field'] && empty($i)) {
276
+					echo '
263 277
 				<div class="smalltext vv_special">
264 278
 					', $txt['visual_verification_hidden'], ':
265 279
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
266 280
 				</div>
267 281
 				<br>';
282
+		}
268 283
 
269 284
 		// Do the actual stuff - image first?
270 285
 		if ($i == 0 && $verify_context['show_visual'])
271 286
 		{
272
-			if ($context['use_graphic_library'])
273
-				echo '
287
+			if ($context['use_graphic_library']) {
288
+							echo '
274 289
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
275
-			else
276
-				echo '
290
+			} else {
291
+							echo '
277 292
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
278 293
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
279 294
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
280 295
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
281 296
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
282 297
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
298
+			}
283 299
 
284 300
 			echo '
285 301
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -287,8 +303,7 @@  discard block
 block discarded – undo
287 303
 					', $txt['visual_verification_description'], ':', $display_type != 'quick_reply' ? '<br>' : '', '
288 304
 					<input type="text" name="', $verify_id, '_vv[code]" value="', !empty($verify_context['text_value']) ? $verify_context['text_value'] : '', '" size="30" tabindex="', $context['tabindex']++, '" class="input_text" required>
289 305
 				</div>';
290
-		}
291
-		else
306
+		} else
292 307
 		{
293 308
 			// Where in the question array is this question?
294 309
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -300,21 +315,24 @@  discard block
 block discarded – undo
300 315
 				</div>';
301 316
 		}
302 317
 
303
-		if ($display_type != 'single')
304
-			echo '
318
+		if ($display_type != 'single') {
319
+					echo '
305 320
 			</div>';
321
+		}
306 322
 
307 323
 		// If we were displaying just one and we did it, break.
308
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
309
-			break;
324
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
325
+					break;
326
+		}
310 327
 	}
311 328
 
312 329
 	// Assume we found something, always,
313 330
 	$verify_context['tracking']++;
314 331
 
315 332
 	// Tell something displaying piecemeal to keep going.
316
-	if ($display_type == 'single')
317
-		return true;
318
-}
333
+	if ($display_type == 'single') {
334
+			return true;
335
+	}
336
+	}
319 337
 
320 338
 ?>
321 339
\ No newline at end of file
Please login to merge, or discard this patch.