Completed
Push — release-2.1 ( 4c82a0...64d581 )
by Rick
09:29
created
other/upgrade.php 3 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -207,6 +207,9 @@  discard block
 block discarded – undo
207 207
 // MD5 Encryption.
208 208
 if (!function_exists('md5_hmac'))
209 209
 {
210
+	/**
211
+	 * @param string $key
212
+	 */
210 213
 	function md5_hmac($data, $key)
211 214
 	{
212 215
 		if (strlen($key) > 64)
@@ -441,6 +444,9 @@  discard block
 block discarded – undo
441 444
 }
442 445
 
443 446
 // Used to direct the user to another location.
447
+/**
448
+ * @param string $location
449
+ */
444 450
 function redirectLocation($location, $addForm = true)
445 451
 {
446 452
 	global $upgradeurl, $upcontext, $command_line;
@@ -2127,6 +2133,9 @@  discard block
 block discarded – undo
2127 2133
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
2128 2134
 }
2129 2135
 
2136
+/**
2137
+ * @param string $filename
2138
+ */
2130 2139
 function parse_sql($filename)
2131 2140
 {
2132 2141
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -2413,6 +2422,9 @@  discard block
 block discarded – undo
2413 2422
 	return true;
2414 2423
 }
2415 2424
 
2425
+/**
2426
+ * @param string $string
2427
+ */
2416 2428
 function upgrade_query($string, $unbuffered = false)
2417 2429
 {
2418 2430
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -3042,6 +3054,9 @@  discard block
 block discarded – undo
3042 3054
 	$upcontext['current_step'] = 1;
3043 3055
 }
3044 3056
 
3057
+/**
3058
+ * @param string $message
3059
+ */
3045 3060
 function print_error($message, $fatal = false)
3046 3061
 {
3047 3062
 	static $fp = null;
@@ -3055,6 +3070,9 @@  discard block
 block discarded – undo
3055 3070
 		exit;
3056 3071
 }
3057 3072
 
3073
+/**
3074
+ * @param string $message
3075
+ */
3058 3076
 function throw_error($message)
3059 3077
 {
3060 3078
 	global $upcontext;
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$totalTime = '';
428 428
 		if ($hours > 0)
429
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
429
+			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
430 430
 		if ($minutes > 0)
431
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
431
+			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
432 432
 		if ($seconds > 0)
433
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
433
+			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
434 434
 
435 435
 		if (!empty($totalTime))
436 436
 			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 	// Do we need to add this setting?
710 710
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
711 711
 
712
-	$custom_av_dir = !empty($modSettings['custom_avatar_dir']) ? $modSettings['custom_avatar_dir'] : $GLOBALS['boarddir'] .'/custom_avatar';
713
-	$custom_av_url = !empty($modSettings['custom_avatar_url']) ? $modSettings['custom_avatar_url'] : $boardurl .'/custom_avatar';
712
+	$custom_av_dir = !empty($modSettings['custom_avatar_dir']) ? $modSettings['custom_avatar_dir'] : $GLOBALS['boarddir'] . '/custom_avatar';
713
+	$custom_av_url = !empty($modSettings['custom_avatar_url']) ? $modSettings['custom_avatar_url'] : $boardurl . '/custom_avatar';
714 714
 
715 715
 	// This little fellow has to cooperate...
716 716
 	quickFileWritable($custom_av_dir);
717 717
 
718 718
 	// Are we good now?
719
-	if(!is_writable($custom_av_dir))
719
+	if (!is_writable($custom_av_dir))
720 720
 		return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
721 721
 	elseif ($need_settings_update)
722 722
 	{
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 				$upcontext['user']['id'] = 1;
913 913
 				$upcontext['user']['name'] = 'Administrator';
914 914
 			}
915
-			$upcontext['user']['pass'] = mt_rand(0,60000);
915
+			$upcontext['user']['pass'] = mt_rand(0, 60000);
916 916
 			// This basically is used to match the GET variables to Settings.php.
917 917
 			$upcontext['upgrade_status']['pass'] = $upcontext['user']['pass'];
918 918
 
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1124 1124
 			$changes['db_port'] = (int) $db_port;
1125 1125
 	}
1126
-	elseif(!empty($db_port))
1126
+	elseif (!empty($db_port))
1127 1127
 	{
1128 1128
 		// If db_port is set and is the same as the default, set it to ''
1129 1129
 		if ($db_type == 'mysql' || $db_type == 'mysqli')
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		}
1728 1728
 
1729 1729
 		if (!empty($deletes))
1730
-			upgrade_query( '
1730
+			upgrade_query('
1731 1731
 				UPDATE ' . $db_prefix . 'log_packages
1732 1732
 				SET install_state = 0
1733 1733
 				WHERE id_install IN (' . implode(',', $deletes) . ')');
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
 	else
1807 1807
 	{
1808 1808
 		require_once($sourcedir . '/ScheduledTasks.php');
1809
-		$forum_version = SMF_VERSION;  // The variable is usually defined in index.php so lets just use the constant to do it for us.
1809
+		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
1810 1810
 		scheduled_fetchSMfiles(); // Now go get those files!
1811 1811
 	}
1812 1812
 
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
 	}
2625 2625
 	elseif ($change['type'] === 'index')
2626 2626
 	{
2627
-		$request = upgrade_query( '
2627
+		$request = upgrade_query('
2628 2628
 			SHOW INDEX
2629 2629
 			FROM ' . $db_prefix . $change['table']);
2630 2630
 		if ($request !== false)
@@ -3271,7 +3271,7 @@  discard block
 block discarded – undo
3271 3271
 	// Try 755 and 775 first since 777 doesn't always work and could be a risk...
3272 3272
 	$chmod_values = array(0755, 0775, 0777);
3273 3273
 
3274
-	foreach($chmod_values as $val)
3274
+	foreach ($chmod_values as $val)
3275 3275
 	{
3276 3276
 		// If it's writable, break out of the loop
3277 3277
 		if (is_writable($file))
@@ -3481,95 +3481,95 @@  discard block
 block discarded – undo
3481 3481
 		// Translation table for the character sets not native for MySQL.
3482 3482
 		$translation_tables = array(
3483 3483
 			'windows-1255' => array(
3484
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
3485
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
3486
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
3487
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
3488
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
3489
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
3490
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '\'\'',
3491
-				'0xFC' => '\'\'',		'0xFF' => '\'\'',		'0xC2' => '0xFF',
3492
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
3493
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
3494
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3495
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3496
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3497
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
3498
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
3499
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3500
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
3501
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
3502
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
3503
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
3504
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
3505
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
3506
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
3507
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
3508
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
3509
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3510
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
3511
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3512
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
3513
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
3514
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
3515
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
3516
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
3517
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
3518
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
3519
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
3520
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
3521
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
3522
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
3523
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
3524
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
3525
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
3526
-				'0xFA' => '0xD7AA',		'0xFF' => '0xD6B2',		'0xFC' => '0xE282AC',
3484
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
3485
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
3486
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
3487
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
3488
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
3489
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
3490
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '\'\'',
3491
+				'0xFC' => '\'\'', '0xFF' => '\'\'', '0xC2' => '0xFF',
3492
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
3493
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
3494
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3495
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3496
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3497
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
3498
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
3499
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3500
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
3501
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
3502
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
3503
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
3504
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
3505
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
3506
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
3507
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
3508
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
3509
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3510
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
3511
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3512
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
3513
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
3514
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
3515
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
3516
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
3517
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
3518
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
3519
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
3520
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
3521
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
3522
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
3523
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
3524
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
3525
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
3526
+				'0xFA' => '0xD7AA', '0xFF' => '0xD6B2', '0xFC' => '0xE282AC',
3527 3527
 				'0xFB' => '0xD792',
3528 3528
 			),
3529 3529
 			'windows-1253' => array(
3530
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
3531
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
3532
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
3533
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
3534
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
3535
-				'0xD2' => '\'\'',			'0xFF' => '\'\'',			'0xCE' => '0xCE9E',
3536
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
3537
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
3538
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
3539
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
3540
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
3541
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
3542
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
3543
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
3544
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3545
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3546
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3547
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
3548
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3549
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
3550
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3551
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
3552
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
3553
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
3554
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3555
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
3556
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
3557
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
3558
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
3559
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
3560
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
3561
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
3562
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
3563
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
3564
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
3565
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
3566
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
3567
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
3568
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
3569
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
3570
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
3571
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
3572
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',		'0xFF' => '0xCE92',
3530
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
3531
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
3532
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
3533
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
3534
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
3535
+				'0xD2' => '\'\'', '0xFF' => '\'\'', '0xCE' => '0xCE9E',
3536
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
3537
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
3538
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
3539
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
3540
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
3541
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
3542
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
3543
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
3544
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3545
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3546
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3547
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
3548
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3549
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
3550
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3551
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
3552
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
3553
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
3554
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3555
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
3556
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
3557
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
3558
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
3559
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
3560
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
3561
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
3562
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
3563
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
3564
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
3565
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
3566
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
3567
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
3568
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
3569
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
3570
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
3571
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
3572
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E', '0xFF' => '0xCE92',
3573 3573
 				'0xD2' => '0xE282AC',
3574 3574
 			),
3575 3575
 		);
@@ -3591,7 +3591,7 @@  discard block
 block discarded – undo
3591 3591
 		$upcontext['table_count'] = count($queryTables);
3592 3592
 		$file_steps = $upcontext['table_count'];
3593 3593
 
3594
-		for($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++)
3594
+		for ($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++)
3595 3595
 		{
3596 3596
 			$table = $queryTables[$_GET['substep']];
3597 3597
 
@@ -3819,7 +3819,7 @@  discard block
 block discarded – undo
3819 3819
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3820 3820
 	$file_steps = $upcontext['table_count'];
3821 3821
 
3822
-	foreach($keys as $id => $table)
3822
+	foreach ($keys as $id => $table)
3823 3823
 		if ($id < $_GET['substep'])
3824 3824
 			$upcontext['previous_tables'][] = $table;
3825 3825
 
@@ -3834,7 +3834,7 @@  discard block
 block discarded – undo
3834 3834
 			$upcontext['cur_table_name'] = isset($keys[$substep + 1]) ? $keys[$substep + 1] : $keys[$substep];
3835 3835
 			$upcontext['cur_table_num'] = $substep + 1;
3836 3836
 
3837
-			$upcontext['step_progress'] = (int)(($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3837
+			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3838 3838
 
3839 3839
 			// Do we need to pause?
3840 3840
 			nextSubstep($substep);
@@ -4071,7 +4071,7 @@  discard block
 block discarded – undo
4071 4071
 				The following files need to be writable to continue the upgrade. Please ensure the Windows permissions are correctly set to allow this:<br>
4072 4072
 				<ul style="margin: 2.5ex; font-family: monospace;">
4073 4073
 					<li>' . implode('</li>
4074
-					<li>', $upcontext['chmod']['files']). '</li>
4074
+					<li>', $upcontext['chmod']['files']) . '</li>
4075 4075
 				</ul>
4076 4076
 			</div>';
4077 4077
 
@@ -4167,7 +4167,7 @@  discard block
 block discarded – undo
4167 4167
 		<title>', $txt['upgrade_upgrade_utility'], '</title>
4168 4168
 		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/index.css?alp21">
4169 4169
 		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/install.css?alp21">
4170
-		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/rtl.css?alp21">' : '' , '
4170
+		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/rtl.css?alp21">' : '', '
4171 4171
 		<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
4172 4172
 		<script src="', $settings['default_theme_url'], '/scripts/script.js"></script>
4173 4173
 		<script>
@@ -4775,11 +4775,11 @@  discard block
 block discarded – undo
4775 4775
 
4776 4776
 				$totalTime = '';
4777 4777
 				if ($hours > 0)
4778
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
4778
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4779 4779
 				if ($minutes > 0)
4780
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
4780
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4781 4781
 				if ($seconds > 0)
4782
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
4782
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4783 4783
 			}
4784 4784
 
4785 4785
 			if ($is_debug && !empty($totalTime))
@@ -4812,11 +4812,11 @@  discard block
 block discarded – undo
4812 4812
 
4813 4813
 				$totalTime = '';
4814 4814
 				if ($hours > 0)
4815
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
4815
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4816 4816
 				if ($minutes > 0)
4817
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
4817
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4818 4818
 				if ($seconds > 0)
4819
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
4819
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4820 4820
 			}
4821 4821
 
4822 4822
 			echo '
@@ -5543,11 +5543,11 @@  discard block
 block discarded – undo
5543 5543
 	{
5544 5544
 		$totalTime = '';
5545 5545
 		if ($hours > 0)
5546
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
5546
+			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
5547 5547
 		if ($minutes > 0)
5548
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
5548
+			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
5549 5549
 		if ($seconds > 0)
5550
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5550
+			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
5551 5551
 	}
5552 5552
 
5553 5553
 	if ($is_debug && !empty($totalTime))
Please login to merge, or discard this patch.
Braces   +1118 added lines, -821 removed lines patch added patch discarded remove patch
@@ -78,11 +78,14 @@  discard block
 block discarded – undo
78 78
 	ini_set('default_socket_timeout', 900);
79 79
 }
80 80
 // Clean the upgrade path if this is from the client.
81
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
82
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
81
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
82
+	for ($i = 1;
83
+}
84
+$i < $_SERVER['argc']; $i++)
83 85
 	{
84
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
85
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
86
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
87
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
88
+		}
86 89
 	}
87 90
 
88 91
 // Are we from the client?
@@ -90,9 +93,9 @@  discard block
 block discarded – undo
90 93
 {
91 94
 	$command_line = true;
92 95
 	$disable_security = 1;
93
-}
94
-else
96
+} else {
95 97
 	$command_line = false;
98
+}
96 99
 
97 100
 // Load this now just because we can.
98 101
 require_once($upgrade_path . '/Settings.php');
@@ -103,10 +106,12 @@  discard block
 block discarded – undo
103 106
 	$upcontext['user'] = unserialize(base64_decode($upgradeData));
104 107
 
105 108
 	// Check for sensible values.
106
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
107
-		$upcontext['user']['started'] = time();
108
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
109
-		$upcontext['user']['updated'] = 0;
109
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
110
+			$upcontext['user']['started'] = time();
111
+	}
112
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
113
+			$upcontext['user']['updated'] = 0;
114
+	}
110 115
 
111 116
 	$upcontext['started'] = $upcontext['user']['started'];
112 117
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -169,8 +174,9 @@  discard block
 block discarded – undo
169 174
 		{
170 175
 			$word = trim($word, '-_\'');
171 176
 
172
-			if ($word != '')
173
-				$returned_words[] = substr($word, 0, 20);
177
+			if ($word != '') {
178
+							$returned_words[] = substr($word, 0, 20);
179
+			}
174 180
 		}
175 181
 
176 182
 		return array_unique($returned_words);
@@ -185,15 +191,17 @@  discard block
 block discarded – undo
185 191
 		global $cachedir, $sourcedir;
186 192
 
187 193
 		// No directory = no game.
188
-		if (!is_dir($cachedir))
189
-			return;
194
+		if (!is_dir($cachedir)) {
195
+					return;
196
+		}
190 197
 
191 198
 		// Remove the files in SMF's own disk cache, if any
192 199
 		$dh = opendir($cachedir);
193 200
 		while ($file = readdir($dh))
194 201
 		{
195
-			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
196
-				@unlink($cachedir . '/' . $file);
202
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
203
+							@unlink($cachedir . '/' . $file);
204
+			}
197 205
 		}
198 206
 		closedir($dh);
199 207
 
@@ -209,8 +217,9 @@  discard block
 block discarded – undo
209 217
 {
210 218
 	function md5_hmac($data, $key)
211 219
 	{
212
-		if (strlen($key) > 64)
213
-			$key = pack('H*', md5($key));
220
+		if (strlen($key) > 64) {
221
+					$key = pack('H*', md5($key));
222
+		}
214 223
 		$key = str_pad($key, 64, chr(0x00));
215 224
 
216 225
 		$k_ipad = $key ^ str_repeat(chr(0x36), 64);
@@ -221,8 +230,9 @@  discard block
 block discarded – undo
221 230
 }
222 231
 
223 232
 // Don't do security check if on Yabbse
224
-if (!isset($modSettings['smfVersion']))
233
+if (!isset($modSettings['smfVersion'])) {
225 234
 	$disable_security = true;
235
+}
226 236
 
227 237
 // This only exists if we're on SMF ;)
228 238
 if (isset($modSettings['smfVersion']))
@@ -240,8 +250,9 @@  discard block
 block discarded – undo
240 250
 			'db_error_skip' => true,
241 251
 		)
242 252
 	);
243
-	while ($row = $smcFunc['db_fetch_assoc']($request))
244
-		$modSettings[$row['variable']] = $row['value'];
253
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
254
+			$modSettings[$row['variable']] = $row['value'];
255
+	}
245 256
 	$smcFunc['db_free_result']($request);
246 257
 }
247 258
 
@@ -251,10 +262,12 @@  discard block
 block discarded – undo
251 262
 	$modSettings['theme_url'] = 'Themes/default';
252 263
 	$modSettings['images_url'] = 'Themes/default/images';
253 264
 }
254
-if (!isset($settings['default_theme_url']))
265
+if (!isset($settings['default_theme_url'])) {
255 266
 	$settings['default_theme_url'] = $modSettings['theme_url'];
256
-if (!isset($settings['default_theme_dir']))
267
+}
268
+if (!isset($settings['default_theme_dir'])) {
257 269
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
270
+}
258 271
 
259 272
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
260 273
 // Default title...
@@ -272,13 +285,15 @@  discard block
 block discarded – undo
272 285
 	$support_js = $upcontext['upgrade_status']['js'];
273 286
 
274 287
 	// Only set this if the upgrader status says so.
275
-	if (empty($is_debug))
276
-		$is_debug = $upcontext['upgrade_status']['debug'];
288
+	if (empty($is_debug)) {
289
+			$is_debug = $upcontext['upgrade_status']['debug'];
290
+	}
277 291
 
278 292
 	// Load the language.
279
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
280
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
281
-}
293
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
294
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
295
+	}
296
+	}
282 297
 // Set the defaults.
283 298
 else
284 299
 {
@@ -296,15 +311,18 @@  discard block
 block discarded – undo
296 311
 }
297 312
 
298 313
 // If this isn't the first stage see whether they are logging in and resuming.
299
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
314
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
300 315
 	checkLogin();
316
+}
301 317
 
302
-if ($command_line)
318
+if ($command_line) {
303 319
 	cmdStep0();
320
+}
304 321
 
305 322
 // Don't error if we're using xml.
306
-if (isset($_GET['xml']))
323
+if (isset($_GET['xml'])) {
307 324
 	$upcontext['return_error'] = true;
325
+}
308 326
 
309 327
 // Loop through all the steps doing each one as required.
310 328
 $upcontext['overall_percent'] = 0;
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 		}
326 344
 
327 345
 		// Call the step and if it returns false that means pause!
328
-		if (function_exists($step[2]) && $step[2]() === false)
329
-			break;
330
-		elseif (function_exists($step[2]))
331
-			$upcontext['current_step']++;
346
+		if (function_exists($step[2]) && $step[2]() === false) {
347
+					break;
348
+		} elseif (function_exists($step[2])) {
349
+					$upcontext['current_step']++;
350
+		}
332 351
 	}
333 352
 	$upcontext['overall_percent'] += $step[3];
334 353
 }
@@ -367,17 +386,18 @@  discard block
 block discarded – undo
367 386
 		// This should not happen my dear... HELP ME DEVELOPERS!!
368 387
 		if (!empty($command_line))
369 388
 		{
370
-			if (function_exists('debug_print_backtrace'))
371
-				debug_print_backtrace();
389
+			if (function_exists('debug_print_backtrace')) {
390
+							debug_print_backtrace();
391
+			}
372 392
 
373 393
 			echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.';
374 394
 			flush();
375 395
 			die();
376 396
 		}
377 397
 
378
-		if (!isset($_GET['xml']))
379
-			template_upgrade_above();
380
-		else
398
+		if (!isset($_GET['xml'])) {
399
+					template_upgrade_above();
400
+		} else
381 401
 		{
382 402
 			header('Content-Type: text/xml; charset=UTF-8');
383 403
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -399,21 +419,24 @@  discard block
 block discarded – undo
399 419
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(safe_serialize($upcontext['upgrade_status']));
400 420
 
401 421
 			// Custom stuff to pass back?
402
-			if (!empty($upcontext['query_string']))
403
-				$upcontext['form_url'] .= $upcontext['query_string'];
422
+			if (!empty($upcontext['query_string'])) {
423
+							$upcontext['form_url'] .= $upcontext['query_string'];
424
+			}
404 425
 
405 426
 			call_user_func('template_' . $upcontext['sub_template']);
406 427
 		}
407 428
 
408 429
 		// Was there an error?
409
-		if (!empty($upcontext['forced_error_message']))
410
-			echo $upcontext['forced_error_message'];
430
+		if (!empty($upcontext['forced_error_message'])) {
431
+					echo $upcontext['forced_error_message'];
432
+		}
411 433
 
412 434
 		// Show the footer.
413
-		if (!isset($_GET['xml']))
414
-			template_upgrade_below();
415
-		else
416
-			template_xml_below();
435
+		if (!isset($_GET['xml'])) {
436
+					template_upgrade_below();
437
+		} else {
438
+					template_xml_below();
439
+		}
417 440
 	}
418 441
 
419 442
 
@@ -425,15 +448,19 @@  discard block
 block discarded – undo
425 448
 		$seconds = intval($active % 60);
426 449
 
427 450
 		$totalTime = '';
428
-		if ($hours > 0)
429
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
430
-		if ($minutes > 0)
431
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
432
-		if ($seconds > 0)
433
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
451
+		if ($hours > 0) {
452
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
453
+		}
454
+		if ($minutes > 0) {
455
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
456
+		}
457
+		if ($seconds > 0) {
458
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
459
+		}
434 460
 
435
-		if (!empty($totalTime))
436
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
461
+		if (!empty($totalTime)) {
462
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
463
+		}
437 464
 	}
438 465
 
439 466
 	// Bang - gone!
@@ -446,8 +473,9 @@  discard block
 block discarded – undo
446 473
 	global $upgradeurl, $upcontext, $command_line;
447 474
 
448 475
 	// Command line users can't be redirected.
449
-	if ($command_line)
450
-		upgradeExit(true);
476
+	if ($command_line) {
477
+			upgradeExit(true);
478
+	}
451 479
 
452 480
 	// Are we providing the core info?
453 481
 	if ($addForm)
@@ -470,19 +498,22 @@  discard block
 block discarded – undo
470 498
 	global $modSettings, $sourcedir, $smcFunc;
471 499
 
472 500
 	// Do the non-SSI stuff...
473
-	if (function_exists('set_magic_quotes_runtime'))
474
-		@set_magic_quotes_runtime(0);
501
+	if (function_exists('set_magic_quotes_runtime')) {
502
+			@set_magic_quotes_runtime(0);
503
+	}
475 504
 
476 505
 	error_reporting(E_ALL);
477 506
 	define('SMF', 1);
478 507
 
479 508
 	// Start the session.
480
-	if (@ini_get('session.save_handler') == 'user')
481
-		@ini_set('session.save_handler', 'files');
509
+	if (@ini_get('session.save_handler') == 'user') {
510
+			@ini_set('session.save_handler', 'files');
511
+	}
482 512
 	@session_start();
483 513
 
484
-	if (empty($smcFunc))
485
-		$smcFunc = array();
514
+	if (empty($smcFunc)) {
515
+			$smcFunc = array();
516
+	}
486 517
 
487 518
 	// We need this for authentication and some upgrade code
488 519
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -495,8 +526,9 @@  discard block
 block discarded – undo
495 526
 	initialize_inputs();
496 527
 
497 528
 	// Get the database going!
498
-	if (empty($db_type))
499
-		$db_type = 'mysql';
529
+	if (empty($db_type)) {
530
+			$db_type = 'mysql';
531
+	}
500 532
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
501 533
 	{
502 534
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -505,16 +537,18 @@  discard block
 block discarded – undo
505 537
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
506 538
 
507 539
 		// Oh dear god!!
508
-		if ($db_connection === null)
509
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
540
+		if ($db_connection === null) {
541
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
542
+		}
510 543
 
511
-		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
512
-			$smcFunc['db_query']('', '
544
+		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
545
+					$smcFunc['db_query']('', '
513 546
 			SET NAMES ' . $db_character_set,
514 547
 			array(
515 548
 				'db_error_skip' => true,
516 549
 			)
517 550
 		);
551
+		}
518 552
 
519 553
 		// Load the modSettings data...
520 554
 		$request = $smcFunc['db_query']('', '
@@ -525,11 +559,11 @@  discard block
 block discarded – undo
525 559
 			)
526 560
 		);
527 561
 		$modSettings = array();
528
-		while ($row = $smcFunc['db_fetch_assoc']($request))
529
-			$modSettings[$row['variable']] = $row['value'];
562
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
563
+					$modSettings[$row['variable']] = $row['value'];
564
+		}
530 565
 		$smcFunc['db_free_result']($request);
531
-	}
532
-	else
566
+	} else
533 567
 	{
534 568
 		return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.');
535 569
 	}
@@ -543,9 +577,10 @@  discard block
 block discarded – undo
543 577
 		cleanRequest();
544 578
 	}
545 579
 
546
-	if (!isset($_GET['substep']))
547
-		$_GET['substep'] = 0;
548
-}
580
+	if (!isset($_GET['substep'])) {
581
+			$_GET['substep'] = 0;
582
+	}
583
+	}
549 584
 
550 585
 function initialize_inputs()
551 586
 {
@@ -583,8 +618,9 @@  discard block
 block discarded – undo
583 618
 		$dh = opendir(dirname(__FILE__));
584 619
 		while ($file = readdir($dh))
585 620
 		{
586
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
587
-				@unlink(dirname(__FILE__) . '/' . $file);
621
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
622
+							@unlink(dirname(__FILE__) . '/' . $file);
623
+			}
588 624
 		}
589 625
 		closedir($dh);
590 626
 
@@ -614,8 +650,9 @@  discard block
 block discarded – undo
614 650
 	{
615 651
 		$upcontext['remote_files_available'] = false;
616 652
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
617
-		if ($test)
618
-			$upcontext['remote_files_available'] = true;
653
+		if ($test) {
654
+					$upcontext['remote_files_available'] = true;
655
+		}
619 656
 		@fclose($test);
620 657
 	}
621 658
 
@@ -623,8 +660,9 @@  discard block
 block discarded – undo
623 660
 	$temp = 'upgrade_php?step';
624 661
 	while (strlen($temp) > 4)
625 662
 	{
626
-		if (isset($_GET[$temp]))
627
-			unset($_GET[$temp]);
663
+		if (isset($_GET[$temp])) {
664
+					unset($_GET[$temp]);
665
+		}
628 666
 		$temp = substr($temp, 1);
629 667
 	}
630 668
 
@@ -650,29 +688,36 @@  discard block
 block discarded – undo
650 688
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql');
651 689
 
652 690
 	// Need legacy scripts?
653
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
654
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
655
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
656
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
657
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
658
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
691
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
692
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
693
+	}
694
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
695
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
696
+	}
697
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
698
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
699
+	}
659 700
 
660 701
 	// This needs to exist!
661
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
662
-		return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
663
-	else
664
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
702
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
703
+			return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
704
+	} else {
705
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
706
+	}
665 707
 
666
-	if (!$check)
667
-		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
708
+	if (!$check) {
709
+			// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
668 710
 		return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.');
711
+	}
669 712
 
670 713
 	// Do they meet the install requirements?
671
-	if (!php_version_check())
672
-		return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
714
+	if (!php_version_check()) {
715
+			return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
716
+	}
673 717
 
674
-	if (!db_version_check())
675
-		return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
718
+	if (!db_version_check()) {
719
+			return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
720
+	}
676 721
 
677 722
 	// Do some checks to make sure they have proper privileges
678 723
 	db_extend('packages');
@@ -687,14 +732,16 @@  discard block
 block discarded – undo
687 732
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
688 733
 
689 734
 	// Sorry... we need CREATE, ALTER and DROP
690
-	if (!$create || !$alter || !$drop)
691
-		return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
735
+	if (!$create || !$alter || !$drop) {
736
+			return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
737
+	}
692 738
 
693 739
 	// Do a quick version spot check.
694 740
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
695 741
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
696
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
697
-		return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
742
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
743
+			return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
744
+	}
698 745
 
699 746
 	// What absolutely needs to be writable?
700 747
 	$writable_files = array(
@@ -716,12 +763,13 @@  discard block
 block discarded – undo
716 763
 	quickFileWritable($custom_av_dir);
717 764
 
718 765
 	// Are we good now?
719
-	if(!is_writable($custom_av_dir))
720
-		return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
721
-	elseif ($need_settings_update)
766
+	if(!is_writable($custom_av_dir)) {
767
+			return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
768
+	} elseif ($need_settings_update)
722 769
 	{
723
-		if (!function_exists('cache_put_data'))
724
-			require_once($sourcedir . '/Load.php');
770
+		if (!function_exists('cache_put_data')) {
771
+					require_once($sourcedir . '/Load.php');
772
+		}
725 773
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
726 774
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
727 775
 	}
@@ -730,28 +778,33 @@  discard block
 block discarded – undo
730 778
 
731 779
 	// Check the cache directory.
732 780
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
733
-	if (!file_exists($cachedir_temp))
734
-		@mkdir($cachedir_temp);
735
-	if (!file_exists($cachedir_temp))
736
-		return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
737
-
738
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
739
-		return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
740
-	elseif (!isset($_GET['skiplang']))
781
+	if (!file_exists($cachedir_temp)) {
782
+			@mkdir($cachedir_temp);
783
+	}
784
+	if (!file_exists($cachedir_temp)) {
785
+			return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
786
+	}
787
+
788
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
789
+			return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
790
+	} elseif (!isset($_GET['skiplang']))
741 791
 	{
742 792
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
743 793
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
744 794
 
745
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
746
-			return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
795
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
796
+					return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
797
+		}
747 798
 	}
748 799
 
749
-	if (!makeFilesWritable($writable_files))
750
-		return false;
800
+	if (!makeFilesWritable($writable_files)) {
801
+			return false;
802
+	}
751 803
 
752 804
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
753
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
754
-		return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
805
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
806
+			return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
807
+	}
755 808
 
756 809
 	// Upgrade the agreement.
757 810
 	elseif (isset($modSettings['agreement']))
@@ -762,8 +815,8 @@  discard block
 block discarded – undo
762 815
 	}
763 816
 
764 817
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
765
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
766
-		$upcontext['warning'] = '
818
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
819
+			$upcontext['warning'] = '
767 820
 			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br>
768 821
 			<ul>
769 822
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -771,10 +824,12 @@  discard block
 block discarded – undo
771 824
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
772 825
 			</ul>
773 826
 			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
827
+	}
774 828
 
775 829
 	// Either we're logged in or we're going to present the login.
776
-	if (checkLogin())
777
-		return true;
830
+	if (checkLogin()) {
831
+			return true;
832
+	}
778 833
 
779 834
 	$upcontext += createToken('login');
780 835
 
@@ -791,8 +846,9 @@  discard block
 block discarded – undo
791 846
 	if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security))
792 847
 	{
793 848
 		// If we've disabled security pick a suitable name!
794
-		if (empty($_POST['user']))
795
-			$_POST['user'] = 'Administrator';
849
+		if (empty($_POST['user'])) {
850
+					$_POST['user'] = 'Administrator';
851
+		}
796 852
 
797 853
 		// Before 2.0 these column names were different!
798 854
 		$oldDB = false;
@@ -807,16 +863,17 @@  discard block
 block discarded – undo
807 863
 					'db_error_skip' => true,
808 864
 				)
809 865
 			);
810
-			if ($smcFunc['db_num_rows']($request) != 0)
811
-				$oldDB = true;
866
+			if ($smcFunc['db_num_rows']($request) != 0) {
867
+							$oldDB = true;
868
+			}
812 869
 			$smcFunc['db_free_result']($request);
813 870
 		}
814 871
 
815 872
 		// Get what we believe to be their details.
816 873
 		if (!$disable_security)
817 874
 		{
818
-			if ($oldDB)
819
-				$request = $smcFunc['db_query']('', '
875
+			if ($oldDB) {
876
+							$request = $smcFunc['db_query']('', '
820 877
 					SELECT id_member, memberName AS member_name, passwd, id_group,
821 878
 					additionalGroups AS additional_groups, lngfile
822 879
 					FROM {db_prefix}members
@@ -826,8 +883,8 @@  discard block
 block discarded – undo
826 883
 						'db_error_skip' => true,
827 884
 					)
828 885
 				);
829
-			else
830
-				$request = $smcFunc['db_query']('', '
886
+			} else {
887
+							$request = $smcFunc['db_query']('', '
831 888
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
832 889
 					FROM {db_prefix}members
833 890
 					WHERE member_name = {string:member_name}',
@@ -836,6 +893,7 @@  discard block
 block discarded – undo
836 893
 						'db_error_skip' => true,
837 894
 					)
838 895
 				);
896
+			}
839 897
 			if ($smcFunc['db_num_rows']($request) != 0)
840 898
 			{
841 899
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -843,13 +901,14 @@  discard block
 block discarded – undo
843 901
 				$groups = explode(',', $addGroups);
844 902
 				$groups[] = $id_group;
845 903
 
846
-				foreach ($groups as $k => $v)
847
-					$groups[$k] = (int) $v;
904
+				foreach ($groups as $k => $v) {
905
+									$groups[$k] = (int) $v;
906
+				}
848 907
 
849 908
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
909
+			} else {
910
+							$upcontext['username_incorrect'] = true;
850 911
 			}
851
-			else
852
-				$upcontext['username_incorrect'] = true;
853 912
 			$smcFunc['db_free_result']($request);
854 913
 		}
855 914
 		$upcontext['username'] = $_POST['user'];
@@ -859,13 +918,14 @@  discard block
 block discarded – undo
859 918
 		{
860 919
 			$upcontext['upgrade_status']['js'] = 1;
861 920
 			$support_js = 1;
921
+		} else {
922
+					$support_js = 0;
862 923
 		}
863
-		else
864
-			$support_js = 0;
865 924
 
866 925
 		// Note down the version we are coming from.
867
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
868
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
926
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
927
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
928
+		}
869 929
 
870 930
 		// Didn't get anywhere?
871 931
 		if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect']))
@@ -899,15 +959,15 @@  discard block
 block discarded – undo
899 959
 							'db_error_skip' => true,
900 960
 						)
901 961
 					);
902
-					if ($smcFunc['db_num_rows']($request) == 0)
903
-						return throw_error('You need to be an admin to perform an upgrade!');
962
+					if ($smcFunc['db_num_rows']($request) == 0) {
963
+											return throw_error('You need to be an admin to perform an upgrade!');
964
+					}
904 965
 					$smcFunc['db_free_result']($request);
905 966
 				}
906 967
 
907 968
 				$upcontext['user']['id'] = $id_member;
908 969
 				$upcontext['user']['name'] = $name;
909
-			}
910
-			else
970
+			} else
911 971
 			{
912 972
 				$upcontext['user']['id'] = 1;
913 973
 				$upcontext['user']['name'] = 'Administrator';
@@ -923,11 +983,11 @@  discard block
 block discarded – undo
923 983
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
924 984
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
925 985
 
926
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
927
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
928
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
929
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
930
-				else
986
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
987
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
988
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
989
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
990
+				} else
931 991
 				{
932 992
 					// Set this as the new language.
933 993
 					$upcontext['language'] = $user_language;
@@ -971,8 +1031,9 @@  discard block
 block discarded – undo
971 1031
 	unset($member_columns);
972 1032
 
973 1033
 	// If we've not submitted then we're done.
974
-	if (empty($_POST['upcont']))
975
-		return false;
1034
+	if (empty($_POST['upcont'])) {
1035
+			return false;
1036
+	}
976 1037
 
977 1038
 	require_once($sourcedir . '/Subs-Admin.php');
978 1039
 	updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\''));
@@ -990,25 +1051,26 @@  discard block
 block discarded – undo
990 1051
 			fwrite($fp, $out);
991 1052
 
992 1053
 			$return_data = '';
993
-			while (!feof($fp))
994
-				$return_data .= fgets($fp, 128);
1054
+			while (!feof($fp)) {
1055
+							$return_data .= fgets($fp, 128);
1056
+			}
995 1057
 
996 1058
 			fclose($fp);
997 1059
 
998 1060
 			// Get the unique site ID.
999 1061
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1000 1062
 
1001
-			if (!empty($ID[1]))
1002
-				$smcFunc['db_insert']('replace',
1063
+			if (!empty($ID[1])) {
1064
+							$smcFunc['db_insert']('replace',
1003 1065
 					$db_prefix . 'settings',
1004 1066
 					array('variable' => 'string', 'value' => 'string'),
1005 1067
 					array('allow_sm_stats', $ID[1]),
1006 1068
 					array('variable')
1007 1069
 				);
1070
+			}
1008 1071
 		}
1009
-	}
1010
-	else
1011
-		$smcFunc['db_query']('', '
1072
+	} else {
1073
+			$smcFunc['db_query']('', '
1012 1074
 			DELETE FROM {db_prefix}settings
1013 1075
 			WHERE variable = {string:allow_sm_stats}',
1014 1076
 			array(
@@ -1016,6 +1078,7 @@  discard block
 block discarded – undo
1016 1078
 				'db_error_skip' => true,
1017 1079
 			)
1018 1080
 		);
1081
+	}
1019 1082
 
1020 1083
 	// Deleting old karma stuff?
1021 1084
 	if (!empty($_POST['delete_karma']))
@@ -1030,20 +1093,22 @@  discard block
 block discarded – undo
1030 1093
 		);
1031 1094
 
1032 1095
 		// Cleaning up old karma member settings.
1033
-		if ($upcontext['karma_installed']['good'])
1034
-			$smcFunc['db_query']('', '
1096
+		if ($upcontext['karma_installed']['good']) {
1097
+					$smcFunc['db_query']('', '
1035 1098
 				ALTER TABLE {db_prefix}members
1036 1099
 				DROP karma_good',
1037 1100
 				array()
1038 1101
 			);
1102
+		}
1039 1103
 
1040 1104
 		// Does karma bad was enable?
1041
-		if ($upcontext['karma_installed']['bad'])
1042
-			$smcFunc['db_query']('', '
1105
+		if ($upcontext['karma_installed']['bad']) {
1106
+					$smcFunc['db_query']('', '
1043 1107
 				ALTER TABLE {db_prefix}members
1044 1108
 				DROP karma_bad',
1045 1109
 				array()
1046 1110
 			);
1111
+		}
1047 1112
 
1048 1113
 		// Cleaning up old karma permissions.
1049 1114
 		$smcFunc['db_query']('', '
@@ -1056,18 +1121,20 @@  discard block
 block discarded – undo
1056 1121
 	}
1057 1122
 
1058 1123
 	// Emptying the error log?
1059
-	if (!empty($_POST['empty_error']))
1060
-		$smcFunc['db_query']('truncate_table', '
1124
+	if (!empty($_POST['empty_error'])) {
1125
+			$smcFunc['db_query']('truncate_table', '
1061 1126
 			TRUNCATE {db_prefix}log_errors',
1062 1127
 			array(
1063 1128
 			)
1064 1129
 		);
1130
+	}
1065 1131
 
1066 1132
 	$changes = array();
1067 1133
 
1068 1134
 	// If we're overriding the language follow it through.
1069
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1070
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1135
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1136
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1137
+	}
1071 1138
 
1072 1139
 	if (!empty($_POST['maint']))
1073 1140
 	{
@@ -1079,37 +1146,42 @@  discard block
 block discarded – undo
1079 1146
 		{
1080 1147
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1081 1148
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1082
-		}
1083
-		else
1149
+		} else
1084 1150
 		{
1085 1151
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1086 1152
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1087 1153
 		}
1088 1154
 	}
1089 1155
 
1090
-	if ($command_line)
1091
-		echo ' * Updating Settings.php...';
1156
+	if ($command_line) {
1157
+			echo ' * Updating Settings.php...';
1158
+	}
1092 1159
 
1093 1160
 	// Backup the current one first.
1094 1161
 	copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
1095 1162
 
1096 1163
 	// Fix some old paths.
1097
-	if (substr($boarddir, 0, 1) == '.')
1098
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1164
+	if (substr($boarddir, 0, 1) == '.') {
1165
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1166
+	}
1099 1167
 
1100
-	if (substr($sourcedir, 0, 1) == '.')
1101
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1168
+	if (substr($sourcedir, 0, 1) == '.') {
1169
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1170
+	}
1102 1171
 
1103
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1104
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1172
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1173
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1174
+	}
1105 1175
 
1106 1176
 	// Not had the database type added before?
1107
-	if (empty($db_type))
1108
-		$changes['db_type'] = 'mysql';
1177
+	if (empty($db_type)) {
1178
+			$changes['db_type'] = 'mysql';
1179
+	}
1109 1180
 
1110 1181
 	// For now we offer a option, this may change in future versions when mysql is completely removed.
1111
-	if (!empty($_POST['convertMysql']) && $db_type == 'mysql')
1112
-		$changes['db_type'] = '\'mysqli\'';
1182
+	if (!empty($_POST['convertMysql']) && $db_type == 'mysql') {
1183
+			$changes['db_type'] = '\'mysqli\'';
1184
+	}
1113 1185
 
1114 1186
 	// If they have a "host:port" setup for the host, split that into separate values
1115 1187
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1120,28 +1192,31 @@  discard block
 block discarded – undo
1120 1192
 		$changes['db_server'] = '\'' . $db_server . '\'';
1121 1193
 
1122 1194
 		// Only set this if we're not using the default port
1123
-		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1124
-			$changes['db_port'] = (int) $db_port;
1125
-	}
1126
-	elseif(!empty($db_port))
1195
+		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1196
+					$changes['db_port'] = (int) $db_port;
1197
+		}
1198
+	} elseif(!empty($db_port))
1127 1199
 	{
1128 1200
 		// If db_port is set and is the same as the default, set it to ''
1129 1201
 		if ($db_type == 'mysql' || $db_type == 'mysqli')
1130 1202
 		{
1131
-			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1132
-				$changes['db_port'] = '\'\'';
1133
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1134
-				$changes['db_port'] = '\'\'';
1203
+			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1204
+							$changes['db_port'] = '\'\'';
1205
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1206
+							$changes['db_port'] = '\'\'';
1207
+			}
1135 1208
 		}
1136 1209
 	}
1137 1210
 
1138 1211
 	// Maybe we haven't had this option yet?
1139
-	if (empty($packagesdir))
1140
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1212
+	if (empty($packagesdir)) {
1213
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1214
+	}
1141 1215
 
1142 1216
 	// Add support for $tasksdir var.
1143
-	if (empty($tasksdir))
1144
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1217
+	if (empty($tasksdir)) {
1218
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1219
+	}
1145 1220
 
1146 1221
 	// @todo Maybe change the cookie name if going to 1.1, too?
1147 1222
 
@@ -1186,8 +1261,7 @@  discard block
 block discarded – undo
1186 1261
 			$found_old = true;
1187 1262
 			// Replace the old line with the new code
1188 1263
 			$settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file);
1189
-		}
1190
-		else
1264
+		} else
1191 1265
 		{
1192 1266
 			$found_old = false;
1193 1267
 			// We want the comments as well as the code...
@@ -1218,8 +1292,9 @@  discard block
 block discarded – undo
1218 1292
 		fclose($file);
1219 1293
 	}
1220 1294
 
1221
-	if ($command_line)
1222
-		echo ' Successful.' . "\n";
1295
+	if ($command_line) {
1296
+			echo ' Successful.' . "\n";
1297
+	}
1223 1298
 
1224 1299
 	// Are we doing debug?
1225 1300
 	if (isset($_POST['debug']))
@@ -1229,8 +1304,9 @@  discard block
 block discarded – undo
1229 1304
 	}
1230 1305
 
1231 1306
 	// If we're not backing up then jump one.
1232
-	if (empty($_POST['backup']))
1233
-		$upcontext['current_step']++;
1307
+	if (empty($_POST['backup'])) {
1308
+			$upcontext['current_step']++;
1309
+	}
1234 1310
 
1235 1311
 	// If we've got here then let's proceed to the next step!
1236 1312
 	return true;
@@ -1245,8 +1321,9 @@  discard block
 block discarded – undo
1245 1321
 	$upcontext['page_title'] = 'Backup Database';
1246 1322
 
1247 1323
 	// Done it already - js wise?
1248
-	if (!empty($_POST['backup_done']))
1249
-		return true;
1324
+	if (!empty($_POST['backup_done'])) {
1325
+			return true;
1326
+	}
1250 1327
 
1251 1328
 	// Some useful stuff here.
1252 1329
 	db_extend();
@@ -1260,9 +1337,10 @@  discard block
 block discarded – undo
1260 1337
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1261 1338
 
1262 1339
 	$table_names = array();
1263
-	foreach ($tables as $table)
1264
-		if (substr($table, 0, 7) !== 'backup_')
1340
+	foreach ($tables as $table) {
1341
+			if (substr($table, 0, 7) !== 'backup_')
1265 1342
 			$table_names[] = $table;
1343
+	}
1266 1344
 
1267 1345
 	$upcontext['table_count'] = count($table_names);
1268 1346
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1272,12 +1350,14 @@  discard block
 block discarded – undo
1272 1350
 	$file_steps = $upcontext['table_count'];
1273 1351
 
1274 1352
 	// What ones have we already done?
1275
-	foreach ($table_names as $id => $table)
1276
-		if ($id < $_GET['substep'])
1353
+	foreach ($table_names as $id => $table) {
1354
+			if ($id < $_GET['substep'])
1277 1355
 			$upcontext['previous_tables'][] = $table;
1356
+	}
1278 1357
 
1279
-	if ($command_line)
1280
-		echo 'Backing Up Tables.';
1358
+	if ($command_line) {
1359
+			echo 'Backing Up Tables.';
1360
+	}
1281 1361
 
1282 1362
 	// If we don't support javascript we backup here.
1283 1363
 	if (!$support_js || isset($_GET['xml']))
@@ -1296,8 +1376,9 @@  discard block
 block discarded – undo
1296 1376
 			backupTable($table_names[$substep]);
1297 1377
 
1298 1378
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1299
-			if (isset($_GET['xml']))
1300
-				return upgradeExit();
1379
+			if (isset($_GET['xml'])) {
1380
+							return upgradeExit();
1381
+			}
1301 1382
 		}
1302 1383
 
1303 1384
 		if ($is_debug && $command_line)
@@ -1330,9 +1411,10 @@  discard block
 block discarded – undo
1330 1411
 
1331 1412
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1332 1413
 
1333
-	if ($command_line)
1334
-		echo ' done.';
1335
-}
1414
+	if ($command_line) {
1415
+			echo ' done.';
1416
+	}
1417
+	}
1336 1418
 
1337 1419
 // Step 2: Everything.
1338 1420
 function DatabaseChanges()
@@ -1341,8 +1423,9 @@  discard block
 block discarded – undo
1341 1423
 	global $upcontext, $support_js, $db_type;
1342 1424
 
1343 1425
 	// Have we just completed this?
1344
-	if (!empty($_POST['database_done']))
1345
-		return true;
1426
+	if (!empty($_POST['database_done'])) {
1427
+			return true;
1428
+	}
1346 1429
 
1347 1430
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1348 1431
 	$upcontext['page_title'] = 'Database Changes';
@@ -1359,15 +1442,16 @@  discard block
 block discarded – undo
1359 1442
 	);
1360 1443
 
1361 1444
 	// How many files are there in total?
1362
-	if (isset($_GET['filecount']))
1363
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1364
-	else
1445
+	if (isset($_GET['filecount'])) {
1446
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1447
+	} else
1365 1448
 	{
1366 1449
 		$upcontext['file_count'] = 0;
1367 1450
 		foreach ($files as $file)
1368 1451
 		{
1369
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1370
-				$upcontext['file_count']++;
1452
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1453
+							$upcontext['file_count']++;
1454
+			}
1371 1455
 		}
1372 1456
 	}
1373 1457
 
@@ -1377,9 +1461,9 @@  discard block
 block discarded – undo
1377 1461
 	$upcontext['cur_file_num'] = 0;
1378 1462
 	foreach ($files as $file)
1379 1463
 	{
1380
-		if ($did_not_do)
1381
-			$did_not_do--;
1382
-		else
1464
+		if ($did_not_do) {
1465
+					$did_not_do--;
1466
+		} else
1383 1467
 		{
1384 1468
 			$upcontext['cur_file_num']++;
1385 1469
 			$upcontext['cur_file_name'] = $file[0];
@@ -1406,12 +1490,13 @@  discard block
 block discarded – undo
1406 1490
 					// Flag to move on to the next.
1407 1491
 					$upcontext['completed_step'] = true;
1408 1492
 					// Did we complete the whole file?
1409
-					if ($nextFile)
1410
-						$upcontext['current_debug_item_num'] = -1;
1493
+					if ($nextFile) {
1494
+											$upcontext['current_debug_item_num'] = -1;
1495
+					}
1411 1496
 					return upgradeExit();
1497
+				} elseif ($support_js) {
1498
+									break;
1412 1499
 				}
1413
-				elseif ($support_js)
1414
-					break;
1415 1500
 			}
1416 1501
 			// Set the progress bar to be right as if we had - even if we hadn't...
1417 1502
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1435,8 +1520,9 @@  discard block
 block discarded – undo
1435 1520
 	global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line;
1436 1521
 
1437 1522
 	// Sorry. Not supported for command line users.
1438
-	if ($command_line)
1439
-		return true;
1523
+	if ($command_line) {
1524
+			return true;
1525
+	}
1440 1526
 
1441 1527
 	// Skipping first?
1442 1528
 	if (!empty($_POST['skip']))
@@ -1446,8 +1532,9 @@  discard block
 block discarded – undo
1446 1532
 	}
1447 1533
 
1448 1534
 	// If we get here withOUT SSI we need to redirect to ensure we get it!
1449
-	if (!isset($_GET['ssi']) || !function_exists('mktree'))
1450
-		redirectLocation('&ssi=1');
1535
+	if (!isset($_GET['ssi']) || !function_exists('mktree')) {
1536
+			redirectLocation('&ssi=1');
1537
+	}
1451 1538
 
1452 1539
 	$upcontext['sub_template'] = 'clean_mods';
1453 1540
 	$upcontext['page_title'] = 'Cleanup Modifications';
@@ -1456,8 +1543,9 @@  discard block
 block discarded – undo
1456 1543
 	$upcontext['skip'] = true;
1457 1544
 
1458 1545
 	// If we're on the second redirect continue...
1459
-	if (isset($_POST['cleandone2']))
1460
-		return true;
1546
+	if (isset($_POST['cleandone2'])) {
1547
+			return true;
1548
+	}
1461 1549
 
1462 1550
 	// Do we already know about some writable files?
1463 1551
 	if (isset($_POST['writable_files']))
@@ -1472,8 +1560,9 @@  discard block
 block discarded – undo
1472 1560
 	}
1473 1561
 
1474 1562
 	// Make sure we have some sort of packages directory.
1475
-	if (!isset($packagesdir))
1476
-		$packagesdir = $boarddir . '/Packages';
1563
+	if (!isset($packagesdir)) {
1564
+			$packagesdir = $boarddir . '/Packages';
1565
+	}
1477 1566
 
1478 1567
 	// Load all theme paths....
1479 1568
 	$request = $smcFunc['db_query']('', '
@@ -1491,10 +1580,11 @@  discard block
 block discarded – undo
1491 1580
 	$theme_paths = array();
1492 1581
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1493 1582
 	{
1494
-		if ($row['id_theme'] == 1)
1495
-			$settings['default_' . $row['variable']] = $row['value'];
1496
-		elseif ($row['variable'] == 'theme_dir')
1497
-			$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1583
+		if ($row['id_theme'] == 1) {
1584
+					$settings['default_' . $row['variable']] = $row['value'];
1585
+		} elseif ($row['variable'] == 'theme_dir') {
1586
+					$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1587
+		}
1498 1588
 	}
1499 1589
 	$smcFunc['db_free_result']($request);
1500 1590
 
@@ -1518,8 +1608,7 @@  discard block
 block discarded – undo
1518 1608
 			$status = 'Missing';
1519 1609
 			$status_color = 'red';
1520 1610
 			$result = 'Removed';
1521
-		}
1522
-		else
1611
+		} else
1523 1612
 		{
1524 1613
 			$status = 'Installed';
1525 1614
 			$status_color = 'green';
@@ -1544,12 +1633,14 @@  discard block
 block discarded – undo
1544 1633
 	$smcFunc['db_free_result']($request);
1545 1634
 
1546 1635
 	// Don't carry on if there are none.
1547
-	if (empty($upcontext['packages']))
1548
-		return true;
1636
+	if (empty($upcontext['packages'])) {
1637
+			return true;
1638
+	}
1549 1639
 
1550 1640
 	// Setup some basics.
1551
-	if (!empty($upcontext['user']['version']))
1552
-		$_SESSION['version_emulate'] = $upcontext['user']['version'];
1641
+	if (!empty($upcontext['user']['version'])) {
1642
+			$_SESSION['version_emulate'] = $upcontext['user']['version'];
1643
+	}
1553 1644
 
1554 1645
 	// Before we get started, don't report notice errors.
1555 1646
 	$oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE);
@@ -1572,34 +1663,40 @@  discard block
 block discarded – undo
1572 1663
 	foreach ($upcontext['packages'] as $id => $package)
1573 1664
 	{
1574 1665
 		// Can't do anything about this....
1575
-		if ($package['missing_file'])
1576
-			continue;
1666
+		if ($package['missing_file']) {
1667
+					continue;
1668
+		}
1577 1669
 
1578 1670
 		// Not testing *and* this wasn't checked?
1579
-		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id])))
1580
-			continue;
1671
+		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) {
1672
+					continue;
1673
+		}
1581 1674
 
1582 1675
 		// What are the themes this was installed into?
1583 1676
 		$cur_theme_paths = array();
1584
-		foreach ($theme_paths as $tid => $data)
1585
-			if ($tid != 1 && in_array($tid, $package['themes']))
1677
+		foreach ($theme_paths as $tid => $data) {
1678
+					if ($tid != 1 && in_array($tid, $package['themes']))
1586 1679
 				$cur_theme_paths[$tid] = $data;
1680
+		}
1587 1681
 
1588 1682
 		// Get the modifications data if applicable.
1589 1683
 		$filename = $package['filename'];
1590 1684
 		$packageInfo = getPackageInfo($filename);
1591
-		if (!is_array($packageInfo))
1592
-			continue;
1685
+		if (!is_array($packageInfo)) {
1686
+					continue;
1687
+		}
1593 1688
 
1594 1689
 		$info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall');
1595 1690
 		// Also get the reinstall details...
1596
-		if (isset($_POST['remove']))
1597
-			$infoInstall = parsePackageInfo($packageInfo['xml'], true);
1691
+		if (isset($_POST['remove'])) {
1692
+					$infoInstall = parsePackageInfo($packageInfo['xml'], true);
1693
+		}
1598 1694
 
1599
-		if (is_file($packagesdir . '/' . $filename))
1600
-			read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1601
-		else
1602
-			copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1695
+		if (is_file($packagesdir . '/' . $filename)) {
1696
+					read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1697
+		} else {
1698
+					copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1699
+		}
1603 1700
 
1604 1701
 		// Work out how we uninstall...
1605 1702
 		$files = array();
@@ -1611,16 +1708,18 @@  discard block
 block discarded – undo
1611 1708
 			if ($change['type'] == 'modification')
1612 1709
 			{
1613 1710
 				$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1614
-				if ($change['boardmod'])
1615
-					$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
1616
-				else
1617
-					$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
1711
+				if ($change['boardmod']) {
1712
+									$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
1713
+				} else {
1714
+									$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
1715
+				}
1618 1716
 
1619 1717
 				foreach ($results as $action)
1620 1718
 				{
1621 1719
 					// Something we can remove? Probably means it existed!
1622
-					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files))
1623
-						$files[] = $action['filename'];
1720
+					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) {
1721
+											$files[] = $action['filename'];
1722
+					}
1624 1723
 					if ($action['type'] == 'failure')
1625 1724
 					{
1626 1725
 						$upcontext['packages'][$id]['needs_removing'] = true;
@@ -1636,17 +1735,19 @@  discard block
 block discarded – undo
1636 1735
 		$upcontext['packages'][$id]['file_count'] = count($files);
1637 1736
 
1638 1737
 		// If we've done something save the changes!
1639
-		if (!$test)
1640
-			package_flush_cache();
1738
+		if (!$test) {
1739
+					package_flush_cache();
1740
+		}
1641 1741
 
1642 1742
 		// Are we attempting to reinstall this thing?
1643 1743
 		if (isset($_POST['remove']) && !$test && isset($infoInstall))
1644 1744
 		{
1645 1745
 			// Need to extract again I'm afraid.
1646
-			if (is_file($packagesdir . '/' . $filename))
1647
-				read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1648
-			else
1649
-				copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1746
+			if (is_file($packagesdir . '/' . $filename)) {
1747
+							read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1748
+			} else {
1749
+							copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1750
+			}
1650 1751
 
1651 1752
 			$errors = false;
1652 1753
 			$upcontext['packages'][$id]['result'] = 'Removed';
@@ -1655,15 +1756,17 @@  discard block
 block discarded – undo
1655 1756
 				if ($change['type'] == 'modification')
1656 1757
 				{
1657 1758
 					$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1658
-					if ($change['boardmod'])
1659
-						$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
1660
-					else
1661
-						$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
1759
+					if ($change['boardmod']) {
1760
+											$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
1761
+					} else {
1762
+											$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
1763
+					}
1662 1764
 
1663 1765
 					// Are there any errors?
1664
-					foreach ($results as $action)
1665
-						if ($action['type'] == 'failure')
1766
+					foreach ($results as $action) {
1767
+											if ($action['type'] == 'failure')
1666 1768
 							$errors = true;
1769
+					}
1667 1770
 				}
1668 1771
 			}
1669 1772
 			if (!$errors)
@@ -1676,10 +1779,11 @@  discard block
 block discarded – undo
1676 1779
 					if ($change['type'] == 'modification')
1677 1780
 					{
1678 1781
 						$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1679
-						if ($change['boardmod'])
1680
-							$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
1681
-						else
1682
-							$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
1782
+						if ($change['boardmod']) {
1783
+													$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
1784
+						} else {
1785
+													$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
1786
+						}
1683 1787
 					}
1684 1788
 				}
1685 1789
 
@@ -1698,9 +1802,10 @@  discard block
 block discarded – undo
1698 1802
 		$writable_files = array();
1699 1803
 		foreach ($upcontext['packages'] as $package)
1700 1804
 		{
1701
-			if (!empty($package['files']))
1702
-				foreach ($package['files'] as $file)
1805
+			if (!empty($package['files'])) {
1806
+							foreach ($package['files'] as $file)
1703 1807
 					$writable_files[] = $file;
1808
+			}
1704 1809
 		}
1705 1810
 
1706 1811
 		if (!empty($writable_files))
@@ -1708,13 +1813,15 @@  discard block
 block discarded – undo
1708 1813
 			$writable_files = array_unique($writable_files);
1709 1814
 			$upcontext['writable_files'] = $writable_files;
1710 1815
 
1711
-			if (!makeFilesWritable($writable_files))
1712
-				return false;
1816
+			if (!makeFilesWritable($writable_files)) {
1817
+							return false;
1818
+			}
1713 1819
 		}
1714 1820
 	}
1715 1821
 
1716
-	if (file_exists($packagesdir . '/temp'))
1717
-		deltree($packagesdir . '/temp');
1822
+	if (file_exists($packagesdir . '/temp')) {
1823
+			deltree($packagesdir . '/temp');
1824
+	}
1718 1825
 
1719 1826
 	// Removing/Reinstalling any packages?
1720 1827
 	if (isset($_POST['remove']))
@@ -1722,32 +1829,35 @@  discard block
 block discarded – undo
1722 1829
 		$deletes = array();
1723 1830
 		foreach ($_POST['remove'] as $id => $dummy)
1724 1831
 		{
1725
-			if (!in_array((int) $id, $reinstall_worked))
1726
-				$deletes[] = (int) $id;
1832
+			if (!in_array((int) $id, $reinstall_worked)) {
1833
+							$deletes[] = (int) $id;
1834
+			}
1727 1835
 		}
1728 1836
 
1729
-		if (!empty($deletes))
1730
-			upgrade_query( '
1837
+		if (!empty($deletes)) {
1838
+					upgrade_query( '
1731 1839
 				UPDATE ' . $db_prefix . 'log_packages
1732 1840
 				SET install_state = 0
1733 1841
 				WHERE id_install IN (' . implode(',', $deletes) . ')');
1842
+		}
1734 1843
 
1735 1844
 		// Ensure we don't lose our changes!
1736 1845
 		package_put_contents($packagesdir . '/installed.list', time());
1737 1846
 
1738 1847
 		$upcontext['sub_template'] = 'cleanup_done';
1739 1848
 		return false;
1740
-	}
1741
-	else
1849
+	} else
1742 1850
 	{
1743 1851
 		$allgood = true;
1744 1852
 		// Is there actually anything that needs our attention?
1745
-		foreach ($upcontext['packages'] as $package)
1746
-			if ($package['color'] != 'green')
1853
+		foreach ($upcontext['packages'] as $package) {
1854
+					if ($package['color'] != 'green')
1747 1855
 				$allgood = false;
1856
+		}
1748 1857
 
1749
-		if ($allgood)
1750
-			return true;
1858
+		if ($allgood) {
1859
+					return true;
1860
+		}
1751 1861
 	}
1752 1862
 
1753 1863
 	$_GET['substep'] = 0;
@@ -1761,8 +1871,9 @@  discard block
 block discarded – undo
1761 1871
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1762 1872
 
1763 1873
 	// Now it's nice to have some of the basic SMF source files.
1764
-	if (!isset($_GET['ssi']) && !$command_line)
1765
-		redirectLocation('&ssi=1');
1874
+	if (!isset($_GET['ssi']) && !$command_line) {
1875
+			redirectLocation('&ssi=1');
1876
+	}
1766 1877
 
1767 1878
 	$upcontext['sub_template'] = 'upgrade_complete';
1768 1879
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1778,14 +1889,16 @@  discard block
 block discarded – undo
1778 1889
 	// Are we in maintenance mode?
1779 1890
 	if (isset($upcontext['user']['main']))
1780 1891
 	{
1781
-		if ($command_line)
1782
-			echo ' * ';
1892
+		if ($command_line) {
1893
+					echo ' * ';
1894
+		}
1783 1895
 		$upcontext['removed_maintenance'] = true;
1784 1896
 		$changes['maintenance'] = $upcontext['user']['main'];
1785 1897
 	}
1786 1898
 	// Otherwise if somehow we are in 2 let's go to 1.
1787
-	elseif (!empty($maintenance) && $maintenance == 2)
1788
-		$changes['maintenance'] = 1;
1899
+	elseif (!empty($maintenance) && $maintenance == 2) {
1900
+			$changes['maintenance'] = 1;
1901
+	}
1789 1902
 
1790 1903
 	// Wipe this out...
1791 1904
 	$upcontext['user'] = array();
@@ -1801,9 +1914,9 @@  discard block
 block discarded – undo
1801 1914
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1802 1915
 
1803 1916
 	// Now is the perfect time to fetch the SM files.
1804
-	if ($command_line)
1805
-		cli_scheduled_fetchSMfiles();
1806
-	else
1917
+	if ($command_line) {
1918
+			cli_scheduled_fetchSMfiles();
1919
+	} else
1807 1920
 	{
1808 1921
 		require_once($sourcedir . '/ScheduledTasks.php');
1809 1922
 		$forum_version = SMF_VERSION;  // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1811,8 +1924,9 @@  discard block
 block discarded – undo
1811 1924
 	}
1812 1925
 
1813 1926
 	// Log what we've done.
1814
-	if (empty($user_info['id']))
1815
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1927
+	if (empty($user_info['id'])) {
1928
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1929
+	}
1816 1930
 
1817 1931
 	// Log the action manually, so CLI still works.
1818 1932
 	$smcFunc['db_insert']('',
@@ -1831,8 +1945,9 @@  discard block
 block discarded – undo
1831 1945
 
1832 1946
 	// Save the current database version.
1833 1947
 	$server_version = $smcFunc['db_server_info']();
1834
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1835
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1948
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1949
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1950
+	}
1836 1951
 
1837 1952
 	if ($command_line)
1838 1953
 	{
@@ -1844,8 +1959,9 @@  discard block
 block discarded – undo
1844 1959
 
1845 1960
 	// Make sure it says we're done.
1846 1961
 	$upcontext['overall_percent'] = 100;
1847
-	if (isset($upcontext['step_progress']))
1848
-		unset($upcontext['step_progress']);
1962
+	if (isset($upcontext['step_progress'])) {
1963
+			unset($upcontext['step_progress']);
1964
+	}
1849 1965
 
1850 1966
 	$_GET['substep'] = 0;
1851 1967
 	return false;
@@ -1856,8 +1972,9 @@  discard block
 block discarded – undo
1856 1972
 {
1857 1973
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1858 1974
 
1859
-	if (empty($modSettings['time_format']))
1860
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1975
+	if (empty($modSettings['time_format'])) {
1976
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1977
+	}
1861 1978
 
1862 1979
 	// What files do we want to get
1863 1980
 	$request = $smcFunc['db_query']('', '
@@ -1891,8 +2008,9 @@  discard block
 block discarded – undo
1891 2008
 		$file_data = fetch_web_data($url);
1892 2009
 
1893 2010
 		// If we got an error - give up - the site might be down.
1894
-		if ($file_data === false)
1895
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
2011
+		if ($file_data === false) {
2012
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
2013
+		}
1896 2014
 
1897 2015
 		// Save the file to the database.
1898 2016
 		$smcFunc['db_query']('substring', '
@@ -1934,8 +2052,9 @@  discard block
 block discarded – undo
1934 2052
 	$themeData = array();
1935 2053
 	foreach ($values as $variable => $value)
1936 2054
 	{
1937
-		if (!isset($value) || $value === null)
1938
-			$value = 0;
2055
+		if (!isset($value) || $value === null) {
2056
+					$value = 0;
2057
+		}
1939 2058
 
1940 2059
 		$themeData[] = array(0, 1, $variable, $value);
1941 2060
 	}
@@ -1964,8 +2083,9 @@  discard block
 block discarded – undo
1964 2083
 
1965 2084
 	foreach ($values as $variable => $value)
1966 2085
 	{
1967
-		if (empty($modSettings[$value[0]]))
1968
-			continue;
2086
+		if (empty($modSettings[$value[0]])) {
2087
+					continue;
2088
+		}
1969 2089
 
1970 2090
 		$smcFunc['db_query']('', '
1971 2091
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1998,8 +2118,9 @@  discard block
 block discarded – undo
1998 2118
 
1999 2119
 	$settingsArray = file($boarddir . '/Settings_bak.php');
2000 2120
 
2001
-	if (count($settingsArray) == 1)
2002
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2121
+	if (count($settingsArray) == 1) {
2122
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2123
+	}
2003 2124
 
2004 2125
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
2005 2126
 	{
@@ -2012,9 +2133,9 @@  discard block
 block discarded – undo
2012 2133
 			{
2013 2134
 				if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
2014 2135
 				{
2015
-					if ($val == '#remove#')
2016
-						unset($settingsArray[$i]);
2017
-					else
2136
+					if ($val == '#remove#') {
2137
+											unset($settingsArray[$i]);
2138
+					} else
2018 2139
 					{
2019 2140
 						$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
2020 2141
 						$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n");
@@ -2026,22 +2147,25 @@  discard block
 block discarded – undo
2026 2147
 		}
2027 2148
 		if (isset($settingsArray[$i]))
2028 2149
 		{
2029
-			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>')
2030
-				$end = $i;
2150
+			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') {
2151
+							$end = $i;
2152
+			}
2031 2153
 		}
2032 2154
 	}
2033 2155
 
2034 2156
 	// Assume end-of-file if the end wasn't found.
2035
-	if (empty($end) || $end < 10)
2036
-		$end = count($settingsArray);
2157
+	if (empty($end) || $end < 10) {
2158
+			$end = count($settingsArray);
2159
+	}
2037 2160
 
2038 2161
 	if (!empty($config_vars))
2039 2162
 	{
2040 2163
 		$settingsArray[$end++] = '';
2041 2164
 		foreach ($config_vars as $var => $val)
2042 2165
 		{
2043
-			if ($val != '#remove#')
2044
-				$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2166
+			if ($val != '#remove#') {
2167
+							$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2168
+			}
2045 2169
 		}
2046 2170
 	}
2047 2171
 	// This should be the last line and even last bytes of the file.
@@ -2054,8 +2178,9 @@  discard block
 block discarded – undo
2054 2178
 	$fp = fopen($boarddir . '/Settings.php', 'r+');
2055 2179
 	for ($i = 0; $i < $end; $i++)
2056 2180
 	{
2057
-		if (isset($settingsArray[$i]))
2058
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2181
+		if (isset($settingsArray[$i])) {
2182
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2183
+		}
2059 2184
 	}
2060 2185
 	fwrite($fp, rtrim($settingsArray[$i]));
2061 2186
 	fclose($fp);
@@ -2086,8 +2211,9 @@  discard block
 block discarded – undo
2086 2211
 	global $smcFunc;
2087 2212
 	static $member_groups = array();
2088 2213
 
2089
-	if (!empty($member_groups))
2090
-		return $member_groups;
2214
+	if (!empty($member_groups)) {
2215
+			return $member_groups;
2216
+	}
2091 2217
 
2092 2218
 	$request = $smcFunc['db_query']('', '
2093 2219
 		SELECT group_name, id_group
@@ -2112,8 +2238,9 @@  discard block
 block discarded – undo
2112 2238
 			)
2113 2239
 		);
2114 2240
 	}
2115
-	while ($row = $smcFunc['db_fetch_row']($request))
2116
-		$member_groups[trim($row[0])] = $row[1];
2241
+	while ($row = $smcFunc['db_fetch_row']($request)) {
2242
+			$member_groups[trim($row[0])] = $row[1];
2243
+	}
2117 2244
 	$smcFunc['db_free_result']($request);
2118 2245
 
2119 2246
 	return $member_groups;
@@ -2166,10 +2293,11 @@  discard block
 block discarded – undo
2166 2293
 		{
2167 2294
 			global $support_js;
2168 2295
 
2169
-			if ($support_js)
2170
-				return true;
2171
-			else
2172
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2296
+			if ($support_js) {
2297
+							return true;
2298
+			} else {
2299
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2300
+			}
2173 2301
 		}
2174 2302
 	}
2175 2303
 
@@ -2187,8 +2315,9 @@  discard block
 block discarded – undo
2187 2315
 				'db_error_skip' => true,
2188 2316
 			)
2189 2317
 		);
2190
-		if ($smcFunc['db_num_rows']($request) === 0)
2191
-			die('Unable to find members table!');
2318
+		if ($smcFunc['db_num_rows']($request) === 0) {
2319
+					die('Unable to find members table!');
2320
+		}
2192 2321
 		$table_status = $smcFunc['db_fetch_assoc']($request);
2193 2322
 		$smcFunc['db_free_result']($request);
2194 2323
 
@@ -2203,17 +2332,20 @@  discard block
 block discarded – undo
2203 2332
 				)
2204 2333
 			);
2205 2334
 			// Got something?
2206
-			if ($smcFunc['db_num_rows']($request) !== 0)
2207
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
2335
+			if ($smcFunc['db_num_rows']($request) !== 0) {
2336
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
2337
+			}
2208 2338
 			$smcFunc['db_free_result']($request);
2209 2339
 
2210 2340
 			// Excellent!
2211
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
2212
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2341
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
2342
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2343
+			}
2213 2344
 		}
2214 2345
 	}
2215
-	if (empty($db_collation))
2216
-		$db_collation = '';
2346
+	if (empty($db_collation)) {
2347
+			$db_collation = '';
2348
+	}
2217 2349
 
2218 2350
 	$endl = $command_line ? "\n" : '<br>' . "\n";
2219 2351
 
@@ -2225,8 +2357,9 @@  discard block
 block discarded – undo
2225 2357
 	$last_step = '';
2226 2358
 
2227 2359
 	// Make sure all newly created tables will have the proper characters set.
2228
-	if (isset($db_character_set) && $db_character_set === 'utf8')
2229
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2360
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
2361
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2362
+	}
2230 2363
 
2231 2364
 	// Count the total number of steps within this file - for progress.
2232 2365
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -2246,15 +2379,18 @@  discard block
 block discarded – undo
2246 2379
 		$do_current = $substep >= $_GET['substep'];
2247 2380
 
2248 2381
 		// Get rid of any comments in the beginning of the line...
2249
-		if (substr(trim($line), 0, 2) === '/*')
2250
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
2382
+		if (substr(trim($line), 0, 2) === '/*') {
2383
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
2384
+		}
2251 2385
 
2252 2386
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
2253
-		if ($is_debug && !$support_js && $command_line)
2254
-			flush();
2387
+		if ($is_debug && !$support_js && $command_line) {
2388
+					flush();
2389
+		}
2255 2390
 
2256
-		if (trim($line) === '')
2257
-			continue;
2391
+		if (trim($line) === '') {
2392
+					continue;
2393
+		}
2258 2394
 
2259 2395
 		if (trim(substr($line, 0, 3)) === '---')
2260 2396
 		{
@@ -2264,8 +2400,9 @@  discard block
 block discarded – undo
2264 2400
 			if (trim($current_data) != '' && $type !== '}')
2265 2401
 			{
2266 2402
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
2267
-				if ($command_line)
2268
-					echo $upcontext['error_message'];
2403
+				if ($command_line) {
2404
+									echo $upcontext['error_message'];
2405
+				}
2269 2406
 			}
2270 2407
 
2271 2408
 			if ($type == ' ')
@@ -2283,17 +2420,18 @@  discard block
 block discarded – undo
2283 2420
 				if ($do_current)
2284 2421
 				{
2285 2422
 					$upcontext['actioned_items'][] = $last_step;
2286
-					if ($command_line)
2287
-						echo ' * ';
2423
+					if ($command_line) {
2424
+											echo ' * ';
2425
+					}
2288 2426
 				}
2289
-			}
2290
-			elseif ($type == '#')
2427
+			} elseif ($type == '#')
2291 2428
 			{
2292 2429
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
2293 2430
 
2294 2431
 				$upcontext['current_debug_item_num']++;
2295
-				if (trim($line) != '---#')
2296
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2432
+				if (trim($line) != '---#') {
2433
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2434
+				}
2297 2435
 
2298 2436
 				// Have we already done something?
2299 2437
 				if (isset($_GET['xml']) && $done_something)
@@ -2304,34 +2442,36 @@  discard block
 block discarded – undo
2304 2442
 
2305 2443
 				if ($do_current)
2306 2444
 				{
2307
-					if (trim($line) == '---#' && $command_line)
2308
-						echo ' done.', $endl;
2309
-					elseif ($command_line)
2310
-						echo ' +++ ', rtrim(substr($line, 4));
2311
-					elseif (trim($line) != '---#')
2445
+					if (trim($line) == '---#' && $command_line) {
2446
+											echo ' done.', $endl;
2447
+					} elseif ($command_line) {
2448
+											echo ' +++ ', rtrim(substr($line, 4));
2449
+					} elseif (trim($line) != '---#')
2312 2450
 					{
2313
-						if ($is_debug)
2314
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2451
+						if ($is_debug) {
2452
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2453
+						}
2315 2454
 					}
2316 2455
 				}
2317 2456
 
2318 2457
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
2319 2458
 				{
2320
-					if ($command_line)
2321
-						echo ' * ';
2322
-					else
2323
-						$upcontext['actioned_items'][] = $last_step;
2459
+					if ($command_line) {
2460
+											echo ' * ';
2461
+					} else {
2462
+											$upcontext['actioned_items'][] = $last_step;
2463
+					}
2324 2464
 				}
2325 2465
 
2326 2466
 				// Small step - only if we're actually doing stuff.
2327
-				if ($do_current)
2328
-					nextSubstep(++$substep);
2329
-				else
2330
-					$substep++;
2331
-			}
2332
-			elseif ($type == '{')
2333
-				$current_type = 'code';
2334
-			elseif ($type == '}')
2467
+				if ($do_current) {
2468
+									nextSubstep(++$substep);
2469
+				} else {
2470
+									$substep++;
2471
+				}
2472
+			} elseif ($type == '{') {
2473
+							$current_type = 'code';
2474
+			} elseif ($type == '}')
2335 2475
 			{
2336 2476
 				$current_type = 'sql';
2337 2477
 
@@ -2344,8 +2484,9 @@  discard block
 block discarded – undo
2344 2484
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
2345 2485
 				{
2346 2486
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
2347
-					if ($command_line)
2348
-						echo $upcontext['error_message'];
2487
+					if ($command_line) {
2488
+											echo $upcontext['error_message'];
2489
+					}
2349 2490
 				}
2350 2491
 
2351 2492
 				// Done with code!
@@ -2425,8 +2566,9 @@  discard block
 block discarded – undo
2425 2566
 	$db_unbuffered = false;
2426 2567
 
2427 2568
 	// Failure?!
2428
-	if ($result !== false)
2429
-		return $result;
2569
+	if ($result !== false) {
2570
+			return $result;
2571
+	}
2430 2572
 
2431 2573
 	$db_error_message = $smcFunc['db_error']($db_connection);
2432 2574
 	// If MySQL we do something more clever.
@@ -2456,17 +2598,16 @@  discard block
 block discarded – undo
2456 2598
 				{
2457 2599
 					mysql_query('REPAIR TABLE `' . $match[1] . '`');
2458 2600
 					$result = mysql_query($string);
2459
-				}
2460
-				else
2601
+				} else
2461 2602
 				{
2462 2603
 					mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2463 2604
 					$result = mysqli_query($db_connection, $string);
2464 2605
 				}
2465
-				if ($result !== false)
2466
-					return $result;
2606
+				if ($result !== false) {
2607
+									return $result;
2608
+				}
2467 2609
 			}
2468
-		}
2469
-		elseif ($mysql_errno == 2013)
2610
+		} elseif ($mysql_errno == 2013)
2470 2611
 		{
2471 2612
 			$db_connection = mysql_connect($db_server, $db_user, $db_passwd);
2472 2613
 			if ($db_type == 'mysql')
@@ -2475,54 +2616,61 @@  discard block
 block discarded – undo
2475 2616
 				if ($db_connection)
2476 2617
 				{
2477 2618
 					$result = mysql_query($string);
2478
-					if ($result !== false)
2479
-						return $result;
2619
+					if ($result !== false) {
2620
+											return $result;
2621
+					}
2480 2622
 				}
2481
-			}
2482
-			else
2623
+			} else
2483 2624
 			{
2484 2625
 				mysqli_select_db($db_connection, $db_name);
2485 2626
 				if ($db_connection)
2486 2627
 				{
2487 2628
 					$result = mysqli_query($db_connection, $string);
2488
-					if ($result !== false)
2489
-						return $result;
2629
+					if ($result !== false) {
2630
+											return $result;
2631
+					}
2490 2632
 				}
2491 2633
 			}
2492 2634
 		}
2493 2635
 		// Duplicate column name... should be okay ;).
2494
-		elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091)))
2495
-			return false;
2636
+		elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091))) {
2637
+					return false;
2638
+		}
2496 2639
 		// Duplicate insert... make sure it's the proper type of query ;).
2497
-		elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query)
2498
-			return false;
2640
+		elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query) {
2641
+					return false;
2642
+		}
2499 2643
 		// Creating an index on a non-existent column.
2500
-		elseif ($mysql_errno == 1072)
2501
-			return false;
2502
-		elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2503
-			return false;
2644
+		elseif ($mysql_errno == 1072) {
2645
+					return false;
2646
+		} elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2647
+					return false;
2648
+		}
2504 2649
 	}
2505 2650
 	// If a table already exists don't go potty.
2506 2651
 	else
2507 2652
 	{
2508 2653
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2509 2654
 		{
2510
-			if (strpos($db_error_message, 'exist') !== false)
2511
-				return true;
2512
-		}
2513
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2655
+			if (strpos($db_error_message, 'exist') !== false) {
2656
+							return true;
2657
+			}
2658
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2514 2659
 		{
2515
-			if (strpos($db_error_message, 'duplicate') !== false)
2516
-				return true;
2660
+			if (strpos($db_error_message, 'duplicate') !== false) {
2661
+							return true;
2662
+			}
2517 2663
 		}
2518 2664
 	}
2519 2665
 
2520 2666
 	// Get the query string so we pass everything.
2521 2667
 	$query_string = '';
2522
-	foreach ($_GET as $k => $v)
2523
-		$query_string .= ';' . $k . '=' . $v;
2524
-	if (strlen($query_string) != 0)
2525
-		$query_string = '?' . substr($query_string, 1);
2668
+	foreach ($_GET as $k => $v) {
2669
+			$query_string .= ';' . $k . '=' . $v;
2670
+	}
2671
+	if (strlen($query_string) != 0) {
2672
+			$query_string = '?' . substr($query_string, 1);
2673
+	}
2526 2674
 
2527 2675
 	if ($command_line)
2528 2676
 	{
@@ -2613,16 +2761,18 @@  discard block
 block discarded – undo
2613 2761
 			{
2614 2762
 				$found |= 1;
2615 2763
 				// Do some checks on the data if we have it set.
2616
-				if (isset($change['col_type']))
2617
-					$found &= $change['col_type'] === $column['type'];
2618
-				if (isset($change['null_allowed']))
2619
-					$found &= $column['null'] == $change['null_allowed'];
2620
-				if (isset($change['default']))
2621
-					$found &= $change['default'] === $column['default'];
2764
+				if (isset($change['col_type'])) {
2765
+									$found &= $change['col_type'] === $column['type'];
2766
+				}
2767
+				if (isset($change['null_allowed'])) {
2768
+									$found &= $column['null'] == $change['null_allowed'];
2769
+				}
2770
+				if (isset($change['default'])) {
2771
+									$found &= $change['default'] === $column['default'];
2772
+				}
2622 2773
 			}
2623 2774
 		}
2624
-	}
2625
-	elseif ($change['type'] === 'index')
2775
+	} elseif ($change['type'] === 'index')
2626 2776
 	{
2627 2777
 		$request = upgrade_query( '
2628 2778
 			SHOW INDEX
@@ -2631,9 +2781,10 @@  discard block
 block discarded – undo
2631 2781
 		{
2632 2782
 			$cur_index = array();
2633 2783
 
2634
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2635
-				if ($row['Key_name'] === $change['name'])
2784
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2785
+							if ($row['Key_name'] === $change['name'])
2636 2786
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2787
+			}
2637 2788
 
2638 2789
 			ksort($cur_index, SORT_NUMERIC);
2639 2790
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2643,14 +2794,17 @@  discard block
 block discarded – undo
2643 2794
 	}
2644 2795
 
2645 2796
 	// If we're trying to add and it's added, we're done.
2646
-	if ($found && in_array($change['method'], array('add', 'change')))
2647
-		return true;
2797
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2798
+			return true;
2799
+	}
2648 2800
 	// Otherwise if we're removing and it wasn't found we're also done.
2649
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2650
-		return true;
2801
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2802
+			return true;
2803
+	}
2651 2804
 	// Otherwise is it just a test?
2652
-	elseif ($is_test)
2653
-		return false;
2805
+	elseif ($is_test) {
2806
+			return false;
2807
+	}
2654 2808
 
2655 2809
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2656 2810
 	$running = false;
@@ -2661,8 +2815,9 @@  discard block
 block discarded – undo
2661 2815
 			SHOW FULL PROCESSLIST');
2662 2816
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2663 2817
 		{
2664
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2665
-				$found = true;
2818
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2819
+							$found = true;
2820
+			}
2666 2821
 		}
2667 2822
 
2668 2823
 		// Can't find it? Then we need to run it fools!
@@ -2674,8 +2829,9 @@  discard block
 block discarded – undo
2674 2829
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2675 2830
 				' . $change['text'], true) !== false;
2676 2831
 
2677
-			if (!$success)
2678
-				return false;
2832
+			if (!$success) {
2833
+							return false;
2834
+			}
2679 2835
 
2680 2836
 			// Return
2681 2837
 			$running = true;
@@ -2708,8 +2864,7 @@  discard block
 block discarded – undo
2708 2864
 	{
2709 2865
 		$column_fix = true;
2710 2866
 		$null_fix = !$change['null_allowed'];
2711
-	}
2712
-	else
2867
+	} else
2713 2868
 	{
2714 2869
 		$request = $smcFunc['db_query']('', '
2715 2870
 			SHOW FULL COLUMNS
@@ -2720,8 +2875,9 @@  discard block
 block discarded – undo
2720 2875
 				'db_error_skip' => true,
2721 2876
 			)
2722 2877
 		);
2723
-		if ($smcFunc['db_num_rows']($request) === 0)
2724
-			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2878
+		if ($smcFunc['db_num_rows']($request) === 0) {
2879
+					die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2880
+		}
2725 2881
 		$table_row = $smcFunc['db_fetch_assoc']($request);
2726 2882
 		$smcFunc['db_free_result']($request);
2727 2883
 
@@ -2743,10 +2899,11 @@  discard block
 block discarded – undo
2743 2899
 				)
2744 2900
 			);
2745 2901
 			// No results? Just forget it all together.
2746
-			if ($smcFunc['db_num_rows']($request) === 0)
2747
-				unset($table_row['Collation']);
2748
-			else
2749
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
2902
+			if ($smcFunc['db_num_rows']($request) === 0) {
2903
+							unset($table_row['Collation']);
2904
+			} else {
2905
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
2906
+			}
2750 2907
 			$smcFunc['db_free_result']($request);
2751 2908
 		}
2752 2909
 	}
@@ -2754,8 +2911,8 @@  discard block
 block discarded – undo
2754 2911
 	if ($column_fix)
2755 2912
 	{
2756 2913
 		// Make sure there are no NULL's left.
2757
-		if ($null_fix)
2758
-			$smcFunc['db_query']('', '
2914
+		if ($null_fix) {
2915
+					$smcFunc['db_query']('', '
2759 2916
 				UPDATE {db_prefix}' . $change['table'] . '
2760 2917
 				SET ' . $change['column'] . ' = {string:default}
2761 2918
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2764,6 +2921,7 @@  discard block
 block discarded – undo
2764 2921
 					'db_error_skip' => true,
2765 2922
 				)
2766 2923
 			);
2924
+		}
2767 2925
 
2768 2926
 		// Do the actual alteration.
2769 2927
 		$smcFunc['db_query']('', '
@@ -2792,8 +2950,9 @@  discard block
 block discarded – undo
2792 2950
 	}
2793 2951
 
2794 2952
 	// Not a column we need to check on?
2795
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2796
-		return;
2953
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2954
+			return;
2955
+	}
2797 2956
 
2798 2957
 	// Break it up you (six|seven).
2799 2958
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2812,13 +2971,13 @@  discard block
 block discarded – undo
2812 2971
 				'new_name' => $temp[2],
2813 2972
 		));
2814 2973
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2815
-		if ($smcFunc['db_num_rows'] != 1)
2816
-			return;
2974
+		if ($smcFunc['db_num_rows'] != 1) {
2975
+					return;
2976
+		}
2817 2977
 
2818 2978
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2819 2979
 		$smcFunc['db_free_result']($request);
2820
-	}
2821
-	else
2980
+	} else
2822 2981
 	{
2823 2982
 		// Do this the old fashion, sure method way.
2824 2983
 		$request = $smcFunc['db_query']('', '
@@ -2829,21 +2988,24 @@  discard block
 block discarded – undo
2829 2988
 		));
2830 2989
 		// Mayday!
2831 2990
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2832
-		if ($smcFunc['db_num_rows'] == 0)
2833
-			return;
2991
+		if ($smcFunc['db_num_rows'] == 0) {
2992
+					return;
2993
+		}
2834 2994
 
2835 2995
 		// Oh where, oh where has my little field gone. Oh where can it be...
2836
-		while ($row = $smcFunc['db_query']($request))
2837
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2996
+		while ($row = $smcFunc['db_query']($request)) {
2997
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2838 2998
 			{
2839 2999
 				$current_type = $row['Type'];
3000
+		}
2840 3001
 				break;
2841 3002
 			}
2842 3003
 	}
2843 3004
 
2844 3005
 	// If this doesn't match, the column may of been altered for a reason.
2845
-	if (trim($current_type) != trim($temp[3]))
2846
-		$temp[3] = $current_type;
3006
+	if (trim($current_type) != trim($temp[3])) {
3007
+			$temp[3] = $current_type;
3008
+	}
2847 3009
 
2848 3010
 	// Piece this back together.
2849 3011
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2855,8 +3017,9 @@  discard block
 block discarded – undo
2855 3017
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2856 3018
 	global $step_progress, $is_debug, $upcontext;
2857 3019
 
2858
-	if ($_GET['substep'] < $substep)
2859
-		$_GET['substep'] = $substep;
3020
+	if ($_GET['substep'] < $substep) {
3021
+			$_GET['substep'] = $substep;
3022
+	}
2860 3023
 
2861 3024
 	if ($command_line)
2862 3025
 	{
@@ -2869,29 +3032,33 @@  discard block
 block discarded – undo
2869 3032
 	}
2870 3033
 
2871 3034
 	@set_time_limit(300);
2872
-	if (function_exists('apache_reset_timeout'))
2873
-		@apache_reset_timeout();
3035
+	if (function_exists('apache_reset_timeout')) {
3036
+			@apache_reset_timeout();
3037
+	}
2874 3038
 
2875
-	if (time() - $start_time <= $timeLimitThreshold)
2876
-		return;
3039
+	if (time() - $start_time <= $timeLimitThreshold) {
3040
+			return;
3041
+	}
2877 3042
 
2878 3043
 	// Do we have some custom step progress stuff?
2879 3044
 	if (!empty($step_progress))
2880 3045
 	{
2881 3046
 		$upcontext['substep_progress'] = 0;
2882 3047
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2883
-		if ($step_progress['current'] > $step_progress['total'])
2884
-			$upcontext['substep_progress'] = 99.9;
2885
-		else
2886
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3048
+		if ($step_progress['current'] > $step_progress['total']) {
3049
+					$upcontext['substep_progress'] = 99.9;
3050
+		} else {
3051
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3052
+		}
2887 3053
 
2888 3054
 		// Make it nicely rounded.
2889 3055
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2890 3056
 	}
2891 3057
 
2892 3058
 	// If this is XML we just exit right away!
2893
-	if (isset($_GET['xml']))
2894
-		return upgradeExit();
3059
+	if (isset($_GET['xml'])) {
3060
+			return upgradeExit();
3061
+	}
2895 3062
 
2896 3063
 	// We're going to pause after this!
2897 3064
 	$upcontext['pause'] = true;
@@ -2899,13 +3066,15 @@  discard block
 block discarded – undo
2899 3066
 	$upcontext['query_string'] = '';
2900 3067
 	foreach ($_GET as $k => $v)
2901 3068
 	{
2902
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2903
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
3069
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
3070
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
3071
+		}
2904 3072
 	}
2905 3073
 
2906 3074
 	// Custom warning?
2907
-	if (!empty($custom_warning))
2908
-		$upcontext['custom_warning'] = $custom_warning;
3075
+	if (!empty($custom_warning)) {
3076
+			$upcontext['custom_warning'] = $custom_warning;
3077
+	}
2909 3078
 
2910 3079
 	upgradeExit();
2911 3080
 }
@@ -2920,25 +3089,26 @@  discard block
 block discarded – undo
2920 3089
 	ob_implicit_flush(true);
2921 3090
 	@set_time_limit(600);
2922 3091
 
2923
-	if (!isset($_SERVER['argv']))
2924
-		$_SERVER['argv'] = array();
3092
+	if (!isset($_SERVER['argv'])) {
3093
+			$_SERVER['argv'] = array();
3094
+	}
2925 3095
 	$_GET['maint'] = 1;
2926 3096
 
2927 3097
 	foreach ($_SERVER['argv'] as $i => $arg)
2928 3098
 	{
2929
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2930
-			$_GET['lang'] = $match[1];
2931
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2932
-			continue;
2933
-		elseif ($arg == '--no-maintenance')
2934
-			$_GET['maint'] = 0;
2935
-		elseif ($arg == '--debug')
2936
-			$is_debug = true;
2937
-		elseif ($arg == '--backup')
2938
-			$_POST['backup'] = 1;
2939
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2940
-			$_GET['conv'] = 1;
2941
-		elseif ($i != 0)
3099
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
3100
+					$_GET['lang'] = $match[1];
3101
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
3102
+					continue;
3103
+		} elseif ($arg == '--no-maintenance') {
3104
+					$_GET['maint'] = 0;
3105
+		} elseif ($arg == '--debug') {
3106
+					$is_debug = true;
3107
+		} elseif ($arg == '--backup') {
3108
+					$_POST['backup'] = 1;
3109
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
3110
+					$_GET['conv'] = 1;
3111
+		} elseif ($i != 0)
2942 3112
 		{
2943 3113
 			echo 'SMF Command-line Upgrader
2944 3114
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2952,10 +3122,12 @@  discard block
 block discarded – undo
2952 3122
 		}
2953 3123
 	}
2954 3124
 
2955
-	if (!php_version_check())
2956
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2957
-	if (!db_version_check())
2958
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3125
+	if (!php_version_check()) {
3126
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
3127
+	}
3128
+	if (!db_version_check()) {
3129
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3130
+	}
2959 3131
 
2960 3132
 	// Do some checks to make sure they have proper privileges
2961 3133
 	db_extend('packages');
@@ -2970,34 +3142,39 @@  discard block
 block discarded – undo
2970 3142
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2971 3143
 
2972 3144
 	// Sorry... we need CREATE, ALTER and DROP
2973
-	if (!$create || !$alter || !$drop)
2974
-		print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
3145
+	if (!$create || !$alter || !$drop) {
3146
+			print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
3147
+	}
2975 3148
 
2976 3149
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2977 3150
 		&& @file_exists($sourcedir . '/QueryString.php')
2978 3151
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2979
-	if (!$check && !isset($modSettings['smfVersion']))
2980
-		print_error('Error: Some files are missing or out-of-date.', true);
3152
+	if (!$check && !isset($modSettings['smfVersion'])) {
3153
+			print_error('Error: Some files are missing or out-of-date.', true);
3154
+	}
2981 3155
 
2982 3156
 	// Do a quick version spot check.
2983 3157
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2984 3158
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2985
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2986
-		print_error('Error: Some files have not yet been updated properly.');
3159
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
3160
+			print_error('Error: Some files have not yet been updated properly.');
3161
+	}
2987 3162
 
2988 3163
 	// Make sure Settings.php is writable.
2989 3164
 		quickFileWritable($boarddir . '/Settings.php');
2990
-	if (!is_writable($boarddir . '/Settings.php'))
2991
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
3165
+	if (!is_writable($boarddir . '/Settings.php')) {
3166
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
3167
+	}
2992 3168
 
2993 3169
 	// Make sure Settings_bak.php is writable.
2994 3170
 		quickFileWritable($boarddir . '/Settings_bak.php');
2995
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2996
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3171
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
3172
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3173
+	}
2997 3174
 
2998
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2999
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
3000
-	elseif (isset($modSettings['agreement']))
3175
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
3176
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
3177
+	} elseif (isset($modSettings['agreement']))
3001 3178
 	{
3002 3179
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
3003 3180
 		fwrite($fp, $modSettings['agreement']);
@@ -3007,31 +3184,36 @@  discard block
 block discarded – undo
3007 3184
 	// Make sure Themes is writable.
3008 3185
 	quickFileWritable($modSettings['theme_dir']);
3009 3186
 
3010
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
3011
-		print_error('Error: Unable to obtain write access to "Themes".');
3187
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
3188
+			print_error('Error: Unable to obtain write access to "Themes".');
3189
+	}
3012 3190
 
3013 3191
 	// Make sure cache directory exists and is writable!
3014 3192
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
3015
-	if (!file_exists($cachedir_temp))
3016
-		@mkdir($cachedir_temp);
3193
+	if (!file_exists($cachedir_temp)) {
3194
+			@mkdir($cachedir_temp);
3195
+	}
3017 3196
 
3018 3197
 	// Make sure the cache temp dir is writable.
3019 3198
 	quickFileWritable($cachedir_temp);
3020 3199
 
3021
-	if (!is_writable($cachedir_temp))
3022
-		print_error('Error: Unable to obtain write access to "cache".', true);
3200
+	if (!is_writable($cachedir_temp)) {
3201
+			print_error('Error: Unable to obtain write access to "cache".', true);
3202
+	}
3023 3203
 
3024
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
3025
-		print_error('Error: Unable to find language files!', true);
3026
-	else
3204
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
3205
+			print_error('Error: Unable to find language files!', true);
3206
+	} else
3027 3207
 	{
3028 3208
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
3029 3209
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
3030 3210
 
3031
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
3032
-			print_error('Error: Language files out of date.', true);
3033
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
3034
-			print_error('Error: Install language is missing for selected language.', true);
3211
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
3212
+					print_error('Error: Language files out of date.', true);
3213
+		}
3214
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
3215
+					print_error('Error: Install language is missing for selected language.', true);
3216
+		}
3035 3217
 
3036 3218
 		// Otherwise include it!
3037 3219
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -3046,14 +3228,16 @@  discard block
 block discarded – undo
3046 3228
 {
3047 3229
 	static $fp = null;
3048 3230
 
3049
-	if ($fp === null)
3050
-		$fp = fopen('php://stderr', 'wb');
3231
+	if ($fp === null) {
3232
+			$fp = fopen('php://stderr', 'wb');
3233
+	}
3051 3234
 
3052 3235
 	fwrite($fp, $message . "\n");
3053 3236
 
3054
-	if ($fatal)
3055
-		exit;
3056
-}
3237
+	if ($fatal) {
3238
+			exit;
3239
+	}
3240
+	}
3057 3241
 
3058 3242
 function throw_error($message)
3059 3243
 {
@@ -3070,8 +3254,9 @@  discard block
 block discarded – undo
3070 3254
 {
3071 3255
 	global $upcontext, $boarddir;
3072 3256
 
3073
-	if (empty($files))
3074
-		return true;
3257
+	if (empty($files)) {
3258
+			return true;
3259
+	}
3075 3260
 
3076 3261
 	$failure = false;
3077 3262
 	// On linux, it's easy - just use is_writable!
@@ -3086,14 +3271,16 @@  discard block
 block discarded – undo
3086 3271
 				@chmod($file, 0755);
3087 3272
 
3088 3273
 				// Well, 755 hopefully worked... if not, try 777.
3089
-				if (!is_writable($file) && !@chmod($file, 0777))
3090
-					$failure = true;
3274
+				if (!is_writable($file) && !@chmod($file, 0777)) {
3275
+									$failure = true;
3276
+				}
3091 3277
 				// Otherwise remove it as it's good!
3092
-				else
3093
-					unset($files[$k]);
3278
+				else {
3279
+									unset($files[$k]);
3280
+				}
3281
+			} else {
3282
+							unset($files[$k]);
3094 3283
 			}
3095
-			else
3096
-				unset($files[$k]);
3097 3284
 		}
3098 3285
 	}
3099 3286
 	// Windows is trickier.  Let's try opening for r+...
@@ -3104,30 +3291,35 @@  discard block
 block discarded – undo
3104 3291
 		foreach ($files as $k => $file)
3105 3292
 		{
3106 3293
 			// Folders can't be opened for write... but the index.php in them can ;).
3107
-			if (is_dir($file))
3108
-				$file .= '/index.php';
3294
+			if (is_dir($file)) {
3295
+							$file .= '/index.php';
3296
+			}
3109 3297
 
3110 3298
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
3111 3299
 			@chmod($file, 0777);
3112 3300
 			$fp = @fopen($file, 'r+');
3113 3301
 
3114 3302
 			// Hmm, okay, try just for write in that case...
3115
-			if (!$fp)
3116
-				$fp = @fopen($file, 'w');
3303
+			if (!$fp) {
3304
+							$fp = @fopen($file, 'w');
3305
+			}
3117 3306
 
3118
-			if (!$fp)
3119
-				$failure = true;
3120
-			else
3121
-				unset($files[$k]);
3307
+			if (!$fp) {
3308
+							$failure = true;
3309
+			} else {
3310
+							unset($files[$k]);
3311
+			}
3122 3312
 			@fclose($fp);
3123 3313
 		}
3124 3314
 	}
3125 3315
 
3126
-	if (empty($files))
3127
-		return true;
3316
+	if (empty($files)) {
3317
+			return true;
3318
+	}
3128 3319
 
3129
-	if (!isset($_SERVER))
3130
-		return !$failure;
3320
+	if (!isset($_SERVER)) {
3321
+			return !$failure;
3322
+	}
3131 3323
 
3132 3324
 	// What still needs to be done?
3133 3325
 	$upcontext['chmod']['files'] = $files;
@@ -3178,36 +3370,40 @@  discard block
 block discarded – undo
3178 3370
 
3179 3371
 		if (!isset($ftp) || $ftp->error !== false)
3180 3372
 		{
3181
-			if (!isset($ftp))
3182
-				$ftp = new ftp_connection(null);
3373
+			if (!isset($ftp)) {
3374
+							$ftp = new ftp_connection(null);
3375
+			}
3183 3376
 			// Save the error so we can mess with listing...
3184
-			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
3185
-				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3377
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) {
3378
+							$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3379
+			}
3186 3380
 
3187 3381
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
3188 3382
 
3189
-			if ($found_path || !isset($upcontext['chmod']['path']))
3190
-				$upcontext['chmod']['path'] = $detect_path;
3383
+			if ($found_path || !isset($upcontext['chmod']['path'])) {
3384
+							$upcontext['chmod']['path'] = $detect_path;
3385
+			}
3191 3386
 
3192
-			if (!isset($upcontext['chmod']['username']))
3193
-				$upcontext['chmod']['username'] = $username;
3387
+			if (!isset($upcontext['chmod']['username'])) {
3388
+							$upcontext['chmod']['username'] = $username;
3389
+			}
3194 3390
 
3195 3391
 			// Don't forget the login token.
3196 3392
 			$upcontext += createToken('login');
3197 3393
 
3198 3394
 			return false;
3199
-		}
3200
-		else
3395
+		} else
3201 3396
 		{
3202 3397
 			// We want to do a relative path for FTP.
3203 3398
 			if (!in_array($upcontext['chmod']['path'], array('', '/')))
3204 3399
 			{
3205 3400
 				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
3206
-				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
3207
-				$ftp_root = substr($ftp_root, 0, -1);
3401
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) {
3402
+								$ftp_root = substr($ftp_root, 0, -1);
3403
+				}
3404
+			} else {
3405
+							$ftp_root = $boarddir;
3208 3406
 			}
3209
-			else
3210
-				$ftp_root = $boarddir;
3211 3407
 
3212 3408
 			// Save the info for next time!
3213 3409
 			$_SESSION['installer_temp_ftp'] = array(
@@ -3221,10 +3417,12 @@  discard block
 block discarded – undo
3221 3417
 
3222 3418
 			foreach ($files as $k => $file)
3223 3419
 			{
3224
-				if (!is_writable($file))
3225
-					$ftp->chmod($file, 0755);
3226
-				if (!is_writable($file))
3227
-					$ftp->chmod($file, 0777);
3420
+				if (!is_writable($file)) {
3421
+									$ftp->chmod($file, 0755);
3422
+				}
3423
+				if (!is_writable($file)) {
3424
+									$ftp->chmod($file, 0777);
3425
+				}
3228 3426
 
3229 3427
 				// Assuming that didn't work calculate the path without the boarddir.
3230 3428
 				if (!is_writable($file))
@@ -3233,19 +3431,23 @@  discard block
 block discarded – undo
3233 3431
 					{
3234 3432
 						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
3235 3433
 						$ftp->chmod($ftp_file, 0755);
3236
-						if (!is_writable($file))
3237
-							$ftp->chmod($ftp_file, 0777);
3434
+						if (!is_writable($file)) {
3435
+													$ftp->chmod($ftp_file, 0777);
3436
+						}
3238 3437
 						// Sometimes an extra slash can help...
3239 3438
 						$ftp_file = '/' . $ftp_file;
3240
-						if (!is_writable($file))
3241
-							$ftp->chmod($ftp_file, 0755);
3242
-						if (!is_writable($file))
3243
-							$ftp->chmod($ftp_file, 0777);
3439
+						if (!is_writable($file)) {
3440
+													$ftp->chmod($ftp_file, 0755);
3441
+						}
3442
+						if (!is_writable($file)) {
3443
+													$ftp->chmod($ftp_file, 0777);
3444
+						}
3244 3445
 					}
3245 3446
 				}
3246 3447
 
3247
-				if (is_writable($file))
3248
-					unset($files[$k]);
3448
+				if (is_writable($file)) {
3449
+									unset($files[$k]);
3450
+				}
3249 3451
 			}
3250 3452
 
3251 3453
 			$ftp->close();
@@ -3255,16 +3457,18 @@  discard block
 block discarded – undo
3255 3457
 	// What remains?
3256 3458
 	$upcontext['chmod']['files'] = $files;
3257 3459
 
3258
-	if (empty($files))
3259
-		return true;
3460
+	if (empty($files)) {
3461
+			return true;
3462
+	}
3260 3463
 
3261 3464
 	return false;
3262 3465
 }
3263 3466
 
3264 3467
 function quickFileWritable($file)
3265 3468
 {
3266
-	if (is_writable($file))
3267
-		return true;
3469
+	if (is_writable($file)) {
3470
+			return true;
3471
+	}
3268 3472
 
3269 3473
 	@chmod($file, 0755);
3270 3474
 
@@ -3274,17 +3478,19 @@  discard block
 block discarded – undo
3274 3478
 	foreach($chmod_values as $val)
3275 3479
 	{
3276 3480
 		// If it's writable, break out of the loop
3277
-		if (is_writable($file))
3278
-			break;
3279
-		else
3280
-			@chmod($file, $val);
3481
+		if (is_writable($file)) {
3482
+					break;
3483
+		} else {
3484
+					@chmod($file, $val);
3485
+		}
3281 3486
 	}
3282 3487
 }
3283 3488
 function smf_strtolower($string)
3284 3489
 {
3285 3490
 	global $sourcedir;
3286
-	if (function_exists('mb_strtolower'))
3287
-		return mb_strtolower($string, 'UTF-8');
3491
+	if (function_exists('mb_strtolower')) {
3492
+			return mb_strtolower($string, 'UTF-8');
3493
+	}
3288 3494
 	require_once($sourcedir . '/Subs-Charset.php');
3289 3495
 	return utf8_strtolower($string);
3290 3496
 }
@@ -3300,8 +3506,7 @@  discard block
 block discarded – undo
3300 3506
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
3301 3507
 	{
3302 3508
 		return true;
3303
-	}
3304
-	else
3509
+	} else
3305 3510
 	{
3306 3511
 		$upcontext['page_title'] = 'Converting to UTF8';
3307 3512
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -3345,8 +3550,9 @@  discard block
 block discarded – undo
3345 3550
 			)
3346 3551
 		);
3347 3552
 		$db_charsets = array();
3348
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3349
-			$db_charsets[] = $row['Charset'];
3553
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3554
+					$db_charsets[] = $row['Charset'];
3555
+		}
3350 3556
 
3351 3557
 		$smcFunc['db_free_result']($request);
3352 3558
 
@@ -3382,13 +3588,15 @@  discard block
 block discarded – undo
3382 3588
 		// If there's a fulltext index, we need to drop it first...
3383 3589
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
3384 3590
 		{
3385
-			while ($row = $smcFunc['db_fetch_assoc']($request))
3386
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3591
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
3592
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3387 3593
 					$upcontext['fulltext_index'][] = $row['Key_name'];
3594
+			}
3388 3595
 			$smcFunc['db_free_result']($request);
3389 3596
 
3390
-			if (isset($upcontext['fulltext_index']))
3391
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3597
+			if (isset($upcontext['fulltext_index'])) {
3598
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3599
+			}
3392 3600
 		}
3393 3601
 
3394 3602
 		// Drop it and make a note...
@@ -3580,8 +3788,9 @@  discard block
 block discarded – undo
3580 3788
 			$replace = '%field%';
3581 3789
 
3582 3790
 			// Build a huge REPLACE statement...
3583
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
3584
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3791
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3792
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3793
+			}
3585 3794
 		}
3586 3795
 
3587 3796
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -3615,8 +3824,9 @@  discard block
 block discarded – undo
3615 3824
 			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3616 3825
 
3617 3826
 			// Just to make sure it doesn't time out.
3618
-			if (function_exists('apache_reset_timeout'))
3619
-				@apache_reset_timeout();
3827
+			if (function_exists('apache_reset_timeout')) {
3828
+							@apache_reset_timeout();
3829
+			}
3620 3830
 
3621 3831
 			$table_charsets = array();
3622 3832
 
@@ -3637,8 +3847,9 @@  discard block
 block discarded – undo
3637 3847
 					{
3638 3848
 						list($charset) = explode('_', $collation);
3639 3849
 
3640
-						if (!isset($table_charsets[$charset]))
3641
-							$table_charsets[$charset] = array();
3850
+						if (!isset($table_charsets[$charset])) {
3851
+													$table_charsets[$charset] = array();
3852
+						}
3642 3853
 
3643 3854
 						$table_charsets[$charset][] = $column_info;
3644 3855
 					}
@@ -3678,10 +3889,11 @@  discard block
 block discarded – undo
3678 3889
 				if (isset($translation_tables[$upcontext['charset_detected']]))
3679 3890
 				{
3680 3891
 					$update = '';
3681
-					foreach ($table_charsets as $charset => $columns)
3682
-						foreach ($columns as $column)
3892
+					foreach ($table_charsets as $charset => $columns) {
3893
+											foreach ($columns as $column)
3683 3894
 							$update .= '
3684 3895
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3896
+					}
3685 3897
 
3686 3898
 					$smcFunc['db_query']('', '
3687 3899
 						UPDATE {raw:table_name}
@@ -3706,8 +3918,9 @@  discard block
 block discarded – undo
3706 3918
 			// Now do the actual conversion (if still needed).
3707 3919
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3708 3920
 			{
3709
-				if ($command_line)
3710
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3921
+				if ($command_line) {
3922
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3923
+				}
3711 3924
 
3712 3925
 				$smcFunc['db_query']('', '
3713 3926
 					ALTER TABLE {raw:table_name}
@@ -3717,8 +3930,9 @@  discard block
 block discarded – undo
3717 3930
 						)
3718 3931
 				);
3719 3932
 
3720
-				if ($command_line)
3721
-					echo " done.\n";
3933
+				if ($command_line) {
3934
+									echo " done.\n";
3935
+				}
3722 3936
 			}
3723 3937
 		}
3724 3938
 
@@ -3748,8 +3962,8 @@  discard block
 block discarded – undo
3748 3962
 		);
3749 3963
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3750 3964
 		{
3751
-			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1)
3752
-				$smcFunc['db_query']('', '
3965
+			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) {
3966
+							$smcFunc['db_query']('', '
3753 3967
 					UPDATE {db_prefix}log_actions
3754 3968
 					SET extra = {string:extra}
3755 3969
 					WHERE id_action = {int:current_action}',
@@ -3758,6 +3972,7 @@  discard block
 block discarded – undo
3758 3972
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3759 3973
 					)
3760 3974
 				);
3975
+			}
3761 3976
 		}
3762 3977
 		$smcFunc['db_free_result']($request);
3763 3978
 
@@ -3779,15 +3994,17 @@  discard block
 block discarded – undo
3779 3994
 	// First thing's first - did we already do this?
3780 3995
 	if (!empty($modSettings['json_done']))
3781 3996
 	{
3782
-		if ($command_line)
3783
-			return DeleteUpgrade();
3784
-		else
3785
-			return true;
3997
+		if ($command_line) {
3998
+					return DeleteUpgrade();
3999
+		} else {
4000
+					return true;
4001
+		}
3786 4002
 	}
3787 4003
 
3788 4004
 	// Done it already - js wise?
3789
-	if (!empty($_POST['json_done']))
3790
-		return true;
4005
+	if (!empty($_POST['json_done'])) {
4006
+			return true;
4007
+	}
3791 4008
 
3792 4009
 	// List of tables affected by this function
3793 4010
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3819,12 +4036,14 @@  discard block
 block discarded – undo
3819 4036
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3820 4037
 	$file_steps = $upcontext['table_count'];
3821 4038
 
3822
-	foreach($keys as $id => $table)
3823
-		if ($id < $_GET['substep'])
4039
+	foreach($keys as $id => $table) {
4040
+			if ($id < $_GET['substep'])
3824 4041
 			$upcontext['previous_tables'][] = $table;
4042
+	}
3825 4043
 
3826
-	if ($command_line)
3827
-		echo 'Converting data from serialize() to json_encode().';
4044
+	if ($command_line) {
4045
+			echo 'Converting data from serialize() to json_encode().';
4046
+	}
3828 4047
 
3829 4048
 	if (!$support_js || isset($_GET['xml']))
3830 4049
 	{
@@ -3864,8 +4083,9 @@  discard block
 block discarded – undo
3864 4083
 
3865 4084
 				// Loop through and fix these...
3866 4085
 				$new_settings = array();
3867
-				if ($command_line)
3868
-					echo "\n" . 'Fixing some settings...';
4086
+				if ($command_line) {
4087
+									echo "\n" . 'Fixing some settings...';
4088
+				}
3869 4089
 
3870 4090
 				foreach ($serialized_settings as $var)
3871 4091
 				{
@@ -3873,22 +4093,24 @@  discard block
 block discarded – undo
3873 4093
 					{
3874 4094
 						// Attempt to unserialize the setting
3875 4095
 						$temp = @safe_unserialize($modSettings[$var]);
3876
-						if (!$temp && $command_line)
3877
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3878
-						elseif ($temp !== false)
3879
-							$new_settings[$var] = json_encode($temp);
4096
+						if (!$temp && $command_line) {
4097
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
4098
+						} elseif ($temp !== false) {
4099
+													$new_settings[$var] = json_encode($temp);
4100
+						}
3880 4101
 					}
3881 4102
 				}
3882 4103
 
3883 4104
 				// Update everything at once
3884
-				if (!function_exists('cache_put_data'))
3885
-					require_once($sourcedir . '/Load.php');
4105
+				if (!function_exists('cache_put_data')) {
4106
+									require_once($sourcedir . '/Load.php');
4107
+				}
3886 4108
 				updateSettings($new_settings, true);
3887 4109
 
3888
-				if ($command_line)
3889
-					echo ' done.';
3890
-			}
3891
-			elseif ($table == 'themes')
4110
+				if ($command_line) {
4111
+									echo ' done.';
4112
+				}
4113
+			} elseif ($table == 'themes')
3892 4114
 			{
3893 4115
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3894 4116
 				$query = $smcFunc['db_query']('', '
@@ -3907,10 +4129,11 @@  discard block
 block discarded – undo
3907 4129
 
3908 4130
 						if ($command_line)
3909 4131
 						{
3910
-							if ($temp === false)
3911
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3912
-							else
3913
-								echo "\n" . 'Fixing admin preferences...';
4132
+							if ($temp === false) {
4133
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
4134
+							} else {
4135
+															echo "\n" . 'Fixing admin preferences...';
4136
+							}
3914 4137
 						}
3915 4138
 
3916 4139
 						if ($temp !== false)
@@ -3930,15 +4153,15 @@  discard block
 block discarded – undo
3930 4153
 								)
3931 4154
 							);
3932 4155
 
3933
-							if ($is_debug || $command_line)
3934
-								echo ' done.';
4156
+							if ($is_debug || $command_line) {
4157
+															echo ' done.';
4158
+							}
3935 4159
 						}
3936 4160
 					}
3937 4161
 
3938 4162
 					$smcFunc['db_free_result']($query);
3939 4163
 				}
3940
-			}
3941
-			else
4164
+			} else
3942 4165
 			{
3943 4166
 				// First item is always the key...
3944 4167
 				$key = $info[0];
@@ -3949,8 +4172,7 @@  discard block
 block discarded – undo
3949 4172
 				{
3950 4173
 					$col_select = $info[1];
3951 4174
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3952
-				}
3953
-				else
4175
+				} else
3954 4176
 				{
3955 4177
 					$col_select = implode(', ', $info);
3956 4178
 				}
@@ -3983,8 +4205,7 @@  discard block
 block discarded – undo
3983 4205
 								if ($temp === false && $command_line)
3984 4206
 								{
3985 4207
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3986
-								}
3987
-								else
4208
+								} else
3988 4209
 								{
3989 4210
 									$row[$col] = json_encode($temp);
3990 4211
 
@@ -4009,16 +4230,18 @@  discard block
 block discarded – undo
4009 4230
 						}
4010 4231
 					}
4011 4232
 
4012
-					if ($command_line)
4013
-						echo ' done.';
4233
+					if ($command_line) {
4234
+											echo ' done.';
4235
+					}
4014 4236
 
4015 4237
 					// Free up some memory...
4016 4238
 					$smcFunc['db_free_result']($query);
4017 4239
 				}
4018 4240
 			}
4019 4241
 			// If this is XML to keep it nice for the user do one table at a time anyway!
4020
-			if (isset($_GET['xml']))
4021
-				return upgradeExit();
4242
+			if (isset($_GET['xml'])) {
4243
+							return upgradeExit();
4244
+			}
4022 4245
 		}
4023 4246
 
4024 4247
 		if ($command_line)
@@ -4033,8 +4256,9 @@  discard block
 block discarded – undo
4033 4256
 
4034 4257
 		$_GET['substep'] = 0;
4035 4258
 		// Make sure we move on!
4036
-		if ($command_line)
4037
-			return DeleteUpgrade();
4259
+		if ($command_line) {
4260
+					return DeleteUpgrade();
4261
+		}
4038 4262
 
4039 4263
 		return true;
4040 4264
 	}
@@ -4054,14 +4278,16 @@  discard block
 block discarded – undo
4054 4278
 	global $upcontext, $txt, $settings;
4055 4279
 
4056 4280
 	// Don't call me twice!
4057
-	if (!empty($upcontext['chmod_called']))
4058
-		return;
4281
+	if (!empty($upcontext['chmod_called'])) {
4282
+			return;
4283
+	}
4059 4284
 
4060 4285
 	$upcontext['chmod_called'] = true;
4061 4286
 
4062 4287
 	// Nothing?
4063
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
4064
-		return;
4288
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
4289
+			return;
4290
+	}
4065 4291
 
4066 4292
 	// Was it a problem with Windows?
4067 4293
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -4093,11 +4319,12 @@  discard block
 block discarded – undo
4093 4319
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\');
4094 4320
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
4095 4321
 
4096
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
4097
-		echo '
4322
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
4323
+			echo '
4098 4324
 					content.write(\'<hr>\n\t\t\t\');
4099 4325
 					content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\');
4100 4326
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
4327
+	}
4101 4328
 
4102 4329
 	echo '
4103 4330
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -4105,17 +4332,19 @@  discard block
 block discarded – undo
4105 4332
 				}
4106 4333
 		</script>';
4107 4334
 
4108
-	if (!empty($upcontext['chmod']['ftp_error']))
4109
-		echo '
4335
+	if (!empty($upcontext['chmod']['ftp_error'])) {
4336
+			echo '
4110 4337
 			<div class="error_message red">
4111 4338
 				The following error was encountered when trying to connect:<br><br>
4112 4339
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
4113 4340
 			</div>
4114 4341
 			<br>';
4342
+	}
4115 4343
 
4116
-	if (empty($upcontext['chmod_in_form']))
4117
-		echo '
4344
+	if (empty($upcontext['chmod_in_form'])) {
4345
+			echo '
4118 4346
 	<form action="', $upcontext['form_url'], '" method="post">';
4347
+	}
4119 4348
 
4120 4349
 	echo '
4121 4350
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -4150,10 +4379,11 @@  discard block
 block discarded – undo
4150 4379
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
4151 4380
 	</div>';
4152 4381
 
4153
-	if (empty($upcontext['chmod_in_form']))
4154
-		echo '
4382
+	if (empty($upcontext['chmod_in_form'])) {
4383
+			echo '
4155 4384
 	</form>';
4156
-}
4385
+	}
4386
+	}
4157 4387
 
4158 4388
 function template_upgrade_above()
4159 4389
 {
@@ -4213,9 +4443,10 @@  discard block
 block discarded – undo
4213 4443
 				<h2>', $txt['upgrade_progress'], '</h2>
4214 4444
 				<ul>';
4215 4445
 
4216
-	foreach ($upcontext['steps'] as $num => $step)
4217
-		echo '
4446
+	foreach ($upcontext['steps'] as $num => $step) {
4447
+			echo '
4218 4448
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
4449
+	}
4219 4450
 
4220 4451
 	echo '
4221 4452
 					</ul>
@@ -4228,8 +4459,8 @@  discard block
 block discarded – undo
4228 4459
 				</div>
4229 4460
 			</div>';
4230 4461
 
4231
-	if (isset($upcontext['step_progress']))
4232
-		echo '
4462
+	if (isset($upcontext['step_progress'])) {
4463
+			echo '
4233 4464
 				<br>
4234 4465
 				<br>
4235 4466
 				<div id="progress_bar_step">
@@ -4238,6 +4469,7 @@  discard block
 block discarded – undo
4238 4469
 						<span>', $txt['upgrade_step_progress'], '</span>
4239 4470
 					</div>
4240 4471
 				</div>';
4472
+	}
4241 4473
 
4242 4474
 	echo '
4243 4475
 				<div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div>
@@ -4268,32 +4500,36 @@  discard block
 block discarded – undo
4268 4500
 {
4269 4501
 	global $upcontext, $txt;
4270 4502
 
4271
-	if (!empty($upcontext['pause']))
4272
-		echo '
4503
+	if (!empty($upcontext['pause'])) {
4504
+			echo '
4273 4505
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
4274 4506
 
4275 4507
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
4276 4508
 								<h3>
4277 4509
 									', $txt['upgrade_paused_overload'], '
4278 4510
 								</h3>';
4511
+	}
4279 4512
 
4280
-	if (!empty($upcontext['custom_warning']))
4281
-		echo '
4513
+	if (!empty($upcontext['custom_warning'])) {
4514
+			echo '
4282 4515
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4283 4516
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4284 4517
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
4285 4518
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
4286 4519
 								</div>';
4520
+	}
4287 4521
 
4288 4522
 	echo '
4289 4523
 								<div class="righttext" style="margin: 1ex;">';
4290 4524
 
4291
-	if (!empty($upcontext['continue']))
4292
-		echo '
4525
+	if (!empty($upcontext['continue'])) {
4526
+			echo '
4293 4527
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
4294
-	if (!empty($upcontext['skip']))
4295
-		echo '
4528
+	}
4529
+	if (!empty($upcontext['skip'])) {
4530
+			echo '
4296 4531
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
4532
+	}
4297 4533
 
4298 4534
 	echo '
4299 4535
 								</div>
@@ -4343,11 +4579,12 @@  discard block
 block discarded – undo
4343 4579
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
4344 4580
 	<smf>';
4345 4581
 
4346
-	if (!empty($upcontext['get_data']))
4347
-		foreach ($upcontext['get_data'] as $k => $v)
4582
+	if (!empty($upcontext['get_data'])) {
4583
+			foreach ($upcontext['get_data'] as $k => $v)
4348 4584
 			echo '
4349 4585
 		<get key="', $k, '">', $v, '</get>';
4350
-}
4586
+	}
4587
+	}
4351 4588
 
4352 4589
 function template_xml_below()
4353 4590
 {
@@ -4388,8 +4625,8 @@  discard block
 block discarded – undo
4388 4625
 	template_chmod();
4389 4626
 
4390 4627
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
4391
-	if ($upcontext['is_large_forum'])
4392
-		echo '
4628
+	if ($upcontext['is_large_forum']) {
4629
+			echo '
4393 4630
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4394 4631
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4395 4632
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4397,10 +4634,11 @@  discard block
 block discarded – undo
4397 4634
 				', $txt['upgrade_warning_lots_data'], '
4398 4635
 			</div>
4399 4636
 		</div>';
4637
+	}
4400 4638
 
4401 4639
 	// A warning message?
4402
-	if (!empty($upcontext['warning']))
4403
-		echo '
4640
+	if (!empty($upcontext['warning'])) {
4641
+			echo '
4404 4642
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4405 4643
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4406 4644
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4408,6 +4646,7 @@  discard block
 block discarded – undo
4408 4646
 				', $upcontext['warning'], '
4409 4647
 			</div>
4410 4648
 		</div>';
4649
+	}
4411 4650
 
4412 4651
 	// Paths are incorrect?
4413 4652
 	echo '
@@ -4423,20 +4662,22 @@  discard block
 block discarded – undo
4423 4662
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
4424 4663
 	{
4425 4664
 		$ago = time() - $upcontext['started'];
4426
-		if ($ago < 60)
4427
-			$ago = $ago . ' seconds';
4428
-		elseif ($ago < 3600)
4429
-			$ago = (int) ($ago / 60) . ' minutes';
4430
-		else
4431
-			$ago = (int) ($ago / 3600) . ' hours';
4665
+		if ($ago < 60) {
4666
+					$ago = $ago . ' seconds';
4667
+		} elseif ($ago < 3600) {
4668
+					$ago = (int) ($ago / 60) . ' minutes';
4669
+		} else {
4670
+					$ago = (int) ($ago / 3600) . ' hours';
4671
+		}
4432 4672
 
4433 4673
 		$active = time() - $upcontext['updated'];
4434
-		if ($active < 60)
4435
-			$updated = $active . ' seconds';
4436
-		elseif ($active < 3600)
4437
-			$updated = (int) ($active / 60) . ' minutes';
4438
-		else
4439
-			$updated = (int) ($active / 3600) . ' hours';
4674
+		if ($active < 60) {
4675
+					$updated = $active . ' seconds';
4676
+		} elseif ($active < 3600) {
4677
+					$updated = (int) ($active / 60) . ' minutes';
4678
+		} else {
4679
+					$updated = (int) ($active / 3600) . ' hours';
4680
+		}
4440 4681
 
4441 4682
 		echo '
4442 4683
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -4445,16 +4686,18 @@  discard block
 block discarded – undo
4445 4686
 			<div style="padding-left: 6ex;">
4446 4687
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
4447 4688
 
4448
-		if ($active < 600)
4449
-			echo '
4689
+		if ($active < 600) {
4690
+					echo '
4450 4691
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
4692
+		}
4451 4693
 
4452
-		if ($active > $upcontext['inactive_timeout'])
4453
-			echo '
4694
+		if ($active > $upcontext['inactive_timeout']) {
4695
+					echo '
4454 4696
 				<br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
4455
-		else
4456
-			echo '
4697
+		} else {
4698
+					echo '
4457 4699
 				<br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
4700
+		}
4458 4701
 
4459 4702
 		echo '
4460 4703
 			</div>
@@ -4470,9 +4713,10 @@  discard block
 block discarded – undo
4470 4713
 					<td>
4471 4714
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
4472 4715
 
4473
-	if (!empty($upcontext['username_incorrect']))
4474
-		echo '
4716
+	if (!empty($upcontext['username_incorrect'])) {
4717
+			echo '
4475 4718
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
4719
+	}
4476 4720
 
4477 4721
 	echo '
4478 4722
 					</td>
@@ -4483,9 +4727,10 @@  discard block
 block discarded – undo
4483 4727
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
4484 4728
 						<input type="hidden" name="hash_passwrd" value="">';
4485 4729
 
4486
-	if (!empty($upcontext['password_failed']))
4487
-		echo '
4730
+	if (!empty($upcontext['password_failed'])) {
4731
+			echo '
4488 4732
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
4733
+	}
4489 4734
 
4490 4735
 	echo '
4491 4736
 					</td>
@@ -4556,8 +4801,8 @@  discard block
 block discarded – undo
4556 4801
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
4557 4802
 
4558 4803
 	// Warning message?
4559
-	if (!empty($upcontext['upgrade_options_warning']))
4560
-		echo '
4804
+	if (!empty($upcontext['upgrade_options_warning'])) {
4805
+			echo '
4561 4806
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
4562 4807
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4563 4808
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -4565,6 +4810,7 @@  discard block
 block discarded – undo
4565 4810
 				', $upcontext['upgrade_options_warning'], '
4566 4811
 			</div>
4567 4812
 		</div>';
4813
+	}
4568 4814
 
4569 4815
 	echo '
4570 4816
 				<table>
@@ -4592,8 +4838,8 @@  discard block
 block discarded – undo
4592 4838
 					</tr>';
4593 4839
 
4594 4840
 	// Offer mysql users to switch to mysqli
4595
-	if ($db_type == 'mysql' && function_exists('mysqli_query'))
4596
-		echo '
4841
+	if ($db_type == 'mysql' && function_exists('mysqli_query')) {
4842
+			echo '
4597 4843
 					<tr valign="top">
4598 4844
 						<td width="2%">
4599 4845
 							<input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check">
@@ -4603,6 +4849,7 @@  discard block
 block discarded – undo
4603 4849
 							<strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br>
4604 4850
 						</td>
4605 4851
 					</tr>';
4852
+	}
4606 4853
 
4607 4854
 	echo '
4608 4855
 					<tr valign="top">
@@ -4622,8 +4869,8 @@  discard block
 block discarded – undo
4622 4869
 						</td>
4623 4870
 					</tr>';
4624 4871
 
4625
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
4626
-		echo '
4872
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4873
+			echo '
4627 4874
 					<tr valign="top">
4628 4875
 						<td width="2%">
4629 4876
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -4632,6 +4879,7 @@  discard block
 block discarded – undo
4632 4879
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
4633 4880
 						</td>
4634 4881
 					</tr>';
4882
+	}
4635 4883
 
4636 4884
 	echo '
4637 4885
 					<tr valign="top">
@@ -4667,10 +4915,11 @@  discard block
 block discarded – undo
4667 4915
 			<span id="debuginfo"></span>';
4668 4916
 
4669 4917
 	// Dont any tables so far?
4670
-	if (!empty($upcontext['previous_tables']))
4671
-		foreach ($upcontext['previous_tables'] as $table)
4918
+	if (!empty($upcontext['previous_tables'])) {
4919
+			foreach ($upcontext['previous_tables'] as $table)
4672 4920
 			echo '
4673 4921
 			<br>Completed Table: &quot;', $table, '&quot;.';
4922
+	}
4674 4923
 
4675 4924
 	echo '
4676 4925
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -4707,12 +4956,13 @@  discard block
 block discarded – undo
4707 4956
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4708 4957
 
4709 4958
 		// If debug flood the screen.
4710
-		if ($is_debug)
4711
-			echo '
4959
+		if ($is_debug) {
4960
+					echo '
4712 4961
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4713 4962
 
4714 4963
 				if (document.getElementById(\'debuginfo\').scrollHeight)
4715 4964
 					document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;';
4965
+		}
4716 4966
 
4717 4967
 		echo '
4718 4968
 				// Get the next update...
@@ -4744,8 +4994,9 @@  discard block
 block discarded – undo
4744 4994
 {
4745 4995
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
4746 4996
 
4747
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4748
-		$is_debug = true;
4997
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4998
+			$is_debug = true;
4999
+	}
4749 5000
 
4750 5001
 	echo '
4751 5002
 		<h3>Executing database changes</h3>
@@ -4760,8 +5011,9 @@  discard block
 block discarded – undo
4760 5011
 	{
4761 5012
 		foreach ($upcontext['actioned_items'] as $num => $item)
4762 5013
 		{
4763
-			if ($num != 0)
4764
-				echo ' Successful!';
5014
+			if ($num != 0) {
5015
+							echo ' Successful!';
5016
+			}
4765 5017
 			echo '<br>' . $item;
4766 5018
 		}
4767 5019
 		if (!empty($upcontext['changes_complete']))
@@ -4774,28 +5026,32 @@  discard block
 block discarded – undo
4774 5026
 				$seconds = intval($active % 60);
4775 5027
 
4776 5028
 				$totalTime = '';
4777
-				if ($hours > 0)
4778
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
4779
-				if ($minutes > 0)
4780
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
4781
-				if ($seconds > 0)
4782
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5029
+				if ($hours > 0) {
5030
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
5031
+				}
5032
+				if ($minutes > 0) {
5033
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
5034
+				}
5035
+				if ($seconds > 0) {
5036
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5037
+				}
4783 5038
 			}
4784 5039
 
4785
-			if ($is_debug && !empty($totalTime))
4786
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
4787
-			else
4788
-				echo ' Successful!<br><br>';
5040
+			if ($is_debug && !empty($totalTime)) {
5041
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
5042
+			} else {
5043
+							echo ' Successful!<br><br>';
5044
+			}
4789 5045
 
4790 5046
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
4791 5047
 		}
4792
-	}
4793
-	else
5048
+	} else
4794 5049
 	{
4795 5050
 		// Tell them how many files we have in total.
4796
-		if ($upcontext['file_count'] > 1)
4797
-			echo '
5051
+		if ($upcontext['file_count'] > 1) {
5052
+					echo '
4798 5053
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
5054
+		}
4799 5055
 
4800 5056
 		echo '
4801 5057
 		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -4811,19 +5067,23 @@  discard block
 block discarded – undo
4811 5067
 				$seconds = intval($active % 60);
4812 5068
 
4813 5069
 				$totalTime = '';
4814
-				if ($hours > 0)
4815
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
4816
-				if ($minutes > 0)
4817
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
4818
-				if ($seconds > 0)
4819
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5070
+				if ($hours > 0) {
5071
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
5072
+				}
5073
+				if ($minutes > 0) {
5074
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
5075
+				}
5076
+				if ($seconds > 0) {
5077
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5078
+				}
4820 5079
 			}
4821 5080
 
4822 5081
 			echo '
4823 5082
 			<br><span id="upgradeCompleted">';
4824 5083
 
4825
-			if (!empty($totalTime))
4826
-				echo 'Completed in ', $totalTime, '<br>';
5084
+			if (!empty($totalTime)) {
5085
+							echo 'Completed in ', $totalTime, '<br>';
5086
+			}
4827 5087
 
4828 5088
 			echo '</span>
4829 5089
 			<div id="debug_section" style="height: 200px; overflow: auto;">
@@ -4860,9 +5120,10 @@  discard block
 block discarded – undo
4860 5120
 			var getData = "";
4861 5121
 			var debugItems = ', $upcontext['debug_items'], ';';
4862 5122
 
4863
-		if ($is_debug)
4864
-			echo '
5123
+		if ($is_debug) {
5124
+					echo '
4865 5125
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
5126
+		}
4866 5127
 
4867 5128
 		echo '
4868 5129
 			function getNextItem()
@@ -4902,9 +5163,10 @@  discard block
 block discarded – undo
4902 5163
 						document.getElementById("error_block").style.display = "";
4903 5164
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4904 5165
 
4905
-	if ($is_debug)
4906
-		echo '
5166
+	if ($is_debug) {
5167
+			echo '
4907 5168
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5169
+	}
4908 5170
 
4909 5171
 	echo '
4910 5172
 					}
@@ -4925,9 +5187,10 @@  discard block
 block discarded – undo
4925 5187
 						document.getElementById("error_block").style.display = "";
4926 5188
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4927 5189
 
4928
-	if ($is_debug)
4929
-		echo '
5190
+	if ($is_debug) {
5191
+			echo '
4930 5192
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5193
+	}
4931 5194
 
4932 5195
 	echo '
4933 5196
 					}
@@ -4986,8 +5249,8 @@  discard block
 block discarded – undo
4986 5249
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4987 5250
 				{';
4988 5251
 
4989
-		if ($is_debug)
4990
-			echo '
5252
+		if ($is_debug) {
5253
+					echo '
4991 5254
 					document.getElementById(\'debug_section\').style.display = "none";
4992 5255
 
4993 5256
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -5005,6 +5268,7 @@  discard block
 block discarded – undo
5005 5268
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
5006 5269
 
5007 5270
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
5271
+		}
5008 5272
 
5009 5273
 		echo '
5010 5274
 
@@ -5012,9 +5276,10 @@  discard block
 block discarded – undo
5012 5276
 					document.getElementById(\'contbutt\').disabled = 0;
5013 5277
 					document.getElementById(\'database_done\').value = 1;';
5014 5278
 
5015
-		if ($upcontext['file_count'] > 1)
5016
-			echo '
5279
+		if ($upcontext['file_count'] > 1) {
5280
+					echo '
5017 5281
 					document.getElementById(\'info1\').style.display = "none";';
5282
+		}
5018 5283
 
5019 5284
 		echo '
5020 5285
 					document.getElementById(\'info2\').style.display = "none";
@@ -5027,9 +5292,10 @@  discard block
 block discarded – undo
5027 5292
 					lastItem = 0;
5028 5293
 					prevFile = curFile;';
5029 5294
 
5030
-		if ($is_debug)
5031
-			echo '
5295
+		if ($is_debug) {
5296
+					echo '
5032 5297
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
5298
+		}
5033 5299
 
5034 5300
 		echo '
5035 5301
 					getNextItem();
@@ -5037,8 +5303,8 @@  discard block
 block discarded – undo
5037 5303
 				}';
5038 5304
 
5039 5305
 		// If debug scroll the screen.
5040
-		if ($is_debug)
5041
-			echo '
5306
+		if ($is_debug) {
5307
+					echo '
5042 5308
 				if (iLastSubStepProgress == -1)
5043 5309
 				{
5044 5310
 					// Give it consistent dots.
@@ -5057,6 +5323,7 @@  discard block
 block discarded – undo
5057 5323
 
5058 5324
 				if (document.getElementById(\'debug_section\').scrollHeight)
5059 5325
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
5326
+		}
5060 5327
 
5061 5328
 		echo '
5062 5329
 				// Update the page.
@@ -5117,9 +5384,10 @@  discard block
 block discarded – undo
5117 5384
 			}';
5118 5385
 
5119 5386
 		// Start things off assuming we've not errored.
5120
-		if (empty($upcontext['error_message']))
5121
-			echo '
5387
+		if (empty($upcontext['error_message'])) {
5388
+					echo '
5122 5389
 			getNextItem();';
5390
+		}
5123 5391
 
5124 5392
 		echo '
5125 5393
 		</script>';
@@ -5136,18 +5404,21 @@  discard block
 block discarded – undo
5136 5404
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
5137 5405
 	<debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>';
5138 5406
 
5139
-	if (!empty($upcontext['error_message']))
5140
-		echo '
5407
+	if (!empty($upcontext['error_message'])) {
5408
+			echo '
5141 5409
 	<error>', $upcontext['error_message'], '</error>';
5410
+	}
5142 5411
 
5143
-	if (!empty($upcontext['error_string']))
5144
-		echo '
5412
+	if (!empty($upcontext['error_string'])) {
5413
+			echo '
5145 5414
 	<sql>', $upcontext['error_string'], '</sql>';
5415
+	}
5146 5416
 
5147
-	if ($is_debug)
5148
-		echo '
5417
+	if ($is_debug) {
5418
+			echo '
5149 5419
 	<curtime>', time(), '</curtime>';
5150
-}
5420
+	}
5421
+	}
5151 5422
 
5152 5423
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
5153 5424
 function template_convert_utf8()
@@ -5164,18 +5435,20 @@  discard block
 block discarded – undo
5164 5435
 			<span id="debuginfo"></span>';
5165 5436
 
5166 5437
 	// Done any tables so far?
5167
-	if (!empty($upcontext['previous_tables']))
5168
-		foreach ($upcontext['previous_tables'] as $table)
5438
+	if (!empty($upcontext['previous_tables'])) {
5439
+			foreach ($upcontext['previous_tables'] as $table)
5169 5440
 			echo '
5170 5441
 			<br>Completed Table: &quot;', $table, '&quot;.';
5442
+	}
5171 5443
 
5172 5444
 	echo '
5173 5445
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
5174 5446
 
5175 5447
 	// If we dropped their index, let's let them know
5176
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
5177
-		echo '
5448
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
5449
+			echo '
5178 5450
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
5451
+	}
5179 5452
 
5180 5453
 	echo '
5181 5454
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>';
@@ -5211,9 +5484,10 @@  discard block
 block discarded – undo
5211 5484
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5212 5485
 
5213 5486
 		// If debug flood the screen.
5214
-		if ($is_debug)
5215
-			echo '
5487
+		if ($is_debug) {
5488
+					echo '
5216 5489
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
5490
+		}
5217 5491
 
5218 5492
 		echo '
5219 5493
 				// Get the next update...
@@ -5282,14 +5556,16 @@  discard block
 block discarded – undo
5282 5556
 		<input type="hidden" name="cleandone" value="1">';
5283 5557
 
5284 5558
 	// Files to make writable?
5285
-	if (!empty($upcontext['writable_files']))
5286
-		echo '
5559
+	if (!empty($upcontext['writable_files'])) {
5560
+			echo '
5287 5561
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5562
+	}
5288 5563
 
5289 5564
 	// We'll want a continue button...
5290
-	if (empty($upcontext['chmod']['files']))
5291
-		$upcontext['continue'] = 1;
5292
-}
5565
+	if (empty($upcontext['chmod']['files'])) {
5566
+			$upcontext['continue'] = 1;
5567
+	}
5568
+	}
5293 5569
 
5294 5570
 // Finished with the mods - let them know what we've done.
5295 5571
 function template_cleanup_done()
@@ -5351,8 +5627,9 @@  discard block
 block discarded – undo
5351 5627
 						&quot;', $language['name'], '&quot; Language Pack
5352 5628
 						<div class="smalltext">(';
5353 5629
 
5354
-			foreach ($language['files'] as $k => $file)
5355
-				echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5630
+			foreach ($language['files'] as $k => $file) {
5631
+							echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5632
+			}
5356 5633
 
5357 5634
 			echo '
5358 5635
 						</div>
@@ -5369,8 +5646,9 @@  discard block
 block discarded – undo
5369 5646
 						&quot;', $theme['name'], '&quot; Theme
5370 5647
 						<div class="smalltext">(';
5371 5648
 
5372
-			foreach ($theme['files'] as $k => $file)
5373
-				echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5649
+			foreach ($theme['files'] as $k => $file) {
5650
+							echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5651
+			}
5374 5652
 
5375 5653
 			echo '
5376 5654
 						</div>
@@ -5381,47 +5659,54 @@  discard block
 block discarded – undo
5381 5659
 
5382 5660
 		echo '
5383 5661
 		</table>';
5384
-	}
5385
-	else
5662
+	} else
5386 5663
 	{
5387 5664
 		$langFiles = 0;
5388 5665
 		$themeFiles = 0;
5389
-		if (!empty($upcontext['languages']))
5390
-			foreach ($upcontext['languages'] as $lang)
5666
+		if (!empty($upcontext['languages'])) {
5667
+					foreach ($upcontext['languages'] as $lang)
5391 5668
 				$langFiles += count($lang['files']);
5392
-		if (!empty($upcontext['themes']))
5393
-			foreach ($upcontext['themes'] as $theme)
5669
+		}
5670
+		if (!empty($upcontext['themes'])) {
5671
+					foreach ($upcontext['themes'] as $theme)
5394 5672
 				$themeFiles += count($theme['files']);
5673
+		}
5395 5674
 		echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>';
5396 5675
 
5397 5676
 		// What we're currently doing?
5398
-		if (!empty($upcontext['current_message']))
5399
-			echo '
5677
+		if (!empty($upcontext['current_message'])) {
5678
+					echo '
5400 5679
 				', $upcontext['current_message'];
5680
+		}
5401 5681
 	}
5402 5682
 
5403 5683
 	echo '
5404 5684
 		<input type="hidden" name="uptempdone" value="1">';
5405 5685
 
5406
-	if (!empty($upcontext['languages']))
5407
-		echo '
5686
+	if (!empty($upcontext['languages'])) {
5687
+			echo '
5408 5688
 		<input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">';
5409
-	if (!empty($upcontext['themes']))
5410
-		echo '
5689
+	}
5690
+	if (!empty($upcontext['themes'])) {
5691
+			echo '
5411 5692
 		<input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">';
5412
-	if (!empty($upcontext['writable_files']))
5413
-		echo '
5693
+	}
5694
+	if (!empty($upcontext['writable_files'])) {
5695
+			echo '
5414 5696
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5697
+	}
5415 5698
 
5416 5699
 	// Offer them the option to upgrade from YaBB SE?
5417
-	if (!empty($upcontext['can_upgrade_yabbse']))
5418
-		echo '
5700
+	if (!empty($upcontext['can_upgrade_yabbse'])) {
5701
+			echo '
5419 5702
 		<br><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check"> Convert the existing YaBB SE template and set it as default.</label><br>';
5703
+	}
5420 5704
 
5421 5705
 	// We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!)
5422
-	if (empty($upcontext['chmod']['files']) || $upcontext['is_test'])
5423
-		$upcontext['continue'] = 1;
5424
-}
5706
+	if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) {
5707
+			$upcontext['continue'] = 1;
5708
+	}
5709
+	}
5425 5710
 
5426 5711
 // Template for the database backup tool/
5427 5712
 function template_serialize_json()
@@ -5438,19 +5723,21 @@  discard block
 block discarded – undo
5438 5723
 			<span id="debuginfo"></span>';
5439 5724
 
5440 5725
 	// Dont any tables so far?
5441
-	if (!empty($upcontext['previous_tables']))
5442
-		foreach ($upcontext['previous_tables'] as $table)
5726
+	if (!empty($upcontext['previous_tables'])) {
5727
+			foreach ($upcontext['previous_tables'] as $table)
5443 5728
 			echo '
5444 5729
 			<br>Completed Table: &quot;', $table, '&quot;.';
5730
+	}
5445 5731
 
5446 5732
 	echo '
5447 5733
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
5448 5734
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>';
5449 5735
 
5450 5736
 	// Try to make sure substep was reset.
5451
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
5452
-		echo '
5737
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
5738
+			echo '
5453 5739
 			<input type="hidden" name="substep" id="substep" value="0">';
5740
+	}
5454 5741
 
5455 5742
 	// Continue please!
5456 5743
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -5483,9 +5770,10 @@  discard block
 block discarded – undo
5483 5770
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5484 5771
 
5485 5772
 		// If debug flood the screen.
5486
-		if ($is_debug)
5487
-			echo '
5773
+		if ($is_debug) {
5774
+					echo '
5488 5775
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
5776
+		}
5489 5777
 
5490 5778
 		echo '
5491 5779
 				// Get the next update...
@@ -5520,8 +5808,8 @@  discard block
 block discarded – undo
5520 5808
 	<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>
5521 5809
 	<form action="', $boardurl, '/index.php">';
5522 5810
 
5523
-	if (!empty($upcontext['can_delete_script']))
5524
-		echo '
5811
+	if (!empty($upcontext['can_delete_script'])) {
5812
+			echo '
5525 5813
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em>
5526 5814
 			<script>
5527 5815
 				function doTheDelete(theCheck)
@@ -5533,6 +5821,7 @@  discard block
 block discarded – undo
5533 5821
 				}
5534 5822
 			</script>
5535 5823
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
5824
+	}
5536 5825
 
5537 5826
 	$active = time() - $upcontext['started'];
5538 5827
 	$hours = floor($active / 3600);
@@ -5542,16 +5831,20 @@  discard block
 block discarded – undo
5542 5831
 	if ($is_debug)
5543 5832
 	{
5544 5833
 		$totalTime = '';
5545
-		if ($hours > 0)
5546
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
5547
-		if ($minutes > 0)
5548
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
5549
-		if ($seconds > 0)
5550
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5834
+		if ($hours > 0) {
5835
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' ';
5836
+		}
5837
+		if ($minutes > 0) {
5838
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' ';
5839
+		}
5840
+		if ($seconds > 0) {
5841
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' ';
5842
+		}
5551 5843
 	}
5552 5844
 
5553
-	if ($is_debug && !empty($totalTime))
5554
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
5845
+	if ($is_debug && !empty($totalTime)) {
5846
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
5847
+	}
5555 5848
 
5556 5849
 	echo '<br>
5557 5850
 			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br>
@@ -5608,16 +5901,19 @@  discard block
 block discarded – undo
5608 5901
 				'empty' => '',
5609 5902
 				'limit' => $limit,
5610 5903
 		));
5611
-		while ($row = $smcFunc['db_fetch_assoc']($request))
5612
-			$arIp[] = $row[$oldCol];
5904
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5905
+					$arIp[] = $row[$oldCol];
5906
+		}
5613 5907
 		$smcFunc['db_free_result']($request);
5614 5908
 
5615 5909
 		// Special case, null ip could keep us in a loop.
5616
-		if (is_null($arIp[0]))
5617
-			unset($arIp[0]);
5910
+		if (is_null($arIp[0])) {
5911
+					unset($arIp[0]);
5912
+		}
5618 5913
 
5619
-		if (empty($arIp))
5620
-			$is_done = true;
5914
+		if (empty($arIp)) {
5915
+					$is_done = true;
5916
+		}
5621 5917
 
5622 5918
 		$updates = array();
5623 5919
 		$cases = array();
@@ -5625,16 +5921,18 @@  discard block
 block discarded – undo
5625 5921
 		{
5626 5922
 			$arIp[$i] = trim($arIp[$i]);
5627 5923
 
5628
-			if (empty($arIp[$i]))
5629
-				continue;
5924
+			if (empty($arIp[$i])) {
5925
+							continue;
5926
+			}
5630 5927
 
5631 5928
 			$updates['ip' . $i] = trim($arIp[$i]);
5632 5929
 			$cases[trim($arIp[$i])] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
5633 5930
 
5634 5931
 			if ($setSize > 0 && $i % $setSize === 0)
5635 5932
 			{
5636
-				if (count($updates) == 1)
5637
-					continue;
5933
+				if (count($updates) == 1) {
5934
+									continue;
5935
+				}
5638 5936
 
5639 5937
 				$updates['whereSet'] = array_values($updates);
5640 5938
 				$smcFunc['db_query']('', '
@@ -5668,8 +5966,7 @@  discard block
 block discarded – undo
5668 5966
 							'ip' => $ip
5669 5967
 					));
5670 5968
 				}
5671
-			}
5672
-			else
5969
+			} else
5673 5970
 			{
5674 5971
 				$updates['whereSet'] = array_values($updates);
5675 5972
 				$request = $smcFunc['db_query']('', '
@@ -5683,9 +5980,9 @@  discard block
 block discarded – undo
5683 5980
 					$updates
5684 5981
 				);
5685 5982
 			}
5983
+		} else {
5984
+					$is_done = true;
5686 5985
 		}
5687
-		else
5688
-			$is_done = true;
5689 5986
 
5690 5987
 		$_GET['a'] += $limit;
5691 5988
 		$step_progress['current'] = $_GET['a'];
Please login to merge, or discard this patch.
Sources/Class-Package.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * of elements, an array of xmlArray's is returned for use with foreach.
258 258
 	 * Example use:
259 259
 	 *  foreach ($xml->set('html/body/p') as $p)
260
-	 * @param $path string The path to search for.
260
+	 * @param string $path string The path to search for.
261 261
 	 * @return array An array of xmlArray objects
262 262
 	 */
263 263
 	public function set($path)
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 * Changes a files atrributes (chmod)
856 856
 	 *
857 857
 	 * @param string $ftp_file The file to CHMOD
858
-	 * @param int|string $chmod The value for the CHMOD operation
858
+	 * @param integer $chmod The value for the CHMOD operation
859 859
 	 * @return boolean Whether or not the operation was successful
860 860
 	 */
861 861
 	public function chmod($ftp_file, $chmod)
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 *
1026 1026
 	 * @param string $ftp_path The path to the directory
1027 1027
 	 * @param bool $search Whether or not to get a recursive directory listing
1028
-	 * @return string|boolean The results of the command or false if unsuccessful
1028
+	 * @return false|string The results of the command or false if unsuccessful
1029 1029
 	 */
1030 1030
 	public function list_dir($ftp_path = '', $search = false)
1031 1031
 	{
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @param string $file The name of a file
1072 1072
 	 * @param string $listing A directory listing or null to generate one
1073
-	 * @return string|boolean The name of the file or false if it wasn't found
1073
+	 * @return string|false The name of the file or false if it wasn't found
1074 1074
 	 */
1075 1075
 	public function locate($file, $listing = null)
1076 1076
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 		if (!$this->connection)
794 794
 		{
795 795
 			$this->error = 'bad_server';
796
-            		$this->last_message = 'Invalid Server';
796
+					$this->last_message = 'Invalid Server';
797 797
 			return;
798 798
 		}
799 799
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 		if (!$this->check_response(220))
802 802
 		{
803 803
 			$this->error = 'bad_response';
804
-		        $this->last_message = 'Bad Response';
804
+				$this->last_message = 'Bad Response';
805 805
 			return;
806 806
 		}
807 807
 
Please login to merge, or discard this patch.
Sources/Load.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2225,9 +2225,9 @@  discard block
 block discarded – undo
2225 2225
  *
2226 2226
  * @uses the template_include() function to include the file.
2227 2227
  * @param string $template_name The name of the template to load
2228
- * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load
2228
+ * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load
2229 2229
  * @param bool $fatal If true, dies with an error message if the template cannot be found
2230
- * @return boolean Whether or not the template was loaded
2230
+ * @return boolean|null Whether or not the template was loaded
2231 2231
  */
2232 2232
 function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
2233 2233
 {
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
  * - all code added with this function is added to the same <style> tag so do make sure your css is valid!
2412 2412
  *
2413 2413
  * @param string $css Some css code
2414
- * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified
2414
+ * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified
2415 2415
  */
2416 2416
 function addInlineCss($css)
2417 2417
 {
@@ -2427,7 +2427,7 @@  discard block
 block discarded – undo
2427 2427
 /**
2428 2428
  * Add a Javascript file for output later
2429 2429
 
2430
- * @param string $filename The name of the file to load
2430
+ * @param string $fileName The name of the file to load
2431 2431
  * @param array $params An array of parameter info
2432 2432
  * Keys are the following:
2433 2433
  * 	- ['external'] (true/false): define if the file is a externally located file. Needs to be set to true if you are loading an external file
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
  *
2526 2526
  * @param string $javascript Some JS code
2527 2527
  * @param bool $defer Whether the script should load in <head> or before the closing <html> tag
2528
- * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified
2528
+ * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified
2529 2529
  */
2530 2530
 function addInlineJavaScript($javascript, $defer = false)
2531 2531
 {
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Set a list of common functions.
74 74
 	$ent_list = empty($modSettings['disableEntityCheck']) ? '&(#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(#021|quot|amp|lt|gt|nbsp);';
75
-	$ent_check = empty($modSettings['disableEntityCheck']) ? function ($string)
75
+	$ent_check = empty($modSettings['disableEntityCheck']) ? function($string)
76 76
 		{
77 77
 			$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
78 78
 			return $string;
79
-		} : function ($string)
79
+		} : function($string)
80 80
 		{
81 81
 			return $string;
82 82
 		};
83
-	$fix_utf8mb4 = function ($string) use ($utf8)
83
+	$fix_utf8mb4 = function($string) use ($utf8)
84 84
 	{
85 85
 		if (!$utf8)
86 86
 			return $string;
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
 			}
99 99
 			elseif ($ord < 224)
100 100
 			{
101
-				$new_string .= $string[$i] . $string[$i+1];
101
+				$new_string .= $string[$i] . $string[$i + 1];
102 102
 				$i += 2;
103 103
 			}
104 104
 			elseif ($ord < 240)
105 105
 			{
106
-				$new_string .= $string[$i] . $string[$i+1] . $string[$i+2];
106
+				$new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2];
107 107
 				$i += 3;
108 108
 			}
109 109
 			elseif ($ord < 248)
110 110
 			{
111 111
 				// Magic happens.
112 112
 				$val = (ord($string[$i]) & 0x07) << 18;
113
-				$val += (ord($string[$i+1]) & 0x3F) << 12;
114
-				$val += (ord($string[$i+2]) & 0x3F) << 6;
115
-				$val += (ord($string[$i+3]) & 0x3F);
113
+				$val += (ord($string[$i + 1]) & 0x3F) << 12;
114
+				$val += (ord($string[$i + 2]) & 0x3F) << 6;
115
+				$val += (ord($string[$i + 3]) & 0x3F);
116 116
 				$new_string .= '&#' . $val . ';';
117 117
 				$i += 4;
118 118
 			}
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
 
126 126
 	// global array of anonymous helper functions, used mostly to properly handle multi byte strings
127 127
 	$smcFunc += array(
128
-		'entity_fix' => function ($string)
128
+		'entity_fix' => function($string)
129 129
 		{
130 130
 			$num = $string[0] === 'x' ? hexdec(substr($string, 1)) : (int) $string;
131 131
 			return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202E || $num === 0x202D ? '' : '&#' . $num . ';';
132 132
 		},
133
-		'htmlspecialchars' => function ($string, $quote_style = ENT_COMPAT, $charset = 'ISO-8859-1') use ($ent_check, $utf8, $fix_utf8mb4)
133
+		'htmlspecialchars' => function($string, $quote_style = ENT_COMPAT, $charset = 'ISO-8859-1') use ($ent_check, $utf8, $fix_utf8mb4)
134 134
 		{
135 135
 			return $fix_utf8mb4($ent_check(htmlspecialchars($string, $quote_style, $utf8 ? 'UTF-8' : $charset)));
136 136
 		},
137
-		'htmltrim' => function ($string) use ($utf8, $space_chars, $ent_check)
137
+		'htmltrim' => function($string) use ($utf8, $space_chars, $ent_check)
138 138
 		{
139 139
 			return preg_replace('~^(?:[ \t\n\r\x0B\x00' . $space_chars . ']|&nbsp;)+|(?:[ \t\n\r\x0B\x00' . $space_chars . ']|&nbsp;)+$~' . ($utf8 ? 'u' : ''), '', $ent_check($string));
140 140
 		},
141
-		'strlen' => function ($string) use ($ent_list, $utf8, $ent_check)
141
+		'strlen' => function($string) use ($ent_list, $utf8, $ent_check)
142 142
 		{
143 143
 			return strlen(preg_replace('~' . $ent_list . ($utf8 ? '|.~u' : '~'), '_', $ent_check($string)));
144 144
 		},
145
-		'strpos' => function ($haystack, $needle, $offset = 0) use ($utf8, $ent_check, $modSettings)
145
+		'strpos' => function($haystack, $needle, $offset = 0) use ($utf8, $ent_check, $modSettings)
146 146
 		{
147 147
 			$haystack_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|&quot;|&amp;|&lt;|&gt;|&nbsp;|.)~' . ($utf8 ? 'u' : ''), $ent_check($haystack), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
148 148
 
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 				return false;
168 168
 			}
169 169
 		},
170
-		'substr' => function ($string, $start, $length = null) use ($utf8, $ent_check, $modSettings)
170
+		'substr' => function($string, $start, $length = null) use ($utf8, $ent_check, $modSettings)
171 171
 		{
172 172
 			$ent_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|&quot;|&amp;|&lt;|&gt;|&nbsp;|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($string), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
173 173
 			return $length === null ? implode('', array_slice($ent_arr, $start)) : implode('', array_slice($ent_arr, $start, $length));
174 174
 		},
175
-		'strtolower' => $utf8 ? function ($string) use ($sourcedir)
175
+		'strtolower' => $utf8 ? function($string) use ($sourcedir)
176 176
 		{
177 177
 			if (!function_exists('mb_strtolower'))
178 178
 			{
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 			return mb_strtolower($string, 'UTF-8');
184 184
 		} : 'strtolower',
185
-		'strtoupper' => $utf8 ? function ($string)
185
+		'strtoupper' => $utf8 ? function($string)
186 186
 		{
187 187
 			global $sourcedir;
188 188
 
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 		'truncate' => function($string, $length) use ($utf8, $ent_check, $ent_list, &$smcFunc)
198 198
 		{
199 199
 			$string = $ent_check($string);
200
-			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~'.  ($utf8 ? 'u' : ''), $string, $matches);
200
+			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches);
201 201
 			$string = $matches[0];
202 202
 			while (strlen($string) > $length)
203
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~'.  ($utf8 ? 'u' : ''), '', $string);
203
+				$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
204 204
 			return $string;
205 205
 		},
206
-		'ucfirst' => $utf8 ? function ($string) use (&$smcFunc)
206
+		'ucfirst' => $utf8 ? function($string) use (&$smcFunc)
207 207
 		{
208 208
 			return $smcFunc['strtoupper']($smcFunc['substr']($string, 0, 1)) . $smcFunc['substr']($string, 1);
209 209
 		} : 'ucfirst',
210
-		'ucwords' => $utf8 ? function ($string) use (&$smcFunc)
210
+		'ucwords' => $utf8 ? function($string) use (&$smcFunc)
211 211
 		{
212 212
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
213 213
 			for ($i = 0, $n = count($words); $i < $n; $i += 2)
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 		else
607 607
 		{
608 608
 			// !!! Compatibility.
609
-			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 :$user_settings['time_offset'];
609
+			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
610 610
 		}
611 611
 	}
612 612
 	// If the user is a guest, initialize all the critical user settings.
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
 			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false)
1262 1262
 				$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1263 1263
 
1264
-			if ( isset($row['member_ip']) )
1264
+			if (isset($row['member_ip']))
1265 1265
 				$row['member_ip'] = inet_dtop($row['member_ip']);
1266
-			if ( isset($row['member_ip2']) )
1266
+			if (isset($row['member_ip2']))
1267 1267
 				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1268 1268
 			$new_loaded_ids[] = $row['id_member'];
1269 1269
 			$loaded_ids[] = $row['id_member'];
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 		'name' => $profile['real_name'],
1412 1412
 		'id' => $profile['id_member'],
1413 1413
 		'href' => $scripturl . '?action=profile;u=' . $profile['id_member'],
1414
-		'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '" '. (!empty($modSettings['onlineEnable']) ? 'class="pm_icon"' : '').'>' . $profile['real_name'] . '</a>',
1414
+		'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '" ' . (!empty($modSettings['onlineEnable']) ? 'class="pm_icon"' : '') . '>' . $profile['real_name'] . '</a>',
1415 1415
 		'email' => $profile['email_address'],
1416 1416
 		'show_email' => !$user_info['is_guest'] && ($user_info['id'] == $profile['id_member'] || allowedTo('moderate_forum')),
1417 1417
 		'registered' => empty($profile['date_registered']) ? $txt['not_applicable'] : timeformat($profile['date_registered']),
@@ -1426,9 +1426,9 @@  discard block
 block discarded – undo
1426 1426
 			$loadedLanguages = getLanguages();
1427 1427
 
1428 1428
 		$memberContext[$user] += array(
1429
-			'username_color' => '<span '. (!empty($profile['member_group_color']) ? 'style="color:'. $profile['member_group_color'] .';"' : '') .'>'. $profile['member_name'] .'</span>',
1430
-			'name_color' => '<span '. (!empty($profile['member_group_color']) ? 'style="color:'. $profile['member_group_color'] .';"' : '') .'>'. $profile['real_name'] .'</span>',
1431
-			'link_color' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '" '. (!empty($profile['member_group_color']) ? 'style="color:'. $profile['member_group_color'] .';"' : '') .'>' . $profile['real_name'] . '</a>',
1429
+			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
1430
+			'name_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['real_name'] . '</span>',
1431
+			'link_color' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '" ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['real_name'] . '</a>',
1432 1432
 			'is_buddy' => $profile['buddy'],
1433 1433
 			'is_reverse_buddy' => in_array($user_info['id'], $buddy_list),
1434 1434
 			'buddies' => $buddy_list,
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 		if (!empty($image))
1499 1499
 			$memberContext[$user]['avatar'] = array(
1500 1500
 				'name' => $profile['avatar'],
1501
-				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_'. $profile['member_name'].'">',
1501
+				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1502 1502
 				'href' => $image,
1503 1503
 				'url' => $image,
1504 1504
 			);
@@ -2813,7 +2813,7 @@  discard block
 block discarded – undo
2813 2813
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2814 2814
 
2815 2815
 					// Get the line we need.
2816
-					$fp = @fopen($language_dir .'/'. $entry);
2816
+					$fp = @fopen($language_dir . '/' . $entry);
2817 2817
 
2818 2818
 					// Yay!
2819 2819
 					if ($fp)
@@ -3463,7 +3463,7 @@  discard block
 block discarded – undo
3463 3463
 	$port = 0;
3464 3464
 
3465 3465
 	// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
3466
-	if(strpos($server,'/') !== false)
3466
+	if (strpos($server, '/') !== false)
3467 3467
 		$host = $server;
3468 3468
 	else
3469 3469
 	{
Please login to merge, or discard this patch.
Braces   +857 added lines, -646 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
  * Load the $modSettings array.
@@ -25,12 +26,13 @@  discard block
 block discarded – undo
25 26
 	global $cache_enable, $sourcedir, $context;
26 27
 
27 28
 	// Most database systems have not set UTF-8 as their default input charset.
28
-	if (!empty($db_character_set))
29
-		$smcFunc['db_query']('set_character_set', '
29
+	if (!empty($db_character_set)) {
30
+			$smcFunc['db_query']('set_character_set', '
30 31
 			SET NAMES ' . $db_character_set,
31 32
 			array(
32 33
 			)
33 34
 		);
35
+	}
34 36
 
35 37
 	// Try to load it from the cache first; it'll never get cached if the setting is off.
36 38
 	if (($modSettings = cache_get_data('modSettings', 90)) == null)
@@ -42,27 +44,35 @@  discard block
 block discarded – undo
42 44
 			)
43 45
 		);
44 46
 		$modSettings = array();
45
-		if (!$request)
46
-			display_db_error();
47
-		while ($row = $smcFunc['db_fetch_row']($request))
48
-			$modSettings[$row[0]] = $row[1];
47
+		if (!$request) {
48
+					display_db_error();
49
+		}
50
+		while ($row = $smcFunc['db_fetch_row']($request)) {
51
+					$modSettings[$row[0]] = $row[1];
52
+		}
49 53
 		$smcFunc['db_free_result']($request);
50 54
 
51 55
 		// Do a few things to protect against missing settings or settings with invalid values...
52
-		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
53
-			$modSettings['defaultMaxTopics'] = 20;
54
-		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
55
-			$modSettings['defaultMaxMessages'] = 15;
56
-		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
57
-			$modSettings['defaultMaxMembers'] = 30;
58
-		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
59
-			$modSettings['defaultMaxListItems'] = 15;
56
+		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
57
+					$modSettings['defaultMaxTopics'] = 20;
58
+		}
59
+		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
60
+					$modSettings['defaultMaxMessages'] = 15;
61
+		}
62
+		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
63
+					$modSettings['defaultMaxMembers'] = 30;
64
+		}
65
+		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) {
66
+					$modSettings['defaultMaxListItems'] = 15;
67
+		}
60 68
 
61
-		if (!is_array($modSettings['attachmentUploadDir']))
62
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
69
+		if (!is_array($modSettings['attachmentUploadDir'])) {
70
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
71
+		}
63 72
 
64
-		if (!empty($cache_enable))
65
-			cache_put_data('modSettings', $modSettings, 90);
73
+		if (!empty($cache_enable)) {
74
+					cache_put_data('modSettings', $modSettings, 90);
75
+		}
66 76
 	}
67 77
 
68 78
 	$modSettings['cache_enable'] = $cache_enable;
@@ -82,8 +92,9 @@  discard block
 block discarded – undo
82 92
 		};
83 93
 	$fix_utf8mb4 = function ($string) use ($utf8)
84 94
 	{
85
-		if (!$utf8)
86
-			return $string;
95
+		if (!$utf8) {
96
+					return $string;
97
+		}
87 98
 
88 99
 		$i = 0;
89 100
 		$len = strlen($string);
@@ -95,18 +106,15 @@  discard block
 block discarded – undo
95 106
 			{
96 107
 				$new_string .= $string[$i];
97 108
 				$i++;
98
-			}
99
-			elseif ($ord < 224)
109
+			} elseif ($ord < 224)
100 110
 			{
101 111
 				$new_string .= $string[$i] . $string[$i+1];
102 112
 				$i += 2;
103
-			}
104
-			elseif ($ord < 240)
113
+			} elseif ($ord < 240)
105 114
 			{
106 115
 				$new_string .= $string[$i] . $string[$i+1] . $string[$i+2];
107 116
 				$i += 3;
108
-			}
109
-			elseif ($ord < 248)
117
+			} elseif ($ord < 248)
110 118
 			{
111 119
 				// Magic happens.
112 120
 				$val = (ord($string[$i]) & 0x07) << 18;
@@ -150,8 +158,7 @@  discard block
 block discarded – undo
150 158
 			{
151 159
 				$result = array_search($needle, array_slice($haystack_arr, $offset));
152 160
 				return is_int($result) ? $result + $offset : false;
153
-			}
154
-			else
161
+			} else
155 162
 			{
156 163
 				$needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|&quot;|&amp;|&lt;|&gt;|&nbsp;|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
157 164
 				$needle_size = count($needle_arr);
@@ -160,8 +167,9 @@  discard block
 block discarded – undo
160 167
 				while ((int) $result === $result)
161 168
 				{
162 169
 					$offset += $result;
163
-					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
164
-						return $offset;
170
+					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) {
171
+											return $offset;
172
+					}
165 173
 					$result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset));
166 174
 				}
167 175
 				return false;
@@ -199,8 +207,9 @@  discard block
 block discarded – undo
199 207
 			$string = $ent_check($string);
200 208
 			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~'.  ($utf8 ? 'u' : ''), $string, $matches);
201 209
 			$string = $matches[0];
202
-			while (strlen($string) > $length)
203
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~'.  ($utf8 ? 'u' : ''), '', $string);
210
+			while (strlen($string) > $length) {
211
+							$string = preg_replace('~(?:' . $ent_list . '|.)$~'.  ($utf8 ? 'u' : ''), '', $string);
212
+			}
204 213
 			return $string;
205 214
 		},
206 215
 		'ucfirst' => $utf8 ? function ($string) use (&$smcFunc)
@@ -210,15 +219,17 @@  discard block
 block discarded – undo
210 219
 		'ucwords' => $utf8 ? function ($string) use (&$smcFunc)
211 220
 		{
212 221
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
213
-			for ($i = 0, $n = count($words); $i < $n; $i += 2)
214
-				$words[$i] = $smcFunc['ucfirst']($words[$i]);
222
+			for ($i = 0, $n = count($words); $i < $n; $i += 2) {
223
+							$words[$i] = $smcFunc['ucfirst']($words[$i]);
224
+			}
215 225
 			return implode('', $words);
216 226
 		} : 'ucwords',
217 227
 	);
218 228
 
219 229
 	// Setting the timezone is a requirement for some functions.
220
-	if (isset($modSettings['default_timezone']))
221
-		date_default_timezone_set($modSettings['default_timezone']);
230
+	if (isset($modSettings['default_timezone'])) {
231
+			date_default_timezone_set($modSettings['default_timezone']);
232
+	}
222 233
 
223 234
 	// Check the load averages?
224 235
 	if (!empty($modSettings['loadavg_enable']))
@@ -226,22 +237,26 @@  discard block
 block discarded – undo
226 237
 		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
227 238
 		{
228 239
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
229
-			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
230
-				$modSettings['load_average'] = (float) $matches[1];
231
-			elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0)
232
-				$modSettings['load_average'] = (float) $matches[1];
233
-			else
234
-				unset($modSettings['load_average']);
240
+			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
241
+							$modSettings['load_average'] = (float) $matches[1];
242
+			} elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) {
243
+							$modSettings['load_average'] = (float) $matches[1];
244
+			} else {
245
+							unset($modSettings['load_average']);
246
+			}
235 247
 
236
-			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
237
-				cache_put_data('loadavg', $modSettings['load_average'], 90);
248
+			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
249
+							cache_put_data('loadavg', $modSettings['load_average'], 90);
250
+			}
238 251
 		}
239 252
 
240
-		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
241
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
253
+		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
254
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
255
+		}
242 256
 
243
-		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum'])
244
-			display_loadavg_error();
257
+		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
258
+					display_loadavg_error();
259
+		}
245 260
 	}
246 261
 
247 262
 	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
@@ -262,8 +277,9 @@  discard block
 block discarded – undo
262 277
 	if (defined('SMF_INTEGRATION_SETTINGS'))
263 278
 	{
264 279
 		$integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true);
265
-		foreach ($integration_settings as $hook => $function)
266
-			add_integration_function($hook, $function, '', false);
280
+		foreach ($integration_settings as $hook => $function) {
281
+					add_integration_function($hook, $function, '', false);
282
+		}
267 283
 	}
268 284
 
269 285
 	// Any files to pre include?
@@ -273,8 +289,9 @@  discard block
 block discarded – undo
273 289
 		foreach ($pre_includes as $include)
274 290
 		{
275 291
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
276
-			if (file_exists($include))
277
-				require_once($include);
292
+			if (file_exists($include)) {
293
+							require_once($include);
294
+			}
278 295
 		}
279 296
 	}
280 297
 
@@ -378,27 +395,28 @@  discard block
 block discarded – undo
378 395
 				break;
379 396
 			}
380 397
 		}
398
+	} else {
399
+			$id_member = 0;
381 400
 	}
382
-	else
383
-		$id_member = 0;
384 401
 
385 402
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
386 403
 	{
387 404
 		$cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false);
388 405
 
389
-		if (empty($cookie_data))
390
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
406
+		if (empty($cookie_data)) {
407
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
408
+		}
391 409
 
392 410
 		list ($id_member, $password) = $cookie_data;
393 411
 		$id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;
394
-	}
395
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
412
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
396 413
 	{
397 414
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
398 415
 		$cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]);
399 416
 
400
-		if (empty($cookie_data))
401
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
417
+		if (empty($cookie_data)) {
418
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
419
+		}
402 420
 
403 421
 		list ($id_member, $password, $login_span) = $cookie_data;
404 422
 		$id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0;
@@ -423,30 +441,34 @@  discard block
 block discarded – undo
423 441
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
424 442
 			$smcFunc['db_free_result']($request);
425 443
 
426
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false)
427
-				$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
444
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) {
445
+							$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);
446
+			}
428 447
 
429
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
430
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
448
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
449
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
450
+			}
431 451
 		}
432 452
 
433 453
 		// Did we find 'im?  If not, junk it.
434 454
 		if (!empty($user_settings))
435 455
 		{
436 456
 			// As much as the password should be right, we can assume the integration set things up.
437
-			if (!empty($already_verified) && $already_verified === true)
438
-				$check = true;
457
+			if (!empty($already_verified) && $already_verified === true) {
458
+							$check = true;
459
+			}
439 460
 			// SHA-512 hash should be 128 characters long.
440
-			elseif (strlen($password) == 128)
441
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
442
-			else
443
-				$check = false;
461
+			elseif (strlen($password) == 128) {
462
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
463
+			} else {
464
+							$check = false;
465
+			}
444 466
 
445 467
 			// Wrong password or not activated - either way, you're going nowhere.
446 468
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
469
+		} else {
470
+					$id_member = 0;
447 471
 		}
448
-		else
449
-			$id_member = 0;
450 472
 
451 473
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
452 474
 		if (!$id_member)
@@ -468,13 +490,15 @@  discard block
 block discarded – undo
468 490
 				{
469 491
 					$tfa_data = smf_json_decode($_COOKIE[$tfacookie]);
470 492
 
471
-					if (is_null($tfa_data))
472
-						$tfa_data = safe_unserialize($_COOKIE[$tfacookie]);
493
+					if (is_null($tfa_data)) {
494
+											$tfa_data = safe_unserialize($_COOKIE[$tfacookie]);
495
+					}
473 496
 
474 497
 					list ($tfamember, $tfasecret) = $tfa_data;
475 498
 
476
-					if ((int) $tfamember != $id_member)
477
-						$tfasecret = null;
499
+					if ((int) $tfamember != $id_member) {
500
+											$tfasecret = null;
501
+					}
478 502
 				}
479 503
 
480 504
 				if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret)
@@ -494,10 +518,12 @@  discard block
 block discarded – undo
494 518
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
495 519
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
496 520
 		{
497
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
521
+			if ($modSettings['tfa_mode'] == 2) {
522
+				//only do this if we are just forcing SOME membergroups
498 523
 			{
499 524
 				//Build an array of ALL user membergroups.
500 525
 				$full_groups = array($user_settings['id_group']);
526
+			}
501 527
 				if (!empty($user_settings['additional_groups']))
502 528
 				{
503 529
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -517,15 +543,17 @@  discard block
 block discarded – undo
517 543
 				);
518 544
 				$row = $smcFunc['db_fetch_assoc']($request);
519 545
 				$smcFunc['db_free_result']($request);
546
+			} else {
547
+							$row['total'] = 1;
520 548
 			}
521
-			else
522
-				$row['total'] = 1; //simplifies logics in the next "if"
549
+			//simplifies logics in the next "if"
523 550
 
524 551
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
525 552
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
526 553
 
527
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
528
-				redirectexit('action=profile;area=tfasetup;forced');
554
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
555
+							redirectexit('action=profile;area=tfasetup;forced');
556
+			}
529 557
 		}
530 558
 	}
531 559
 
@@ -562,33 +590,37 @@  discard block
 block discarded – undo
562 590
 				updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
563 591
 				$user_settings['last_login'] = time();
564 592
 
565
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
566
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
593
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
594
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
595
+				}
567 596
 
568
-				if (!empty($modSettings['cache_enable']))
569
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
597
+				if (!empty($modSettings['cache_enable'])) {
598
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
599
+				}
570 600
 			}
601
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
602
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
571 603
 		}
572
-		elseif (empty($_SESSION['id_msg_last_visit']))
573
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
574 604
 
575 605
 		$username = $user_settings['member_name'];
576 606
 
577
-		if (empty($user_settings['additional_groups']))
578
-			$user_info = array(
607
+		if (empty($user_settings['additional_groups'])) {
608
+					$user_info = array(
579 609
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
580 610
 			);
581
-		else
582
-			$user_info = array(
611
+		} else {
612
+					$user_info = array(
583 613
 				'groups' => array_merge(
584 614
 					array($user_settings['id_group'], $user_settings['id_post_group']),
585 615
 					explode(',', $user_settings['additional_groups'])
586 616
 				)
587 617
 			);
618
+		}
588 619
 
589 620
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
590
-		foreach ($user_info['groups'] as $k => $v)
591
-			$user_info['groups'][$k] = (int) $v;
621
+		foreach ($user_info['groups'] as $k => $v) {
622
+					$user_info['groups'][$k] = (int) $v;
623
+		}
592 624
 
593 625
 		// This is a logged in user, so definitely not a spider.
594 626
 		$user_info['possibly_robot'] = false;
@@ -602,8 +634,7 @@  discard block
 block discarded – undo
602 634
 			$time_system = new DateTime('now', $tz_system);
603 635
 			$time_user = new DateTime('now', $tz_user);
604 636
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
605
-		}
606
-		else
637
+		} else
607 638
 		{
608 639
 			// !!! Compatibility.
609 640
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 :$user_settings['time_offset'];
@@ -617,16 +648,18 @@  discard block
 block discarded – undo
617 648
 		$user_info = array('groups' => array(-1));
618 649
 		$user_settings = array();
619 650
 
620
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
621
-			$_COOKIE[$cookiename] = '';
651
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
652
+					$_COOKIE[$cookiename] = '';
653
+		}
622 654
 
623 655
 		// Expire the 2FA cookie
624 656
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
625 657
 		{
626 658
 			$tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true);
627 659
 
628
-			if (is_null($tfa_data))
629
-				$tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
660
+			if (is_null($tfa_data)) {
661
+							$tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
662
+			}
630 663
 
631 664
 			list ($id, $user, $exp, $state, $preserve) = $tfa_data;
632 665
 
@@ -638,19 +671,20 @@  discard block
 block discarded – undo
638 671
 		}
639 672
 
640 673
 		// Create a login token if it doesn't exist yet.
641
-		if (!isset($_SESSION['token']['post-login']))
642
-			createToken('login');
643
-		else
644
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
674
+		if (!isset($_SESSION['token']['post-login'])) {
675
+					createToken('login');
676
+		} else {
677
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
678
+		}
645 679
 
646 680
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
647 681
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
648 682
 		{
649 683
 			require_once($sourcedir . '/ManageSearchEngines.php');
650 684
 			$user_info['possibly_robot'] = SpiderCheck();
685
+		} elseif (!empty($modSettings['spider_mode'])) {
686
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
651 687
 		}
652
-		elseif (!empty($modSettings['spider_mode']))
653
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
654 688
 		// If we haven't turned on proper spider hunts then have a guess!
655 689
 		else
656 690
 		{
@@ -698,8 +732,9 @@  discard block
 block discarded – undo
698 732
 	$user_info['groups'] = array_unique($user_info['groups']);
699 733
 
700 734
 	// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
701
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
702
-		unset($user_info['ignoreboards'][$tmp]);
735
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
736
+			unset($user_info['ignoreboards'][$tmp]);
737
+	}
703 738
 
704 739
 	// Allow the user to change their language.
705 740
 	if (!empty($modSettings['userLanguage']))
@@ -712,31 +747,36 @@  discard block
 block discarded – undo
712 747
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
713 748
 
714 749
 			// Make it permanent for members.
715
-			if (!empty($user_info['id']))
716
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
717
-			else
718
-				$_SESSION['language'] = $user_info['language'];
750
+			if (!empty($user_info['id'])) {
751
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
752
+			} else {
753
+							$_SESSION['language'] = $user_info['language'];
754
+			}
755
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
756
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
719 757
 		}
720
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
721
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
722 758
 	}
723 759
 
724 760
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
725
-	if ($user_info['is_admin'])
726
-		$user_info['query_see_board'] = '1=1';
761
+	if ($user_info['is_admin']) {
762
+			$user_info['query_see_board'] = '1=1';
763
+	}
727 764
 	// Otherwise just the groups in $user_info['groups'].
728
-	else
729
-		$user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
765
+	else {
766
+			$user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
767
+	}
730 768
 
731 769
 	// Build the list of boards they WANT to see.
732 770
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
733 771
 
734 772
 	// If they aren't ignoring any boards then they want to see all the boards they can see
735
-	if (empty($user_info['ignoreboards']))
736
-		$user_info['query_wanna_see_board'] = $user_info['query_see_board'];
773
+	if (empty($user_info['ignoreboards'])) {
774
+			$user_info['query_wanna_see_board'] = $user_info['query_see_board'];
775
+	}
737 776
 	// Ok I guess they don't want to see all the boards
738
-	else
739
-		$user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
777
+	else {
778
+			$user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
779
+	}
740 780
 
741 781
 	call_integration_hook('integrate_user_info');
742 782
 }
@@ -794,9 +834,9 @@  discard block
 block discarded – undo
794 834
 		}
795 835
 
796 836
 		// Remember redirection is the key to avoiding fallout from your bosses.
797
-		if (!empty($topic))
798
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
799
-		else
837
+		if (!empty($topic)) {
838
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
839
+		} else
800 840
 		{
801 841
 			loadPermissions();
802 842
 			loadTheme();
@@ -814,10 +854,11 @@  discard block
 block discarded – undo
814 854
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
815 855
 	{
816 856
 		// @todo SLOW?
817
-		if (!empty($topic))
818
-			$temp = cache_get_data('topic_board-' . $topic, 120);
819
-		else
820
-			$temp = cache_get_data('board-' . $board, 120);
857
+		if (!empty($topic)) {
858
+					$temp = cache_get_data('topic_board-' . $topic, 120);
859
+		} else {
860
+					$temp = cache_get_data('board-' . $board, 120);
861
+		}
821 862
 
822 863
 		if (!empty($temp))
823 864
 		{
@@ -855,8 +896,9 @@  discard block
 block discarded – undo
855 896
 			$row = $smcFunc['db_fetch_assoc']($request);
856 897
 
857 898
 			// Set the current board.
858
-			if (!empty($row['id_board']))
859
-				$board = $row['id_board'];
899
+			if (!empty($row['id_board'])) {
900
+							$board = $row['id_board'];
901
+			}
860 902
 
861 903
 			// Basic operating information. (globals... :/)
862 904
 			$board_info = array(
@@ -892,21 +934,23 @@  discard block
 block discarded – undo
892 934
 
893 935
 			do
894 936
 			{
895
-				if (!empty($row['id_moderator']))
896
-					$board_info['moderators'][$row['id_moderator']] = array(
937
+				if (!empty($row['id_moderator'])) {
938
+									$board_info['moderators'][$row['id_moderator']] = array(
897 939
 						'id' => $row['id_moderator'],
898 940
 						'name' => $row['real_name'],
899 941
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
900 942
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
901 943
 					);
944
+				}
902 945
 
903
-				if (!empty($row['id_moderator_group']))
904
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
946
+				if (!empty($row['id_moderator_group'])) {
947
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
905 948
 						'id' => $row['id_moderator_group'],
906 949
 						'name' => $row['group_name'],
907 950
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
908 951
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
909 952
 					);
953
+				}
910 954
 			}
911 955
 			while ($row = $smcFunc['db_fetch_assoc']($request));
912 956
 
@@ -938,12 +982,12 @@  discard block
 block discarded – undo
938 982
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
939 983
 			{
940 984
 				// @todo SLOW?
941
-				if (!empty($topic))
942
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
985
+				if (!empty($topic)) {
986
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
987
+				}
943 988
 				cache_put_data('board-' . $board, $board_info, 120);
944 989
 			}
945
-		}
946
-		else
990
+		} else
947 991
 		{
948 992
 			// Otherwise the topic is invalid, there are no moderators, etc.
949 993
 			$board_info = array(
@@ -957,8 +1001,9 @@  discard block
 block discarded – undo
957 1001
 		$smcFunc['db_free_result']($request);
958 1002
 	}
959 1003
 
960
-	if (!empty($topic))
961
-		$_GET['board'] = (int) $board;
1004
+	if (!empty($topic)) {
1005
+			$_GET['board'] = (int) $board;
1006
+	}
962 1007
 
963 1008
 	if (!empty($board))
964 1009
 	{
@@ -968,10 +1013,12 @@  discard block
 block discarded – undo
968 1013
 		// Now check if the user is a moderator.
969 1014
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
970 1015
 
971
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
972
-			$board_info['error'] = 'access';
973
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
974
-			$board_info['error'] = 'access';
1016
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1017
+					$board_info['error'] = 'access';
1018
+		}
1019
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1020
+					$board_info['error'] = 'access';
1021
+		}
975 1022
 
976 1023
 		// Build up the linktree.
977 1024
 		$context['linktree'] = array_merge(
@@ -994,8 +1041,9 @@  discard block
 block discarded – undo
994 1041
 	$context['current_board'] = $board;
995 1042
 
996 1043
 	// No posting in redirection boards!
997
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
998
-		$board_info['error'] == 'post_in_redirect';
1044
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1045
+			$board_info['error'] == 'post_in_redirect';
1046
+	}
999 1047
 
1000 1048
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1001 1049
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1021,24 +1069,23 @@  discard block
 block discarded – undo
1021 1069
 			ob_end_clean();
1022 1070
 			header('HTTP/1.1 403 Forbidden');
1023 1071
 			die;
1024
-		}
1025
-		elseif ($board_info['error'] == 'post_in_redirect')
1072
+		} elseif ($board_info['error'] == 'post_in_redirect')
1026 1073
 		{
1027 1074
 			// Slightly different error message here...
1028 1075
 			fatal_lang_error('cannot_post_redirect', false);
1029
-		}
1030
-		elseif ($user_info['is_guest'])
1076
+		} elseif ($user_info['is_guest'])
1031 1077
 		{
1032 1078
 			loadLanguage('Errors');
1033 1079
 			is_not_guest($txt['topic_gone']);
1080
+		} else {
1081
+					fatal_lang_error('topic_gone', false);
1034 1082
 		}
1035
-		else
1036
-			fatal_lang_error('topic_gone', false);
1037 1083
 	}
1038 1084
 
1039
-	if ($user_info['is_mod'])
1040
-		$user_info['groups'][] = 3;
1041
-}
1085
+	if ($user_info['is_mod']) {
1086
+			$user_info['groups'][] = 3;
1087
+	}
1088
+	}
1042 1089
 
1043 1090
 /**
1044 1091
  * Load this user's permissions.
@@ -1059,8 +1106,9 @@  discard block
 block discarded – undo
1059 1106
 		asort($cache_groups);
1060 1107
 		$cache_groups = implode(',', $cache_groups);
1061 1108
 		// If it's a spider then cache it different.
1062
-		if ($user_info['possibly_robot'])
1063
-			$cache_groups .= '-spider';
1109
+		if ($user_info['possibly_robot']) {
1110
+					$cache_groups .= '-spider';
1111
+		}
1064 1112
 
1065 1113
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1066 1114
 		{
@@ -1068,9 +1116,9 @@  discard block
 block discarded – undo
1068 1116
 			banPermissions();
1069 1117
 
1070 1118
 			return;
1119
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1120
+					list ($user_info['permissions'], $removals) = $temp;
1071 1121
 		}
1072
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1073
-			list ($user_info['permissions'], $removals) = $temp;
1074 1122
 	}
1075 1123
 
1076 1124
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1092,23 +1140,26 @@  discard block
 block discarded – undo
1092 1140
 		$removals = array();
1093 1141
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1094 1142
 		{
1095
-			if (empty($row['add_deny']))
1096
-				$removals[] = $row['permission'];
1097
-			else
1098
-				$user_info['permissions'][] = $row['permission'];
1143
+			if (empty($row['add_deny'])) {
1144
+							$removals[] = $row['permission'];
1145
+			} else {
1146
+							$user_info['permissions'][] = $row['permission'];
1147
+			}
1099 1148
 		}
1100 1149
 		$smcFunc['db_free_result']($request);
1101 1150
 
1102
-		if (isset($cache_groups))
1103
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1151
+		if (isset($cache_groups)) {
1152
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1153
+		}
1104 1154
 	}
1105 1155
 
1106 1156
 	// Get the board permissions.
1107 1157
 	if (!empty($board))
1108 1158
 	{
1109 1159
 		// Make sure the board (if any) has been loaded by loadBoard().
1110
-		if (!isset($board_info['profile']))
1111
-			fatal_lang_error('no_board');
1160
+		if (!isset($board_info['profile'])) {
1161
+					fatal_lang_error('no_board');
1162
+		}
1112 1163
 
1113 1164
 		$request = $smcFunc['db_query']('', '
1114 1165
 			SELECT permission, add_deny
@@ -1124,20 +1175,23 @@  discard block
 block discarded – undo
1124 1175
 		);
1125 1176
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1126 1177
 		{
1127
-			if (empty($row['add_deny']))
1128
-				$removals[] = $row['permission'];
1129
-			else
1130
-				$user_info['permissions'][] = $row['permission'];
1178
+			if (empty($row['add_deny'])) {
1179
+							$removals[] = $row['permission'];
1180
+			} else {
1181
+							$user_info['permissions'][] = $row['permission'];
1182
+			}
1131 1183
 		}
1132 1184
 		$smcFunc['db_free_result']($request);
1133 1185
 	}
1134 1186
 
1135 1187
 	// Remove all the permissions they shouldn't have ;).
1136
-	if (!empty($modSettings['permission_enable_deny']))
1137
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1188
+	if (!empty($modSettings['permission_enable_deny'])) {
1189
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1190
+	}
1138 1191
 
1139
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1140
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1192
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1193
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1194
+	}
1141 1195
 
1142 1196
 	// Banned?  Watch, don't touch..
1143 1197
 	banPermissions();
@@ -1149,17 +1203,18 @@  discard block
 block discarded – undo
1149 1203
 		{
1150 1204
 			require_once($sourcedir . '/Subs-Auth.php');
1151 1205
 			rebuildModCache();
1206
+		} else {
1207
+					$user_info['mod_cache'] = $_SESSION['mc'];
1152 1208
 		}
1153
-		else
1154
-			$user_info['mod_cache'] = $_SESSION['mc'];
1155 1209
 
1156 1210
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1157 1211
 		// For example this drastically simplifies certain changes to the profile area.
1158 1212
 		$user_info['permissions'][] = 'is_not_guest';
1159 1213
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1160 1214
 		$user_info['permissions'][] = 'profile_view_own';
1161
-		if (in_array('profile_view', $user_info['permissions']))
1162
-			$user_info['permissions'][] = 'profile_view_any';
1215
+		if (in_array('profile_view', $user_info['permissions'])) {
1216
+					$user_info['permissions'][] = 'profile_view_any';
1217
+		}
1163 1218
 	}
1164 1219
 }
1165 1220
 
@@ -1177,8 +1232,9 @@  discard block
 block discarded – undo
1177 1232
 	global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1178 1233
 
1179 1234
 	// Can't just look for no users :P.
1180
-	if (empty($users))
1181
-		return array();
1235
+	if (empty($users)) {
1236
+			return array();
1237
+	}
1182 1238
 
1183 1239
 	// Pass the set value
1184 1240
 	$context['loadMemberContext_set'] = $set;
@@ -1193,8 +1249,9 @@  discard block
 block discarded – undo
1193 1249
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1194 1250
 		{
1195 1251
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1196
-			if ($data == null)
1197
-				continue;
1252
+			if ($data == null) {
1253
+							continue;
1254
+			}
1198 1255
 
1199 1256
 			$loaded_ids[] = $data['id_member'];
1200 1257
 			$user_profile[$data['id_member']] = $data;
@@ -1258,13 +1315,16 @@  discard block
 block discarded – undo
1258 1315
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1259 1316
 		{
1260 1317
 			// Take care of proxying avatar if required, do this here for maximum reach
1261
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false)
1262
-				$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1318
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) {
1319
+							$row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret);
1320
+			}
1263 1321
 
1264
-			if ( isset($row['member_ip']) )
1265
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1266
-			if ( isset($row['member_ip2']) )
1267
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1322
+			if ( isset($row['member_ip']) ) {
1323
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1324
+			}
1325
+			if ( isset($row['member_ip2']) ) {
1326
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1327
+			}
1268 1328
 			$new_loaded_ids[] = $row['id_member'];
1269 1329
 			$loaded_ids[] = $row['id_member'];
1270 1330
 			$row['options'] = array();
@@ -1283,8 +1343,9 @@  discard block
 block discarded – undo
1283 1343
 				'loaded_ids' => $new_loaded_ids,
1284 1344
 			)
1285 1345
 		);
1286
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1287
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1346
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1347
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1348
+		}
1288 1349
 		$smcFunc['db_free_result']($request);
1289 1350
 	}
1290 1351
 
@@ -1295,10 +1356,11 @@  discard block
 block discarded – undo
1295 1356
 	{
1296 1357
 		foreach ($loaded_ids as $a_member)
1297 1358
 		{
1298
-			if (!empty($user_profile[$a_member]['additional_groups']))
1299
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1300
-			else
1301
-				$groups = array($user_profile[$a_member]['id_group']);
1359
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1360
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1361
+			} else {
1362
+							$groups = array($user_profile[$a_member]['id_group']);
1363
+			}
1302 1364
 
1303 1365
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1304 1366
 
@@ -1311,8 +1373,9 @@  discard block
 block discarded – undo
1311 1373
 
1312 1374
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1313 1375
 	{
1314
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1315
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1376
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1377
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1378
+		}
1316 1379
 	}
1317 1380
 
1318 1381
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1338,14 +1401,17 @@  discard block
 block discarded – undo
1338 1401
 		foreach ($temp_mods as $id)
1339 1402
 		{
1340 1403
 			// By popular demand, don't show admins or global moderators as moderators.
1341
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1342
-				$user_profile[$id]['member_group'] = $row['member_group'];
1404
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1405
+							$user_profile[$id]['member_group'] = $row['member_group'];
1406
+			}
1343 1407
 
1344 1408
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1345
-			if (!empty($row['icons']))
1346
-				$user_profile[$id]['icons'] = $row['icons'];
1347
-			if (!empty($row['member_group_color']))
1348
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1409
+			if (!empty($row['icons'])) {
1410
+							$user_profile[$id]['icons'] = $row['icons'];
1411
+			}
1412
+			if (!empty($row['member_group_color'])) {
1413
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1414
+			}
1349 1415
 		}
1350 1416
 	}
1351 1417
 
@@ -1367,12 +1433,14 @@  discard block
 block discarded – undo
1367 1433
 	static $loadedLanguages = array();
1368 1434
 
1369 1435
 	// If this person's data is already loaded, skip it.
1370
-	if (isset($dataLoaded[$user]))
1371
-		return true;
1436
+	if (isset($dataLoaded[$user])) {
1437
+			return true;
1438
+	}
1372 1439
 
1373 1440
 	// We can't load guests or members not loaded by loadMemberData()!
1374
-	if ($user == 0)
1375
-		return false;
1441
+	if ($user == 0) {
1442
+			return false;
1443
+	}
1376 1444
 	if (!isset($user_profile[$user]))
1377 1445
 	{
1378 1446
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1398,12 +1466,16 @@  discard block
 block discarded – undo
1398 1466
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1399 1467
 
1400 1468
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1401
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1469
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1470
+		//icon is set and exists
1402 1471
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1403
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1472
+	} elseif (isset($profile['icons'][1])) {
1473
+		//icon is set and doesn't exist, fallback to default
1404 1474
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1405
-	else //not set, bye bye
1475
+	} else {
1476
+		//not set, bye bye
1406 1477
 		$group_icon_url = '';
1478
+	}
1407 1479
 
1408 1480
 	// These minimal values are always loaded
1409 1481
 	$memberContext[$user] = array(
@@ -1422,8 +1494,9 @@  discard block
 block discarded – undo
1422 1494
 	if ($context['loadMemberContext_set'] != 'minimal')
1423 1495
 	{
1424 1496
 		// Go the extra mile and load the user's native language name.
1425
-		if (empty($loadedLanguages))
1426
-			$loadedLanguages = getLanguages();
1497
+		if (empty($loadedLanguages)) {
1498
+					$loadedLanguages = getLanguages();
1499
+		}
1427 1500
 
1428 1501
 		$memberContext[$user] += array(
1429 1502
 			'username_color' => '<span '. (!empty($profile['member_group_color']) ? 'style="color:'. $profile['member_group_color'] .';"' : '') .'>'. $profile['member_name'] .'</span>',
@@ -1477,31 +1550,33 @@  discard block
 block discarded – undo
1477 1550
 	{
1478 1551
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1479 1552
 		{
1480
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1481
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1482
-			else
1483
-				$image = get_gravatar_url($profile['email_address']);
1484
-		}
1485
-		else
1553
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1554
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1555
+			} else {
1556
+							$image = get_gravatar_url($profile['email_address']);
1557
+			}
1558
+		} else
1486 1559
 		{
1487 1560
 			// So it's stored in the member table?
1488 1561
 			if (!empty($profile['avatar']))
1489 1562
 			{
1490 1563
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1564
+			} elseif (!empty($profile['filename'])) {
1565
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1491 1566
 			}
1492
-			elseif (!empty($profile['filename']))
1493
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1494 1567
 			// Right... no avatar...use the default one
1495
-			else
1496
-				$image = $modSettings['avatar_url'] . '/default.png';
1568
+			else {
1569
+							$image = $modSettings['avatar_url'] . '/default.png';
1570
+			}
1497 1571
 		}
1498
-		if (!empty($image))
1499
-			$memberContext[$user]['avatar'] = array(
1572
+		if (!empty($image)) {
1573
+					$memberContext[$user]['avatar'] = array(
1500 1574
 				'name' => $profile['avatar'],
1501 1575
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_'. $profile['member_name'].'">',
1502 1576
 				'href' => $image,
1503 1577
 				'url' => $image,
1504 1578
 			);
1579
+		}
1505 1580
 	}
1506 1581
 
1507 1582
 	// Are we also loading the members custom fields into context?
@@ -1509,35 +1584,41 @@  discard block
 block discarded – undo
1509 1584
 	{
1510 1585
 		$memberContext[$user]['custom_fields'] = array();
1511 1586
 
1512
-		if (!isset($context['display_fields']))
1513
-			$context['display_fields'] = smf_json_decode($modSettings['displayFields'], true);
1587
+		if (!isset($context['display_fields'])) {
1588
+					$context['display_fields'] = smf_json_decode($modSettings['displayFields'], true);
1589
+		}
1514 1590
 
1515 1591
 		foreach ($context['display_fields'] as $custom)
1516 1592
 		{
1517
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1518
-				continue;
1593
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1594
+							continue;
1595
+			}
1519 1596
 
1520 1597
 			$value = $profile['options'][$custom['col_name']];
1521 1598
 
1522 1599
 			// Don't show the "disabled" option for the "gender" field.
1523
-			if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled')
1524
-				continue;
1600
+			if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') {
1601
+							continue;
1602
+			}
1525 1603
 
1526 1604
 			// BBC?
1527
-			if ($custom['bbc'])
1528
-				$value = parse_bbc($value);
1605
+			if ($custom['bbc']) {
1606
+							$value = parse_bbc($value);
1607
+			}
1529 1608
 			// ... or checkbox?
1530
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1531
-				$value = $value ? $txt['yes'] : $txt['no'];
1609
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1610
+							$value = $value ? $txt['yes'] : $txt['no'];
1611
+			}
1532 1612
 
1533 1613
 			// Enclosing the user input within some other text?
1534
-			if (!empty($custom['enclose']))
1535
-				$value = strtr($custom['enclose'], array(
1614
+			if (!empty($custom['enclose'])) {
1615
+							$value = strtr($custom['enclose'], array(
1536 1616
 					'{SCRIPTURL}' => $scripturl,
1537 1617
 					'{IMAGES_URL}' => $settings['images_url'],
1538 1618
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1539 1619
 					'{INPUT}' => $value,
1540 1620
 				));
1621
+			}
1541 1622
 
1542 1623
 			$memberContext[$user]['custom_fields'][] = array(
1543 1624
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1564,8 +1645,9 @@  discard block
 block discarded – undo
1564 1645
 	global $smcFunc, $txt, $scripturl, $settings;
1565 1646
 
1566 1647
 	// Do not waste my time...
1567
-	if (empty($users) || empty($params))
1568
-		return false;
1648
+	if (empty($users) || empty($params)) {
1649
+			return false;
1650
+	}
1569 1651
 
1570 1652
 	// Make sure it's an array.
1571 1653
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1589,31 +1671,36 @@  discard block
 block discarded – undo
1589 1671
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1590 1672
 	{
1591 1673
 		// BBC?
1592
-		if (!empty($row['bbc']))
1593
-			$row['value'] = parse_bbc($row['value']);
1674
+		if (!empty($row['bbc'])) {
1675
+					$row['value'] = parse_bbc($row['value']);
1676
+		}
1594 1677
 
1595 1678
 		// ... or checkbox?
1596
-		elseif (isset($row['type']) && $row['type'] == 'check')
1597
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1679
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1680
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1681
+		}
1598 1682
 
1599 1683
 		// Enclosing the user input within some other text?
1600
-		if (!empty($row['enclose']))
1601
-			$row['value'] = strtr($row['enclose'], array(
1684
+		if (!empty($row['enclose'])) {
1685
+					$row['value'] = strtr($row['enclose'], array(
1602 1686
 				'{SCRIPTURL}' => $scripturl,
1603 1687
 				'{IMAGES_URL}' => $settings['images_url'],
1604 1688
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1605 1689
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1606 1690
 			));
1691
+		}
1607 1692
 
1608 1693
 		// Send a simple array if there is just 1 param
1609
-		if (count($params) == 1)
1610
-			$return[$row['id_member']] = $row;
1694
+		if (count($params) == 1) {
1695
+					$return[$row['id_member']] = $row;
1696
+		}
1611 1697
 
1612 1698
 		// More than 1? knock yourself out...
1613 1699
 		else
1614 1700
 		{
1615
-			if (!isset($return[$row['id_member']]))
1616
-				$return[$row['id_member']] = array();
1701
+			if (!isset($return[$row['id_member']])) {
1702
+							$return[$row['id_member']] = array();
1703
+			}
1617 1704
 
1618 1705
 			$return[$row['id_member']][$row['variable']] = $row;
1619 1706
 		}
@@ -1647,8 +1734,9 @@  discard block
 block discarded – undo
1647 1734
 	global $context;
1648 1735
 
1649 1736
 	// Don't know any browser!
1650
-	if (empty($context['browser']))
1651
-		detectBrowser();
1737
+	if (empty($context['browser'])) {
1738
+			detectBrowser();
1739
+	}
1652 1740
 
1653 1741
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1654 1742
 }
@@ -1666,8 +1754,9 @@  discard block
 block discarded – undo
1666 1754
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1667 1755
 
1668 1756
 	// The theme was specified by parameter.
1669
-	if (!empty($id_theme))
1670
-		$id_theme = (int) $id_theme;
1757
+	if (!empty($id_theme)) {
1758
+			$id_theme = (int) $id_theme;
1759
+	}
1671 1760
 	// The theme was specified by REQUEST.
1672 1761
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1673 1762
 	{
@@ -1675,51 +1764,58 @@  discard block
 block discarded – undo
1675 1764
 		$_SESSION['id_theme'] = $id_theme;
1676 1765
 	}
1677 1766
 	// The theme was specified by REQUEST... previously.
1678
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1679
-		$id_theme = (int) $_SESSION['id_theme'];
1767
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1768
+			$id_theme = (int) $_SESSION['id_theme'];
1769
+	}
1680 1770
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1681
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1682
-		$id_theme = $user_info['theme'];
1771
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1772
+			$id_theme = $user_info['theme'];
1773
+	}
1683 1774
 	// The theme was specified by the board.
1684
-	elseif (!empty($board_info['theme']))
1685
-		$id_theme = $board_info['theme'];
1775
+	elseif (!empty($board_info['theme'])) {
1776
+			$id_theme = $board_info['theme'];
1777
+	}
1686 1778
 	// The theme is the forum's default.
1687
-	else
1688
-		$id_theme = $modSettings['theme_guests'];
1779
+	else {
1780
+			$id_theme = $modSettings['theme_guests'];
1781
+	}
1689 1782
 
1690 1783
 	// Verify the id_theme... no foul play.
1691 1784
 	// Always allow the board specific theme, if they are overriding.
1692
-	if (!empty($board_info['theme']) && $board_info['override_theme'])
1693
-		$id_theme = $board_info['theme'];
1785
+	if (!empty($board_info['theme']) && $board_info['override_theme']) {
1786
+			$id_theme = $board_info['theme'];
1787
+	}
1694 1788
 	// If they have specified a particular theme to use with SSI allow it to be used.
1695
-	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1696
-		$id_theme = (int) $id_theme;
1697
-	elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1789
+	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1790
+			$id_theme = (int) $id_theme;
1791
+	} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1698 1792
 	{
1699 1793
 		$themes = explode(',', $modSettings['enableThemes']);
1700
-		if (!in_array($id_theme, $themes))
1701
-			$id_theme = $modSettings['theme_guests'];
1702
-		else
1794
+		if (!in_array($id_theme, $themes)) {
1795
+					$id_theme = $modSettings['theme_guests'];
1796
+		} else {
1797
+					$id_theme = (int) $id_theme;
1798
+		}
1799
+	} else {
1703 1800
 			$id_theme = (int) $id_theme;
1704 1801
 	}
1705
-	else
1706
-		$id_theme = (int) $id_theme;
1707 1802
 
1708 1803
 	$member = empty($user_info['id']) ? -1 : $user_info['id'];
1709 1804
 
1710 1805
 	// Disable image proxy if we don't have SSL enabled
1711
-	if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2)
1712
-		$image_proxy_enabled = false;
1806
+	if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) {
1807
+			$image_proxy_enabled = false;
1808
+	}
1713 1809
 
1714 1810
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated'])
1715 1811
 	{
1716 1812
 		$themeData = $temp;
1717 1813
 		$flag = true;
1814
+	} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1815
+			$themeData = $temp + array($member => array());
1816
+	} else {
1817
+			$themeData = array(-1 => array(), 0 => array(), $member => array());
1718 1818
 	}
1719
-	elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1720
-		$themeData = $temp + array($member => array());
1721
-	else
1722
-		$themeData = array(-1 => array(), 0 => array(), $member => array());
1723 1819
 
1724 1820
 	if (empty($flag))
1725 1821
 	{
@@ -1738,31 +1834,37 @@  discard block
 block discarded – undo
1738 1834
 		while ($row = $smcFunc['db_fetch_assoc']($result))
1739 1835
 		{
1740 1836
 			// There are just things we shouldn't be able to change as members.
1741
-			if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url')))
1742
-				continue;
1837
+			if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
1838
+							continue;
1839
+			}
1743 1840
 
1744 1841
 			// If this is the theme_dir of the default theme, store it.
1745
-			if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1746
-				$themeData[0]['default_' . $row['variable']] = $row['value'];
1842
+			if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1843
+							$themeData[0]['default_' . $row['variable']] = $row['value'];
1844
+			}
1747 1845
 
1748 1846
 			// If this isn't set yet, is a theme option, or is not the default theme..
1749
-			if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1750
-				$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1847
+			if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1848
+							$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1849
+			}
1751 1850
 		}
1752 1851
 		$smcFunc['db_free_result']($result);
1753 1852
 
1754
-		if (!empty($themeData[-1]))
1755
-			foreach ($themeData[-1] as $k => $v)
1853
+		if (!empty($themeData[-1])) {
1854
+					foreach ($themeData[-1] as $k => $v)
1756 1855
 			{
1757 1856
 				if (!isset($themeData[$member][$k]))
1758 1857
 					$themeData[$member][$k] = $v;
1858
+		}
1759 1859
 			}
1760 1860
 
1761
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1762
-			cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1861
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1862
+					cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1863
+		}
1763 1864
 		// Only if we didn't already load that part of the cache...
1764
-		elseif (!isset($temp))
1765
-			cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1865
+		elseif (!isset($temp)) {
1866
+					cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1867
+		}
1766 1868
 	}
1767 1869
 
1768 1870
 	$settings = $themeData[0];
@@ -1779,20 +1881,24 @@  discard block
 block discarded – undo
1779 1881
 	$settings['template_dirs'][] = $settings['theme_dir'];
1780 1882
 
1781 1883
 	// Based on theme (if there is one).
1782
-	if (!empty($settings['base_theme_dir']))
1783
-		$settings['template_dirs'][] = $settings['base_theme_dir'];
1884
+	if (!empty($settings['base_theme_dir'])) {
1885
+			$settings['template_dirs'][] = $settings['base_theme_dir'];
1886
+	}
1784 1887
 
1785 1888
 	// Lastly the default theme.
1786
-	if ($settings['theme_dir'] != $settings['default_theme_dir'])
1787
-		$settings['template_dirs'][] = $settings['default_theme_dir'];
1889
+	if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1890
+			$settings['template_dirs'][] = $settings['default_theme_dir'];
1891
+	}
1788 1892
 
1789
-	if (!$initialize)
1790
-		return;
1893
+	if (!$initialize) {
1894
+			return;
1895
+	}
1791 1896
 
1792 1897
 	// Check to see if we're forcing SSL
1793 1898
 	if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) &&
1794
-		(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI')
1795
-		redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://')));
1899
+		(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') {
1900
+			redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://')));
1901
+	}
1796 1902
 
1797 1903
 	// Check to see if they're accessing it from the wrong place.
1798 1904
 	if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME']))
@@ -1800,8 +1906,9 @@  discard block
 block discarded – undo
1800 1906
 		$detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
1801 1907
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1802 1908
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1803
-		if ($temp != '/')
1804
-			$detected_url .= $temp;
1909
+		if ($temp != '/') {
1910
+					$detected_url .= $temp;
1911
+		}
1805 1912
 	}
1806 1913
 	if (isset($detected_url) && $detected_url != $boardurl)
1807 1914
 	{
@@ -1813,8 +1920,9 @@  discard block
 block discarded – undo
1813 1920
 			foreach ($aliases as $alias)
1814 1921
 			{
1815 1922
 				// Rip off all the boring parts, spaces, etc.
1816
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1817
-					$do_fix = true;
1923
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1924
+									$do_fix = true;
1925
+				}
1818 1926
 			}
1819 1927
 		}
1820 1928
 
@@ -1822,20 +1930,22 @@  discard block
 block discarded – undo
1822 1930
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1823 1931
 		{
1824 1932
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1825
-			if (empty($_GET))
1826
-				redirectexit('wwwRedirect');
1827
-			else
1933
+			if (empty($_GET)) {
1934
+							redirectexit('wwwRedirect');
1935
+			} else
1828 1936
 			{
1829 1937
 				list ($k, $v) = each($_GET);
1830 1938
 
1831
-				if ($k != 'wwwRedirect')
1832
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1939
+				if ($k != 'wwwRedirect') {
1940
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1941
+				}
1833 1942
 			}
1834 1943
 		}
1835 1944
 
1836 1945
 		// #3 is just a check for SSL...
1837
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1838
-			$do_fix = true;
1946
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1947
+					$do_fix = true;
1948
+		}
1839 1949
 
1840 1950
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1841 1951
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1869,8 +1979,9 @@  discard block
 block discarded – undo
1869 1979
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1870 1980
 				}
1871 1981
 			}
1872
-			foreach ($context['linktree'] as $k => $dummy)
1873
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
1982
+			foreach ($context['linktree'] as $k => $dummy) {
1983
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
1984
+			}
1874 1985
 		}
1875 1986
 	}
1876 1987
 	// Set up the contextual user array.
@@ -1889,16 +2000,16 @@  discard block
 block discarded – undo
1889 2000
 			'email' => $user_info['email'],
1890 2001
 			'ignoreusers' => $user_info['ignoreusers'],
1891 2002
 		);
1892
-		if (!$context['user']['is_guest'])
1893
-			$context['user']['name'] = $user_info['name'];
1894
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1895
-			$context['user']['name'] = $txt['guest_title'];
2003
+		if (!$context['user']['is_guest']) {
2004
+					$context['user']['name'] = $user_info['name'];
2005
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2006
+					$context['user']['name'] = $txt['guest_title'];
2007
+		}
1896 2008
 
1897 2009
 		// Determine the current smiley set.
1898 2010
 		$user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];
1899 2011
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1900
-	}
1901
-	else
2012
+	} else
1902 2013
 	{
1903 2014
 		$context['user'] = array(
1904 2015
 			'id' => -1,
@@ -1914,18 +2025,24 @@  discard block
 block discarded – undo
1914 2025
 	}
1915 2026
 
1916 2027
 	// Some basic information...
1917
-	if (!isset($context['html_headers']))
1918
-		$context['html_headers'] = '';
1919
-	if (!isset($context['javascript_files']))
1920
-		$context['javascript_files'] = array();
1921
-	if (!isset($context['css_files']))
1922
-		$context['css_files'] = array();
1923
-	if (!isset($context['css_header']))
1924
-		$context['css_header'] = array();
1925
-	if (!isset($context['javascript_inline']))
1926
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1927
-	if (!isset($context['javascript_vars']))
1928
-		$context['javascript_vars'] = array();
2028
+	if (!isset($context['html_headers'])) {
2029
+			$context['html_headers'] = '';
2030
+	}
2031
+	if (!isset($context['javascript_files'])) {
2032
+			$context['javascript_files'] = array();
2033
+	}
2034
+	if (!isset($context['css_files'])) {
2035
+			$context['css_files'] = array();
2036
+	}
2037
+	if (!isset($context['css_header'])) {
2038
+			$context['css_header'] = array();
2039
+	}
2040
+	if (!isset($context['javascript_inline'])) {
2041
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2042
+	}
2043
+	if (!isset($context['javascript_vars'])) {
2044
+			$context['javascript_vars'] = array();
2045
+	}
1929 2046
 
1930 2047
 	$context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2';
1931 2048
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -1937,8 +2054,9 @@  discard block
 block discarded – undo
1937 2054
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
1938 2055
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
1939 2056
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
1940
-	if (isset($modSettings['load_average']))
1941
-		$context['load_average'] = $modSettings['load_average'];
2057
+	if (isset($modSettings['load_average'])) {
2058
+			$context['load_average'] = $modSettings['load_average'];
2059
+	}
1942 2060
 
1943 2061
 	// Detect the browser. This is separated out because it's also used in attachment downloads
1944 2062
 	detectBrowser();
@@ -1952,8 +2070,9 @@  discard block
 block discarded – undo
1952 2070
 	// This allows sticking some HTML on the page output - useful for controls.
1953 2071
 	$context['insert_after_template'] = '';
1954 2072
 
1955
-	if (!isset($txt))
1956
-		$txt = array();
2073
+	if (!isset($txt)) {
2074
+			$txt = array();
2075
+	}
1957 2076
 
1958 2077
 	$simpleActions = array(
1959 2078
 		'findmember',
@@ -2004,37 +2123,39 @@  discard block
 block discarded – undo
2004 2123
 	{
2005 2124
 		loadLanguage('index+Modifications');
2006 2125
 		$context['template_layers'] = array();
2007
-	}
2008
-
2009
-	else
2126
+	} else
2010 2127
 	{
2011 2128
 		// Custom templates to load, or just default?
2012
-		if (isset($settings['theme_templates']))
2013
-			$templates = explode(',', $settings['theme_templates']);
2014
-		else
2015
-			$templates = array('index');
2129
+		if (isset($settings['theme_templates'])) {
2130
+					$templates = explode(',', $settings['theme_templates']);
2131
+		} else {
2132
+					$templates = array('index');
2133
+		}
2016 2134
 
2017 2135
 		// Load each template...
2018
-		foreach ($templates as $template)
2019
-			loadTemplate($template);
2136
+		foreach ($templates as $template) {
2137
+					loadTemplate($template);
2138
+		}
2020 2139
 
2021 2140
 		// ...and attempt to load their associated language files.
2022 2141
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2023 2142
 		loadLanguage($required_files, '', false);
2024 2143
 
2025 2144
 		// Custom template layers?
2026
-		if (isset($settings['theme_layers']))
2027
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2028
-		else
2029
-			$context['template_layers'] = array('html', 'body');
2145
+		if (isset($settings['theme_layers'])) {
2146
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2147
+		} else {
2148
+					$context['template_layers'] = array('html', 'body');
2149
+		}
2030 2150
 	}
2031 2151
 
2032 2152
 	// Initialize the theme.
2033 2153
 	loadSubTemplate('init', 'ignore');
2034 2154
 
2035 2155
 	// Allow overriding the board wide time/number formats.
2036
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2037
-		$user_info['time_format'] = $txt['time_format'];
2156
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2157
+			$user_info['time_format'] = $txt['time_format'];
2158
+	}
2038 2159
 
2039 2160
 	// Set the character set from the template.
2040 2161
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2042,12 +2163,14 @@  discard block
 block discarded – undo
2042 2163
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2043 2164
 
2044 2165
 	// Guests may still need a name.
2045
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2046
-		$context['user']['name'] = $txt['guest_title'];
2166
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2167
+			$context['user']['name'] = $txt['guest_title'];
2168
+	}
2047 2169
 
2048 2170
 	// Any theme-related strings that need to be loaded?
2049
-	if (!empty($settings['require_theme_strings']))
2050
-		loadLanguage('ThemeStrings', '', false);
2171
+	if (!empty($settings['require_theme_strings'])) {
2172
+			loadLanguage('ThemeStrings', '', false);
2173
+	}
2051 2174
 
2052 2175
 	// Make a special URL for the language.
2053 2176
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2058,8 +2181,9 @@  discard block
 block discarded – undo
2058 2181
 	// Here is my luvly Responsive CSS
2059 2182
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive');
2060 2183
 
2061
-	if ($context['right_to_left'])
2062
-		loadCSSFile('rtl.css', array(), 'smf_rtl');
2184
+	if ($context['right_to_left']) {
2185
+			loadCSSFile('rtl.css', array(), 'smf_rtl');
2186
+	}
2063 2187
 
2064 2188
 	// We allow theme variants, because we're cool.
2065 2189
 	$context['theme_variant'] = '';
@@ -2067,14 +2191,17 @@  discard block
 block discarded – undo
2067 2191
 	if (!empty($settings['theme_variants']))
2068 2192
 	{
2069 2193
 		// Overriding - for previews and that ilk.
2070
-		if (!empty($_REQUEST['variant']))
2071
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2194
+		if (!empty($_REQUEST['variant'])) {
2195
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2196
+		}
2072 2197
 		// User selection?
2073
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2074
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2198
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2199
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2200
+		}
2075 2201
 		// If not a user variant, select the default.
2076
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2077
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2202
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2203
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2204
+		}
2078 2205
 
2079 2206
 		// Do this to keep things easier in the templates.
2080 2207
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2083,20 +2210,23 @@  discard block
 block discarded – undo
2083 2210
 		if (!empty($context['theme_variant']))
2084 2211
 		{
2085 2212
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']);
2086
-			if ($context['right_to_left'])
2087
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']);
2213
+			if ($context['right_to_left']) {
2214
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']);
2215
+			}
2088 2216
 		}
2089 2217
 	}
2090 2218
 
2091 2219
 	// Let's be compatible with old themes!
2092
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2093
-		$context['template_layers'] = array('main');
2220
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2221
+			$context['template_layers'] = array('main');
2222
+	}
2094 2223
 
2095 2224
 	$context['tabindex'] = 1;
2096 2225
 
2097 2226
 	// Compatibility.
2098
-	if (!isset($settings['theme_version']))
2099
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2227
+	if (!isset($settings['theme_version'])) {
2228
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2229
+	}
2100 2230
 
2101 2231
 	// Default JS variables for use in every theme
2102 2232
 	$context['javascript_vars'] = array(
@@ -2115,18 +2245,18 @@  discard block
 block discarded – undo
2115 2245
 	);
2116 2246
 
2117 2247
 	// Add the JQuery library to the list of files to load.
2118
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2119
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery');
2120
-
2121
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2122
-		loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery');
2123
-
2124
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2125
-		loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery');
2248
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2249
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery');
2250
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2251
+			loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery');
2252
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2253
+			loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery');
2254
+	}
2126 2255
 
2127 2256
 	// Auto loading? template_javascript() will take care of the local half of this.
2128
-	else
2129
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery');
2257
+	else {
2258
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery');
2259
+	}
2130 2260
 
2131 2261
 	// Queue our JQuery plugins!
2132 2262
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2149,12 +2279,12 @@  discard block
 block discarded – undo
2149 2279
 			require_once($sourcedir . '/ScheduledTasks.php');
2150 2280
 
2151 2281
 			// What to do, what to do?!
2152
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2153
-				AutoTask();
2154
-			else
2155
-				ReduceMailQueue();
2156
-		}
2157
-		else
2282
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2283
+							AutoTask();
2284
+			} else {
2285
+							ReduceMailQueue();
2286
+			}
2287
+		} else
2158 2288
 		{
2159 2289
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2160 2290
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2205,8 +2335,9 @@  discard block
 block discarded – undo
2205 2335
 		foreach ($theme_includes as $include)
2206 2336
 		{
2207 2337
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2208
-			if (file_exists($include))
2209
-				require_once($include);
2338
+			if (file_exists($include)) {
2339
+							require_once($include);
2340
+			}
2210 2341
 		}
2211 2342
 	}
2212 2343
 
@@ -2236,16 +2367,19 @@  discard block
 block discarded – undo
2236 2367
 	// Do any style sheets first, cause we're easy with those.
2237 2368
 	if (!empty($style_sheets))
2238 2369
 	{
2239
-		if (!is_array($style_sheets))
2240
-			$style_sheets = array($style_sheets);
2370
+		if (!is_array($style_sheets)) {
2371
+					$style_sheets = array($style_sheets);
2372
+		}
2241 2373
 
2242
-		foreach ($style_sheets as $sheet)
2243
-			loadCSSFile($sheet . '.css', array(), $sheet);
2374
+		foreach ($style_sheets as $sheet) {
2375
+					loadCSSFile($sheet . '.css', array(), $sheet);
2376
+		}
2244 2377
 	}
2245 2378
 
2246 2379
 	// No template to load?
2247
-	if ($template_name === false)
2248
-		return true;
2380
+	if ($template_name === false) {
2381
+			return true;
2382
+	}
2249 2383
 
2250 2384
 	$loaded = false;
2251 2385
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2260,12 +2394,14 @@  discard block
 block discarded – undo
2260 2394
 
2261 2395
 	if ($loaded)
2262 2396
 	{
2263
-		if ($db_show_debug === true)
2264
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2397
+		if ($db_show_debug === true) {
2398
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2399
+		}
2265 2400
 
2266 2401
 		// If they have specified an initialization function for this template, go ahead and call it now.
2267
-		if (function_exists('template_' . $template_name . '_init'))
2268
-			call_user_func('template_' . $template_name . '_init');
2402
+		if (function_exists('template_' . $template_name . '_init')) {
2403
+					call_user_func('template_' . $template_name . '_init');
2404
+		}
2269 2405
 	}
2270 2406
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2271 2407
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2285,13 +2421,14 @@  discard block
 block discarded – undo
2285 2421
 		loadTemplate($template_name);
2286 2422
 	}
2287 2423
 	// Cause an error otherwise.
2288
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2289
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2290
-	elseif ($fatal)
2291
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2292
-	else
2293
-		return false;
2294
-}
2424
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2425
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2426
+	} elseif ($fatal) {
2427
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2428
+	} else {
2429
+			return false;
2430
+	}
2431
+	}
2295 2432
 
2296 2433
 
2297 2434
 /**
@@ -2310,17 +2447,19 @@  discard block
 block discarded – undo
2310 2447
 {
2311 2448
 	global $context, $txt, $db_show_debug;
2312 2449
 
2313
-	if ($db_show_debug === true)
2314
-		$context['debug']['sub_templates'][] = $sub_template_name;
2450
+	if ($db_show_debug === true) {
2451
+			$context['debug']['sub_templates'][] = $sub_template_name;
2452
+	}
2315 2453
 
2316 2454
 	// Figure out what the template function is named.
2317 2455
 	$theme_function = 'template_' . $sub_template_name;
2318
-	if (function_exists($theme_function))
2319
-		$theme_function();
2320
-	elseif ($fatal === false)
2321
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2322
-	elseif ($fatal !== 'ignore')
2323
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2456
+	if (function_exists($theme_function)) {
2457
+			$theme_function();
2458
+	} elseif ($fatal === false) {
2459
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2460
+	} elseif ($fatal !== 'ignore') {
2461
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2462
+	}
2324 2463
 
2325 2464
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2326 2465
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2357,8 +2496,9 @@  discard block
 block discarded – undo
2357 2496
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2358 2497
 
2359 2498
 	// If this is an external file, automatically set this to false.
2360
-	if (!empty($params['external']))
2361
-		$params['minimize'] = false;
2499
+	if (!empty($params['external'])) {
2500
+			$params['minimize'] = false;
2501
+	}
2362 2502
 
2363 2503
 	// Account for shorthand like admin.css?alp21 filenames
2364 2504
 	$has_seed = strpos($fileName, '.css?');
@@ -2375,13 +2515,10 @@  discard block
 block discarded – undo
2375 2515
 			{
2376 2516
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2377 2517
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2518
+			} else {
2519
+							$fileUrl = false;
2378 2520
 			}
2379
-
2380
-			else
2381
-				$fileUrl = false;
2382
-		}
2383
-
2384
-		else
2521
+		} else
2385 2522
 		{
2386 2523
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2387 2524
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2396,12 +2533,14 @@  discard block
 block discarded – undo
2396 2533
 	}
2397 2534
 
2398 2535
 	// Add it to the array for use in the template
2399
-	if (!empty($fileName))
2400
-		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2536
+	if (!empty($fileName)) {
2537
+			$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2538
+	}
2401 2539
 
2402
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2403
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2404
-}
2540
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2541
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2542
+	}
2543
+	}
2405 2544
 
2406 2545
 /**
2407 2546
  * Add a block of inline css code to be executed later
@@ -2418,8 +2557,9 @@  discard block
 block discarded – undo
2418 2557
 	global $context;
2419 2558
 
2420 2559
 	// Gotta add something...
2421
-	if (empty($css))
2422
-		return false;
2560
+	if (empty($css)) {
2561
+			return false;
2562
+	}
2423 2563
 
2424 2564
 	$context['css_header'][] = $css;
2425 2565
 }
@@ -2454,8 +2594,9 @@  discard block
 block discarded – undo
2454 2594
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2455 2595
 
2456 2596
 	// If this is an external file, automatically set this to false.
2457
-	if (!empty($params['external']))
2458
-		$params['minimize'] = false;
2597
+	if (!empty($params['external'])) {
2598
+			$params['minimize'] = false;
2599
+	}
2459 2600
 
2460 2601
 	// Account for shorthand like admin.js?alp21 filenames
2461 2602
 	$has_seed = strpos($fileName, '.js?');
@@ -2472,16 +2613,12 @@  discard block
 block discarded – undo
2472 2613
 			{
2473 2614
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2474 2615
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2475
-			}
2476
-
2477
-			else
2616
+			} else
2478 2617
 			{
2479 2618
 				$fileUrl = false;
2480 2619
 				$filePath = false;
2481 2620
 			}
2482
-		}
2483
-
2484
-		else
2621
+		} else
2485 2622
 		{
2486 2623
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2487 2624
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2496,9 +2633,10 @@  discard block
 block discarded – undo
2496 2633
 	}
2497 2634
 
2498 2635
 	// Add it to the array for use in the template
2499
-	if (!empty($fileName))
2500
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2501
-}
2636
+	if (!empty($fileName)) {
2637
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2638
+	}
2639
+	}
2502 2640
 
2503 2641
 /**
2504 2642
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2512,9 +2650,10 @@  discard block
 block discarded – undo
2512 2650
 {
2513 2651
 	global $context;
2514 2652
 
2515
-	if (!empty($key) && (!empty($value) || $value === '0'))
2516
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2517
-}
2653
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2654
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2655
+	}
2656
+	}
2518 2657
 
2519 2658
 /**
2520 2659
  * Add a block of inline Javascript code to be executed later
@@ -2531,8 +2670,9 @@  discard block
 block discarded – undo
2531 2670
 {
2532 2671
 	global $context;
2533 2672
 
2534
-	if (empty($javascript))
2535
-		return false;
2673
+	if (empty($javascript)) {
2674
+			return false;
2675
+	}
2536 2676
 
2537 2677
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2538 2678
 }
@@ -2553,15 +2693,18 @@  discard block
 block discarded – undo
2553 2693
 	static $already_loaded = array();
2554 2694
 
2555 2695
 	// Default to the user's language.
2556
-	if ($lang == '')
2557
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2696
+	if ($lang == '') {
2697
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2698
+	}
2558 2699
 
2559 2700
 	// Do we want the English version of language file as fallback?
2560
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2561
-		loadLanguage($template_name, 'english', false);
2701
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2702
+			loadLanguage($template_name, 'english', false);
2703
+	}
2562 2704
 
2563
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2564
-		return $lang;
2705
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2706
+			return $lang;
2707
+	}
2565 2708
 
2566 2709
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2567 2710
 	if (empty($settings['default_theme_dir']))
@@ -2572,8 +2715,9 @@  discard block
 block discarded – undo
2572 2715
 
2573 2716
 	// What theme are we in?
2574 2717
 	$theme_name = basename($settings['theme_url']);
2575
-	if (empty($theme_name))
2576
-		$theme_name = 'unknown';
2718
+	if (empty($theme_name)) {
2719
+			$theme_name = 'unknown';
2720
+	}
2577 2721
 
2578 2722
 	// For each file open it up and write it out!
2579 2723
 	foreach (explode('+', $template_name) as $template)
@@ -2652,8 +2796,9 @@  discard block
 block discarded – undo
2652 2796
 	}
2653 2797
 
2654 2798
 	// Keep track of what we're up to soldier.
2655
-	if ($db_show_debug === true)
2656
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2799
+	if ($db_show_debug === true) {
2800
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2801
+	}
2657 2802
 
2658 2803
 	// Remember what we have loaded, and in which language.
2659 2804
 	$already_loaded[$template_name] = $lang;
@@ -2699,8 +2844,9 @@  discard block
 block discarded – undo
2699 2844
 				)
2700 2845
 			);
2701 2846
 			// In the EXTREMELY unlikely event this happens, give an error message.
2702
-			if ($smcFunc['db_num_rows']($result) == 0)
2703
-				fatal_lang_error('parent_not_found', 'critical');
2847
+			if ($smcFunc['db_num_rows']($result) == 0) {
2848
+							fatal_lang_error('parent_not_found', 'critical');
2849
+			}
2704 2850
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2705 2851
 			{
2706 2852
 				if (!isset($boards[$row['id_board']]))
@@ -2717,8 +2863,8 @@  discard block
 block discarded – undo
2717 2863
 					);
2718 2864
 				}
2719 2865
 				// If a moderator exists for this board, add that moderator for all children too.
2720
-				if (!empty($row['id_moderator']))
2721
-					foreach ($boards as $id => $dummy)
2866
+				if (!empty($row['id_moderator'])) {
2867
+									foreach ($boards as $id => $dummy)
2722 2868
 					{
2723 2869
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2724 2870
 							'id' => $row['id_moderator'],
@@ -2726,11 +2872,12 @@  discard block
 block discarded – undo
2726 2872
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2727 2873
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2728 2874
 						);
2875
+				}
2729 2876
 					}
2730 2877
 
2731 2878
 				// If a moderator group exists for this board, add that moderator group for all children too
2732
-				if (!empty($row['id_moderator_group']))
2733
-					foreach ($boards as $id => $dummy)
2879
+				if (!empty($row['id_moderator_group'])) {
2880
+									foreach ($boards as $id => $dummy)
2734 2881
 					{
2735 2882
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2736 2883
 							'id' => $row['id_moderator_group'],
@@ -2738,6 +2885,7 @@  discard block
 block discarded – undo
2738 2885
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2739 2886
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2740 2887
 						);
2888
+				}
2741 2889
 					}
2742 2890
 			}
2743 2891
 			$smcFunc['db_free_result']($result);
@@ -2765,23 +2913,27 @@  discard block
 block discarded – undo
2765 2913
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2766 2914
 	{
2767 2915
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2768
-		if (empty($smcFunc['ucwords']))
2769
-			reloadSettings();
2916
+		if (empty($smcFunc['ucwords'])) {
2917
+					reloadSettings();
2918
+		}
2770 2919
 
2771 2920
 		// If we don't have our theme information yet, let's get it.
2772
-		if (empty($settings['default_theme_dir']))
2773
-			loadTheme(0, false);
2921
+		if (empty($settings['default_theme_dir'])) {
2922
+					loadTheme(0, false);
2923
+		}
2774 2924
 
2775 2925
 		// Default language directories to try.
2776 2926
 		$language_directories = array(
2777 2927
 			$settings['default_theme_dir'] . '/languages',
2778 2928
 		);
2779
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2780
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
2929
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
2930
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
2931
+		}
2781 2932
 
2782 2933
 		// We possibly have a base theme directory.
2783
-		if (!empty($settings['base_theme_dir']))
2784
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
2934
+		if (!empty($settings['base_theme_dir'])) {
2935
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
2936
+		}
2785 2937
 
2786 2938
 		// Remove any duplicates.
2787 2939
 		$language_directories = array_unique($language_directories);
@@ -2795,20 +2947,21 @@  discard block
 block discarded – undo
2795 2947
 		foreach ($language_directories as $language_dir)
2796 2948
 		{
2797 2949
 			// Can't look in here... doesn't exist!
2798
-			if (!file_exists($language_dir))
2799
-				continue;
2950
+			if (!file_exists($language_dir)) {
2951
+							continue;
2952
+			}
2800 2953
 
2801 2954
 			$dir = dir($language_dir);
2802 2955
 			while ($entry = $dir->read())
2803 2956
 			{
2804 2957
 				// Look for the index language file....
2805
-				if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches))
2806
-					continue;
2807
-
2808
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2809
-					$langName = $langList[$matches[1]];
2958
+				if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) {
2959
+									continue;
2960
+				}
2810 2961
 
2811
-				else
2962
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
2963
+									$langName = $langList[$matches[1]];
2964
+				} else
2812 2965
 				{
2813 2966
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2814 2967
 
@@ -2851,20 +3004,23 @@  discard block
 block discarded – undo
2851 3004
 		}
2852 3005
 
2853 3006
 		// Do we need to store the lang list?
2854
-		if (empty($langList))
2855
-			updateSettings(array('langList' => json_encode($catchLang)));
3007
+		if (empty($langList)) {
3008
+					updateSettings(array('langList' => json_encode($catchLang)));
3009
+		}
2856 3010
 
2857 3011
 		// Favoring UTF8? Then prevent us from selecting non-UTF8 versions.
2858 3012
 		if ($favor_utf8)
2859 3013
 		{
2860
-			foreach ($context['languages'] as $lang)
2861
-				if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8']))
3014
+			foreach ($context['languages'] as $lang) {
3015
+							if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8']))
2862 3016
 					unset($context['languages'][$lang['filename']]);
3017
+			}
2863 3018
 		}
2864 3019
 
2865 3020
 		// Let's cash in on this deal.
2866
-		if (!empty($modSettings['cache_enable']))
2867
-			cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3021
+		if (!empty($modSettings['cache_enable'])) {
3022
+					cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3023
+		}
2868 3024
 	}
2869 3025
 
2870 3026
 	return $context['languages'];
@@ -2887,8 +3043,9 @@  discard block
 block discarded – undo
2887 3043
 	global $modSettings, $options, $txt;
2888 3044
 	static $censor_vulgar = null, $censor_proper;
2889 3045
 
2890
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2891
-		return $text;
3046
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3047
+			return $text;
3048
+	}
2892 3049
 
2893 3050
 	// If they haven't yet been loaded, load them.
2894 3051
 	if ($censor_vulgar == null)
@@ -2916,9 +3073,9 @@  discard block
 block discarded – undo
2916 3073
 	{
2917 3074
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
2918 3075
 		$text = $func($censor_vulgar, $censor_proper, $text);
3076
+	} else {
3077
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
2919 3078
 	}
2920
-	else
2921
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
2922 3079
 
2923 3080
 	return $text;
2924 3081
 }
@@ -2944,38 +3101,42 @@  discard block
 block discarded – undo
2944 3101
 	@ini_set('track_errors', '1');
2945 3102
 
2946 3103
 	// Don't include the file more than once, if $once is true.
2947
-	if ($once && in_array($filename, $templates))
2948
-		return;
3104
+	if ($once && in_array($filename, $templates)) {
3105
+			return;
3106
+	}
2949 3107
 	// Add this file to the include list, whether $once is true or not.
2950
-	else
2951
-		$templates[] = $filename;
3108
+	else {
3109
+			$templates[] = $filename;
3110
+	}
2952 3111
 
2953 3112
 	// Are we going to use eval?
2954 3113
 	if (empty($modSettings['disableTemplateEval']))
2955 3114
 	{
2956 3115
 		$file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
2957 3116
 		$settings['current_include_filename'] = $filename;
2958
-	}
2959
-	else
3117
+	} else
2960 3118
 	{
2961 3119
 		$file_found = file_exists($filename);
2962 3120
 
2963
-		if ($once && $file_found)
2964
-			require_once($filename);
2965
-		elseif ($file_found)
2966
-			require($filename);
3121
+		if ($once && $file_found) {
3122
+					require_once($filename);
3123
+		} elseif ($file_found) {
3124
+					require($filename);
3125
+		}
2967 3126
 	}
2968 3127
 
2969 3128
 	if ($file_found !== true)
2970 3129
 	{
2971 3130
 		ob_end_clean();
2972
-		if (!empty($modSettings['enableCompressedOutput']))
2973
-			@ob_start('ob_gzhandler');
2974
-		else
2975
-			ob_start();
3131
+		if (!empty($modSettings['enableCompressedOutput'])) {
3132
+					@ob_start('ob_gzhandler');
3133
+		} else {
3134
+					ob_start();
3135
+		}
2976 3136
 
2977
-		if (isset($_GET['debug']))
2978
-			header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3137
+		if (isset($_GET['debug'])) {
3138
+					header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3139
+		}
2979 3140
 
2980 3141
 		// Don't cache error pages!!
2981 3142
 		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -2994,12 +3155,13 @@  discard block
 block discarded – undo
2994 3155
 		echo '<!DOCTYPE html>
2995 3156
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
2996 3157
 	<head>';
2997
-		if (isset($context['character_set']))
2998
-			echo '
3158
+		if (isset($context['character_set'])) {
3159
+					echo '
2999 3160
 		<meta charset="', $context['character_set'], '">';
3161
+		}
3000 3162
 
3001
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3002
-			echo '
3163
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3164
+					echo '
3003 3165
 		<title>', $mtitle, '</title>
3004 3166
 	</head>
3005 3167
 	<body>
@@ -3007,8 +3169,8 @@  discard block
 block discarded – undo
3007 3169
 		', $mmessage, '
3008 3170
 	</body>
3009 3171
 </html>';
3010
-		elseif (!allowedTo('admin_forum'))
3011
-			echo '
3172
+		} elseif (!allowedTo('admin_forum')) {
3173
+					echo '
3012 3174
 		<title>', $txt['template_parse_error'], '</title>
3013 3175
 	</head>
3014 3176
 	<body>
@@ -3016,15 +3178,17 @@  discard block
 block discarded – undo
3016 3178
 		', $txt['template_parse_error_message'], '
3017 3179
 	</body>
3018 3180
 </html>';
3019
-		else
3181
+		} else
3020 3182
 		{
3021 3183
 			require_once($sourcedir . '/Subs-Package.php');
3022 3184
 
3023 3185
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3024
-			if (empty($error) && ini_get('track_errors') && !empty($php_errormsg))
3025
-				$error = $php_errormsg;
3026
-			if (empty($error))
3027
-				$error = $txt['template_parse_errmsg'];
3186
+			if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) {
3187
+							$error = $php_errormsg;
3188
+			}
3189
+			if (empty($error)) {
3190
+							$error = $txt['template_parse_errmsg'];
3191
+			}
3028 3192
 
3029 3193
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3030 3194
 
@@ -3035,11 +3199,12 @@  discard block
 block discarded – undo
3035 3199
 		<h3>', $txt['template_parse_error'], '</h3>
3036 3200
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3037 3201
 
3038
-			if (!empty($error))
3039
-				echo '
3202
+			if (!empty($error)) {
3203
+							echo '
3040 3204
 		<hr>
3041 3205
 
3042 3206
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3207
+			}
3043 3208
 
3044 3209
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3045 3210
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3049,10 +3214,11 @@  discard block
 block discarded – undo
3049 3214
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3050 3215
 
3051 3216
 				// Fix the PHP code stuff...
3052
-				if (!isBrowser('gecko'))
3053
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3054
-				else
3055
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3217
+				if (!isBrowser('gecko')) {
3218
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3219
+				} else {
3220
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3221
+				}
3056 3222
 
3057 3223
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3058 3224
 				$j = -1;
@@ -3060,8 +3226,9 @@  discard block
 block discarded – undo
3060 3226
 				{
3061 3227
 					$j++;
3062 3228
 
3063
-					if (substr_count($line, '<br>') == 0)
3064
-						continue;
3229
+					if (substr_count($line, '<br>') == 0) {
3230
+											continue;
3231
+					}
3065 3232
 
3066 3233
 					$n = substr_count($line, '<br>');
3067 3234
 					for ($i = 0; $i < $n; $i++)
@@ -3080,38 +3247,42 @@  discard block
 block discarded – undo
3080 3247
 				// Figure out what the color coding was before...
3081 3248
 				$line = max($match[1] - 9, 1);
3082 3249
 				$last_line = '';
3083
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3084
-					if (strpos($data2[$line2], '<') !== false)
3250
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3251
+									if (strpos($data2[$line2], '<') !== false)
3085 3252
 					{
3086 3253
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3087 3254
 							$last_line = $color_match[1];
3255
+				}
3088 3256
 						break;
3089 3257
 					}
3090 3258
 
3091 3259
 				// Show the relevant lines...
3092 3260
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3093 3261
 				{
3094
-					if ($line == $match[1])
3095
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3262
+					if ($line == $match[1]) {
3263
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3264
+					}
3096 3265
 
3097 3266
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3098
-					if (isset($data2[$line]) && $data2[$line] != '')
3099
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3267
+					if (isset($data2[$line]) && $data2[$line] != '') {
3268
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3269
+					}
3100 3270
 
3101 3271
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3102 3272
 					{
3103 3273
 						$last_line = $color_match[1];
3104 3274
 						echo '</', substr($last_line, 1, 4), '>';
3275
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3276
+											$last_line = '';
3277
+					} elseif ($last_line != '' && $data2[$line] != '') {
3278
+											echo '</', substr($last_line, 1, 4), '>';
3105 3279
 					}
3106
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3107
-						$last_line = '';
3108
-					elseif ($last_line != '' && $data2[$line] != '')
3109
-						echo '</', substr($last_line, 1, 4), '>';
3110 3280
 
3111
-					if ($line == $match[1])
3112
-						echo '</pre></div><pre style="margin: 0;">';
3113
-					else
3114
-						echo "\n";
3281
+					if ($line == $match[1]) {
3282
+											echo '</pre></div><pre style="margin: 0;">';
3283
+					} else {
3284
+											echo "\n";
3285
+					}
3115 3286
 				}
3116 3287
 
3117 3288
 				echo '</pre></div>';
@@ -3135,8 +3306,9 @@  discard block
 block discarded – undo
3135 3306
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port;
3136 3307
 
3137 3308
 	// Figure out what type of database we are using.
3138
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3139
-		$db_type = 'mysql';
3309
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3310
+			$db_type = 'mysql';
3311
+	}
3140 3312
 
3141 3313
 	// Load the file for the database.
3142 3314
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3144,8 +3316,9 @@  discard block
 block discarded – undo
3144 3316
 	$db_options = array();
3145 3317
 
3146 3318
 	// Add in the port if needed
3147
-	if (!empty($db_port))
3148
-		$db_options['port'] = $db_port;
3319
+	if (!empty($db_port)) {
3320
+			$db_options['port'] = $db_port;
3321
+	}
3149 3322
 
3150 3323
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
3151 3324
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3164,13 +3337,15 @@  discard block
 block discarded – undo
3164 3337
 	}
3165 3338
 
3166 3339
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3167
-	if (!$db_connection)
3168
-		display_db_error();
3340
+	if (!$db_connection) {
3341
+			display_db_error();
3342
+	}
3169 3343
 
3170 3344
 	// If in SSI mode fix up the prefix.
3171
-	if (SMF == 'SSI')
3172
-		db_fix_prefix($db_prefix, $db_name);
3173
-}
3345
+	if (SMF == 'SSI') {
3346
+			db_fix_prefix($db_prefix, $db_name);
3347
+	}
3348
+	}
3174 3349
 
3175 3350
 /**
3176 3351
  * Try to retrieve a cache entry. On failure, call the appropriate function.
@@ -3188,8 +3363,9 @@  discard block
 block discarded – undo
3188 3363
 
3189 3364
 	// @todo Why are we doing this if caching is disabled?
3190 3365
 
3191
-	if (function_exists('call_integration_hook'))
3192
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3366
+	if (function_exists('call_integration_hook')) {
3367
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3368
+	}
3193 3369
 
3194 3370
 	/* Refresh the cache if either:
3195 3371
 		1. Caching is disabled.
@@ -3203,16 +3379,19 @@  discard block
 block discarded – undo
3203 3379
 		require_once($sourcedir . '/' . $file);
3204 3380
 		$cache_block = call_user_func_array($function, $params);
3205 3381
 
3206
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3207
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3382
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3383
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3384
+		}
3208 3385
 	}
3209 3386
 
3210 3387
 	// Some cached data may need a freshening up after retrieval.
3211
-	if (!empty($cache_block['post_retri_eval']))
3212
-		eval($cache_block['post_retri_eval']);
3388
+	if (!empty($cache_block['post_retri_eval'])) {
3389
+			eval($cache_block['post_retri_eval']);
3390
+	}
3213 3391
 
3214
-	if (function_exists('call_integration_hook'))
3215
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3392
+	if (function_exists('call_integration_hook')) {
3393
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3394
+	}
3216 3395
 
3217 3396
 	return $cache_block['data'];
3218 3397
 }
@@ -3240,8 +3419,9 @@  discard block
 block discarded – undo
3240 3419
 	global $cache_hits, $cache_count, $db_show_debug, $cachedir;
3241 3420
 	global $cache_accelerator, $cache_enable, $cache_memcached;
3242 3421
 
3243
-	if (empty($cache_enable))
3244
-		return;
3422
+	if (empty($cache_enable)) {
3423
+			return;
3424
+	}
3245 3425
 
3246 3426
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3247 3427
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3260,10 +3440,12 @@  discard block
 block discarded – undo
3260 3440
 			if ((function_exists('memcached_set') || function_exists('memcache_set')) && isset($cache_memcached) && trim($cache_memcached) != '')
3261 3441
 			{
3262 3442
 				// Not connected yet?
3263
-				if (empty($memcached))
3264
-					get_memcached_server();
3265
-				if (!$memcached)
3266
-					return;
3443
+				if (empty($memcached)) {
3444
+									get_memcached_server();
3445
+				}
3446
+				if (!$memcached) {
3447
+									return;
3448
+				}
3267 3449
 
3268 3450
 				memcache_set($memcached, $key, $value, 0, $ttl);
3269 3451
 			}
@@ -3273,10 +3455,11 @@  discard block
 block discarded – undo
3273 3455
 			if (function_exists('apc_store'))
3274 3456
 			{
3275 3457
 				// An extended key is needed to counteract a bug in APC.
3276
-				if ($value === null)
3277
-					apc_delete($key . 'smf');
3278
-				else
3279
-					apc_store($key . 'smf', $value, $ttl);
3458
+				if ($value === null) {
3459
+									apc_delete($key . 'smf');
3460
+				} else {
3461
+									apc_store($key . 'smf', $value, $ttl);
3462
+				}
3280 3463
 			}
3281 3464
 			break;
3282 3465
 		case 'apcu':
@@ -3284,57 +3467,65 @@  discard block
 block discarded – undo
3284 3467
 			if (function_exists('apcu_store'))
3285 3468
 			{
3286 3469
 				// Not sure if this bug exists in APCu or not?
3287
-				if ($value === null)
3288
-					apcu_delete($key . 'smf');
3289
-				else
3290
-					apcu_store($key . 'smf', $value, $ttl);
3470
+				if ($value === null) {
3471
+									apcu_delete($key . 'smf');
3472
+				} else {
3473
+									apcu_store($key . 'smf', $value, $ttl);
3474
+				}
3291 3475
 			}
3292 3476
 			break;
3293 3477
 		case 'zend':
3294 3478
 			// Zend Platform/ZPS/etc.
3295
-			if (function_exists('zend_shm_cache_store'))
3296
-				zend_shm_cache_store('SMF::' . $key, $value, $ttl);
3297
-			elseif (function_exists('output_cache_put'))
3298
-				output_cache_put($key, $value);
3479
+			if (function_exists('zend_shm_cache_store')) {
3480
+							zend_shm_cache_store('SMF::' . $key, $value, $ttl);
3481
+			} elseif (function_exists('output_cache_put')) {
3482
+							output_cache_put($key, $value);
3483
+			}
3299 3484
 			break;
3300 3485
 		case 'xcache':
3301 3486
 			if (function_exists('xcache_set') && ini_get('xcache.var_size') > 0)
3302 3487
 			{
3303
-				if ($value === null)
3304
-					xcache_unset($key);
3305
-				else
3306
-					xcache_set($key, $value, $ttl);
3488
+				if ($value === null) {
3489
+									xcache_unset($key);
3490
+				} else {
3491
+									xcache_set($key, $value, $ttl);
3492
+				}
3307 3493
 			}
3308 3494
 			break;
3309 3495
 		default:
3310 3496
 			// Otherwise custom cache?
3311
-			if ($value === null)
3312
-				@unlink($cachedir . '/data_' . $key . '.php');
3313
-			else
3497
+			if ($value === null) {
3498
+							@unlink($cachedir . '/data_' . $key . '.php');
3499
+			} else
3314 3500
 			{
3315 3501
 				$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
3316 3502
 
3317 3503
 				// Write out the cache file, check that the cache write was successful; all the data must be written
3318 3504
 				// If it fails due to low diskspace, or other, remove the cache file
3319
-				if (file_put_contents($cachedir . '/data_' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data))
3320
-					@unlink($cachedir . '/data_' . $key . '.php');
3505
+				if (file_put_contents($cachedir . '/data_' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data)) {
3506
+									@unlink($cachedir . '/data_' . $key . '.php');
3507
+				}
3321 3508
 			}
3322 3509
 			break;
3323 3510
 	}
3324 3511
 
3325
-	if (function_exists('call_integration_hook'))
3326
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3512
+	if (function_exists('call_integration_hook')) {
3513
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3514
+	}
3327 3515
 
3328
-	if (isset($db_show_debug) && $db_show_debug === true)
3329
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3516
+	if (isset($db_show_debug) && $db_show_debug === true) {
3517
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3518
+	}
3330 3519
 
3331 3520
 	// Invalidate the opcode cache
3332
-	if (function_exists('opcache_invalidate'))
3333
-   		opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
3521
+	if (function_exists('opcache_invalidate')) {
3522
+	   		opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
3523
+	}
3334 3524
 
3335
-	if (function_exists('apc_delete_file'))
3336
-   		@apc_delete_file($cachedir . '/data_' . $key . '.php');
3337
-}
3525
+	if (function_exists('apc_delete_file')) {
3526
+	   		@apc_delete_file($cachedir . '/data_' . $key . '.php');
3527
+	}
3528
+	}
3338 3529
 
3339 3530
 /**
3340 3531
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3351,8 +3542,9 @@  discard block
 block discarded – undo
3351 3542
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug, $cachedir;
3352 3543
 	global $cache_accelerator, $cache_enable, $cache_memcached;
3353 3544
 
3354
-	if (empty($cache_enable))
3355
-		return;
3545
+	if (empty($cache_enable)) {
3546
+			return;
3547
+	}
3356 3548
 
3357 3549
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3358 3550
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3371,37 +3563,42 @@  discard block
 block discarded – undo
3371 3563
 			if ((function_exists('memcache_get') || function_exists('memcached_get')) && isset($cache_memcached) && trim($cache_memcached) != '')
3372 3564
 			{
3373 3565
 				// Not connected yet?
3374
-				if (empty($memcached))
3375
-					get_memcached_server();
3566
+				if (empty($memcached)) {
3567
+									get_memcached_server();
3568
+				}
3376 3569
 				if (!$memcached)
3377 3570
 				{
3378 3571
 					$cache_misses_count = isset($cache_misses) ? $cache_misses + 1 : 1;
3379 3572
 					$value = null;
3573
+				} else {
3574
+									$value = (function_exists('memcache_get')) ? memcache_get($memcached, $key) : memcached_get($memcached, $key);
3380 3575
 				}
3381
-				else
3382
-					$value = (function_exists('memcache_get')) ? memcache_get($memcached, $key) : memcached_get($memcached, $key);
3383 3576
 			}
3384 3577
 			break;
3385 3578
 		case 'apc':
3386 3579
 			// This is the free APC from PECL.
3387
-			if (function_exists('apc_fetch'))
3388
-				$value = apc_fetch($key . 'smf');
3580
+			if (function_exists('apc_fetch')) {
3581
+							$value = apc_fetch($key . 'smf');
3582
+			}
3389 3583
 			break;
3390 3584
 		case 'apcu':
3391 3585
 			// APC User Cache. A continuation of the now-unsupported APC but without opcode cache
3392
-			if (function_exists('apcu_fetch'))
3393
-				$value = apcu_fetch($key . 'smf');
3586
+			if (function_exists('apcu_fetch')) {
3587
+							$value = apcu_fetch($key . 'smf');
3588
+			}
3394 3589
 			break;
3395 3590
 		case 'zend':
3396 3591
 			// Zend's pricey stuff.
3397
-			if (function_exists('zend_shm_cache_fetch'))
3398
-				$value = zend_shm_cache_fetch('SMF::' . $key);
3399
-			elseif (function_exists('output_cache_get'))
3400
-				$value = output_cache_get($key, $ttl);
3592
+			if (function_exists('zend_shm_cache_fetch')) {
3593
+							$value = zend_shm_cache_fetch('SMF::' . $key);
3594
+			} elseif (function_exists('output_cache_get')) {
3595
+							$value = output_cache_get($key, $ttl);
3596
+			}
3401 3597
 			break;
3402 3598
 		case 'xcache':
3403
-			if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0)
3404
-				$value = xcache_get($key);
3599
+			if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
3600
+							$value = xcache_get($key);
3601
+			}
3405 3602
 			break;
3406 3603
 		default:
3407 3604
 			// Otherwise it's SMF data!
@@ -3409,8 +3606,9 @@  discard block
 block discarded – undo
3409 3606
 			{
3410 3607
 				// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
3411 3608
 				// causing newer files to take effect a while later.
3412
-				if (function_exists('opcache_invalidate'))
3413
-					opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
3609
+				if (function_exists('opcache_invalidate')) {
3610
+									opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
3611
+				}
3414 3612
 
3415 3613
 				// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
3416 3614
 				@include($cachedir . '/data_' . $key . '.php');
@@ -3430,16 +3628,18 @@  discard block
 block discarded – undo
3430 3628
 
3431 3629
 		if (empty($value))
3432 3630
 		{
3433
-			if (!isset($cache_misses))
3434
-				$cache_misses = array();
3631
+			if (!isset($cache_misses)) {
3632
+							$cache_misses = array();
3633
+			}
3435 3634
 
3436 3635
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3437 3636
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3438 3637
 		}
3439 3638
 	}
3440 3639
 
3441
-	if (function_exists('call_integration_hook') && isset($value))
3442
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3640
+	if (function_exists('call_integration_hook') && isset($value)) {
3641
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3642
+	}
3443 3643
 
3444 3644
 	return empty($value) ? null : smf_json_decode($value, true);
3445 3645
 }
@@ -3463,9 +3663,9 @@  discard block
 block discarded – undo
3463 3663
 	$port = 0;
3464 3664
 
3465 3665
 	// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
3466
-	if(strpos($server,'/') !== false)
3467
-		$host = $server;
3468
-	else
3666
+	if(strpos($server,'/') !== false) {
3667
+			$host = $server;
3668
+	} else
3469 3669
 	{
3470 3670
 		$server = explode(':', $server);
3471 3671
 		$host = $server[0];
@@ -3480,22 +3680,26 @@  discard block
 block discarded – undo
3480 3680
 	// Don't wait too long: yes, we want the server, but we might be able to run the query faster!
3481 3681
 	if (empty($db_persist))
3482 3682
 	{
3483
-		if ($cache === 'memcached')
3484
-			$memcached = memcached_connect($host, $port);
3485
-		if ($cache === 'memcache')
3486
-			$memcached = memcache_connect($host, $port);
3487
-	}
3488
-	else
3683
+		if ($cache === 'memcached') {
3684
+					$memcached = memcached_connect($host, $port);
3685
+		}
3686
+		if ($cache === 'memcache') {
3687
+					$memcached = memcache_connect($host, $port);
3688
+		}
3689
+	} else
3489 3690
 	{
3490
-		if ($cache === 'memcached')
3491
-			$memcached = memcached_pconnect($host, $port);
3492
-		if ($cache === 'memcache')
3493
-			$memcached = memcache_pconnect($host, $port);
3691
+		if ($cache === 'memcached') {
3692
+					$memcached = memcached_pconnect($host, $port);
3693
+		}
3694
+		if ($cache === 'memcache') {
3695
+					$memcached = memcache_pconnect($host, $port);
3696
+		}
3494 3697
 	}
3495 3698
 
3496
-	if (!$memcached && $level > 0)
3497
-		get_memcached_server($level - 1);
3498
-}
3699
+	if (!$memcached && $level > 0) {
3700
+			get_memcached_server($level - 1);
3701
+	}
3702
+	}
3499 3703
 
3500 3704
 /**
3501 3705
  * Helper function to set an array of data for an user's avatar.
@@ -3513,8 +3717,9 @@  discard block
 block discarded – undo
3513 3717
 	global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret;
3514 3718
 
3515 3719
 	// Come on!
3516
-	if (empty($data))
3517
-		return array();
3720
+	if (empty($data)) {
3721
+			return array();
3722
+	}
3518 3723
 
3519 3724
 	// Set a nice default var.
3520 3725
 	$image = '';
@@ -3522,11 +3727,11 @@  discard block
 block discarded – undo
3522 3727
 	// Gravatar has been set as mandatory!
3523 3728
 	if (!empty($modSettings['gravatarOverride']))
3524 3729
 	{
3525
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3526
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3527
-
3528
-		else if (!empty($data['email']))
3529
-			$image = get_gravatar_url($data['email']);
3730
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3731
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3732
+		} else if (!empty($data['email'])) {
3733
+					$image = get_gravatar_url($data['email']);
3734
+		}
3530 3735
 	}
3531 3736
 
3532 3737
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3538,54 +3743,60 @@  discard block
 block discarded – undo
3538 3743
 			// Gravatar.
3539 3744
 			if (stristr($data['avatar'], 'gravatar://'))
3540 3745
 			{
3541
-				if ($data['avatar'] == 'gravatar://')
3542
-					$image = get_gravatar_url($data['email']);
3543
-
3544
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3545
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3746
+				if ($data['avatar'] == 'gravatar://') {
3747
+									$image = get_gravatar_url($data['email']);
3748
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3749
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3750
+				}
3546 3751
 			}
3547 3752
 
3548 3753
 			// External url.
3549 3754
 			else
3550 3755
 			{
3551 3756
 				// Using ssl?
3552
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false)
3553
-					$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3757
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) {
3758
+									$image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret);
3759
+				}
3554 3760
 
3555 3761
 				// Just a plain external url.
3556
-				else
3557
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3762
+				else {
3763
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3764
+				}
3558 3765
 			}
3559 3766
 		}
3560 3767
 
3561 3768
 		// Perhaps this user has an attachment as avatar...
3562
-		else if (!empty($data['filename']))
3563
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3769
+		else if (!empty($data['filename'])) {
3770
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3771
+		}
3564 3772
 
3565 3773
 		// Right... no avatar... use our default image.
3566
-		else
3567
-			$image = $modSettings['avatar_url'] . '/default.png';
3774
+		else {
3775
+					$image = $modSettings['avatar_url'] . '/default.png';
3776
+		}
3568 3777
 	}
3569 3778
 
3570 3779
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3571 3780
 
3572 3781
 	// At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed.
3573
-	if (!empty($image))
3574
-		return array(
3782
+	if (!empty($image)) {
3783
+			return array(
3575 3784
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3576 3785
 			'image' => '<img class="avatar" src="' . $image . '" />',
3577 3786
 			'href' => $image,
3578 3787
 			'url' => $image,
3579 3788
 		);
3789
+	}
3580 3790
 
3581 3791
 	// Fallback to make life easier for everyone...
3582
-	else
3583
-		return array(
3792
+	else {
3793
+			return array(
3584 3794
 			'name' => '',
3585 3795
 			'image' => '',
3586 3796
 			'href' => '',
3587 3797
 			'url' => '',
3588 3798
 		);
3589
-}
3799
+	}
3800
+	}
3590 3801
 
3591 3802
 ?>
3592 3803
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs.php 3 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)
@@ -5015,7 +5015,7 @@  discard block
 block discarded – undo
5015 5015
 
5016 5016
 /**
5017 5017
  * @param string $ip_address An IP address in IPv4, IPv6 or decimal notation
5018
- * @return binary The IP address in binary or false
5018
+ * @return string The IP address in binary or false
5019 5019
  */
5020 5020
 function inet_ptod($ip_address)
5021 5021
 {
@@ -5413,7 +5413,7 @@  discard block
 block discarded – undo
5413 5413
  * It assumes the data is already a string.
5414 5414
  * @param string $data The data to print
5415 5415
  * @param string $type The content type. Defaults to Json.
5416
- * @return void
5416
+ * @return false|null
5417 5417
  */
5418 5418
 function smf_serverResponse($data = '', $type = 'Content-Type: application/json')
5419 5419
 {
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1094 1094
 				),
1095 1095
 				'content' => '$1',
1096
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1096
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1097 1097
 				{
1098 1098
 					$returnContext = '';
1099 1099
 
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1143 1143
 							$returnContext .= '
1144
-													<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>';
1144
+													<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>';
1145 1145
 						else
1146 1146
 							$returnContext .= '
1147 1147
 													<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>';
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 				'type' => 'unparsed_content',
1172 1172
 				'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>',
1173 1173
 				// @todo Maybe this can be simplified?
1174
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1174
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1175 1175
 				{
1176 1176
 					if (!isset($disabled['code']))
1177 1177
 					{
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 				'type' => 'unparsed_equals_content',
1209 1209
 				'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>',
1210 1210
 				// @todo Maybe this can be simplified?
1211
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1211
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1212 1212
 				{
1213 1213
 					if (!isset($disabled['code']))
1214 1214
 					{
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 				'type' => 'unparsed_content',
1253 1253
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1254 1254
 				// @todo Should this respect guest_hideContacts?
1255
-				'validate' => function (&$tag, &$data, $disabled)
1255
+				'validate' => function(&$tag, &$data, $disabled)
1256 1256
 				{
1257 1257
 					$data = strtr($data, array('<br>' => ''));
1258 1258
 				},
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 				'type' => 'unparsed_commas_content',
1272 1272
 				'test' => '\d+,\d+\]',
1273 1273
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1274
-				'validate' => function (&$tag, &$data, $disabled)
1274
+				'validate' => function(&$tag, &$data, $disabled)
1275 1275
 				{
1276 1276
 					if (isset($disabled['url']))
1277 1277
 						$tag['content'] = '$1';
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1317 1317
 				),
1318 1318
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1319
-				'validate' => function (&$tag, &$data, $disabled)
1319
+				'validate' => function(&$tag, &$data, $disabled)
1320 1320
 				{
1321 1321
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1322 1322
 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 				'tag' => 'img',
1340 1340
 				'type' => 'unparsed_content',
1341 1341
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1342
-				'validate' => function (&$tag, &$data, $disabled)
1342
+				'validate' => function(&$tag, &$data, $disabled)
1343 1343
 				{
1344 1344
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1345 1345
 
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 				'tag' => 'iurl',
1363 1363
 				'type' => 'unparsed_content',
1364 1364
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1365
-				'validate' => function (&$tag, &$data, $disabled)
1365
+				'validate' => function(&$tag, &$data, $disabled)
1366 1366
 				{
1367 1367
 					$data = strtr($data, array('<br>' => ''));
1368 1368
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 				'quoted' => 'optional',
1377 1377
 				'before' => '<a href="$1" class="bbc_link">',
1378 1378
 				'after' => '</a>',
1379
-				'validate' => function (&$tag, &$data, $disabled)
1379
+				'validate' => function(&$tag, &$data, $disabled)
1380 1380
 				{
1381 1381
 					if (substr($data, 0, 1) == '#')
1382 1382
 						$data = '#post_' . substr($data, 1);
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 				'tag' => 'php',
1457 1457
 				'type' => 'unparsed_content',
1458 1458
 				'content' => '<span class="phpcode">$1</span>',
1459
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1459
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1460 1460
 				{
1461 1461
 					if (!isset($disabled['php']))
1462 1462
 					{
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 				'test' => '[1-7]\]',
1555 1555
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1556 1556
 				'after' => '</span>',
1557
-				'validate' => function (&$tag, &$data, $disabled)
1557
+				'validate' => function(&$tag, &$data, $disabled)
1558 1558
 				{
1559 1559
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1560 1560
 					$data = $sizes[$data] . 'em';
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 				'tag' => 'time',
1593 1593
 				'type' => 'unparsed_content',
1594 1594
 				'content' => '$1',
1595
-				'validate' => function (&$tag, &$data, $disabled)
1595
+				'validate' => function(&$tag, &$data, $disabled)
1596 1596
 				{
1597 1597
 					if (is_numeric($data))
1598 1598
 						$data = timeformat($data);
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 				'tag' => 'url',
1621 1621
 				'type' => 'unparsed_content',
1622 1622
 				'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',
1623
-				'validate' => function (&$tag, &$data, $disabled)
1623
+				'validate' => function(&$tag, &$data, $disabled)
1624 1624
 				{
1625 1625
 					$data = strtr($data, array('<br>' => ''));
1626 1626
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 				'quoted' => 'optional',
1635 1635
 				'before' => '<a href="$1" class="bbc_link" target="_blank">',
1636 1636
 				'after' => '</a>',
1637
-				'validate' => function (&$tag, &$data, $disabled)
1637
+				'validate' => function(&$tag, &$data, $disabled)
1638 1638
 				{
1639 1639
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1640 1640
 					if (empty($scheme))
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
 		{
1661 1661
 			if (isset($temp_bbc))
1662 1662
 				$bbc_codes = $temp_bbc;
1663
-			usort($codes, function ($a, $b) {
1663
+			usort($codes, function($a, $b) {
1664 1664
 				return strcmp($a['tag'], $b['tag']);
1665 1665
 			});
1666 1666
 			return $codes;
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
 	(?!@)										# not succeeded by a @, avoid matching "foo.na" in "[email protected]"
1915 1915
 )';
1916 1916
 
1917
-						$data = preg_replace_callback('~' . $url_regex . '~', function ($matches) {
1917
+						$data = preg_replace_callback('~' . $url_regex . '~', function($matches) {
1918 1918
 									$url = array_shift($matches);
1919 1919
 
1920 1920
 									$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2625 2625
 		{
2626 2626
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2627
-			$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">';
2627
+			$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">';
2628 2628
 
2629 2629
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2630 2630
 
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 
2642 2642
 	// Replace away!
2643 2643
 	$message = preg_replace_callback($smileyPregSearch,
2644
-		function ($matches) use ($smileyPregReplacements)
2644
+		function($matches) use ($smileyPregReplacements)
2645 2645
 		{
2646 2646
 			return $smileyPregReplacements[$matches[1]];
2647 2647
 		}, $message);
@@ -2707,13 +2707,13 @@  discard block
 block discarded – undo
2707 2707
 	{
2708 2708
 		if (defined('SID') && SID != '')
2709 2709
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2710
-				function ($m) use ($scripturl)
2710
+				function($m) use ($scripturl)
2711 2711
 				{
2712
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2712
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2713 2713
 				}, $setLocation);
2714 2714
 		else
2715 2715
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2716
-				function ($m) use ($scripturl)
2716
+				function($m) use ($scripturl)
2717 2717
 				{
2718 2718
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2719 2719
 				}, $setLocation);
@@ -3036,7 +3036,7 @@  discard block
 block discarded – undo
3036 3036
 
3037 3037
 	// Add a generic "Are you sure?" confirmation message.
3038 3038
 	addInlineJavaScript('
3039
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3039
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3040 3040
 
3041 3041
 	// Now add the capping code for avatars.
3042 3042
 	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')
@@ -3400,7 +3400,7 @@  discard block
 block discarded – undo
3400 3400
 
3401 3401
 		else
3402 3402
 			echo '
3403
-	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3403
+	<script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>';
3404 3404
 	}
3405 3405
 
3406 3406
 	// Inline JavaScript - Actually useful some times!
@@ -3478,14 +3478,14 @@  discard block
 block discarded – undo
3478 3478
 
3479 3479
 		else
3480 3480
 			echo '
3481
-	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3481
+	<link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">';
3482 3482
 	}
3483 3483
 
3484 3484
 	// Print the rest after the minified files.
3485 3485
 	if (!empty($normal))
3486 3486
 		foreach ($normal as $nf)
3487 3487
 			echo '
3488
-	<link rel="stylesheet" href="', $nf ,'">';
3488
+	<link rel="stylesheet" href="', $nf, '">';
3489 3489
 
3490 3490
 	if ($db_show_debug === true)
3491 3491
 	{
@@ -3501,7 +3501,7 @@  discard block
 block discarded – undo
3501 3501
 	<style>';
3502 3502
 
3503 3503
 		foreach ($context['css_header'] as $css)
3504
-			echo $css .'
3504
+			echo $css . '
3505 3505
 	';
3506 3506
 
3507 3507
 		echo'
@@ -3531,7 +3531,7 @@  discard block
 block discarded – undo
3531 3531
 		return false;
3532 3532
 
3533 3533
 	// Did we already did this?
3534
-	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3534
+	$toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400);
3535 3535
 
3536 3536
 	// Already done?
3537 3537
 	if (!empty($toCache))
@@ -3539,25 +3539,25 @@  discard block
 block discarded – undo
3539 3539
 
3540 3540
 	// Yep, need a bunch of files.
3541 3541
 	require_once($sourcedir . '/minify/src/Minify.php');
3542
-	require_once($sourcedir . '/minify/src/'. strtoupper($type) .'.php');
3542
+	require_once($sourcedir . '/minify/src/' . strtoupper($type) . '.php');
3543 3543
 	require_once($sourcedir . '/minify/src/Exception.php');
3544 3544
 	require_once($sourcedir . '/minify/src/Converter.php');
3545 3545
 
3546 3546
 	// No namespaces, sorry!
3547
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3547
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3548 3548
 
3549 3549
 	// Temp path.
3550
-	$cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/';
3550
+	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
3551 3551
 
3552 3552
 	// What kind of file are we going to create?
3553
-	$toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type;
3553
+	$toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type;
3554 3554
 
3555 3555
 	// File has to exists, if it isn't try to create it.
3556 3556
 	if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate))
3557 3557
 	{
3558 3558
 		loadLanguage('Errors');
3559 3559
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3560
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3560
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3561 3561
 
3562 3562
 		// The process failed so roll back to print each individual file.
3563 3563
 		return $data;
@@ -3592,14 +3592,14 @@  discard block
 block discarded – undo
3592 3592
 	{
3593 3593
 		loadLanguage('Errors');
3594 3594
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3595
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3595
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3596 3596
 
3597 3597
 		// The process failed so roll back to print each individual file.
3598 3598
 		return $data;
3599 3599
 	}
3600 3600
 
3601 3601
 	// And create a long lived cache entry.
3602
-	cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400);
3602
+	cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400);
3603 3603
 
3604 3604
 	return true;
3605 3605
 }
@@ -3656,7 +3656,7 @@  discard block
 block discarded – undo
3656 3656
 	else
3657 3657
 		$path = $modSettings['attachmentUploadDir'];
3658 3658
 
3659
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3659
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3660 3660
 }
3661 3661
 
3662 3662
 /**
@@ -3700,10 +3700,10 @@  discard block
 block discarded – undo
3700 3700
 		$valid_low = isValidIP($ip_parts[0]);
3701 3701
 		$valid_high = isValidIP($ip_parts[1]);
3702 3702
 		$count = 0;
3703
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
3703
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
3704 3704
 		$max = ($mode == ':' ? 'ffff' : '255');
3705 3705
 		$min = 0;
3706
-		if(!$valid_low)
3706
+		if (!$valid_low)
3707 3707
 		{
3708 3708
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
3709 3709
 			$valid_low = isValidIP($ip_parts[0]);
@@ -3717,7 +3717,7 @@  discard block
 block discarded – undo
3717 3717
 		}
3718 3718
 
3719 3719
 		$count = 0;
3720
-		if(!$valid_high)
3720
+		if (!$valid_high)
3721 3721
 		{
3722 3722
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
3723 3723
 			$valid_high = isValidIP($ip_parts[1]);
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 			}
3731 3731
 		}
3732 3732
 
3733
-		if($valid_high && $valid_low)
3733
+		if ($valid_high && $valid_low)
3734 3734
 		{
3735 3735
 			$ip_array['low'] = $ip_parts[0];
3736 3736
 			$ip_array['high'] = $ip_parts[1];
@@ -4003,7 +4003,7 @@  discard block
 block discarded – undo
4003 4003
 		addInlineJavaScript('
4004 4004
 	var user_menus = new smc_PopupMenu();
4005 4005
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4006
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4006
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4007 4007
 		if ($context['allow_pm'])
4008 4008
 			addInlineJavaScript('
4009 4009
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4631,7 +4631,7 @@  discard block
 block discarded – undo
4631 4631
 		// No? try a fallback to $sourcedir
4632 4632
 		else
4633 4633
 		{
4634
-			$absPath = $sourcedir .'/'. $file;
4634
+			$absPath = $sourcedir . '/' . $file;
4635 4635
 
4636 4636
 			if (file_exists($absPath))
4637 4637
 				require_once($absPath);
@@ -4712,15 +4712,15 @@  discard block
 block discarded – undo
4712 4712
 
4713 4713
 	// UTF-8 occurences of MS special characters
4714 4714
 	$findchars_utf8 = array(
4715
-		"\xe2\80\x9a",	// single low-9 quotation mark
4716
-		"\xe2\80\x9e",	// double low-9 quotation mark
4717
-		"\xe2\80\xa6",	// horizontal ellipsis
4718
-		"\xe2\x80\x98",	// left single curly quote
4719
-		"\xe2\x80\x99",	// right single curly quote
4720
-		"\xe2\x80\x9c",	// left double curly quote
4721
-		"\xe2\x80\x9d",	// right double curly quote
4722
-		"\xe2\x80\x93",	// en dash
4723
-		"\xe2\x80\x94",	// em dash
4715
+		"\xe2\80\x9a", // single low-9 quotation mark
4716
+		"\xe2\80\x9e", // double low-9 quotation mark
4717
+		"\xe2\80\xa6", // horizontal ellipsis
4718
+		"\xe2\x80\x98", // left single curly quote
4719
+		"\xe2\x80\x99", // right single curly quote
4720
+		"\xe2\x80\x9c", // left double curly quote
4721
+		"\xe2\x80\x9d", // right double curly quote
4722
+		"\xe2\x80\x93", // en dash
4723
+		"\xe2\x80\x94", // em dash
4724 4724
 	);
4725 4725
 
4726 4726
 	// windows 1252 / iso equivalents
@@ -4738,15 +4738,15 @@  discard block
 block discarded – undo
4738 4738
 
4739 4739
 	// safe replacements
4740 4740
 	$replacechars = array(
4741
-		',',	// &sbquo;
4742
-		',,',	// &bdquo;
4743
-		'...',	// &hellip;
4744
-		"'",	// &lsquo;
4745
-		"'",	// &rsquo;
4746
-		'"',	// &ldquo;
4747
-		'"',	// &rdquo;
4748
-		'-',	// &ndash;
4749
-		'--',	// &mdash;
4741
+		',', // &sbquo;
4742
+		',,', // &bdquo;
4743
+		'...', // &hellip;
4744
+		"'", // &lsquo;
4745
+		"'", // &rsquo;
4746
+		'"', // &ldquo;
4747
+		'"', // &rdquo;
4748
+		'-', // &ndash;
4749
+		'--', // &mdash;
4750 4750
 	);
4751 4751
 
4752 4752
 	if ($context['utf8'])
@@ -5032,7 +5032,7 @@  discard block
 block discarded – undo
5032 5032
  */
5033 5033
 function inet_dtop($bin)
5034 5034
 {
5035
-	if(empty($bin))
5035
+	if (empty($bin))
5036 5036
 		return '';
5037 5037
 
5038 5038
 	global $db_type;
@@ -5063,28 +5063,28 @@  discard block
 block discarded – undo
5063 5063
  */
5064 5064
 function _safe_serialize($value)
5065 5065
 {
5066
-	if(is_null($value))
5066
+	if (is_null($value))
5067 5067
 		return 'N;';
5068 5068
 
5069
-	if(is_bool($value))
5070
-		return 'b:'. (int) $value .';';
5069
+	if (is_bool($value))
5070
+		return 'b:' . (int) $value . ';';
5071 5071
 
5072
-	if(is_int($value))
5073
-		return 'i:'. $value .';';
5072
+	if (is_int($value))
5073
+		return 'i:' . $value . ';';
5074 5074
 
5075
-	if(is_float($value))
5076
-		return 'd:'. str_replace(',', '.', $value) .';';
5075
+	if (is_float($value))
5076
+		return 'd:' . str_replace(',', '.', $value) . ';';
5077 5077
 
5078
-	if(is_string($value))
5079
-		return 's:'. strlen($value) .':"'. $value .'";';
5078
+	if (is_string($value))
5079
+		return 's:' . strlen($value) . ':"' . $value . '";';
5080 5080
 
5081
-	if(is_array($value))
5081
+	if (is_array($value))
5082 5082
 	{
5083 5083
 		$out = '';
5084
-		foreach($value as $k => $v)
5084
+		foreach ($value as $k => $v)
5085 5085
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5086 5086
 
5087
-		return 'a:'. count($value) .':{'. $out .'}';
5087
+		return 'a:' . count($value) . ':{' . $out . '}';
5088 5088
 	}
5089 5089
 
5090 5090
 	// safe_serialize cannot serialize resources or objects.
@@ -5126,7 +5126,7 @@  discard block
 block discarded – undo
5126 5126
 function _safe_unserialize($str)
5127 5127
 {
5128 5128
 	// Input  is not a string.
5129
-	if(empty($str) || !is_string($str))
5129
+	if (empty($str) || !is_string($str))
5130 5130
 		return false;
5131 5131
 
5132 5132
 	$stack = array();
@@ -5140,40 +5140,40 @@  discard block
 block discarded – undo
5140 5140
 	 *   3 - in array, expecting value or another array
5141 5141
 	 */
5142 5142
 	$state = 0;
5143
-	while($state != 1)
5143
+	while ($state != 1)
5144 5144
 	{
5145 5145
 		$type = isset($str[0]) ? $str[0] : '';
5146
-		if($type == '}')
5146
+		if ($type == '}')
5147 5147
 			$str = substr($str, 1);
5148 5148
 
5149
-		else if($type == 'N' && $str[1] == ';')
5149
+		else if ($type == 'N' && $str[1] == ';')
5150 5150
 		{
5151 5151
 			$value = null;
5152 5152
 			$str = substr($str, 2);
5153 5153
 		}
5154
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5154
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5155 5155
 		{
5156 5156
 			$value = $matches[1] == '1' ? true : false;
5157 5157
 			$str = substr($str, 4);
5158 5158
 		}
5159
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5159
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5160 5160
 		{
5161
-			$value = (int)$matches[1];
5161
+			$value = (int) $matches[1];
5162 5162
 			$str = $matches[2];
5163 5163
 		}
5164
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5164
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5165 5165
 		{
5166
-			$value = (float)$matches[1];
5166
+			$value = (float) $matches[1];
5167 5167
 			$str = $matches[3];
5168 5168
 		}
5169
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5169
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5170 5170
 		{
5171
-			$value = substr($matches[2], 0, (int)$matches[1]);
5172
-			$str = substr($matches[2], (int)$matches[1] + 2);
5171
+			$value = substr($matches[2], 0, (int) $matches[1]);
5172
+			$str = substr($matches[2], (int) $matches[1] + 2);
5173 5173
 		}
5174
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5174
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5175 5175
 		{
5176
-			$expectedLength = (int)$matches[1];
5176
+			$expectedLength = (int) $matches[1];
5177 5177
 			$str = $matches[2];
5178 5178
 		}
5179 5179
 
@@ -5181,10 +5181,10 @@  discard block
 block discarded – undo
5181 5181
 		else
5182 5182
 			return false;
5183 5183
 
5184
-		switch($state)
5184
+		switch ($state)
5185 5185
 		{
5186 5186
 			case 3: // In array, expecting value or another array.
5187
-				if($type == 'a')
5187
+				if ($type == 'a')
5188 5188
 				{
5189 5189
 					$stack[] = &$list;
5190 5190
 					$list[$key] = array();
@@ -5193,7 +5193,7 @@  discard block
 block discarded – undo
5193 5193
 					$state = 2;
5194 5194
 					break;
5195 5195
 				}
5196
-				if($type != '}')
5196
+				if ($type != '}')
5197 5197
 				{
5198 5198
 					$list[$key] = $value;
5199 5199
 					$state = 2;
@@ -5204,29 +5204,29 @@  discard block
 block discarded – undo
5204 5204
 				return false;
5205 5205
 
5206 5206
 			case 2: // in array, expecting end of array or a key
5207
-				if($type == '}')
5207
+				if ($type == '}')
5208 5208
 				{
5209 5209
 					// Array size is less than expected.
5210
-					if(count($list) < end($expected))
5210
+					if (count($list) < end($expected))
5211 5211
 						return false;
5212 5212
 
5213 5213
 					unset($list);
5214
-					$list = &$stack[count($stack)-1];
5214
+					$list = &$stack[count($stack) - 1];
5215 5215
 					array_pop($stack);
5216 5216
 
5217 5217
 					// Go to terminal state if we're at the end of the root array.
5218 5218
 					array_pop($expected);
5219 5219
 
5220
-					if(count($expected) == 0)
5220
+					if (count($expected) == 0)
5221 5221
 						$state = 1;
5222 5222
 
5223 5223
 					break;
5224 5224
 				}
5225 5225
 
5226
-				if($type == 'i' || $type == 's')
5226
+				if ($type == 'i' || $type == 's')
5227 5227
 				{
5228 5228
 					// Array size exceeds expected length.
5229
-					if(count($list) >= end($expected))
5229
+					if (count($list) >= end($expected))
5230 5230
 						return false;
5231 5231
 
5232 5232
 					$key = $value;
@@ -5239,7 +5239,7 @@  discard block
 block discarded – undo
5239 5239
 
5240 5240
 			// Expecting array or value.
5241 5241
 			case 0:
5242
-				if($type == 'a')
5242
+				if ($type == 'a')
5243 5243
 				{
5244 5244
 					$data = array();
5245 5245
 					$list = &$data;
@@ -5248,7 +5248,7 @@  discard block
 block discarded – undo
5248 5248
 					break;
5249 5249
 				}
5250 5250
 
5251
-				if($type != '}')
5251
+				if ($type != '}')
5252 5252
 				{
5253 5253
 					$data = $value;
5254 5254
 					$state = 1;
@@ -5261,7 +5261,7 @@  discard block
 block discarded – undo
5261 5261
 	}
5262 5262
 
5263 5263
 	// Trailing data in input.
5264
-	if(!empty($str))
5264
+	if (!empty($str))
5265 5265
 		return false;
5266 5266
 
5267 5267
 	return $data;
@@ -5315,7 +5315,7 @@  discard block
 block discarded – undo
5315 5315
 	// Set different modes.
5316 5316
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5317 5317
 
5318
-	foreach($chmodValues as $val)
5318
+	foreach ($chmodValues as $val)
5319 5319
 	{
5320 5320
 		// If it's writable, break out of the loop.
5321 5321
 		if (is_writable($file))
@@ -5353,13 +5353,13 @@  discard block
 block discarded – undo
5353 5353
 	$returnArray = @json_decode($json, $returnAsArray);
5354 5354
 
5355 5355
 	// PHP 5.3 so no json_last_error_msg()
5356
-	switch(json_last_error())
5356
+	switch (json_last_error())
5357 5357
 	{
5358 5358
 		case JSON_ERROR_NONE:
5359 5359
 			$jsonError = false;
5360 5360
 			break;
5361 5361
 		case JSON_ERROR_DEPTH:
5362
-			$jsonError =  'JSON_ERROR_DEPTH';
5362
+			$jsonError = 'JSON_ERROR_DEPTH';
5363 5363
 			break;
5364 5364
 		case JSON_ERROR_STATE_MISMATCH:
5365 5365
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5387,10 +5387,10 @@  discard block
 block discarded – undo
5387 5387
 		loadLanguage('Errors');
5388 5388
 
5389 5389
 		if (!empty($jsonDebug))
5390
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5390
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5391 5391
 
5392 5392
 		else
5393
-			log_error($txt['json_'. $jsonError], 'critical');
5393
+			log_error($txt['json_' . $jsonError], 'critical');
5394 5394
 
5395 5395
 		// Everyone expects an array.
5396 5396
 		return array();
@@ -5471,7 +5471,7 @@  discard block
 block discarded – undo
5471 5471
 	global $smcFunc;
5472 5472
 
5473 5473
 	// This recursive function creates the index array from the strings
5474
-	$add_string_to_index = function ($string, $index) use (&$smcFunc, &$add_string_to_index)
5474
+	$add_string_to_index = function($string, $index) use (&$smcFunc, &$add_string_to_index)
5475 5475
 	{
5476 5476
 		static $depth = 0;
5477 5477
 		$depth++;
@@ -5501,7 +5501,7 @@  discard block
 block discarded – undo
5501 5501
 	};
5502 5502
 
5503 5503
 	// This recursive function turns the index array into a regular expression
5504
-	$index_to_regex = function (&$index, $delim) use (&$smcFunc, &$index_to_regex)
5504
+	$index_to_regex = function(&$index, $delim) use (&$smcFunc, &$index_to_regex)
5505 5505
 	{
5506 5506
 		static $depth = 0;
5507 5507
 		$depth++;
@@ -5524,9 +5524,9 @@  discard block
 block discarded – undo
5524 5524
 				$sub_regex = $index_to_regex($value, $delim);
5525 5525
 
5526 5526
 				if (count(array_keys($value)) == 1)
5527
-					$new_key .= explode('(?'.'>', $sub_regex)[0];
5527
+					$new_key .= explode('(?' . '>', $sub_regex)[0];
5528 5528
 				else
5529
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5529
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
5530 5530
 			}
5531 5531
 
5532 5532
 			if ($depth > 1)
@@ -5568,7 +5568,7 @@  discard block
 block discarded – undo
5568 5568
 		$index = $add_string_to_index($string, $index);
5569 5569
 
5570 5570
 	while (!empty($index))
5571
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5571
+		$regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
5572 5572
 
5573 5573
 	return $regexes;
5574 5574
 }
Please login to merge, or discard this patch.
Braces   +1233 added lines, -921 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
 	}
@@ -972,12 +1023,14 @@  discard block
 block discarded – undo
972 1023
 
973 1024
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
974 1025
 
975
-			foreach ($temp as $tag)
976
-				$disabled[trim($tag)] = true;
1026
+			foreach ($temp as $tag) {
1027
+							$disabled[trim($tag)] = true;
1028
+			}
977 1029
 		}
978 1030
 
979
-		if (empty($modSettings['enableEmbeddedFlash']))
980
-			$disabled['flash'] = true;
1031
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1032
+					$disabled['flash'] = true;
1033
+		}
981 1034
 
982 1035
 		/* The following bbc are formatted as an array, with keys as follows:
983 1036
 
@@ -1098,8 +1151,9 @@  discard block
 block discarded – undo
1098 1151
 					$returnContext = '';
1099 1152
 
1100 1153
 					// BBC or the entire attachments feature is disabled
1101
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1102
-						return $data;
1154
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1155
+											return $data;
1156
+					}
1103 1157
 
1104 1158
 					// Save the attach ID.
1105 1159
 					$attachID = $data;
@@ -1110,8 +1164,9 @@  discard block
 block discarded – undo
1110 1164
 					$currentAttachment = parseAttachBBC($attachID);
1111 1165
 
1112 1166
 					// parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do.
1113
-					if (is_string($currentAttachment))
1114
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1167
+					if (is_string($currentAttachment)) {
1168
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1169
+					}
1115 1170
 
1116 1171
 					if (!empty($currentAttachment['is_image']))
1117 1172
 					{
@@ -1122,34 +1177,33 @@  discard block
 block discarded – undo
1122 1177
 						{
1123 1178
 							$width = ' width="' . $params['{width}'] . '"';
1124 1179
 							$height = ' height="' . $params['{height}'] . '"';
1125
-						}
1126
-						elseif (!empty($params['{width}']) && empty($params['{height}']))
1180
+						} elseif (!empty($params['{width}']) && empty($params['{height}']))
1127 1181
 						{
1128 1182
 							$width = ' width="' . $params['{width}'] . '"';
1129 1183
 							$height = '';
1130
-						}
1131
-						elseif (empty($params['{width}']) && !empty($params['{height}']))
1184
+						} elseif (empty($params['{width}']) && !empty($params['{height}']))
1132 1185
 						{
1133 1186
 							$width = '';
1134 1187
 							$height = ' height="' . $params['{height}'] . '"';
1135
-						}
1136
-						else
1188
+						} else
1137 1189
 						{
1138 1190
 							$width = ' width="' . $currentAttachment['width'] . '"';
1139 1191
 							$height = ' height="' . $currentAttachment['height'] . '"';
1140 1192
 						}
1141 1193
 
1142
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1143
-							$returnContext .= '
1194
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1195
+													$returnContext .= '
1144 1196
 													<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>';
1145
-						else
1146
-							$returnContext .= '
1197
+						} else {
1198
+													$returnContext .= '
1147 1199
 													<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>';
1200
+						}
1148 1201
 					}
1149 1202
 
1150 1203
 					// No image. Show a link.
1151
-					else
1152
-						$returnContext .= $currentAttachment['link'];
1204
+					else {
1205
+											$returnContext .= $currentAttachment['link'];
1206
+					}
1153 1207
 
1154 1208
 					// Gotta append what we just did.
1155 1209
 					$data = $returnContext;
@@ -1180,8 +1234,9 @@  discard block
 block discarded – undo
1180 1234
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1181 1235
 						{
1182 1236
 							// Do PHP code coloring?
1183
-							if ($php_parts[$php_i] != '&lt;?php')
1184
-								continue;
1237
+							if ($php_parts[$php_i] != '&lt;?php') {
1238
+															continue;
1239
+							}
1185 1240
 
1186 1241
 							$php_string = '';
1187 1242
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1197,8 +1252,9 @@  discard block
 block discarded – undo
1197 1252
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1198 1253
 
1199 1254
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1200
-						if ($context['browser']['is_opera'])
1201
-							$data .= '&nbsp;';
1255
+						if ($context['browser']['is_opera']) {
1256
+													$data .= '&nbsp;';
1257
+						}
1202 1258
 					}
1203 1259
 				},
1204 1260
 				'block_level' => true,
@@ -1217,8 +1273,9 @@  discard block
 block discarded – undo
1217 1273
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1218 1274
 						{
1219 1275
 							// Do PHP code coloring?
1220
-							if ($php_parts[$php_i] != '&lt;?php')
1221
-								continue;
1276
+							if ($php_parts[$php_i] != '&lt;?php') {
1277
+															continue;
1278
+							}
1222 1279
 
1223 1280
 							$php_string = '';
1224 1281
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1234,8 +1291,9 @@  discard block
 block discarded – undo
1234 1291
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1235 1292
 
1236 1293
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1237
-						if ($context['browser']['is_opera'])
1238
-							$data[0] .= '&nbsp;';
1294
+						if ($context['browser']['is_opera']) {
1295
+													$data[0] .= '&nbsp;';
1296
+						}
1239 1297
 					}
1240 1298
 				},
1241 1299
 				'block_level' => true,
@@ -1273,11 +1331,13 @@  discard block
 block discarded – undo
1273 1331
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1274 1332
 				'validate' => function (&$tag, &$data, $disabled)
1275 1333
 				{
1276
-					if (isset($disabled['url']))
1277
-						$tag['content'] = '$1';
1334
+					if (isset($disabled['url'])) {
1335
+											$tag['content'] = '$1';
1336
+					}
1278 1337
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1279
-					if (empty($scheme))
1280
-						$data[0] = '//' . ltrim($data[0], ':/');
1338
+					if (empty($scheme)) {
1339
+											$data[0] = '//' . ltrim($data[0], ':/');
1340
+					}
1281 1341
 				},
1282 1342
 				'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>',
1283 1343
 			),
@@ -1324,14 +1384,16 @@  discard block
 block discarded – undo
1324 1384
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1325 1385
 					if ($image_proxy_enabled)
1326 1386
 					{
1327
-						if (empty($scheme))
1328
-							$data = 'http://' . ltrim($data, ':/');
1387
+						if (empty($scheme)) {
1388
+													$data = 'http://' . ltrim($data, ':/');
1389
+						}
1329 1390
 												
1330
-						if ($scheme != 'https')
1331
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1391
+						if ($scheme != 'https') {
1392
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1393
+						}
1394
+					} elseif (empty($scheme)) {
1395
+											$data = '//' . ltrim($data, ':/');
1332 1396
 					}
1333
-					elseif (empty($scheme))
1334
-						$data = '//' . ltrim($data, ':/');
1335 1397
 				},
1336 1398
 				'disabled_content' => '($1)',
1337 1399
 			),
@@ -1347,14 +1409,16 @@  discard block
 block discarded – undo
1347 1409
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1348 1410
 					if ($image_proxy_enabled)
1349 1411
 					{
1350
-						if (empty($scheme))
1351
-							$data = 'http://' . ltrim($data, ':/');
1412
+						if (empty($scheme)) {
1413
+													$data = 'http://' . ltrim($data, ':/');
1414
+						}
1352 1415
 												
1353
-						if ($scheme != 'https')
1354
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1416
+						if ($scheme != 'https') {
1417
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1418
+						}
1419
+					} elseif (empty($scheme)) {
1420
+											$data = '//' . ltrim($data, ':/');
1355 1421
 					}
1356
-					elseif (empty($scheme))
1357
-						$data = '//' . ltrim($data, ':/');
1358 1422
 				},
1359 1423
 				'disabled_content' => '($1)',
1360 1424
 			),
@@ -1366,8 +1430,9 @@  discard block
 block discarded – undo
1366 1430
 				{
1367 1431
 					$data = strtr($data, array('<br>' => ''));
1368 1432
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1369
-					if (empty($scheme))
1370
-						$data = '//' . ltrim($data, ':/');
1433
+					if (empty($scheme)) {
1434
+											$data = '//' . ltrim($data, ':/');
1435
+					}
1371 1436
 				},
1372 1437
 			),
1373 1438
 			array(
@@ -1378,13 +1443,14 @@  discard block
 block discarded – undo
1378 1443
 				'after' => '</a>',
1379 1444
 				'validate' => function (&$tag, &$data, $disabled)
1380 1445
 				{
1381
-					if (substr($data, 0, 1) == '#')
1382
-						$data = '#post_' . substr($data, 1);
1383
-					else
1446
+					if (substr($data, 0, 1) == '#') {
1447
+											$data = '#post_' . substr($data, 1);
1448
+					} else
1384 1449
 					{
1385 1450
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1386
-						if (empty($scheme))
1387
-							$data = '//' . ltrim($data, ':/');
1451
+						if (empty($scheme)) {
1452
+													$data = '//' . ltrim($data, ':/');
1453
+						}
1388 1454
 					}
1389 1455
 				},
1390 1456
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1462,8 +1528,9 @@  discard block
 block discarded – undo
1462 1528
 					{
1463 1529
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1464 1530
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1465
-						if ($add_begin)
1466
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1531
+						if ($add_begin) {
1532
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1533
+						}
1467 1534
 					}
1468 1535
 				},
1469 1536
 				'block_level' => false,
@@ -1594,10 +1661,11 @@  discard block
 block discarded – undo
1594 1661
 				'content' => '$1',
1595 1662
 				'validate' => function (&$tag, &$data, $disabled)
1596 1663
 				{
1597
-					if (is_numeric($data))
1598
-						$data = timeformat($data);
1599
-					else
1600
-						$tag['content'] = '[time]$1[/time]';
1664
+					if (is_numeric($data)) {
1665
+											$data = timeformat($data);
1666
+					} else {
1667
+											$tag['content'] = '[time]$1[/time]';
1668
+					}
1601 1669
 				},
1602 1670
 			),
1603 1671
 			array(
@@ -1624,8 +1692,9 @@  discard block
 block discarded – undo
1624 1692
 				{
1625 1693
 					$data = strtr($data, array('<br>' => ''));
1626 1694
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1627
-					if (empty($scheme))
1628
-						$data = '//' . ltrim($data, ':/');
1695
+					if (empty($scheme)) {
1696
+											$data = '//' . ltrim($data, ':/');
1697
+					}
1629 1698
 				},
1630 1699
 			),
1631 1700
 			array(
@@ -1637,8 +1706,9 @@  discard block
 block discarded – undo
1637 1706
 				'validate' => function (&$tag, &$data, $disabled)
1638 1707
 				{
1639 1708
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1640
-					if (empty($scheme))
1641
-						$data = '//' . ltrim($data, ':/');
1709
+					if (empty($scheme)) {
1710
+											$data = '//' . ltrim($data, ':/');
1711
+					}
1642 1712
 				},
1643 1713
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1644 1714
 				'disabled_after' => ' ($1)',
@@ -1658,8 +1728,9 @@  discard block
 block discarded – undo
1658 1728
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1659 1729
 		if ($message === false)
1660 1730
 		{
1661
-			if (isset($temp_bbc))
1662
-				$bbc_codes = $temp_bbc;
1731
+			if (isset($temp_bbc)) {
1732
+							$bbc_codes = $temp_bbc;
1733
+			}
1663 1734
 			usort($codes, function ($a, $b) {
1664 1735
 				return strcmp($a['tag'], $b['tag']);
1665 1736
 			});
@@ -1679,8 +1750,9 @@  discard block
 block discarded – undo
1679 1750
 		);
1680 1751
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1681 1752
 		{
1682
-			foreach ($itemcodes as $c => $dummy)
1683
-				$bbc_codes[$c] = array();
1753
+			foreach ($itemcodes as $c => $dummy) {
1754
+							$bbc_codes[$c] = array();
1755
+			}
1684 1756
 		}
1685 1757
 
1686 1758
 		// Shhhh!
@@ -1701,12 +1773,14 @@  discard block
 block discarded – undo
1701 1773
 		foreach ($codes as $code)
1702 1774
 		{
1703 1775
 			// Make it easier to process parameters later
1704
-			if (!empty($code['parameters']))
1705
-				ksort($code['parameters'], SORT_STRING);
1776
+			if (!empty($code['parameters'])) {
1777
+							ksort($code['parameters'], SORT_STRING);
1778
+			}
1706 1779
 
1707 1780
 			// If we are not doing every tag only do ones we are interested in.
1708
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1709
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1781
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
1782
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1783
+			}
1710 1784
 		}
1711 1785
 		$codes = null;
1712 1786
 	}
@@ -1717,8 +1791,9 @@  discard block
 block discarded – undo
1717 1791
 		// It's likely this will change if the message is modified.
1718 1792
 		$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']);
1719 1793
 
1720
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1721
-			return $temp;
1794
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
1795
+					return $temp;
1796
+		}
1722 1797
 
1723 1798
 		$cache_t = microtime();
1724 1799
 	}
@@ -1750,8 +1825,9 @@  discard block
 block discarded – undo
1750 1825
 		$disabled['flash'] = true;
1751 1826
 
1752 1827
 		// @todo Change maybe?
1753
-		if (!isset($_GET['images']))
1754
-			$disabled['img'] = true;
1828
+		if (!isset($_GET['images'])) {
1829
+					$disabled['img'] = true;
1830
+		}
1755 1831
 
1756 1832
 		// @todo Interface/setting to add more?
1757 1833
 	}
@@ -1777,8 +1853,9 @@  discard block
 block discarded – undo
1777 1853
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
1778 1854
 
1779 1855
 		// Failsafe.
1780
-		if ($pos === false || $last_pos > $pos)
1781
-			$pos = strlen($message) + 1;
1856
+		if ($pos === false || $last_pos > $pos) {
1857
+					$pos = strlen($message) + 1;
1858
+		}
1782 1859
 
1783 1860
 		// Can't have a one letter smiley, URL, or email! (sorry.)
1784 1861
 		if ($last_pos < $pos - 1)
@@ -1797,8 +1874,9 @@  discard block
 block discarded – undo
1797 1874
 
1798 1875
 				// <br> should be empty.
1799 1876
 				$empty_tags = array('br', 'hr');
1800
-				foreach ($empty_tags as $tag)
1801
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1877
+				foreach ($empty_tags as $tag) {
1878
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1879
+				}
1802 1880
 
1803 1881
 				// b, u, i, s, pre... basic tags.
1804 1882
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote');
@@ -1807,8 +1885,9 @@  discard block
 block discarded – undo
1807 1885
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
1808 1886
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
1809 1887
 
1810
-					if ($diff > 0)
1811
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1888
+					if ($diff > 0) {
1889
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1890
+					}
1812 1891
 				}
1813 1892
 
1814 1893
 				// Do <img ...> - with security... action= -> action-.
@@ -1821,8 +1900,9 @@  discard block
 block discarded – undo
1821 1900
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
1822 1901
 
1823 1902
 						// Remove action= from the URL - no funny business, now.
1824
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
1825
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1903
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
1904
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1905
+						}
1826 1906
 
1827 1907
 						// Check if the image is larger than allowed.
1828 1908
 						if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
@@ -1843,9 +1923,9 @@  discard block
 block discarded – undo
1843 1923
 
1844 1924
 							// Set the new image tag.
1845 1925
 							$replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]';
1926
+						} else {
1927
+													$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1846 1928
 						}
1847
-						else
1848
-							$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1849 1929
 					}
1850 1930
 
1851 1931
 					$data = strtr($data, $replaces);
@@ -1858,16 +1938,18 @@  discard block
 block discarded – undo
1858 1938
 				$no_autolink_area = false;
1859 1939
 				if (!empty($open_tags))
1860 1940
 				{
1861
-					foreach ($open_tags as $open_tag)
1862
-						if (in_array($open_tag['tag'], $no_autolink_tags))
1941
+					foreach ($open_tags as $open_tag) {
1942
+											if (in_array($open_tag['tag'], $no_autolink_tags))
1863 1943
 							$no_autolink_area = true;
1944
+					}
1864 1945
 				}
1865 1946
 
1866 1947
 				// Don't go backwards.
1867 1948
 				// @todo Don't think is the real solution....
1868 1949
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
1869
-				if ($pos < $lastAutoPos)
1870
-					$no_autolink_area = true;
1950
+				if ($pos < $lastAutoPos) {
1951
+									$no_autolink_area = true;
1952
+				}
1871 1953
 				$lastAutoPos = $pos;
1872 1954
 
1873 1955
 				if (!$no_autolink_area)
@@ -1922,17 +2004,19 @@  discard block
 block discarded – undo
1922 2004
 									if ($scheme == 'mailto')
1923 2005
 									{
1924 2006
 										$email_address = str_replace('mailto:', '', $url);
1925
-										if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
1926
-											return '[email=' . $email_address . ']' . $url . '[/email]';
1927
-										else
1928
-											return $url;
2007
+										if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2008
+																					return '[email=' . $email_address . ']' . $url . '[/email]';
2009
+										} else {
2010
+																					return $url;
2011
+										}
1929 2012
 									}
1930 2013
 
1931 2014
 									// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
1932
-									if (empty($scheme))
1933
-										$fullUrl = '//' . ltrim($url, ':/');
1934
-									else
1935
-										$fullUrl = $url;
2015
+									if (empty($scheme)) {
2016
+																			$fullUrl = '//' . ltrim($url, ':/');
2017
+									} else {
2018
+																			$fullUrl = $url;
2019
+									}
1936 2020
 
1937 2021
 									return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
1938 2022
 								}, $data);
@@ -1962,16 +2046,18 @@  discard block
 block discarded – undo
1962 2046
 		}
1963 2047
 
1964 2048
 		// Are we there yet?  Are we there yet?
1965
-		if ($pos >= strlen($message) - 1)
1966
-			break;
2049
+		if ($pos >= strlen($message) - 1) {
2050
+					break;
2051
+		}
1967 2052
 
1968 2053
 		$tags = strtolower($message[$pos + 1]);
1969 2054
 
1970 2055
 		if ($tags == '/' && !empty($open_tags))
1971 2056
 		{
1972 2057
 			$pos2 = strpos($message, ']', $pos + 1);
1973
-			if ($pos2 == $pos + 2)
1974
-				continue;
2058
+			if ($pos2 == $pos + 2) {
2059
+							continue;
2060
+			}
1975 2061
 
1976 2062
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
1977 2063
 
@@ -1981,8 +2067,9 @@  discard block
 block discarded – undo
1981 2067
 			do
1982 2068
 			{
1983 2069
 				$tag = array_pop($open_tags);
1984
-				if (!$tag)
1985
-					break;
2070
+				if (!$tag) {
2071
+									break;
2072
+				}
1986 2073
 
1987 2074
 				if (!empty($tag['block_level']))
1988 2075
 				{
@@ -1996,10 +2083,11 @@  discard block
 block discarded – undo
1996 2083
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
1997 2084
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
1998 2085
 					{
1999
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2000
-							if ($temp['tag'] == $look_for)
2086
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2087
+													if ($temp['tag'] == $look_for)
2001 2088
 							{
2002 2089
 								$block_level = !empty($temp['block_level']);
2090
+						}
2003 2091
 								break;
2004 2092
 							}
2005 2093
 					}
@@ -2021,15 +2109,15 @@  discard block
 block discarded – undo
2021 2109
 			{
2022 2110
 				$open_tags = $to_close;
2023 2111
 				continue;
2024
-			}
2025
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2112
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2026 2113
 			{
2027 2114
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2028 2115
 				{
2029
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2030
-						if ($temp['tag'] == $look_for)
2116
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2117
+											if ($temp['tag'] == $look_for)
2031 2118
 						{
2032 2119
 							$block_level = !empty($temp['block_level']);
2120
+					}
2033 2121
 							break;
2034 2122
 						}
2035 2123
 				}
@@ -2037,8 +2125,9 @@  discard block
 block discarded – undo
2037 2125
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2038 2126
 				if (!$block_level)
2039 2127
 				{
2040
-					foreach ($to_close as $tag)
2041
-						array_push($open_tags, $tag);
2128
+					foreach ($to_close as $tag) {
2129
+											array_push($open_tags, $tag);
2130
+					}
2042 2131
 					continue;
2043 2132
 				}
2044 2133
 			}
@@ -2050,10 +2139,12 @@  discard block
 block discarded – undo
2050 2139
 				$pos2 = $pos - 1;
2051 2140
 
2052 2141
 				// See the comment at the end of the big loop - just eating whitespace ;).
2053
-				if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>')
2054
-					$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2055
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
2056
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2142
+				if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') {
2143
+									$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2144
+				}
2145
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0) {
2146
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2147
+				}
2057 2148
 			}
2058 2149
 
2059 2150
 			if (!empty($to_close))
@@ -2066,8 +2157,9 @@  discard block
 block discarded – undo
2066 2157
 		}
2067 2158
 
2068 2159
 		// No tags for this character, so just keep going (fastest possible course.)
2069
-		if (!isset($bbc_codes[$tags]))
2070
-			continue;
2160
+		if (!isset($bbc_codes[$tags])) {
2161
+					continue;
2162
+		}
2071 2163
 
2072 2164
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2073 2165
 		$tag = null;
@@ -2076,44 +2168,52 @@  discard block
 block discarded – undo
2076 2168
 			$pt_strlen = strlen($possible['tag']);
2077 2169
 
2078 2170
 			// Not a match?
2079
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2080
-				continue;
2171
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2172
+							continue;
2173
+			}
2081 2174
 
2082 2175
 			$next_c = $message[$pos + 1 + $pt_strlen];
2083 2176
 
2084 2177
 			// A test validation?
2085
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2086
-				continue;
2178
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2179
+							continue;
2180
+			}
2087 2181
 			// Do we want parameters?
2088 2182
 			elseif (!empty($possible['parameters']))
2089 2183
 			{
2090
-				if ($next_c != ' ')
2091
-					continue;
2092
-			}
2093
-			elseif (isset($possible['type']))
2184
+				if ($next_c != ' ') {
2185
+									continue;
2186
+				}
2187
+			} elseif (isset($possible['type']))
2094 2188
 			{
2095 2189
 				// Do we need an equal sign?
2096
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2097
-					continue;
2190
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2191
+									continue;
2192
+				}
2098 2193
 				// Maybe we just want a /...
2099
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2100
-					continue;
2194
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2195
+									continue;
2196
+				}
2101 2197
 				// An immediate ]?
2102
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2103
-					continue;
2198
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2199
+									continue;
2200
+				}
2104 2201
 			}
2105 2202
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2106
-			elseif ($next_c != ']')
2107
-				continue;
2203
+			elseif ($next_c != ']') {
2204
+							continue;
2205
+			}
2108 2206
 
2109 2207
 			// Check allowed tree?
2110
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2111
-				continue;
2112
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2113
-				continue;
2208
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2209
+							continue;
2210
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2211
+							continue;
2212
+			}
2114 2213
 			// If this is in the list of disallowed child tags, don't parse it.
2115
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2116
-				continue;
2214
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2215
+							continue;
2216
+			}
2117 2217
 
2118 2218
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2119 2219
 
@@ -2125,8 +2225,9 @@  discard block
 block discarded – undo
2125 2225
 				foreach ($open_tags as $open_quote)
2126 2226
 				{
2127 2227
 					// Every parent quote this quote has flips the styling
2128
-					if ($open_quote['tag'] == 'quote')
2129
-						$quote_alt = !$quote_alt;
2228
+					if ($open_quote['tag'] == 'quote') {
2229
+											$quote_alt = !$quote_alt;
2230
+					}
2130 2231
 				}
2131 2232
 				// Add a class to the quote to style alternating blockquotes
2132 2233
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2137,8 +2238,9 @@  discard block
 block discarded – undo
2137 2238
 			{
2138 2239
 				// Build a regular expression for each parameter for the current tag.
2139 2240
 				$preg = array();
2140
-				foreach ($possible['parameters'] as $p => $info)
2141
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2241
+				foreach ($possible['parameters'] as $p => $info) {
2242
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2243
+				}
2142 2244
 
2143 2245
 				// Extract the string that potentially holds our parameters.
2144 2246
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2158,24 +2260,27 @@  discard block
 block discarded – undo
2158 2260
 
2159 2261
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2160 2262
 
2161
-					if ($match)
2162
-						$blob_counter = count($blobs) + 1;
2263
+					if ($match) {
2264
+											$blob_counter = count($blobs) + 1;
2265
+					}
2163 2266
 				}
2164 2267
 
2165 2268
 				// Didn't match our parameter list, try the next possible.
2166
-				if (!$match)
2167
-					continue;
2269
+				if (!$match) {
2270
+									continue;
2271
+				}
2168 2272
 
2169 2273
 				$params = array();
2170 2274
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2171 2275
 				{
2172 2276
 					$key = strtok(ltrim($matches[$i]), '=');
2173
-					if (isset($possible['parameters'][$key]['value']))
2174
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2175
-					elseif (isset($possible['parameters'][$key]['validate']))
2176
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2177
-					else
2178
-						$params['{' . $key . '}'] = $matches[$i + 1];
2277
+					if (isset($possible['parameters'][$key]['value'])) {
2278
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2279
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2280
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2281
+					} else {
2282
+											$params['{' . $key . '}'] = $matches[$i + 1];
2283
+					}
2179 2284
 
2180 2285
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2181 2286
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2183,23 +2288,26 @@  discard block
 block discarded – undo
2183 2288
 
2184 2289
 				foreach ($possible['parameters'] as $p => $info)
2185 2290
 				{
2186
-					if (!isset($params['{' . $p . '}']))
2187
-						$params['{' . $p . '}'] = '';
2291
+					if (!isset($params['{' . $p . '}'])) {
2292
+											$params['{' . $p . '}'] = '';
2293
+					}
2188 2294
 				}
2189 2295
 
2190 2296
 				$tag = $possible;
2191 2297
 
2192 2298
 				// Put the parameters into the string.
2193
-				if (isset($tag['before']))
2194
-					$tag['before'] = strtr($tag['before'], $params);
2195
-				if (isset($tag['after']))
2196
-					$tag['after'] = strtr($tag['after'], $params);
2197
-				if (isset($tag['content']))
2198
-					$tag['content'] = strtr($tag['content'], $params);
2299
+				if (isset($tag['before'])) {
2300
+									$tag['before'] = strtr($tag['before'], $params);
2301
+				}
2302
+				if (isset($tag['after'])) {
2303
+									$tag['after'] = strtr($tag['after'], $params);
2304
+				}
2305
+				if (isset($tag['content'])) {
2306
+									$tag['content'] = strtr($tag['content'], $params);
2307
+				}
2199 2308
 
2200 2309
 				$pos1 += strlen($given_param_string);
2201
-			}
2202
-			else
2310
+			} else
2203 2311
 			{
2204 2312
 				$tag = $possible;
2205 2313
 				$params = array();
@@ -2210,8 +2318,9 @@  discard block
 block discarded – undo
2210 2318
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2211 2319
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2212 2320
 		{
2213
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2214
-				continue;
2321
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2322
+							continue;
2323
+			}
2215 2324
 
2216 2325
 			$tag = $itemcodes[$message[$pos + 1]];
2217 2326
 
@@ -2232,9 +2341,9 @@  discard block
 block discarded – undo
2232 2341
 			{
2233 2342
 				array_pop($open_tags);
2234 2343
 				$code = '</li>';
2344
+			} else {
2345
+							$code = '';
2235 2346
 			}
2236
-			else
2237
-				$code = '';
2238 2347
 
2239 2348
 			// Now we open a new tag.
2240 2349
 			$open_tags[] = array(
@@ -2281,12 +2390,14 @@  discard block
 block discarded – undo
2281 2390
 		}
2282 2391
 
2283 2392
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2284
-		if ($tag === null)
2285
-			continue;
2393
+		if ($tag === null) {
2394
+					continue;
2395
+		}
2286 2396
 
2287 2397
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2288
-		if (isset($inside['disallow_children']))
2289
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2398
+		if (isset($inside['disallow_children'])) {
2399
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2400
+		}
2290 2401
 
2291 2402
 		// Is this tag disabled?
2292 2403
 		if (isset($disabled[$tag['tag']]))
@@ -2296,14 +2407,13 @@  discard block
 block discarded – undo
2296 2407
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2297 2408
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2298 2409
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2299
-			}
2300
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2410
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2301 2411
 			{
2302 2412
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2303 2413
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2414
+			} else {
2415
+							$tag['content'] = $tag['disabled_content'];
2304 2416
 			}
2305
-			else
2306
-				$tag['content'] = $tag['disabled_content'];
2307 2417
 		}
2308 2418
 
2309 2419
 		// we use this a lot
@@ -2313,8 +2423,9 @@  discard block
 block discarded – undo
2313 2423
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2314 2424
 		{
2315 2425
 			$n = count($open_tags) - 1;
2316
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2317
-				$n--;
2426
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2427
+							$n--;
2428
+			}
2318 2429
 
2319 2430
 			// Close all the non block level tags so this tag isn't surrounded by them.
2320 2431
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2325,10 +2436,12 @@  discard block
 block discarded – undo
2325 2436
 				$pos1 += $ot_strlen + 2;
2326 2437
 
2327 2438
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2328
-				if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>')
2329
-					$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2330
-				if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
2331
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2439
+				if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') {
2440
+									$message = substr($message, 0, $pos) . substr($message, $pos + 4);
2441
+				}
2442
+				if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0) {
2443
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2444
+				}
2332 2445
 
2333 2446
 				array_pop($open_tags);
2334 2447
 			}
@@ -2346,16 +2459,19 @@  discard block
 block discarded – undo
2346 2459
 		elseif ($tag['type'] == 'unparsed_content')
2347 2460
 		{
2348 2461
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2349
-			if ($pos2 === false)
2350
-				continue;
2462
+			if ($pos2 === false) {
2463
+							continue;
2464
+			}
2351 2465
 
2352 2466
 			$data = substr($message, $pos1, $pos2 - $pos1);
2353 2467
 
2354
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2355
-				$data = substr($data, 4);
2468
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2469
+							$data = substr($data, 4);
2470
+			}
2356 2471
 
2357
-			if (isset($tag['validate']))
2358
-				$tag['validate']($tag, $data, $disabled, $params);
2472
+			if (isset($tag['validate'])) {
2473
+							$tag['validate']($tag, $data, $disabled, $params);
2474
+			}
2359 2475
 
2360 2476
 			$code = strtr($tag['content'], array('$1' => $data));
2361 2477
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2371,34 +2487,40 @@  discard block
 block discarded – undo
2371 2487
 			if (isset($tag['quoted']))
2372 2488
 			{
2373 2489
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2374
-				if ($tag['quoted'] != 'optional' && !$quoted)
2375
-					continue;
2490
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2491
+									continue;
2492
+				}
2376 2493
 
2377
-				if ($quoted)
2378
-					$pos1 += 6;
2494
+				if ($quoted) {
2495
+									$pos1 += 6;
2496
+				}
2497
+			} else {
2498
+							$quoted = false;
2379 2499
 			}
2380
-			else
2381
-				$quoted = false;
2382 2500
 
2383 2501
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2384
-			if ($pos2 === false)
2385
-				continue;
2502
+			if ($pos2 === false) {
2503
+							continue;
2504
+			}
2386 2505
 
2387 2506
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2388
-			if ($pos3 === false)
2389
-				continue;
2507
+			if ($pos3 === false) {
2508
+							continue;
2509
+			}
2390 2510
 
2391 2511
 			$data = array(
2392 2512
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2393 2513
 				substr($message, $pos1, $pos2 - $pos1)
2394 2514
 			);
2395 2515
 
2396
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2397
-				$data[0] = substr($data[0], 4);
2516
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2517
+							$data[0] = substr($data[0], 4);
2518
+			}
2398 2519
 
2399 2520
 			// Validation for my parking, please!
2400
-			if (isset($tag['validate']))
2401
-				$tag['validate']($tag, $data, $disabled, $params);
2521
+			if (isset($tag['validate'])) {
2522
+							$tag['validate']($tag, $data, $disabled, $params);
2523
+			}
2402 2524
 
2403 2525
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2404 2526
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2415,23 +2537,27 @@  discard block
 block discarded – undo
2415 2537
 		elseif ($tag['type'] == 'unparsed_commas_content')
2416 2538
 		{
2417 2539
 			$pos2 = strpos($message, ']', $pos1);
2418
-			if ($pos2 === false)
2419
-				continue;
2540
+			if ($pos2 === false) {
2541
+							continue;
2542
+			}
2420 2543
 
2421 2544
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2422
-			if ($pos3 === false)
2423
-				continue;
2545
+			if ($pos3 === false) {
2546
+							continue;
2547
+			}
2424 2548
 
2425 2549
 			// We want $1 to be the content, and the rest to be csv.
2426 2550
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2427 2551
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2428 2552
 
2429
-			if (isset($tag['validate']))
2430
-				$tag['validate']($tag, $data, $disabled, $params);
2553
+			if (isset($tag['validate'])) {
2554
+							$tag['validate']($tag, $data, $disabled, $params);
2555
+			}
2431 2556
 
2432 2557
 			$code = $tag['content'];
2433
-			foreach ($data as $k => $d)
2434
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2558
+			foreach ($data as $k => $d) {
2559
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2560
+			}
2435 2561
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2436 2562
 			$pos += strlen($code) - 1 + 2;
2437 2563
 		}
@@ -2439,24 +2565,28 @@  discard block
 block discarded – undo
2439 2565
 		elseif ($tag['type'] == 'unparsed_commas')
2440 2566
 		{
2441 2567
 			$pos2 = strpos($message, ']', $pos1);
2442
-			if ($pos2 === false)
2443
-				continue;
2568
+			if ($pos2 === false) {
2569
+							continue;
2570
+			}
2444 2571
 
2445 2572
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2446 2573
 
2447
-			if (isset($tag['validate']))
2448
-				$tag['validate']($tag, $data, $disabled, $params);
2574
+			if (isset($tag['validate'])) {
2575
+							$tag['validate']($tag, $data, $disabled, $params);
2576
+			}
2449 2577
 
2450 2578
 			// Fix after, for disabled code mainly.
2451
-			foreach ($data as $k => $d)
2452
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2579
+			foreach ($data as $k => $d) {
2580
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2581
+			}
2453 2582
 
2454 2583
 			$open_tags[] = $tag;
2455 2584
 
2456 2585
 			// Replace them out, $1, $2, $3, $4, etc.
2457 2586
 			$code = $tag['before'];
2458
-			foreach ($data as $k => $d)
2459
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2587
+			foreach ($data as $k => $d) {
2588
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2589
+			}
2460 2590
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2461 2591
 			$pos += strlen($code) - 1 + 2;
2462 2592
 		}
@@ -2467,28 +2597,33 @@  discard block
 block discarded – undo
2467 2597
 			if (isset($tag['quoted']))
2468 2598
 			{
2469 2599
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2470
-				if ($tag['quoted'] != 'optional' && !$quoted)
2471
-					continue;
2600
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2601
+									continue;
2602
+				}
2472 2603
 
2473
-				if ($quoted)
2474
-					$pos1 += 6;
2604
+				if ($quoted) {
2605
+									$pos1 += 6;
2606
+				}
2607
+			} else {
2608
+							$quoted = false;
2475 2609
 			}
2476
-			else
2477
-				$quoted = false;
2478 2610
 
2479 2611
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2480
-			if ($pos2 === false)
2481
-				continue;
2612
+			if ($pos2 === false) {
2613
+							continue;
2614
+			}
2482 2615
 
2483 2616
 			$data = substr($message, $pos1, $pos2 - $pos1);
2484 2617
 
2485 2618
 			// Validation for my parking, please!
2486
-			if (isset($tag['validate']))
2487
-				$tag['validate']($tag, $data, $disabled, $params);
2619
+			if (isset($tag['validate'])) {
2620
+							$tag['validate']($tag, $data, $disabled, $params);
2621
+			}
2488 2622
 
2489 2623
 			// For parsed content, we must recurse to avoid security problems.
2490
-			if ($tag['type'] != 'unparsed_equals')
2491
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2624
+			if ($tag['type'] != 'unparsed_equals') {
2625
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2626
+			}
2492 2627
 
2493 2628
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2494 2629
 
@@ -2500,34 +2635,40 @@  discard block
 block discarded – undo
2500 2635
 		}
2501 2636
 
2502 2637
 		// If this is block level, eat any breaks after it.
2503
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2504
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2638
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2639
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2640
+		}
2505 2641
 
2506 2642
 		// Are we trimming outside this tag?
2507
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2508
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2643
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2644
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2645
+		}
2509 2646
 	}
2510 2647
 
2511 2648
 	// Close any remaining tags.
2512
-	while ($tag = array_pop($open_tags))
2513
-		$message .= "\n" . $tag['after'] . "\n";
2649
+	while ($tag = array_pop($open_tags)) {
2650
+			$message .= "\n" . $tag['after'] . "\n";
2651
+	}
2514 2652
 
2515 2653
 	// Parse the smileys within the parts where it can be done safely.
2516 2654
 	if ($smileys === true)
2517 2655
 	{
2518 2656
 		$message_parts = explode("\n", $message);
2519
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2520
-			parsesmileys($message_parts[$i]);
2657
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2658
+					parsesmileys($message_parts[$i]);
2659
+		}
2521 2660
 
2522 2661
 		$message = implode('', $message_parts);
2523 2662
 	}
2524 2663
 
2525 2664
 	// No smileys, just get rid of the markers.
2526
-	else
2527
-		$message = strtr($message, array("\n" => ''));
2665
+	else {
2666
+			$message = strtr($message, array("\n" => ''));
2667
+	}
2528 2668
 
2529
-	if ($message !== '' && $message[0] === ' ')
2530
-		$message = '&nbsp;' . substr($message, 1);
2669
+	if ($message !== '' && $message[0] === ' ') {
2670
+			$message = '&nbsp;' . substr($message, 1);
2671
+	}
2531 2672
 
2532 2673
 	// Cleanup whitespace.
2533 2674
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2536,15 +2677,16 @@  discard block
 block discarded – undo
2536 2677
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2537 2678
 
2538 2679
 	// Cache the output if it took some time...
2539
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2540
-		cache_put_data($cache_key, $message, 240);
2680
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
2681
+			cache_put_data($cache_key, $message, 240);
2682
+	}
2541 2683
 
2542 2684
 	// If this was a force parse revert if needed.
2543 2685
 	if (!empty($parse_tags))
2544 2686
 	{
2545
-		if (empty($temp_bbc))
2546
-			$bbc_codes = array();
2547
-		else
2687
+		if (empty($temp_bbc)) {
2688
+					$bbc_codes = array();
2689
+		} else
2548 2690
 		{
2549 2691
 			$bbc_codes = $temp_bbc;
2550 2692
 			unset($temp_bbc);
@@ -2571,8 +2713,9 @@  discard block
 block discarded – undo
2571 2713
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2572 2714
 
2573 2715
 	// No smiley set at all?!
2574
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2575
-		return;
2716
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
2717
+			return;
2718
+	}
2576 2719
 
2577 2720
 	// If smileyPregSearch hasn't been set, do it now.
2578 2721
 	if (empty($smileyPregSearch))
@@ -2583,8 +2726,7 @@  discard block
 block discarded – undo
2583 2726
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2584 2727
 			$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');
2585 2728
 			$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'], '', '', '', '');
2586
-		}
2587
-		else
2729
+		} else
2588 2730
 		{
2589 2731
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2590 2732
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2608,9 +2750,9 @@  discard block
 block discarded – undo
2608 2750
 				$smcFunc['db_free_result']($result);
2609 2751
 
2610 2752
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
2753
+			} else {
2754
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2611 2755
 			}
2612
-			else
2613
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2614 2756
 		}
2615 2757
 
2616 2758
 		// The non-breaking-space is a complex thing...
@@ -2687,35 +2829,41 @@  discard block
 block discarded – undo
2687 2829
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
2688 2830
 
2689 2831
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
2690
-	if (!empty($context['flush_mail']))
2691
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2832
+	if (!empty($context['flush_mail'])) {
2833
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2692 2834
 		AddMailQueue(true);
2835
+	}
2693 2836
 
2694 2837
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
2695 2838
 
2696
-	if ($add)
2697
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2839
+	if ($add) {
2840
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2841
+	}
2698 2842
 
2699 2843
 	// Put the session ID in.
2700
-	if (defined('SID') && SID != '')
2701
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2844
+	if (defined('SID') && SID != '') {
2845
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2846
+	}
2702 2847
 	// Keep that debug in their for template debugging!
2703
-	elseif (isset($_GET['debug']))
2704
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2848
+	elseif (isset($_GET['debug'])) {
2849
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2850
+	}
2705 2851
 
2706 2852
 	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'])))
2707 2853
 	{
2708
-		if (defined('SID') && SID != '')
2709
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2854
+		if (defined('SID') && SID != '') {
2855
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2710 2856
 				function ($m) use ($scripturl)
2711 2857
 				{
2712 2858
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2859
+		}
2713 2860
 				}, $setLocation);
2714
-		else
2715
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2861
+		else {
2862
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2716 2863
 				function ($m) use ($scripturl)
2717 2864
 				{
2718 2865
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2866
+		}
2719 2867
 				}, $setLocation);
2720 2868
 	}
2721 2869
 
@@ -2726,8 +2874,9 @@  discard block
 block discarded – undo
2726 2874
 	header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
2727 2875
 
2728 2876
 	// Debugging.
2729
-	if (isset($db_show_debug) && $db_show_debug === true)
2730
-		$_SESSION['debug_redirect'] = $db_cache;
2877
+	if (isset($db_show_debug) && $db_show_debug === true) {
2878
+			$_SESSION['debug_redirect'] = $db_cache;
2879
+	}
2731 2880
 
2732 2881
 	obExit(false);
2733 2882
 }
@@ -2746,51 +2895,60 @@  discard block
 block discarded – undo
2746 2895
 
2747 2896
 	// Attempt to prevent a recursive loop.
2748 2897
 	++$level;
2749
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
2750
-		exit;
2751
-	if ($from_fatal_error)
2752
-		$has_fatal_error = true;
2898
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
2899
+			exit;
2900
+	}
2901
+	if ($from_fatal_error) {
2902
+			$has_fatal_error = true;
2903
+	}
2753 2904
 
2754 2905
 	// Clear out the stat cache.
2755 2906
 	trackStats();
2756 2907
 
2757 2908
 	// If we have mail to send, send it.
2758
-	if (!empty($context['flush_mail']))
2759
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2909
+	if (!empty($context['flush_mail'])) {
2910
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2760 2911
 		AddMailQueue(true);
2912
+	}
2761 2913
 
2762 2914
 	$do_header = $header === null ? !$header_done : $header;
2763
-	if ($do_footer === null)
2764
-		$do_footer = $do_header;
2915
+	if ($do_footer === null) {
2916
+			$do_footer = $do_header;
2917
+	}
2765 2918
 
2766 2919
 	// Has the template/header been done yet?
2767 2920
 	if ($do_header)
2768 2921
 	{
2769 2922
 		// Was the page title set last minute? Also update the HTML safe one.
2770
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
2771
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
2923
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
2924
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
2925
+		}
2772 2926
 
2773 2927
 		// Start up the session URL fixer.
2774 2928
 		ob_start('ob_sessrewrite');
2775 2929
 
2776
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
2777
-			$buffers = explode(',', $settings['output_buffers']);
2778
-		elseif (!empty($settings['output_buffers']))
2779
-			$buffers = $settings['output_buffers'];
2780
-		else
2781
-			$buffers = array();
2930
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
2931
+					$buffers = explode(',', $settings['output_buffers']);
2932
+		} elseif (!empty($settings['output_buffers'])) {
2933
+					$buffers = $settings['output_buffers'];
2934
+		} else {
2935
+					$buffers = array();
2936
+		}
2782 2937
 
2783
-		if (isset($modSettings['integrate_buffer']))
2784
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
2938
+		if (isset($modSettings['integrate_buffer'])) {
2939
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
2940
+		}
2785 2941
 
2786
-		if (!empty($buffers))
2787
-			foreach ($buffers as $function)
2942
+		if (!empty($buffers)) {
2943
+					foreach ($buffers as $function)
2788 2944
 			{
2789 2945
 				$call = call_helper($function, true);
2946
+		}
2790 2947
 
2791 2948
 				// Is it valid?
2792
-				if (!empty($call))
2793
-					ob_start($call);
2949
+				if (!empty($call)) {
2950
+									ob_start($call);
2951
+				}
2794 2952
 			}
2795 2953
 
2796 2954
 		// Display the screen in the logical order.
@@ -2802,8 +2960,9 @@  discard block
 block discarded – undo
2802 2960
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
2803 2961
 
2804 2962
 		// Anything special to put out?
2805
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
2806
-			echo $context['insert_after_template'];
2963
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
2964
+					echo $context['insert_after_template'];
2965
+		}
2807 2966
 
2808 2967
 		// Just so we don't get caught in an endless loop of errors from the footer...
2809 2968
 		if (!$footer_done)
@@ -2812,14 +2971,16 @@  discard block
 block discarded – undo
2812 2971
 			template_footer();
2813 2972
 
2814 2973
 			// (since this is just debugging... it's okay that it's after </html>.)
2815
-			if (!isset($_REQUEST['xml']))
2816
-				displayDebug();
2974
+			if (!isset($_REQUEST['xml'])) {
2975
+							displayDebug();
2976
+			}
2817 2977
 		}
2818 2978
 	}
2819 2979
 
2820 2980
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
2821
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
2822
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
2981
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
2982
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
2983
+	}
2823 2984
 
2824 2985
 	// For session check verification.... don't switch browsers...
2825 2986
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -2828,9 +2989,10 @@  discard block
 block discarded – undo
2828 2989
 	call_integration_hook('integrate_exit', array($do_footer));
2829 2990
 
2830 2991
 	// Don't exit if we're coming from index.php; that will pass through normally.
2831
-	if (!$from_index)
2832
-		exit;
2833
-}
2992
+	if (!$from_index) {
2993
+			exit;
2994
+	}
2995
+	}
2834 2996
 
2835 2997
 /**
2836 2998
  * Get the size of a specified image with better error handling.
@@ -2849,8 +3011,9 @@  discard block
 block discarded – undo
2849 3011
 	$url = str_replace(' ', '%20', $url);
2850 3012
 
2851 3013
 	// Can we pull this from the cache... please please?
2852
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
2853
-		return $temp;
3014
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3015
+			return $temp;
3016
+	}
2854 3017
 	$t = microtime();
2855 3018
 
2856 3019
 	// Get the host to pester...
@@ -2860,12 +3023,10 @@  discard block
 block discarded – undo
2860 3023
 	if ($url == '' || $url == 'http://' || $url == 'https://')
2861 3024
 	{
2862 3025
 		return false;
2863
-	}
2864
-	elseif (!isset($match[1]))
3026
+	} elseif (!isset($match[1]))
2865 3027
 	{
2866 3028
 		$size = @getimagesize($url);
2867
-	}
2868
-	else
3029
+	} else
2869 3030
 	{
2870 3031
 		// Try to connect to the server... give it half a second.
2871 3032
 		$temp = 0;
@@ -2904,12 +3065,14 @@  discard block
 block discarded – undo
2904 3065
 	}
2905 3066
 
2906 3067
 	// If we didn't get it, we failed.
2907
-	if (!isset($size))
2908
-		$size = false;
3068
+	if (!isset($size)) {
3069
+			$size = false;
3070
+	}
2909 3071
 
2910 3072
 	// If this took a long time, we may never have to do it again, but then again we might...
2911
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
2912
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3073
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3074
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3075
+	}
2913 3076
 
2914 3077
 	// Didn't work.
2915 3078
 	return $size;
@@ -2927,8 +3090,9 @@  discard block
 block discarded – undo
2927 3090
 
2928 3091
 	// Under SSI this function can be called more then once.  That can cause some problems.
2929 3092
 	//   So only run the function once unless we are forced to run it again.
2930
-	if ($loaded && !$forceload)
2931
-		return;
3093
+	if ($loaded && !$forceload) {
3094
+			return;
3095
+	}
2932 3096
 
2933 3097
 	$loaded = true;
2934 3098
 
@@ -2940,14 +3104,16 @@  discard block
 block discarded – undo
2940 3104
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
2941 3105
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
2942 3106
 	{
2943
-		if (trim($context['news_lines'][$i]) == '')
2944
-			continue;
3107
+		if (trim($context['news_lines'][$i]) == '') {
3108
+					continue;
3109
+		}
2945 3110
 
2946 3111
 		// Clean it up for presentation ;).
2947 3112
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
2948 3113
 	}
2949
-	if (!empty($context['news_lines']))
2950
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3114
+	if (!empty($context['news_lines'])) {
3115
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3116
+	}
2951 3117
 
2952 3118
 	if (!$user_info['is_guest'])
2953 3119
 	{
@@ -2956,40 +3122,48 @@  discard block
 block discarded – undo
2956 3122
 		$context['user']['alerts'] = &$user_info['alerts'];
2957 3123
 
2958 3124
 		// Personal message popup...
2959
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
2960
-			$context['user']['popup_messages'] = true;
2961
-		else
2962
-			$context['user']['popup_messages'] = false;
3125
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3126
+					$context['user']['popup_messages'] = true;
3127
+		} else {
3128
+					$context['user']['popup_messages'] = false;
3129
+		}
2963 3130
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
2964 3131
 
2965
-		if (allowedTo('moderate_forum'))
2966
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3132
+		if (allowedTo('moderate_forum')) {
3133
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3134
+		}
2967 3135
 
2968 3136
 		$context['user']['avatar'] = array();
2969 3137
 
2970 3138
 		// Check for gravatar first since we might be forcing them...
2971 3139
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
2972 3140
 		{
2973
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
2974
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
2975
-			else
2976
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3141
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3142
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3143
+			} else {
3144
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3145
+			}
2977 3146
 		}
2978 3147
 		// Uploaded?
2979
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
2980
-			$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';
3148
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3149
+					$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';
3150
+		}
2981 3151
 		// Full URL?
2982
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
2983
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3152
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3153
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3154
+		}
2984 3155
 		// Otherwise we assume it's server stored.
2985
-		elseif ($user_info['avatar']['url'] != '')
2986
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3156
+		elseif ($user_info['avatar']['url'] != '') {
3157
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3158
+		}
2987 3159
 		// No avatar at all? Fine, we have a big fat default avatar ;)
2988
-		else
2989
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3160
+		else {
3161
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3162
+		}
2990 3163
 
2991
-		if (!empty($context['user']['avatar']))
2992
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3164
+		if (!empty($context['user']['avatar'])) {
3165
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3166
+		}
2993 3167
 
2994 3168
 		// Figure out how long they've been logged in.
2995 3169
 		$context['user']['total_time_logged_in'] = array(
@@ -2997,8 +3171,7 @@  discard block
 block discarded – undo
2997 3171
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
2998 3172
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
2999 3173
 		);
3000
-	}
3001
-	else
3174
+	} else
3002 3175
 	{
3003 3176
 		$context['user']['messages'] = 0;
3004 3177
 		$context['user']['unread_messages'] = 0;
@@ -3006,12 +3179,14 @@  discard block
 block discarded – undo
3006 3179
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3007 3180
 		$context['user']['popup_messages'] = false;
3008 3181
 
3009
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3010
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3182
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3183
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3184
+		}
3011 3185
 
3012 3186
 		// If we've upgraded recently, go easy on the passwords.
3013
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3014
-			$context['disable_login_hashing'] = true;
3187
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3188
+					$context['disable_login_hashing'] = true;
3189
+		}
3015 3190
 	}
3016 3191
 
3017 3192
 	// Setup the main menu items.
@@ -3024,8 +3199,8 @@  discard block
 block discarded – undo
3024 3199
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3025 3200
 
3026 3201
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3027
-	if ($context['show_pm_popup'])
3028
-		addInlineJavaScript('
3202
+	if ($context['show_pm_popup']) {
3203
+			addInlineJavaScript('
3029 3204
 		jQuery(document).ready(function($) {
3030 3205
 			new smc_Popup({
3031 3206
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3033,15 +3208,17 @@  discard block
 block discarded – undo
3033 3208
 				icon_class: \'generic_icons mail_new\'
3034 3209
 			});
3035 3210
 		});');
3211
+	}
3036 3212
 
3037 3213
 	// Add a generic "Are you sure?" confirmation message.
3038 3214
 	addInlineJavaScript('
3039 3215
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3040 3216
 
3041 3217
 	// Now add the capping code for avatars.
3042
-	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')
3043
-		addInlineCss('
3218
+	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') {
3219
+			addInlineCss('
3044 3220
 img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3221
+	}
3045 3222
 
3046 3223
 	// This looks weird, but it's because BoardIndex.php references the variable.
3047 3224
 	$context['common_stats']['latest_member'] = array(
@@ -3058,11 +3235,13 @@  discard block
 block discarded – undo
3058 3235
 	);
3059 3236
 	$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']);
3060 3237
 
3061
-	if (empty($settings['theme_version']))
3062
-		addJavaScriptVar('smf_scripturl', $scripturl);
3238
+	if (empty($settings['theme_version'])) {
3239
+			addJavaScriptVar('smf_scripturl', $scripturl);
3240
+	}
3063 3241
 
3064
-	if (!isset($context['page_title']))
3065
-		$context['page_title'] = '';
3242
+	if (!isset($context['page_title'])) {
3243
+			$context['page_title'] = '';
3244
+	}
3066 3245
 
3067 3246
 	// Set some specific vars.
3068 3247
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3072,21 +3251,23 @@  discard block
 block discarded – undo
3072 3251
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3073 3252
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3074 3253
 
3075
-	if (!empty($context['meta_keywords']))
3076
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3254
+	if (!empty($context['meta_keywords'])) {
3255
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3256
+	}
3077 3257
 
3078
-	if (!empty($context['canonical_url']))
3079
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3258
+	if (!empty($context['canonical_url'])) {
3259
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3260
+	}
3080 3261
 
3081
-	if (!empty($settings['og_image']))
3082
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3262
+	if (!empty($settings['og_image'])) {
3263
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3264
+	}
3083 3265
 
3084 3266
 	if (!empty($context['meta_description']))
3085 3267
 	{
3086 3268
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3087 3269
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3088
-	}
3089
-	else
3270
+	} else
3090 3271
 	{
3091 3272
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3092 3273
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3112,8 +3293,9 @@  discard block
 block discarded – undo
3112 3293
 	$memory_needed = memoryReturnBytes($needed);
3113 3294
 
3114 3295
 	// should we account for how much is currently being used?
3115
-	if ($in_use)
3116
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3296
+	if ($in_use) {
3297
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3298
+	}
3117 3299
 
3118 3300
 	// if more is needed, request it
3119 3301
 	if ($memory_current < $memory_needed)
@@ -3136,8 +3318,9 @@  discard block
 block discarded – undo
3136 3318
  */
3137 3319
 function memoryReturnBytes($val)
3138 3320
 {
3139
-	if (is_integer($val))
3140
-		return $val;
3321
+	if (is_integer($val)) {
3322
+			return $val;
3323
+	}
3141 3324
 
3142 3325
 	// Separate the number from the designator
3143 3326
 	$val = trim($val);
@@ -3173,10 +3356,11 @@  discard block
 block discarded – undo
3173 3356
 		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3174 3357
 
3175 3358
 		// Are we debugging the template/html content?
3176
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3177
-			header('Content-Type: application/xhtml+xml');
3178
-		elseif (!isset($_REQUEST['xml']))
3179
-			header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3359
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3360
+					header('Content-Type: application/xhtml+xml');
3361
+		} elseif (!isset($_REQUEST['xml'])) {
3362
+					header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3363
+		}
3180 3364
 	}
3181 3365
 
3182 3366
 	header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3185,8 +3369,9 @@  discard block
 block discarded – undo
3185 3369
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3186 3370
 	{
3187 3371
 		$position = array_search('body', $context['template_layers']);
3188
-		if ($position === false)
3189
-			$position = array_search('main', $context['template_layers']);
3372
+		if ($position === false) {
3373
+					$position = array_search('main', $context['template_layers']);
3374
+		}
3190 3375
 
3191 3376
 		if ($position !== false)
3192 3377
 		{
@@ -3214,15 +3399,15 @@  discard block
 block discarded – undo
3214 3399
 
3215 3400
 			foreach ($securityFiles as $i => $securityFile)
3216 3401
 			{
3217
-				if (!file_exists($boarddir . '/' . $securityFile))
3218
-					unset($securityFiles[$i]);
3402
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3403
+									unset($securityFiles[$i]);
3404
+				}
3219 3405
 			}
3220 3406
 
3221 3407
 			// We are already checking so many files...just few more doesn't make any difference! :P
3222
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3223
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3224
-
3225
-			else
3408
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3409
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3410
+			} else
3226 3411
 			{
3227 3412
 				$path = $modSettings['attachmentUploadDir'];
3228 3413
 				$id_folder_thumb = 1;
@@ -3231,8 +3416,9 @@  discard block
 block discarded – undo
3231 3416
 			secureDirectory($cachedir);
3232 3417
 
3233 3418
 			// If agreement is enabled, at least the english version shall exists
3234
-			if ($modSettings['requireAgreement'])
3235
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3419
+			if ($modSettings['requireAgreement']) {
3420
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3421
+			}
3236 3422
 
3237 3423
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3238 3424
 			{
@@ -3247,18 +3433,21 @@  discard block
 block discarded – undo
3247 3433
 					echo '
3248 3434
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3249 3435
 
3250
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3251
-						echo '
3436
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3437
+											echo '
3252 3438
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3439
+					}
3253 3440
 				}
3254 3441
 
3255
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3256
-					echo '
3442
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3443
+									echo '
3257 3444
 				<strong>', $txt['cache_writable'], '</strong><br>';
3445
+				}
3258 3446
 
3259
-				if (!empty($agreement))
3260
-					echo '
3447
+				if (!empty($agreement)) {
3448
+									echo '
3261 3449
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3450
+				}
3262 3451
 
3263 3452
 				echo '
3264 3453
 			</p>
@@ -3273,16 +3462,18 @@  discard block
 block discarded – undo
3273 3462
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3274 3463
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3275 3464
 
3276
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3277
-				echo '
3465
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3466
+							echo '
3278 3467
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3468
+			}
3279 3469
 
3280
-			if (!empty($_SESSION['ban']['expire_time']))
3281
-				echo '
3470
+			if (!empty($_SESSION['ban']['expire_time'])) {
3471
+							echo '
3282 3472
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3283
-			else
3284
-				echo '
3473
+			} else {
3474
+							echo '
3285 3475
 					<div>', $txt['your_ban_expires_never'], '</div>';
3476
+			}
3286 3477
 
3287 3478
 			echo '
3288 3479
 				</div>';
@@ -3298,8 +3489,9 @@  discard block
 block discarded – undo
3298 3489
 	global $forum_copyright, $software_year, $forum_version;
3299 3490
 
3300 3491
 	// Don't display copyright for things like SSI.
3301
-	if (!isset($forum_version) || !isset($software_year))
3302
-		return;
3492
+	if (!isset($forum_version) || !isset($software_year)) {
3493
+			return;
3494
+	}
3303 3495
 
3304 3496
 	// Put in the version...
3305 3497
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3317,9 +3509,10 @@  discard block
 block discarded – undo
3317 3509
 	$context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3));
3318 3510
 	$context['load_queries'] = $db_count;
3319 3511
 
3320
-	foreach (array_reverse($context['template_layers']) as $layer)
3321
-		loadSubTemplate($layer . '_below', true);
3322
-}
3512
+	foreach (array_reverse($context['template_layers']) as $layer) {
3513
+			loadSubTemplate($layer . '_below', true);
3514
+	}
3515
+	}
3323 3516
 
3324 3517
 /**
3325 3518
  * Output the Javascript files
@@ -3350,8 +3543,7 @@  discard block
 block discarded – undo
3350 3543
 			{
3351 3544
 				echo '
3352 3545
 		var ', $key, ';';
3353
-			}
3354
-			else
3546
+			} else
3355 3547
 			{
3356 3548
 				echo '
3357 3549
 		var ', $key, ' = ', $value, ';';
@@ -3366,26 +3558,27 @@  discard block
 block discarded – undo
3366 3558
 	foreach ($context['javascript_files'] as $id => $js_file)
3367 3559
 	{
3368 3560
 		// Last minute call! allow theme authors to disable single files.
3369
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3370
-			continue;
3561
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3562
+					continue;
3563
+		}
3371 3564
 
3372 3565
 		// By default all files don't get minimized unless the file explicitly says so!
3373 3566
 		if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3374 3567
 		{
3375
-			if ($do_deferred && !empty($js_file['options']['defer']))
3376
-				$toMinifyDefer[] = $js_file;
3377
-
3378
-			elseif (!$do_deferred && empty($js_file['options']['defer']))
3379
-				$toMinify[] = $js_file;
3568
+			if ($do_deferred && !empty($js_file['options']['defer'])) {
3569
+							$toMinifyDefer[] = $js_file;
3570
+			} elseif (!$do_deferred && empty($js_file['options']['defer'])) {
3571
+							$toMinify[] = $js_file;
3572
+			}
3380 3573
 
3381 3574
 			// Grab a random seed.
3382
-			if (!isset($minSeed))
3383
-				$minSeed = $js_file['options']['seed'];
3384
-		}
3385
-
3386
-		elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer'])))
3387
-			echo '
3575
+			if (!isset($minSeed)) {
3576
+							$minSeed = $js_file['options']['seed'];
3577
+			}
3578
+		} elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) {
3579
+					echo '
3388 3580
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
3581
+		}
3389 3582
 	}
3390 3583
 
3391 3584
 	if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer)))
@@ -3393,14 +3586,14 @@  discard block
 block discarded – undo
3393 3586
 		$result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred);
3394 3587
 
3395 3588
 		// Minify process couldn't work, print each individual files.
3396
-		if (!empty($result) && is_array($result))
3397
-			foreach ($result as $minFailedFile)
3589
+		if (!empty($result) && is_array($result)) {
3590
+					foreach ($result as $minFailedFile)
3398 3591
 				echo '
3399 3592
 	<script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>';
3400
-
3401
-		else
3402
-			echo '
3593
+		} else {
3594
+					echo '
3403 3595
 	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3596
+		}
3404 3597
 	}
3405 3598
 
3406 3599
 	// Inline JavaScript - Actually useful some times!
@@ -3411,8 +3604,9 @@  discard block
 block discarded – undo
3411 3604
 			echo '
3412 3605
 <script>';
3413 3606
 
3414
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3415
-				echo $js_code;
3607
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
3608
+							echo $js_code;
3609
+			}
3416 3610
 
3417 3611
 			echo '
3418 3612
 </script>';
@@ -3423,8 +3617,9 @@  discard block
 block discarded – undo
3423 3617
 			echo '
3424 3618
 	<script>';
3425 3619
 
3426
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3427
-				echo $js_code;
3620
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
3621
+							echo $js_code;
3622
+			}
3428 3623
 
3429 3624
 			echo '
3430 3625
 	</script>';
@@ -3449,8 +3644,9 @@  discard block
 block discarded – undo
3449 3644
 	foreach ($context['css_files'] as $id => $file)
3450 3645
 	{
3451 3646
 		// Last minute call! allow theme authors to disable single files.
3452
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3453
-			continue;
3647
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3648
+					continue;
3649
+		}
3454 3650
 
3455 3651
 		// By default all files don't get minimized unless the file explicitly says so!
3456 3652
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
@@ -3458,12 +3654,12 @@  discard block
 block discarded – undo
3458 3654
 			$toMinify[] = $file;
3459 3655
 
3460 3656
 			// Grab a random seed.
3461
-			if (!isset($minSeed))
3462
-				$minSeed = $file['options']['seed'];
3657
+			if (!isset($minSeed)) {
3658
+							$minSeed = $file['options']['seed'];
3659
+			}
3660
+		} else {
3661
+					$normal[] = $file['fileUrl'];
3463 3662
 		}
3464
-
3465
-		else
3466
-			$normal[] = $file['fileUrl'];
3467 3663
 	}
3468 3664
 
3469 3665
 	if (!empty($toMinify))
@@ -3471,28 +3667,30 @@  discard block
 block discarded – undo
3471 3667
 		$result = custMinify($toMinify, 'css');
3472 3668
 
3473 3669
 		// Minify process couldn't work, print each individual files.
3474
-		if (!empty($result) && is_array($result))
3475
-			foreach ($result as $minFailedFile)
3670
+		if (!empty($result) && is_array($result)) {
3671
+					foreach ($result as $minFailedFile)
3476 3672
 				echo '
3477 3673
 	<link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">';
3478
-
3479
-		else
3480
-			echo '
3674
+		} else {
3675
+					echo '
3481 3676
 	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3677
+		}
3482 3678
 	}
3483 3679
 
3484 3680
 	// Print the rest after the minified files.
3485
-	if (!empty($normal))
3486
-		foreach ($normal as $nf)
3681
+	if (!empty($normal)) {
3682
+			foreach ($normal as $nf)
3487 3683
 			echo '
3488 3684
 	<link rel="stylesheet" href="', $nf ,'">';
3685
+	}
3489 3686
 
3490 3687
 	if ($db_show_debug === true)
3491 3688
 	{
3492 3689
 		// Try to keep only what's useful.
3493 3690
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3494
-		foreach ($context['css_files'] as $file)
3495
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3691
+		foreach ($context['css_files'] as $file) {
3692
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3693
+		}
3496 3694
 	}
3497 3695
 
3498 3696
 	if (!empty($context['css_header']))
@@ -3500,9 +3698,10 @@  discard block
 block discarded – undo
3500 3698
 		echo '
3501 3699
 	<style>';
3502 3700
 
3503
-		foreach ($context['css_header'] as $css)
3504
-			echo $css .'
3701
+		foreach ($context['css_header'] as $css) {
3702
+					echo $css .'
3505 3703
 	';
3704
+		}
3506 3705
 
3507 3706
 		echo'
3508 3707
 	</style>';
@@ -3527,15 +3726,17 @@  discard block
 block discarded – undo
3527 3726
 	$data = !empty($data) ? $data : false;
3528 3727
 	$minFailed = array();
3529 3728
 
3530
-	if (empty($type) || empty($data))
3531
-		return false;
3729
+	if (empty($type) || empty($data)) {
3730
+			return false;
3731
+	}
3532 3732
 
3533 3733
 	// Did we already did this?
3534 3734
 	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3535 3735
 
3536 3736
 	// Already done?
3537
-	if (!empty($toCache))
3538
-		return true;
3737
+	if (!empty($toCache)) {
3738
+			return true;
3739
+	}
3539 3740
 
3540 3741
 	// Yep, need a bunch of files.
3541 3742
 	require_once($sourcedir . '/minify/src/Minify.php');
@@ -3623,8 +3824,9 @@  discard block
 block discarded – undo
3623 3824
 	global $modSettings, $smcFunc;
3624 3825
 
3625 3826
 	// Just make up a nice hash...
3626
-	if ($new)
3627
-		return sha1(md5($filename . time()) . mt_rand());
3827
+	if ($new) {
3828
+			return sha1(md5($filename . time()) . mt_rand());
3829
+	}
3628 3830
 
3629 3831
 	// Grab the file hash if it wasn't added.
3630 3832
 	// Left this for legacy.
@@ -3638,23 +3840,25 @@  discard block
 block discarded – undo
3638 3840
 				'id_attach' => $attachment_id,
3639 3841
 			));
3640 3842
 
3641
-		if ($smcFunc['db_num_rows']($request) === 0)
3642
-			return false;
3843
+		if ($smcFunc['db_num_rows']($request) === 0) {
3844
+					return false;
3845
+		}
3643 3846
 
3644 3847
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
3645 3848
 		$smcFunc['db_free_result']($request);
3646 3849
 	}
3647 3850
 
3648 3851
 	// Still no hash? mmm...
3649
-	if (empty($file_hash))
3650
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
3852
+	if (empty($file_hash)) {
3853
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
3854
+	}
3651 3855
 
3652 3856
 	// Are we using multiple directories?
3653
-	if (!empty($modSettings['currentAttachmentUploadDir']))
3654
-		$path = $modSettings['attachmentUploadDir'][$dir];
3655
-
3656
-	else
3657
-		$path = $modSettings['attachmentUploadDir'];
3857
+	if (!empty($modSettings['currentAttachmentUploadDir'])) {
3858
+			$path = $modSettings['attachmentUploadDir'][$dir];
3859
+	} else {
3860
+			$path = $modSettings['attachmentUploadDir'];
3861
+	}
3658 3862
 
3659 3863
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3660 3864
 }
@@ -3669,8 +3873,9 @@  discard block
 block discarded – undo
3669 3873
 function ip2range($fullip)
3670 3874
 {
3671 3875
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
3672
-	if ($fullip == 'unknown')
3673
-		$fullip = '255.255.255.255';
3876
+	if ($fullip == 'unknown') {
3877
+			$fullip = '255.255.255.255';
3878
+	}
3674 3879
 
3675 3880
 	$ip_parts = explode('-', $fullip);
3676 3881
 	$ip_array = array();
@@ -3694,10 +3899,11 @@  discard block
 block discarded – undo
3694 3899
 		$ip_array['low'] = $ip_parts[0];
3695 3900
 		$ip_array['high'] = $ip_parts[1];
3696 3901
 		return $ip_array;
3697
-	}
3698
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
3902
+	} elseif (count($ip_parts) == 2) {
3903
+		// if ip 22.22.*-22.22.*
3699 3904
 	{
3700 3905
 		$valid_low = isValidIP($ip_parts[0]);
3906
+	}
3701 3907
 		$valid_high = isValidIP($ip_parts[1]);
3702 3908
 		$count = 0;
3703 3909
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -3712,7 +3918,9 @@  discard block
 block discarded – undo
3712 3918
 				$ip_parts[0] .= $mode . $min;
3713 3919
 				$valid_low = isValidIP($ip_parts[0]);
3714 3920
 				$count++;
3715
-				if ($count > 9) break;
3921
+				if ($count > 9) {
3922
+					break;
3923
+				}
3716 3924
 			}
3717 3925
 		}
3718 3926
 
@@ -3726,7 +3934,9 @@  discard block
 block discarded – undo
3726 3934
 				$ip_parts[1] .= $mode . $max;
3727 3935
 				$valid_high = isValidIP($ip_parts[1]);
3728 3936
 				$count++;
3729
-				if ($count > 9) break;
3937
+				if ($count > 9) {
3938
+					break;
3939
+				}
3730 3940
 			}
3731 3941
 		}
3732 3942
 
@@ -3751,46 +3961,54 @@  discard block
 block discarded – undo
3751 3961
 {
3752 3962
 	global $modSettings;
3753 3963
 
3754
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
3755
-		return $host;
3964
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
3965
+			return $host;
3966
+	}
3756 3967
 	$t = microtime();
3757 3968
 
3758 3969
 	// Try the Linux host command, perhaps?
3759 3970
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
3760 3971
 	{
3761
-		if (!isset($modSettings['host_to_dis']))
3762
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3763
-		else
3764
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
3972
+		if (!isset($modSettings['host_to_dis'])) {
3973
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3974
+		} else {
3975
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
3976
+		}
3765 3977
 
3766 3978
 		// Did host say it didn't find anything?
3767
-		if (strpos($test, 'not found') !== false)
3768
-			$host = '';
3979
+		if (strpos($test, 'not found') !== false) {
3980
+					$host = '';
3981
+		}
3769 3982
 		// Invalid server option?
3770
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
3771
-			updateSettings(array('host_to_dis' => 1));
3983
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
3984
+					updateSettings(array('host_to_dis' => 1));
3985
+		}
3772 3986
 		// Maybe it found something, after all?
3773
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
3774
-			$host = $match[1];
3987
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
3988
+					$host = $match[1];
3989
+		}
3775 3990
 	}
3776 3991
 
3777 3992
 	// This is nslookup; usually only Windows, but possibly some Unix?
3778 3993
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
3779 3994
 	{
3780 3995
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
3781
-		if (strpos($test, 'Non-existent domain') !== false)
3782
-			$host = '';
3783
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
3784
-			$host = $match[1];
3996
+		if (strpos($test, 'Non-existent domain') !== false) {
3997
+					$host = '';
3998
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
3999
+					$host = $match[1];
4000
+		}
3785 4001
 	}
3786 4002
 
3787 4003
 	// This is the last try :/.
3788
-	if (!isset($host) || $host === false)
3789
-		$host = @gethostbyaddr($ip);
4004
+	if (!isset($host) || $host === false) {
4005
+			$host = @gethostbyaddr($ip);
4006
+	}
3790 4007
 
3791 4008
 	// It took a long time, so let's cache it!
3792
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
3793
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4009
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4010
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4011
+	}
3794 4012
 
3795 4013
 	return $host;
3796 4014
 }
@@ -3826,20 +4044,21 @@  discard block
 block discarded – undo
3826 4044
 			{
3827 4045
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
3828 4046
 				$total = 0;
3829
-				for ($i = 0; $i < $max_chars; $i++)
3830
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4047
+				for ($i = 0; $i < $max_chars; $i++) {
4048
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4049
+				}
3831 4050
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
3832 4051
 			}
3833 4052
 		}
3834 4053
 		return array_unique($returned_ints);
3835
-	}
3836
-	else
4054
+	} else
3837 4055
 	{
3838 4056
 		// Trim characters before and after and add slashes for database insertion.
3839 4057
 		$returned_words = array();
3840
-		foreach ($words as $word)
3841
-			if (($word = trim($word, '-_\'')) !== '')
4058
+		foreach ($words as $word) {
4059
+					if (($word = trim($word, '-_\'')) !== '')
3842 4060
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4061
+		}
3843 4062
 
3844 4063
 		// Filter out all words that occur more than once.
3845 4064
 		return array_unique($returned_words);
@@ -3861,16 +4080,18 @@  discard block
 block discarded – undo
3861 4080
 	global $settings, $txt;
3862 4081
 
3863 4082
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
3864
-	if (function_exists('template_create_button') && !$force_use)
3865
-		return template_create_button($name, $alt, $label = '', $custom = '');
4083
+	if (function_exists('template_create_button') && !$force_use) {
4084
+			return template_create_button($name, $alt, $label = '', $custom = '');
4085
+	}
3866 4086
 
3867
-	if (!$settings['use_image_buttons'])
3868
-		return $txt[$alt];
3869
-	elseif (!empty($settings['use_buttons']))
3870
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
3871
-	else
3872
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
3873
-}
4087
+	if (!$settings['use_image_buttons']) {
4088
+			return $txt[$alt];
4089
+	} elseif (!empty($settings['use_buttons'])) {
4090
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4091
+	} else {
4092
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4093
+	}
4094
+	}
3874 4095
 
3875 4096
 /**
3876 4097
  * Empty out the cache in use as best it can
@@ -3894,16 +4115,19 @@  discard block
 block discarded – undo
3894 4115
 			if (function_exists('memcache_flush') || function_exists('memcached_flush') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
3895 4116
 			{
3896 4117
 				// Not connected yet?
3897
-				if (empty($memcached))
3898
-					get_memcached_server();
3899
-				if (!$memcached)
3900
-					return;
4118
+				if (empty($memcached)) {
4119
+									get_memcached_server();
4120
+				}
4121
+				if (!$memcached) {
4122
+									return;
4123
+				}
3901 4124
 
3902 4125
 				// clear it out
3903
-				if (function_exists('memcache_flush'))
3904
-					memcache_flush($memcached);
3905
-				else
3906
-					memcached_flush($memcached);
4126
+				if (function_exists('memcache_flush')) {
4127
+									memcache_flush($memcached);
4128
+				} else {
4129
+									memcached_flush($memcached);
4130
+				}
3907 4131
 			}
3908 4132
 			break;
3909 4133
 		case 'apc':
@@ -3914,14 +4138,15 @@  discard block
 block discarded – undo
3914 4138
 				{
3915 4139
 					apc_clear_cache('user');
3916 4140
 					apc_clear_cache('system');
4141
+				} elseif ($type === 'user') {
4142
+									apc_clear_cache('user');
3917 4143
 				}
3918
-				elseif ($type === 'user')
3919
-					apc_clear_cache('user');
3920 4144
 			}
3921 4145
 			break;
3922 4146
 		case 'zend':
3923
-			if (function_exists('zend_shm_cache_clear'))
3924
-				zend_shm_cache_clear('SMF');
4147
+			if (function_exists('zend_shm_cache_clear')) {
4148
+							zend_shm_cache_clear('SMF');
4149
+			}
3925 4150
 			break;
3926 4151
 		case 'xcache':
3927 4152
 			if (function_exists('xcache_clear_cache'))
@@ -3932,23 +4157,27 @@  discard block
 block discarded – undo
3932 4157
 					xcache_clear_cache(XC_TYPE_VAR, 0);
3933 4158
 					xcache_clear_cache(XC_TYPE_PHP, 0);
3934 4159
 				}
3935
-				if ($type === 'user')
3936
-					xcache_clear_cache(XC_TYPE_VAR, 0);
3937
-				if ($type === 'data')
3938
-					xcache_clear_cache(XC_TYPE_PHP, 0);
4160
+				if ($type === 'user') {
4161
+									xcache_clear_cache(XC_TYPE_VAR, 0);
4162
+				}
4163
+				if ($type === 'data') {
4164
+									xcache_clear_cache(XC_TYPE_PHP, 0);
4165
+				}
3939 4166
 			}
3940 4167
 			break;
3941 4168
 		default:
3942 4169
 			// No directory = no game.
3943
-			if (!is_dir($cachedir))
3944
-				return;
4170
+			if (!is_dir($cachedir)) {
4171
+							return;
4172
+			}
3945 4173
 
3946 4174
 			// Remove the files in SMF's own disk cache, if any
3947 4175
 			$dh = opendir($cachedir);
3948 4176
 			while ($file = readdir($dh))
3949 4177
 			{
3950
-				if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
3951
-					@unlink($cachedir . '/' . $file);
4178
+				if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
4179
+									@unlink($cachedir . '/' . $file);
4180
+				}
3952 4181
 			}
3953 4182
 			closedir($dh);
3954 4183
 			break;
@@ -3956,8 +4185,9 @@  discard block
 block discarded – undo
3956 4185
 
3957 4186
 	// Invalidate cache, to be sure!
3958 4187
 	// ... as long as index.php can be modified, anyway.
3959
-	if (empty($type))
3960
-		@touch($cachedir . '/' . 'index.php');
4188
+	if (empty($type)) {
4189
+			@touch($cachedir . '/' . 'index.php');
4190
+	}
3961 4191
 
3962 4192
 	call_integration_hook('integrate_clean_cache');
3963 4193
 	clearstatcache();
@@ -4004,9 +4234,10 @@  discard block
 block discarded – undo
4004 4234
 	var user_menus = new smc_PopupMenu();
4005 4235
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4006 4236
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4007
-		if ($context['allow_pm'])
4008
-			addInlineJavaScript('
4237
+		if ($context['allow_pm']) {
4238
+					addInlineJavaScript('
4009 4239
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4240
+		}
4010 4241
 
4011 4242
 		if (!empty($modSettings['enable_ajax_alerts']))
4012 4243
 		{
@@ -4166,88 +4397,96 @@  discard block
 block discarded – undo
4166 4397
 
4167 4398
 		// Now we put the buttons in the context so the theme can use them.
4168 4399
 		$menu_buttons = array();
4169
-		foreach ($buttons as $act => $button)
4170
-			if (!empty($button['show']))
4400
+		foreach ($buttons as $act => $button) {
4401
+					if (!empty($button['show']))
4171 4402
 			{
4172 4403
 				$button['active_button'] = false;
4404
+		}
4173 4405
 
4174 4406
 				// This button needs some action.
4175
-				if (isset($button['action_hook']))
4176
-					$needs_action_hook = true;
4407
+				if (isset($button['action_hook'])) {
4408
+									$needs_action_hook = true;
4409
+				}
4177 4410
 
4178 4411
 				// Make sure the last button truly is the last button.
4179 4412
 				if (!empty($button['is_last']))
4180 4413
 				{
4181
-					if (isset($last_button))
4182
-						unset($menu_buttons[$last_button]['is_last']);
4414
+					if (isset($last_button)) {
4415
+											unset($menu_buttons[$last_button]['is_last']);
4416
+					}
4183 4417
 					$last_button = $act;
4184 4418
 				}
4185 4419
 
4186 4420
 				// Go through the sub buttons if there are any.
4187
-				if (!empty($button['sub_buttons']))
4188
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4421
+				if (!empty($button['sub_buttons'])) {
4422
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4189 4423
 					{
4190 4424
 						if (empty($subbutton['show']))
4191 4425
 							unset($button['sub_buttons'][$key]);
4426
+				}
4192 4427
 
4193 4428
 						// 2nd level sub buttons next...
4194 4429
 						if (!empty($subbutton['sub_buttons']))
4195 4430
 						{
4196 4431
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4197 4432
 							{
4198
-								if (empty($sub_button2['show']))
4199
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4433
+								if (empty($sub_button2['show'])) {
4434
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4435
+								}
4200 4436
 							}
4201 4437
 						}
4202 4438
 					}
4203 4439
 
4204 4440
 				// Does this button have its own icon?
4205
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4206
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4207
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4208
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4209
-				elseif (isset($button['icon']))
4210
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4211
-				else
4212
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4441
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4442
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4443
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4444
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4445
+				} elseif (isset($button['icon'])) {
4446
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4447
+				} else {
4448
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4449
+				}
4213 4450
 
4214 4451
 				$menu_buttons[$act] = $button;
4215 4452
 			}
4216 4453
 
4217
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4218
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4454
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4455
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4456
+		}
4219 4457
 	}
4220 4458
 
4221 4459
 	$context['menu_buttons'] = $menu_buttons;
4222 4460
 
4223 4461
 	// Logging out requires the session id in the url.
4224
-	if (isset($context['menu_buttons']['logout']))
4225
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4462
+	if (isset($context['menu_buttons']['logout'])) {
4463
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4464
+	}
4226 4465
 
4227 4466
 	// Figure out which action we are doing so we can set the active tab.
4228 4467
 	// Default to home.
4229 4468
 	$current_action = 'home';
4230 4469
 
4231
-	if (isset($context['menu_buttons'][$context['current_action']]))
4232
-		$current_action = $context['current_action'];
4233
-	elseif ($context['current_action'] == 'search2')
4234
-		$current_action = 'search';
4235
-	elseif ($context['current_action'] == 'theme')
4236
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4237
-	elseif ($context['current_action'] == 'register2')
4238
-		$current_action = 'register';
4239
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4240
-		$current_action = 'login';
4241
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4242
-		$current_action = 'moderate';
4470
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4471
+			$current_action = $context['current_action'];
4472
+	} elseif ($context['current_action'] == 'search2') {
4473
+			$current_action = 'search';
4474
+	} elseif ($context['current_action'] == 'theme') {
4475
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4476
+	} elseif ($context['current_action'] == 'register2') {
4477
+			$current_action = 'register';
4478
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4479
+			$current_action = 'login';
4480
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4481
+			$current_action = 'moderate';
4482
+	}
4243 4483
 
4244 4484
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4245 4485
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4246 4486
 	{
4247 4487
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4248 4488
 		$context[$current_action] = true;
4249
-	}
4250
-	elseif ($context['current_action'] == 'pm')
4489
+	} elseif ($context['current_action'] == 'pm')
4251 4490
 	{
4252 4491
 		$current_action = 'self_pm';
4253 4492
 		$context['self_pm'] = true;
@@ -4290,12 +4529,14 @@  discard block
 block discarded – undo
4290 4529
 	}
4291 4530
 
4292 4531
 	// Not all actions are simple.
4293
-	if (!empty($needs_action_hook))
4294
-		call_integration_hook('integrate_current_action', array(&$current_action));
4532
+	if (!empty($needs_action_hook)) {
4533
+			call_integration_hook('integrate_current_action', array(&$current_action));
4534
+	}
4295 4535
 
4296
-	if (isset($context['menu_buttons'][$current_action]))
4297
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4298
-}
4536
+	if (isset($context['menu_buttons'][$current_action])) {
4537
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4538
+	}
4539
+	}
4299 4540
 
4300 4541
 /**
4301 4542
  * Generate a random seed and ensure it's stored in settings.
@@ -4319,16 +4560,19 @@  discard block
 block discarded – undo
4319 4560
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4320 4561
 	global $context, $txt;
4321 4562
 
4322
-	if ($db_show_debug === true)
4323
-		$context['debug']['hooks'][] = $hook;
4563
+	if ($db_show_debug === true) {
4564
+			$context['debug']['hooks'][] = $hook;
4565
+	}
4324 4566
 
4325 4567
 	// Need to have some control.
4326
-	if (!isset($context['instances']))
4327
-		$context['instances'] = array();
4568
+	if (!isset($context['instances'])) {
4569
+			$context['instances'] = array();
4570
+	}
4328 4571
 
4329 4572
 	$results = array();
4330
-	if (empty($modSettings[$hook]))
4331
-		return $results;
4573
+	if (empty($modSettings[$hook])) {
4574
+			return $results;
4575
+	}
4332 4576
 
4333 4577
 	// Define some needed vars.
4334 4578
 	$function = false;
@@ -4338,14 +4582,16 @@  discard block
 block discarded – undo
4338 4582
 	foreach ($functions as $function)
4339 4583
 	{
4340 4584
 		// Hook has been marked as "disabled". Skip it!
4341
-		if (strpos($function, '!') !== false)
4342
-			continue;
4585
+		if (strpos($function, '!') !== false) {
4586
+					continue;
4587
+		}
4343 4588
 
4344 4589
 		$call = call_helper($function, true);
4345 4590
 
4346 4591
 		// Is it valid?
4347
-		if (!empty($call))
4348
-			$results[$function] = call_user_func_array($call, $parameters);
4592
+		if (!empty($call)) {
4593
+					$results[$function] = call_user_func_array($call, $parameters);
4594
+		}
4349 4595
 
4350 4596
 		// Whatever it was suppose to call, it failed :(
4351 4597
 		elseif (!empty($function))
@@ -4361,8 +4607,9 @@  discard block
 block discarded – undo
4361 4607
 			}
4362 4608
 
4363 4609
 			// "Assume" the file resides on $boarddir somewhere...
4364
-			else
4365
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4610
+			else {
4611
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4612
+			}
4366 4613
 		}
4367 4614
 	}
4368 4615
 
@@ -4384,12 +4631,14 @@  discard block
 block discarded – undo
4384 4631
 	global $smcFunc, $modSettings;
4385 4632
 
4386 4633
 	// Any objects?
4387
-	if ($object)
4388
-		$function = $function . '#';
4634
+	if ($object) {
4635
+			$function = $function . '#';
4636
+	}
4389 4637
 
4390 4638
 	// Any files  to load?
4391
-	if (!empty($file) && is_string($file))
4392
-		$function = $file . (!empty($function) ? '|' . $function : '');
4639
+	if (!empty($file) && is_string($file)) {
4640
+			$function = $file . (!empty($function) ? '|' . $function : '');
4641
+	}
4393 4642
 
4394 4643
 	// Get the correct string.
4395 4644
 	$integration_call = $function;
@@ -4411,13 +4660,14 @@  discard block
 block discarded – undo
4411 4660
 		if (!empty($current_functions))
4412 4661
 		{
4413 4662
 			$current_functions = explode(',', $current_functions);
4414
-			if (in_array($integration_call, $current_functions))
4415
-				return;
4663
+			if (in_array($integration_call, $current_functions)) {
4664
+							return;
4665
+			}
4416 4666
 
4417 4667
 			$permanent_functions = array_merge($current_functions, array($integration_call));
4668
+		} else {
4669
+					$permanent_functions = array($integration_call);
4418 4670
 		}
4419
-		else
4420
-			$permanent_functions = array($integration_call);
4421 4671
 
4422 4672
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4423 4673
 	}
@@ -4426,8 +4676,9 @@  discard block
 block discarded – undo
4426 4676
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4427 4677
 
4428 4678
 	// Do nothing, if it's already there.
4429
-	if (in_array($integration_call, $functions))
4430
-		return;
4679
+	if (in_array($integration_call, $functions)) {
4680
+			return;
4681
+	}
4431 4682
 
4432 4683
 	$functions[] = $integration_call;
4433 4684
 	$modSettings[$hook] = implode(',', $functions);
@@ -4450,12 +4701,14 @@  discard block
 block discarded – undo
4450 4701
 	global $smcFunc, $modSettings;
4451 4702
 
4452 4703
 	// Any objects?
4453
-	if ($object)
4454
-		$function = $function . '#';
4704
+	if ($object) {
4705
+			$function = $function . '#';
4706
+	}
4455 4707
 
4456 4708
 	// Any files  to load?
4457
-	if (!empty($file) && is_string($file))
4458
-		$function = $file . '|' . $function;
4709
+	if (!empty($file) && is_string($file)) {
4710
+			$function = $file . '|' . $function;
4711
+	}
4459 4712
 
4460 4713
 	// Get the correct string.
4461 4714
 	$integration_call = $function;
@@ -4476,16 +4729,18 @@  discard block
 block discarded – undo
4476 4729
 	{
4477 4730
 		$current_functions = explode(',', $current_functions);
4478 4731
 
4479
-		if (in_array($integration_call, $current_functions))
4480
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4732
+		if (in_array($integration_call, $current_functions)) {
4733
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4734
+		}
4481 4735
 	}
4482 4736
 
4483 4737
 	// Turn the function list into something usable.
4484 4738
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4485 4739
 
4486 4740
 	// You can only remove it if it's available.
4487
-	if (!in_array($integration_call, $functions))
4488
-		return;
4741
+	if (!in_array($integration_call, $functions)) {
4742
+			return;
4743
+	}
4489 4744
 
4490 4745
 	$functions = array_diff($functions, array($integration_call));
4491 4746
 	$modSettings[$hook] = implode(',', $functions);
@@ -4506,17 +4761,20 @@  discard block
 block discarded – undo
4506 4761
 	global $context, $smcFunc, $txt, $db_show_debug;
4507 4762
 
4508 4763
 	// Really?
4509
-	if (empty($string))
4510
-		return false;
4764
+	if (empty($string)) {
4765
+			return false;
4766
+	}
4511 4767
 
4512 4768
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4513 4769
 	// A closure? should be a callable one.
4514
-	if (is_array($string) || $string instanceof Closure)
4515
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4770
+	if (is_array($string) || $string instanceof Closure) {
4771
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4772
+	}
4516 4773
 
4517 4774
 	// No full objects, sorry! pass a method or a property instead!
4518
-	if (is_object($string))
4519
-		return false;
4775
+	if (is_object($string)) {
4776
+			return false;
4777
+	}
4520 4778
 
4521 4779
 	// Stay vitaminized my friends...
4522 4780
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4528,8 +4786,9 @@  discard block
 block discarded – undo
4528 4786
 	$string = load_file($string);
4529 4787
 
4530 4788
 	// Loaded file failed
4531
-	if (empty($string))
4532
-		return false;
4789
+	if (empty($string)) {
4790
+			return false;
4791
+	}
4533 4792
 
4534 4793
 	// Found a method.
4535 4794
 	if (strpos($string, '::') !== false)
@@ -4550,8 +4809,9 @@  discard block
 block discarded – undo
4550 4809
 				// Add another one to the list.
4551 4810
 				if ($db_show_debug === true)
4552 4811
 				{
4553
-					if (!isset($context['debug']['instances']))
4554
-						$context['debug']['instances'] = array();
4812
+					if (!isset($context['debug']['instances'])) {
4813
+											$context['debug']['instances'] = array();
4814
+					}
4555 4815
 
4556 4816
 					$context['debug']['instances'][$class] = $class;
4557 4817
 				}
@@ -4561,13 +4821,15 @@  discard block
 block discarded – undo
4561 4821
 		}
4562 4822
 
4563 4823
 		// Right then. This is a call to a static method.
4564
-		else
4565
-			$func = array($class, $method);
4824
+		else {
4825
+					$func = array($class, $method);
4826
+		}
4566 4827
 	}
4567 4828
 
4568 4829
 	// Nope! just a plain regular function.
4569
-	else
4570
-		$func = $string;
4830
+	else {
4831
+			$func = $string;
4832
+	}
4571 4833
 
4572 4834
 	// Right, we got what we need, time to do some checks.
4573 4835
 	if (!is_callable($func, false, $callable_name))
@@ -4583,17 +4845,18 @@  discard block
 block discarded – undo
4583 4845
 	else
4584 4846
 	{
4585 4847
 		// What are we gonna do about it?
4586
-		if ($return)
4587
-			return $func;
4848
+		if ($return) {
4849
+					return $func;
4850
+		}
4588 4851
 
4589 4852
 		// If this is a plain function, avoid the heat of calling call_user_func().
4590 4853
 		else
4591 4854
 		{
4592
-			if (is_array($func))
4593
-				call_user_func($func);
4594
-
4595
-			else
4596
-				$func();
4855
+			if (is_array($func)) {
4856
+							call_user_func($func);
4857
+			} else {
4858
+							$func();
4859
+			}
4597 4860
 		}
4598 4861
 	}
4599 4862
 }
@@ -4610,31 +4873,34 @@  discard block
 block discarded – undo
4610 4873
 {
4611 4874
 	global $sourcedir, $txt, $boarddir, $settings;
4612 4875
 
4613
-	if (empty($string))
4614
-		return false;
4876
+	if (empty($string)) {
4877
+			return false;
4878
+	}
4615 4879
 
4616 4880
 	if (strpos($string, '|') !== false)
4617 4881
 	{
4618 4882
 		list ($file, $string) = explode('|', $string);
4619 4883
 
4620 4884
 		// Match the wildcards to their regular vars.
4621
-		if (empty($settings['theme_dir']))
4622
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4623
-
4624
-		else
4625
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4885
+		if (empty($settings['theme_dir'])) {
4886
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4887
+		} else {
4888
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4889
+		}
4626 4890
 
4627 4891
 		// Load the file if it can be loaded.
4628
-		if (file_exists($absPath))
4629
-			require_once($absPath);
4892
+		if (file_exists($absPath)) {
4893
+					require_once($absPath);
4894
+		}
4630 4895
 
4631 4896
 		// No? try a fallback to $sourcedir
4632 4897
 		else
4633 4898
 		{
4634 4899
 			$absPath = $sourcedir .'/'. $file;
4635 4900
 
4636
-			if (file_exists($absPath))
4637
-				require_once($absPath);
4901
+			if (file_exists($absPath)) {
4902
+							require_once($absPath);
4903
+			}
4638 4904
 
4639 4905
 			// Sorry, can't do much for you at this point.
4640 4906
 			else
@@ -4661,8 +4927,9 @@  discard block
 block discarded – undo
4661 4927
 	global $user_info, $smcFunc;
4662 4928
 
4663 4929
 	// Make sure we have something to work with.
4664
-	if (empty($topic))
4665
-		return array();
4930
+	if (empty($topic)) {
4931
+			return array();
4932
+	}
4666 4933
 
4667 4934
 
4668 4935
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -4685,8 +4952,9 @@  discard block
 block discarded – undo
4685 4952
 				'topic' => $topic,
4686 4953
 			)
4687 4954
 		);
4688
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4689
-			$temp[] = (int) $row['content_id'];
4955
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4956
+					$temp[] = (int) $row['content_id'];
4957
+		}
4690 4958
 
4691 4959
 		cache_put_data($cache_key, $temp, $ttl);
4692 4960
 	}
@@ -4707,8 +4975,9 @@  discard block
 block discarded – undo
4707 4975
 {
4708 4976
 	global $context;
4709 4977
 
4710
-	if (empty($string))
4711
-		return $string;
4978
+	if (empty($string)) {
4979
+			return $string;
4980
+	}
4712 4981
 
4713 4982
 	// UTF-8 occurences of MS special characters
4714 4983
 	$findchars_utf8 = array(
@@ -4749,10 +5018,11 @@  discard block
 block discarded – undo
4749 5018
 		'--',	// &mdash;
4750 5019
 	);
4751 5020
 
4752
-	if ($context['utf8'])
4753
-		$string = str_replace($findchars_utf8, $replacechars, $string);
4754
-	else
4755
-		$string = str_replace($findchars_iso, $replacechars, $string);
5021
+	if ($context['utf8']) {
5022
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5023
+	} else {
5024
+			$string = str_replace($findchars_iso, $replacechars, $string);
5025
+	}
4756 5026
 
4757 5027
 	return $string;
4758 5028
 }
@@ -4771,49 +5041,59 @@  discard block
 block discarded – undo
4771 5041
 {
4772 5042
 	global $context;
4773 5043
 
4774
-	if (!isset($matches[2]))
4775
-		return '';
5044
+	if (!isset($matches[2])) {
5045
+			return '';
5046
+	}
4776 5047
 
4777 5048
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4778 5049
 
4779 5050
 	// remove left to right / right to left overrides
4780
-	if ($num === 0x202D || $num === 0x202E)
4781
-		return '';
5051
+	if ($num === 0x202D || $num === 0x202E) {
5052
+			return '';
5053
+	}
4782 5054
 
4783 5055
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
4784
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
4785
-		return '&#' . $num . ';';
5056
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5057
+			return '&#' . $num . ';';
5058
+	}
4786 5059
 
4787 5060
 	if (empty($context['utf8']))
4788 5061
 	{
4789 5062
 		// no control characters
4790
-		if ($num < 0x20)
4791
-			return '';
5063
+		if ($num < 0x20) {
5064
+					return '';
5065
+		}
4792 5066
 		// text is text
4793
-		elseif ($num < 0x80)
4794
-			return chr($num);
5067
+		elseif ($num < 0x80) {
5068
+					return chr($num);
5069
+		}
4795 5070
 		// all others get html-ised
4796
-		else
4797
-			return '&#' . $matches[2] . ';';
4798
-	}
4799
-	else
5071
+		else {
5072
+					return '&#' . $matches[2] . ';';
5073
+		}
5074
+	} else
4800 5075
 	{
4801 5076
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
4802 5077
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
4803
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
4804
-			return '';
5078
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5079
+					return '';
5080
+		}
4805 5081
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4806
-		elseif ($num < 0x80)
4807
-			return chr($num);
5082
+		elseif ($num < 0x80) {
5083
+					return chr($num);
5084
+		}
4808 5085
 		// <0x800 (2048)
4809
-		elseif ($num < 0x800)
4810
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5086
+		elseif ($num < 0x800) {
5087
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5088
+		}
4811 5089
 		// < 0x10000 (65536)
4812
-		elseif ($num < 0x10000)
4813
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5090
+		elseif ($num < 0x10000) {
5091
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5092
+		}
4814 5093
 		// <= 0x10FFFF (1114111)
4815
-		else
4816
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5094
+		else {
5095
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5096
+		}
4817 5097
 	}
4818 5098
 }
4819 5099
 
@@ -4829,28 +5109,34 @@  discard block
 block discarded – undo
4829 5109
  */
4830 5110
 function fixchar__callback($matches)
4831 5111
 {
4832
-	if (!isset($matches[1]))
4833
-		return '';
5112
+	if (!isset($matches[1])) {
5113
+			return '';
5114
+	}
4834 5115
 
4835 5116
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
4836 5117
 
4837 5118
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
4838 5119
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
4839
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
4840
-		return '';
5120
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5121
+			return '';
5122
+	}
4841 5123
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4842
-	elseif ($num < 0x80)
4843
-		return chr($num);
5124
+	elseif ($num < 0x80) {
5125
+			return chr($num);
5126
+	}
4844 5127
 	// <0x800 (2048)
4845
-	elseif ($num < 0x800)
4846
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5128
+	elseif ($num < 0x800) {
5129
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5130
+	}
4847 5131
 	// < 0x10000 (65536)
4848
-	elseif ($num < 0x10000)
4849
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5132
+	elseif ($num < 0x10000) {
5133
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5134
+	}
4850 5135
 	// <= 0x10FFFF (1114111)
4851
-	else
4852
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4853
-}
5136
+	else {
5137
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5138
+	}
5139
+	}
4854 5140
 
4855 5141
 /**
4856 5142
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -4863,17 +5149,19 @@  discard block
 block discarded – undo
4863 5149
  */
4864 5150
 function entity_fix__callback($matches)
4865 5151
 {
4866
-	if (!isset($matches[2]))
4867
-		return '';
5152
+	if (!isset($matches[2])) {
5153
+			return '';
5154
+	}
4868 5155
 
4869 5156
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4870 5157
 
4871 5158
 	// we don't allow control characters, characters out of range, byte markers, etc
4872
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
4873
-		return '';
4874
-	else
4875
-		return '&#' . $num . ';';
4876
-}
5159
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5160
+			return '';
5161
+	} else {
5162
+			return '&#' . $num . ';';
5163
+	}
5164
+	}
4877 5165
 
4878 5166
 /**
4879 5167
  * Return a Gravatar URL based on
@@ -4897,18 +5185,23 @@  discard block
 block discarded – undo
4897 5185
 		$ratings = array('G', 'PG', 'R', 'X');
4898 5186
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
4899 5187
 		$url_params = array();
4900
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
4901
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
4902
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
4903
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
4904
-		if (!empty($modSettings['avatar_max_width_external']))
4905
-			$size_string = (int) $modSettings['avatar_max_width_external'];
4906
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
4907
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5188
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5189
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5190
+		}
5191
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5192
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5193
+		}
5194
+		if (!empty($modSettings['avatar_max_width_external'])) {
5195
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5196
+		}
5197
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5198
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
4908 5199
 				$size_string = $modSettings['avatar_max_height_external'];
5200
+		}
4909 5201
 
4910
-		if (!empty($size_string))
4911
-			$url_params[] = 's=' . $size_string;
5202
+		if (!empty($size_string)) {
5203
+					$url_params[] = 's=' . $size_string;
5204
+		}
4912 5205
 	}
4913 5206
 	$http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www';
4914 5207
 
@@ -5019,8 +5312,9 @@  discard block
 block discarded – undo
5019 5312
  */
5020 5313
 function inet_ptod($ip_address)
5021 5314
 {
5022
-	if (!isValidIP($ip_address))
5023
-		return $ip_address;
5315
+	if (!isValidIP($ip_address)) {
5316
+			return $ip_address;
5317
+	}
5024 5318
 
5025 5319
 	$bin = inet_pton($ip_address);
5026 5320
 	return $bin;
@@ -5032,13 +5326,15 @@  discard block
 block discarded – undo
5032 5326
  */
5033 5327
 function inet_dtop($bin)
5034 5328
 {
5035
-	if(empty($bin))
5036
-		return '';
5329
+	if(empty($bin)) {
5330
+			return '';
5331
+	}
5037 5332
 
5038 5333
 	global $db_type;
5039 5334
 
5040
-	if ($db_type == 'postgresql')
5041
-		return $bin;
5335
+	if ($db_type == 'postgresql') {
5336
+			return $bin;
5337
+	}
5042 5338
 
5043 5339
 	$ip_address = inet_ntop($bin);
5044 5340
 
@@ -5063,26 +5359,32 @@  discard block
 block discarded – undo
5063 5359
  */
5064 5360
 function _safe_serialize($value)
5065 5361
 {
5066
-	if(is_null($value))
5067
-		return 'N;';
5362
+	if(is_null($value)) {
5363
+			return 'N;';
5364
+	}
5068 5365
 
5069
-	if(is_bool($value))
5070
-		return 'b:'. (int) $value .';';
5366
+	if(is_bool($value)) {
5367
+			return 'b:'. (int) $value .';';
5368
+	}
5071 5369
 
5072
-	if(is_int($value))
5073
-		return 'i:'. $value .';';
5370
+	if(is_int($value)) {
5371
+			return 'i:'. $value .';';
5372
+	}
5074 5373
 
5075
-	if(is_float($value))
5076
-		return 'd:'. str_replace(',', '.', $value) .';';
5374
+	if(is_float($value)) {
5375
+			return 'd:'. str_replace(',', '.', $value) .';';
5376
+	}
5077 5377
 
5078
-	if(is_string($value))
5079
-		return 's:'. strlen($value) .':"'. $value .'";';
5378
+	if(is_string($value)) {
5379
+			return 's:'. strlen($value) .':"'. $value .'";';
5380
+	}
5080 5381
 
5081 5382
 	if(is_array($value))
5082 5383
 	{
5083 5384
 		$out = '';
5084
-		foreach($value as $k => $v)
5085
-			$out .= _safe_serialize($k) . _safe_serialize($v);
5385
+		foreach($value as $k => $v) {
5386
+					$out .= _safe_serialize($k) . _safe_serialize($v);
5387
+		}
5086 5388
 
5087 5389
 		return 'a:'. count($value) .':{'. $out .'}';
5088 5390
 	}
@@ -5108,8 +5410,9 @@  discard block
 block discarded – undo
5108 5410
 
5109 5411
 	$out = _safe_serialize($value);
5110 5412
 
5111
-	if (isset($mbIntEnc))
5112
-		mb_internal_encoding($mbIntEnc);
5413
+	if (isset($mbIntEnc)) {
5414
+			mb_internal_encoding($mbIntEnc);
5415
+	}
5113 5416
 
5114 5417
 	return $out;
5115 5418
 }
@@ -5126,8 +5429,9 @@  discard block
 block discarded – undo
5126 5429
 function _safe_unserialize($str)
5127 5430
 {
5128 5431
 	// Input  is not a string.
5129
-	if(empty($str) || !is_string($str))
5130
-		return false;
5432
+	if(empty($str) || !is_string($str)) {
5433
+			return false;
5434
+	}
5131 5435
 
5132 5436
 	$stack = array();
5133 5437
 	$expected = array();
@@ -5143,43 +5447,38 @@  discard block
 block discarded – undo
5143 5447
 	while($state != 1)
5144 5448
 	{
5145 5449
 		$type = isset($str[0]) ? $str[0] : '';
5146
-		if($type == '}')
5147
-			$str = substr($str, 1);
5148
-
5149
-		else if($type == 'N' && $str[1] == ';')
5450
+		if($type == '}') {
5451
+					$str = substr($str, 1);
5452
+		} else if($type == 'N' && $str[1] == ';')
5150 5453
 		{
5151 5454
 			$value = null;
5152 5455
 			$str = substr($str, 2);
5153
-		}
5154
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5456
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5155 5457
 		{
5156 5458
 			$value = $matches[1] == '1' ? true : false;
5157 5459
 			$str = substr($str, 4);
5158
-		}
5159
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5460
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5160 5461
 		{
5161 5462
 			$value = (int)$matches[1];
5162 5463
 			$str = $matches[2];
5163
-		}
5164
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5464
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5165 5465
 		{
5166 5466
 			$value = (float)$matches[1];
5167 5467
 			$str = $matches[3];
5168
-		}
5169
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5468
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5170 5469
 		{
5171 5470
 			$value = substr($matches[2], 0, (int)$matches[1]);
5172 5471
 			$str = substr($matches[2], (int)$matches[1] + 2);
5173
-		}
5174
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5472
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5175 5473
 		{
5176 5474
 			$expectedLength = (int)$matches[1];
5177 5475
 			$str = $matches[2];
5178 5476
 		}
5179 5477
 
5180 5478
 		// Object or unknown/malformed type.
5181
-		else
5182
-			return false;
5479
+		else {
5480
+					return false;
5481
+		}
5183 5482
 
5184 5483
 		switch($state)
5185 5484
 		{
@@ -5207,8 +5506,9 @@  discard block
 block discarded – undo
5207 5506
 				if($type == '}')
5208 5507
 				{
5209 5508
 					// Array size is less than expected.
5210
-					if(count($list) < end($expected))
5211
-						return false;
5509
+					if(count($list) < end($expected)) {
5510
+											return false;
5511
+					}
5212 5512
 
5213 5513
 					unset($list);
5214 5514
 					$list = &$stack[count($stack)-1];
@@ -5217,8 +5517,9 @@  discard block
 block discarded – undo
5217 5517
 					// Go to terminal state if we're at the end of the root array.
5218 5518
 					array_pop($expected);
5219 5519
 
5220
-					if(count($expected) == 0)
5221
-						$state = 1;
5520
+					if(count($expected) == 0) {
5521
+											$state = 1;
5522
+					}
5222 5523
 
5223 5524
 					break;
5224 5525
 				}
@@ -5226,8 +5527,9 @@  discard block
 block discarded – undo
5226 5527
 				if($type == 'i' || $type == 's')
5227 5528
 				{
5228 5529
 					// Array size exceeds expected length.
5229
-					if(count($list) >= end($expected))
5230
-						return false;
5530
+					if(count($list) >= end($expected)) {
5531
+											return false;
5532
+					}
5231 5533
 
5232 5534
 					$key = $value;
5233 5535
 					$state = 3;
@@ -5261,8 +5563,9 @@  discard block
 block discarded – undo
5261 5563
 	}
5262 5564
 
5263 5565
 	// Trailing data in input.
5264
-	if(!empty($str))
5265
-		return false;
5566
+	if(!empty($str)) {
5567
+			return false;
5568
+	}
5266 5569
 
5267 5570
 	return $data;
5268 5571
 }
@@ -5285,8 +5588,9 @@  discard block
 block discarded – undo
5285 5588
 
5286 5589
 	$out = _safe_unserialize($str);
5287 5590
 
5288
-	if (isset($mbIntEnc))
5289
-		mb_internal_encoding($mbIntEnc);
5591
+	if (isset($mbIntEnc)) {
5592
+			mb_internal_encoding($mbIntEnc);
5593
+	}
5290 5594
 
5291 5595
 	return $out;
5292 5596
 }
@@ -5301,12 +5605,14 @@  discard block
 block discarded – undo
5301 5605
 function smf_chmod($file, $value = 0)
5302 5606
 {
5303 5607
 	// No file? no checks!
5304
-	if (empty($file))
5305
-		return false;
5608
+	if (empty($file)) {
5609
+			return false;
5610
+	}
5306 5611
 
5307 5612
 	// Already writable?
5308
-	if (is_writable($file))
5309
-		return true;
5613
+	if (is_writable($file)) {
5614
+			return true;
5615
+	}
5310 5616
 
5311 5617
 	// Do we have a file or a dir?
5312 5618
 	$isDir = is_dir($file);
@@ -5322,10 +5628,9 @@  discard block
 block discarded – undo
5322 5628
 		{
5323 5629
 			$isWritable = true;
5324 5630
 			break;
5631
+		} else {
5632
+					@chmod($file, $val);
5325 5633
 		}
5326
-
5327
-		else
5328
-			@chmod($file, $val);
5329 5634
 	}
5330 5635
 
5331 5636
 	return $isWritable;
@@ -5344,8 +5649,9 @@  discard block
 block discarded – undo
5344 5649
 	global $txt;
5345 5650
 
5346 5651
 	// Come on...
5347
-	if (empty($json) || !is_string($json))
5348
-		return array();
5652
+	if (empty($json) || !is_string($json)) {
5653
+			return array();
5654
+	}
5349 5655
 
5350 5656
 	$returnArray = array();
5351 5657
 	$jsonError = false;
@@ -5386,11 +5692,11 @@  discard block
 block discarded – undo
5386 5692
 		$jsonDebug = $jsonDebug[0];
5387 5693
 		loadLanguage('Errors');
5388 5694
 
5389
-		if (!empty($jsonDebug))
5390
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5391
-
5392
-		else
5393
-			log_error($txt['json_'. $jsonError], 'critical');
5695
+		if (!empty($jsonDebug)) {
5696
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5697
+		} else {
5698
+					log_error($txt['json_'. $jsonError], 'critical');
5699
+		}
5394 5700
 
5395 5701
 		// Everyone expects an array.
5396 5702
 		return array();
@@ -5420,8 +5726,9 @@  discard block
 block discarded – undo
5420 5726
 	global $db_show_debug, $modSettings;
5421 5727
 
5422 5728
 	// Defensive programming anyone?
5423
-	if (empty($data))
5424
-		return false;
5729
+	if (empty($data)) {
5730
+			return false;
5731
+	}
5425 5732
 
5426 5733
 	// Don't need extra stuff...
5427 5734
 	$db_show_debug = false;
@@ -5429,11 +5736,11 @@  discard block
 block discarded – undo
5429 5736
 	// Kill anything else.
5430 5737
 	ob_end_clean();
5431 5738
 
5432
-	if (!empty($modSettings['CompressedOutput']))
5433
-		@ob_start('ob_gzhandler');
5434
-
5435
-	else
5436
-		ob_start();
5739
+	if (!empty($modSettings['CompressedOutput'])) {
5740
+			@ob_start('ob_gzhandler');
5741
+	} else {
5742
+			ob_start();
5743
+	}
5437 5744
 
5438 5745
 	// Set the header.
5439 5746
 	header($type);
@@ -5481,20 +5788,21 @@  discard block
 block discarded – undo
5481 5788
 
5482 5789
 		$first = $substr($string, 0, 1);
5483 5790
 
5484
-		if (empty($index[$first]))
5485
-			$index[$first] = array();
5791
+		if (empty($index[$first])) {
5792
+					$index[$first] = array();
5793
+		}
5486 5794
 
5487 5795
 		if ($strlen($string) > 1)
5488 5796
 		{
5489 5797
 			// Sanity check on recursion
5490
-			if ($depth > 99)
5491
-				$index[$first][$substr($string, 1)] = '';
5492
-			
5493
-			else
5494
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
5798
+			if ($depth > 99) {
5799
+							$index[$first][$substr($string, 1)] = '';
5800
+			} else {
5801
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
5802
+			}
5803
+		} else {
5804
+					$index[$first][''] = '';
5495 5805
 		}
5496
-		else
5497
-			$index[$first][''] = '';
5498 5806
 
5499 5807
 		$depth--;
5500 5808
 		return $index;
@@ -5517,29 +5825,30 @@  discard block
 block discarded – undo
5517 5825
 			$key_regex = preg_quote($key, $delim);
5518 5826
 			$new_key = $key;
5519 5827
 
5520
-			if (empty($value))
5521
-				$sub_regex = '';
5522
-			else
5828
+			if (empty($value)) {
5829
+							$sub_regex = '';
5830
+			} else
5523 5831
 			{
5524 5832
 				$sub_regex = $index_to_regex($value, $delim);
5525 5833
 
5526
-				if (count(array_keys($value)) == 1)
5527
-					$new_key .= explode('(?'.'>', $sub_regex)[0];
5528
-				else
5529
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5834
+				if (count(array_keys($value)) == 1) {
5835
+									$new_key .= explode('(?'.'>', $sub_regex)[0];
5836
+				} else {
5837
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
5838
+				}
5530 5839
 			}
5531 5840
 
5532
-			if ($depth > 1)
5533
-				$regex[$new_key] = $key_regex . $sub_regex;
5534
-			else
5841
+			if ($depth > 1) {
5842
+							$regex[$new_key] = $key_regex . $sub_regex;
5843
+			} else
5535 5844
 			{
5536 5845
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
5537 5846
 				{
5538 5847
 					$regex[$new_key] = $key_regex . $sub_regex;
5539 5848
 					unset($index[$key]);
5849
+				} else {
5850
+									break;
5540 5851
 				}
5541
-				else
5542
-					break;
5543 5852
 			}
5544 5853
 		}
5545 5854
 		
@@ -5550,10 +5859,11 @@  discard block
 block discarded – undo
5550 5859
 			$l1 = $strlen($k1);
5551 5860
 			$l2 = $strlen($k2);
5552 5861
 			
5553
-			if ($l1 == $l2)
5554
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
5555
-			else
5556
-				return $l1 > $l2 ? -1 : 1;
5862
+			if ($l1 == $l2) {
5863
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
5864
+			} else {
5865
+							return $l1 > $l2 ? -1 : 1;
5866
+			}
5557 5867
 		});
5558 5868
 
5559 5869
 		$depth--;
@@ -5564,11 +5874,13 @@  discard block
 block discarded – undo
5564 5874
 	$index = array();
5565 5875
 	$regexes = array();
5566 5876
 
5567
-	foreach ($strings as $string)
5568
-		$index = $add_string_to_index($string, $index);
5877
+	foreach ($strings as $string) {
5878
+			$index = $add_string_to_index($string, $index);
5879
+	}
5569 5880
 
5570
-	while (!empty($index))
5571
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5881
+	while (!empty($index)) {
5882
+			$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5883
+	}
5572 5884
 
5573 5885
 	return $regexes;
5574 5886
 }
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Spacing   +29 added lines, -30 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	echo '
56 56
 		<div class="profile_user_avatar floatleft">
57
-			<a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['member']['avatar']['image'],'</a>
57
+			<a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['member']['avatar']['image'], '</a>
58 58
 		</div>
59 59
 		<div class="profile_user_info floatleft">
60 60
 			<span class="profile_username"><a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['user']['name'], '</a></span>
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		echo '
330 330
 					<dt>', $txt['profile_warning_level'], ': </dt>
331 331
 					<dd>
332
-						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning') , '">', $context['member']['warning'], '%</a>';
332
+						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
333 333
 
334 334
 		// Can we provide information on what this means?
335 335
 		if (!empty($context['warning_status']))
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
348 348
 		if (!empty($context['activate_message']))
349 349
 			echo '
350
-					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="'. $txt['profileConfirm'] .'"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
350
+					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
351 351
 
352 352
 		// If the current member is banned, show a message and possibly a link to the ban.
353 353
 		if (!empty($context['member']['bans']))
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		foreach ($context['posts'] as $post)
474 474
 		{
475 475
 			echo '
476
-			<div class="', $post['css_class'] ,'">
476
+			<div class="', $post['css_class'], '">
477 477
 				<div class="counter">', $post['counter'], '</div>
478 478
 				<div class="topic_details">
479 479
 					<h5><strong><a href="', $scripturl, '?board=', $post['board']['id'], '.0">', $post['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $post['topic'], '.', $post['start'], '#msg', $post['id'], '">', $post['subject'], '</a></strong></h5>
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 			// How about... even... remove it entirely?!
510 510
 			if ($post['can_delete'])
511 511
 				echo '
512
-						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
512
+						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
513 513
 
514 514
 			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
515 515
 				echo '
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 					<td>', $alert['time'], '</td>
581 581
 					<td>
582 582
 						<ul class="quickbuttons">
583
-							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id ,';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'] ,'</a></li>
584
-							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read') ,';aid=', $id ,';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button','"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']),'</a></li>
585
-							<li><input type="checkbox" name="mark[', $id ,']" value="', $id ,'"></li>
583
+							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
584
+							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>
585
+							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>
586 586
 						</ul>
587 587
 					</td>
588 588
 				</tr>';
@@ -592,17 +592,17 @@  discard block
 block discarded – undo
592 592
 			</table>
593 593
 			<div class="pagesection">
594 594
 				<div class="floatleft">
595
-					', $context['pagination'] ,'
595
+					', $context['pagination'], '
596 596
 				</div>
597 597
 				<div class="floatright">
598
-					', $txt['check_all'] ,': <input type="checkbox" name="select_all" id="select_all">
598
+					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
599 599
 					<select name="mark_as">
600
-						<option value="read">', $txt['quick_mod_markread'] ,'</option>
601
-						<option value="unread">', $txt['quick_mod_markunread'] ,'</option>
602
-						<option value="remove">', $txt['quick_mod_remove'] ,'</option>
600
+						<option value="read">', $txt['quick_mod_markread'], '</option>
601
+						<option value="unread">', $txt['quick_mod_markunread'], '</option>
602
+						<option value="remove">', $txt['quick_mod_remove'], '</option>
603 603
 					</select>
604 604
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
605
-					<input type="submit" name="req" value="', $txt['quick_mod_go'] ,'" class="button_submit you_sure">
605
+					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button_submit you_sure">
606 606
 				</div>
607 607
 			</div>
608 608
 		</form>';
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 				<div class="floatright">
660 660
 					<ul class="quickbuttons">
661 661
 						<li><a href="', $scripturl, '?action=post;', (empty($draft['topic']['id']) ? 'board=' . $draft['board']['id'] : 'topic=' . $draft['topic']['id']), '.0;id_draft=', $draft['id_draft'], '"><span class="generic_icons reply_button"></span>', $txt['draft_edit'], '</a></li>
662
-						<li><a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';area=showdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
662
+						<li><a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';area=showdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
663 663
 					</ul>
664 664
 				</div>
665 665
 			</div>';
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	if (empty($context['buddies']))
716 716
 		echo '
717 717
 			<tr class="windowbg">
718
-				<td colspan="', allowedTo('moderate_forum') ? '10' : '9','"><strong>', $txt['no_buddies'], '</strong></td>
718
+				<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td>
719 719
 			</tr>';
720 720
 
721 721
 		// Now loop through each buddy showing info on each.
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 				<th scope="col">', $txt['email'], '</th>';
819 819
 
820 820
 	echo '
821
-				<th scope="col">', $txt['ignore_remove'] ,'</th>
821
+				<th scope="col">', $txt['ignore_remove'], '</th>
822 822
 			</tr>';
823 823
 
824 824
 	// If they don't have anyone on their ignore list, don't list it!
825 825
 	if (empty($context['ignore_list']))
826 826
 		echo '
827 827
 			<tr class="windowbg">
828
-				<td colspan="', allowedTo('moderate_forum') ? '4' : '3','"><strong>', $txt['no_ignore'], '</strong></td>
828
+				<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td>
829 829
 			</tr>';
830 830
 
831 831
 	// Now loop through each buddy showing info on each.
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 	else
1064 1064
 	{
1065 1065
 		echo '
1066
-		<div class="information">',$txt['showPermissions_help'],'</div>
1066
+		<div class="information">',$txt['showPermissions_help'], '</div>
1067 1067
 		<div id="permissions" class="flow_hidden">';
1068 1068
 
1069 1069
 		if (!empty($context['no_access_boards']))
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 
1111 1111
 				if ($permission['is_denied'])
1112 1112
 					echo '
1113
-									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']),'</span>';
1113
+									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1114 1114
 				else
1115 1115
 					echo '
1116 1116
 									', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 		{
1897 1897
 			echo '
1898 1898
 				<tr class="windowbg">
1899
-					<td>', $txt['alert_' . $alert_id], isset($alert_details['help']) ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $alert_details['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help floatright"><span class="generic_icons help" title="'. $txt['help'].'"></span></a>' : '', '</td>';
1899
+					<td>', $txt['alert_' . $alert_id], isset($alert_details['help']) ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $alert_details['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help floatright"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a>' : '', '</td>';
1900 1900
 
1901 1901
 			foreach ($context['alert_bits'] as $type => $bitmask)
1902 1902
 			{
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 						<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2079 2079
 				elseif ($group['type'] == 2 && $group['pending'])
2080 2080
 					echo '
2081
-						<span class="floatright">', $txt['approval_pending'],'</span>';
2081
+						<span class="floatright">', $txt['approval_pending'], '</span>';
2082 2082
 				elseif ($group['type'] == 2)
2083 2083
 					echo '
2084 2084
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2383 2383
 				<dl class="settings">
2384 2384
 					<dt>
2385
-						<strong>', $txt['preview'] , '</strong>
2385
+						<strong>', $txt['preview'], '</strong>
2386 2386
 					</dt>
2387 2387
 					<dd id="body_preview">
2388 2388
 						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
 								', !empty($context['member']['avatar']['allow_server_stored']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['choose_avatar_gallery'] . '</label><br />' : '', '
2802 2802
 								', !empty($context['member']['avatar']['allow_external']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['my_own_pic'] . '</label><br />' : '', '
2803 2803
 								', !empty($context['member']['avatar']['allow_upload']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['avatar_will_upload'] . '</label><br />' : '', '
2804
-								', !empty($context['member']['avatar']['allow_gravatar']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"'. ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>' : '', '
2804
+								', !empty($context['member']['avatar']['allow_gravatar']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>' : '', '
2805 2805
 							</dt>
2806 2806
 							<dd>';
2807 2807
 
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
 	echo '
2969 2969
 							<dt>
2970 2970
 								<strong><label for="easyformat">', $txt['time_format'], ':</label></strong><br>
2971
-								<a href="', $scripturl, '?action=helpadmin;help=time_format" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'],'"></span></a>
2971
+								<a href="', $scripturl, '?action=helpadmin;help=time_format" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
2972 2972
 								<span class="smalltext">&nbsp;<label for="time_format">', $txt['date_format'], '</label></span>
2973 2973
 							</dt>
2974 2974
 							<dd>
@@ -3034,8 +3034,7 @@  discard block
 block discarded – undo
3034 3034
 							<div class="roundframe">
3035 3035
 								<div>
3036 3036
 		', !empty($context['tfa_backup']) ? '
3037
-									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3038
-			($modSettings['tfa_mode'] == 2 ? '
3037
+									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? '
3039 3038
 									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3040 3039
 									<div class="smalltext">', $txt['tfa_desc'], '</div>
3041 3040
 									<div id="basicinfo" style="width: 60%">
@@ -3043,7 +3042,7 @@  discard block
 block discarded – undo
3043 3042
 											<div class="title_top">
3044 3043
 												<strong>', $txt['tfa_step1'], '</strong><br />
3045 3044
 												', !empty($context['tfa_pass_error']) ? '<div class="error smalltext">' . $txt['tfa_pass_invalid'] . '</div>' : '', '
3046
-												<input type="password" name="passwd" style="width: 200px;"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '' ,'>
3045
+												<input type="password" name="passwd" style="width: 200px;"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
3047 3046
 											</div>
3048 3047
 											<div class="title_top">
3049 3048
 												<strong>', $txt['tfa_step2'], '</strong>
@@ -3051,9 +3050,9 @@  discard block
 block discarded – undo
3051 3050
 												<div class="tfacode">', $context['tfa_secret'], '</div>
3052 3051
 											</div>
3053 3052
 											<div class="title_top">
3054
-												<strong>', $txt['tfa_step3'] , '</strong><br />
3053
+												<strong>', $txt['tfa_step3'], '</strong><br />
3055 3054
 												', !empty($context['tfa_error']) ? '<div class="error smalltext">' . $txt['tfa_code_invalid'] . '</div>' : '', '
3056
-												<input type="text" name="tfa_code" style="width: 200px;"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '' ,'>
3055
+												<input type="text" name="tfa_code" style="width: 200px;"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
3057 3056
 												<input type="submit" name="save" value="', $txt['tfa_enable'], '" class="button_submit" style="float: none;" />
3058 3057
 											</div>
3059 3058
 											<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		<a class="menu_icon mobile_generic_menu_', $context['cur_menu_id'], '"></a>
53 53
 		<div id="mobile_generic_menu_', $context['cur_menu_id'], '" class="popup_container">
54 54
 			<div class="popup_window description">
55
-				<div class="popup_heading">', $txt['mobile_user_menu'],'
55
+				<div class="popup_heading">', $txt['mobile_user_menu'], '
56 56
 				<a href="javascript:void(0);" class="generic_icons hide_popup"></a></div>
57 57
 				', template_generic_menu($menu_context), '
58 58
 			</div>
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		</script>';
68 68
 }
69 69
 
70
-function template_generic_menu (&$menu_context)
70
+function template_generic_menu(&$menu_context)
71 71
 {
72 72
 	global $context;
73 73
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	foreach ($menu_context['sections'] as $section)
82 82
 	{
83 83
 		echo '
84
-						<li ', !empty($section['areas']) ? 'class="subsections"' : '', '><a class="', !empty($section['selected']) ? 'active ' : '', '" href="', $section['url'], $menu_context['extra_parameters'], '">', $section['title'] , '</a>
84
+						<li ', !empty($section['areas']) ? 'class="subsections"' : '', '><a class="', !empty($section['selected']) ? 'active ' : '', '" href="', $section['url'], $menu_context['extra_parameters'], '">', $section['title'], '</a>
85 85
 							<ul>';
86 86
 
87 87
 		// For every area of this section show a link to that area (bold if it's currently selected.)
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 				echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
221 221
 
222 222
 			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
223
-				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'],'"></span></a>';
223
+				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
224 224
 
225 225
 			echo $tab_context['title'];
226 226
 		}
Please login to merge, or discard this patch.
Themes/default/Reports.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@
 block discarded – undo
148 148
 	<head>
149 149
 		<meta charset="', $context['character_set'], '">
150 150
 		<title>', $context['page_title'], '</title>
151
-		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/report.css', $modSettings['browser_cache'] ,'">
151
+		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/report.css', $modSettings['browser_cache'], '">
152 152
 	</head>
153 153
 	<body>';
154 154
 }
Please login to merge, or discard this patch.
Themes/default/PersonalMessage.template.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 			foreach ($message['custom_fields']['above_member'] as $custom)
233 233
 				echo '
234
-					<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
234
+					<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
235 235
 
236 236
 			echo '
237 237
 				</ul>
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		if (!empty($message['custom_fields']['below_avatar']))
269 269
 			foreach ($message['custom_fields']['below_avatar'] as $custom)
270 270
 				echo '
271
-				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
271
+				<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
272 272
 
273 273
 			if (!$message['member']['is_guest'])
274 274
 				echo '
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 					foreach ($message['custom_fields']['icons'] as $custom)
312 312
 						echo '
313
-						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
313
+						<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
314 314
 
315 315
 					echo '
316 316
 					</ol>
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				if (!empty($message['custom_fields']['standard']))
369 369
 					foreach ($message['custom_fields']['standard'] as $custom)
370 370
 						echo '
371
-				<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
371
+				<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
372 372
 
373 373
 				// Are we showing the warning status?
374 374
 				if ($message['member']['can_see_warning'])
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 				if (!empty($message['custom_fields']['bottom_poster']))
380 380
 					foreach ($message['custom_fields']['bottom_poster'] as $custom)
381 381
 						echo '
382
-				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
382
+				<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
383 383
 			}
384 384
 
385 385
 			// Done with the information about the poster... on to the post itself.
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 
479 479
 				foreach ($message['custom_fields']['above_signature'] as $custom)
480 480
 					echo '
481
-							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
481
+							<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
482 482
 
483 483
 				echo '
484 484
 						</ul>
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
 				foreach ($message['custom_fields']['below_signature'] as $custom)
501 501
 					echo '
502
-							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
502
+							<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
503 503
 
504 504
 				echo '
505 505
 						</ul>
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	while ($message = $context['get_pmessage']('subject'))
632 632
 	{
633 633
 		echo '
634
-		<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','">
634
+		<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '">
635 635
 			<td class="table_icon">
636 636
 			<script>
637 637
 				currentLabels[', $message['id'], '] = {';
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
 					// You can only reply if they are not a guest...
904 904
 					if (!$message['member']['is_guest'])
905 905
 						echo '
906
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
907
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
906
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], '
907
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator'];
908 908
 					// This is for "forwarding" - even if the member is gone.
909 909
 					else
910 910
 						echo '
911
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
911
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator'];
912 912
 				}
913 913
 
914 914
 				echo '
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
1009 1009
 				<dl>
1010 1010
 					<dt>
1011
-						<strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
1011
+						<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
1012 1012
 					</dt>
1013 1013
 					<dd class="error" id="error_list">
1014 1014
 						', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), '
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 					<span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
1065 1065
 				</dt>
1066 1066
 				<dd id="pm_subject">
1067
-					<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
1067
+					<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
1068 1068
 				</dd>
1069 1069
 			</dl><hr>';
1070 1070
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 		echo '
1428 1428
 		<div class="padding">
1429 1429
 			<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
1430
-			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure">
1430
+			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button_submit you_sure">
1431 1431
 		</div>';
1432 1432
 
1433 1433
 	echo '
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 	if (!empty($context['rules']))
1592 1592
 		echo '
1593 1593
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1594
-			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">';
1594
+			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button_submit smalltext you_sure">';
1595 1595
 
1596 1596
 	echo '
1597 1597
 		</div>
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
 
1833 1833
 		echo '
1834 1834
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
1835
-					<option value="">', $txt['pm_rule_sel_action'] , ':</option>
1836
-					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option>
1837
-					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option>
1835
+					<option value="">', $txt['pm_rule_sel_action'], ':</option>
1836
+					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option>
1837
+					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option>
1838 1838
 				</select>
1839 1839
 				<span id="labdiv', $k, '">
1840 1840
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 					</div>
1952 1952
 					<ul class="quickbuttons">
1953 1953
 						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li>
1954
-						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1954
+						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1955 1955
 					</ul>
1956 1956
 				</div>';
1957 1957
 		}
Please login to merge, or discard this patch.
Themes/default/Display.template.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	echo '
40 40
 		<div id="display_head" class="information">
41 41
 			<h2 class="display_title"><span id="top_subject">', $context['subject'], '</span>', ($context['is_locked']) ? ' <span class="generic_icons lock"></span>' : '', ($context['is_sticky']) ? ' <span class="generic_icons sticky"></span>' : '', '</h2>
42
-			<p>',$txt['started_by'],' ', $context['topic_poster_name'],', ', $context['topic_started_time'],'</p>';
42
+			<p>',$txt['started_by'], ' ', $context['topic_poster_name'], ', ', $context['topic_started_time'], '</p>';
43 43
 
44 44
 	// Next - Prev
45 45
 	echo '
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			<div id="poll">
75 75
 				<div class="cat_bar">
76 76
 					<h3 class="catbg">
77
-						<span class="generic_icons poll"></span>', $context['poll']['is_locked'] ? '<span class="generic_icons lock"></span>' : '' ,' ', $context['poll']['question'], '
77
+						<span class="generic_icons poll"></span>', $context['poll']['is_locked'] ? '<span class="generic_icons lock"></span>' : '', ' ', $context['poll']['question'], '
78 78
 					</h3>
79 79
 				</div>
80 80
 				<div class="windowbg noup">
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	// Mobile action - moderation buttons (top)
189 189
 	echo '
190 190
 			<div class="mobile_buttons floatright">
191
-				<a class="button mobile_act">', $txt['mobile_action'],'</a>
192
-				', ($context['can_moderate_forum'] || $context['user']['is_mod']) ? '<a class="button mobile_mod">'. $txt['mobile_moderation'].'</a>' : '','
191
+				<a class="button mobile_act">', $txt['mobile_action'], '</a>
192
+				', ($context['can_moderate_forum'] || $context['user']['is_mod']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
193 193
 			</div>';
194 194
 
195 195
 	// Show the topic information - icon, subject, etc.
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	// Mobile action - moderation buttons (bottom)
214 214
 	echo '
215 215
 			<div class="mobile_buttons floatright">
216
-				<a class="button mobile_act">', $txt['mobile_action'],'</a>
217
-				', ($context['can_moderate_forum'] || $context['user']['is_mod']) ? '<a class="button mobile_mod">'. $txt['mobile_moderation'].'</a>' : '','
216
+				<a class="button mobile_act">', $txt['mobile_action'], '</a>
217
+				', ($context['can_moderate_forum'] || $context['user']['is_mod']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
218 218
 			</div>';
219 219
 
220 220
 	// Show the page index... "Pages: [1]".
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	echo '
249 249
 			<div id="mobile_action" class="popup_container">
250 250
 				<div class="popup_window description">
251
-					<div class="popup_heading">', $txt['mobile_action'],'
251
+					<div class="popup_heading">', $txt['mobile_action'], '
252 252
 					<a href="javascript:void(0);" class="generic_icons hide_popup"></a></div>
253 253
 					', template_button_strip($context['normal_buttons']), '
254 254
 				</div>
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		echo '
260 260
 			<div id="mobile_moderation" class="popup_container">
261 261
 				<div class="popup_window description">
262
-					<div class="popup_heading">', $txt['mobile_moderation'],'
262
+					<div class="popup_heading">', $txt['mobile_moderation'], '
263 263
 					<a href="javascript:void(0);" class="generic_icons hide_popup"></a></div>
264 264
 					<div id="moderationbuttons_mobile">
265 265
 						', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip_mobile')), '
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 							sTemplateBodyNormal: ', JavaScriptEscape('%body%'), ',
348 348
 							sTemplateSubjectNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a>'), ',
349 349
 							sTemplateTopSubject: ', JavaScriptEscape('%subject%'), ',
350
-							sTemplateReasonEdit: ', JavaScriptEscape($txt['reason_for_edit'] .': <input type="text" name="modify_reason" value="%modify_reason%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="input_text quickModifyMargin">'), ',
350
+							sTemplateReasonEdit: ', JavaScriptEscape($txt['reason_for_edit'] . ': <input type="text" name="modify_reason" value="%modify_reason%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="input_text quickModifyMargin">'), ',
351 351
 							sTemplateReasonNormal: ', JavaScriptEscape('%modify_text'), ',
352 352
 							sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), ($context['can_reply']) ? ',
353 353
 							sFormRemoveAccessKeys: \'postmodify\'' : '', '
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
 	// Show the message anchor and a "new" anchor if this message is new.
422 422
 	echo '
423
-				<div class="', $message['css_class'] ,'">', $message['id'] != $context['first_message'] ? '
423
+				<div class="', $message['css_class'], '">', $message['id'] != $context['first_message'] ? '
424 424
 					<a id="msg' . $message['id'] . '"></a>' . ($message['first_new'] ? '<a id="new"></a>' : '') : '', '
425 425
 					<div class="post_wrapper">';
426 426
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
 		foreach ($message['custom_fields']['above_member'] as $custom)
439 439
 			echo '
440
-									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
440
+									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
441 441
 
442 442
 		echo '
443 443
 								</ul>
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	if (!empty($message['custom_fields']['below_avatar']))
474 474
 		foreach ($message['custom_fields']['below_avatar'] as $custom)
475 475
 			echo '
476
-								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
476
+								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
477 477
 
478 478
 	// Show the post group icons, but not for guests.
479 479
 	if (!$message['member']['is_guest'])
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
 			foreach ($message['custom_fields']['icons'] as $custom)
520 520
 				echo '
521
-										<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
521
+										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
522 522
 
523 523
 			echo '
524 524
 									</ol>
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		if (!empty($message['custom_fields']['standard']))
557 557
 			foreach ($message['custom_fields']['standard'] as $custom)
558 558
 				echo '
559
-								<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
559
+								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
560 560
 
561 561
 	}
562 562
 	// Otherwise, show the guest's email.
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	if (!empty($message['custom_fields']['bottom_poster']))
595 595
 		foreach ($message['custom_fields']['bottom_poster'] as $custom)
596 596
 			echo '
597
-									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
597
+									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
598 598
 
599 599
 	// Poster info ends.
600 600
 	echo '
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 			$base .= (isset($txt[$base . $count])) ? $count : 'n';
782 782
 
783 783
 			echo '
784
-									<li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=msg;like=' . $message['id'] .';'. $context['session_var'] .'='. $context['session_id'], comma_format($count)), '</li>';
784
+									<li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=msg;like=' . $message['id'] . ';' . $context['session_var'] . '=' . $context['session_id'], comma_format($count)), '</li>';
785 785
 		}
786 786
 
787 787
 		echo '
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		if ($context['can_quote'])
799 799
 			echo '
800 800
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
801
-									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>';
801
+									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>';
802 802
 
803 803
 		// Can the user modify the contents of this post? Show the modify inline image.
804 804
 		if ($message['can_modify'])
@@ -820,10 +820,10 @@  discard block
 block discarded – undo
820 820
 		// How about... even... remove it entirely?!
821 821
 		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
822 822
 			echo '
823
-											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>';
823
+											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>';
824 824
 		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
825 825
 			echo '
826
-											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
826
+											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
827 827
 
828 828
 		// What about splitting it off the rest of the topic?
829 829
 		if ($context['can_split'] && !empty($context['real_num_replies']))
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 
882 882
 		foreach ($message['custom_fields']['above_signature'] as $custom)
883 883
 			echo '
884
-									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
884
+									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
885 885
 
886 886
 		echo '
887 887
 								</ul>
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 
904 904
 		foreach ($message['custom_fields']['below_signature'] as $custom)
905 905
 			echo '
906
-									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
906
+									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
907 907
 
908 908
 		echo '
909 909
 								</ul>
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 	echo '
1005 1005
 				<br class="clear_right">
1006 1006
 				<span id="post_confirm_buttons">
1007
-					', template_control_richedit_buttons($context['post_box_name']) ,'
1007
+					', template_control_richedit_buttons($context['post_box_name']), '
1008 1008
 				</span>';
1009 1009
 		echo '
1010 1010
 					</form>
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 						sJumpAnchor: "quickreply",
1048 1048
 						bIsFull: true
1049 1049
 					});
1050
-					var oEditorID = "', $context['post_box_name'] ,'";
1050
+					var oEditorID = "', $context['post_box_name'], '";
1051 1051
 					var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
1052 1052
 					var oJumpAnchor = "quickreply";
1053 1053
 				</script>';
Please login to merge, or discard this patch.
Braces   +202 added lines, -137 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
 				<p>';
52 52
 
53 53
 		// Show just numbers...?
54
-		if ($settings['display_who_viewing'] == 1)
55
-				echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+						echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
56 57
 		// Or show the actual people viewing the topic?
57
-		else
58
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
59 61
 
60 62
 		// Now show how many guests are here too.
61 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -93,10 +95,11 @@  discard block
 block discarded – undo
93 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
94 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
95 97
 
96
-				if ($context['allow_results_view'])
97
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
98 100
 							', $option['bar_ndt'], '
99 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
100 103
 
101 104
 				echo '
102 105
 						</dd>';
@@ -105,9 +108,10 @@  discard block
 block discarded – undo
105 108
 			echo '
106 109
 					</dl>';
107 110
 
108
-			if ($context['allow_results_view'])
109
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
110 113
 						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
111 115
 		}
112 116
 		// They are allowed to vote! Go to it!
113 117
 		else
@@ -116,17 +120,19 @@  discard block
 block discarded – undo
116 120
 						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
117 121
 
118 122
 			// Show a warning if they are allowed more than one option.
119
-			if ($context['poll']['allowed_warning'])
120
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
121 125
 							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
122 127
 
123 128
 			echo '
124 129
 							<ul class="options">';
125 130
 
126 131
 			// Show each option with its button - a radio likely.
127
-			foreach ($context['poll']['options'] as $option)
128
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
129 134
 								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
130 136
 
131 137
 			echo '
132 138
 							</ul>
@@ -138,9 +144,10 @@  discard block
 block discarded – undo
138 144
 		}
139 145
 
140 146
 		// Is the clock ticking?
141
-		if (!empty($context['poll']['expire_time']))
142
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
143 149
 						<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
144 151
 
145 152
 		echo '
146 153
 					</div>
@@ -164,11 +171,12 @@  discard block
 block discarded – undo
164 171
 			<div class="information">
165 172
 				<ul>';
166 173
 
167
-		foreach ($context['linked_calendar_events'] as $event)
168
-			echo '
174
+		foreach ($context['linked_calendar_events'] as $event) {
175
+					echo '
169 176
 					<li>
170 177
 						', ($event['can_edit'] ? '<a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify"></span></a> ' : ''), '<strong>', $event['title'], '</strong>: ', $event['start_date'], ($event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : ''), '
171 178
 					</li>';
179
+		}
172 180
 
173 181
 		echo '
174 182
 				</ul>
@@ -203,8 +211,9 @@  discard block
 block discarded – undo
203 211
 	$context['removableMessageIDs'] = array();
204 212
 
205 213
 	// Get all the messages...
206
-	while ($message = $context['get_message']())
207
-		template_single_post($message);
214
+	while ($message = $context['get_message']()) {
215
+			template_single_post($message);
216
+	}
208 217
 
209 218
 	echo '
210 219
 				</form>
@@ -241,8 +250,9 @@  discard block
 block discarded – undo
241 250
 			<div id="display_jump_to">&nbsp;</div>';
242 251
 
243 252
 	// Show quickreply
244
-	if ($context['can_reply'])
245
-	template_quickreply();
253
+	if ($context['can_reply']) {
254
+		template_quickreply();
255
+	}
246 256
 
247 257
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
248 258
 	echo '
@@ -255,8 +265,8 @@  discard block
 block discarded – undo
255 265
 			</div>';
256 266
 
257 267
 	// Show the moderation button & pop only if user can moderate
258
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
259
-		echo '
268
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
269
+			echo '
260 270
 			<div id="mobile_moderation" class="popup_container">
261 271
 				<div class="popup_window description">
262 272
 					<div class="popup_heading">', $txt['mobile_moderation'],'
@@ -266,6 +276,7 @@  discard block
 block discarded – undo
266 276
 					</div>
267 277
 				</div>
268 278
 			</div>';
279
+	}
269 280
 
270 281
 		echo '
271 282
 				<script>';
@@ -389,9 +400,10 @@  discard block
 block discarded – undo
389 400
 						});
390 401
 					}';
391 402
 
392
-	if (!empty($context['ignoredMsgs']))
393
-		echo '
403
+	if (!empty($context['ignoredMsgs'])) {
404
+			echo '
394 405
 					ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
406
+	}
395 407
 
396 408
 	echo '
397 409
 				</script>';
@@ -408,8 +420,9 @@  discard block
 block discarded – undo
408 420
 
409 421
 	$ignoring = false;
410 422
 
411
-	if ($message['can_remove'])
412
-		$context['removableMessageIDs'][] = $message['id'];
423
+	if ($message['can_remove']) {
424
+			$context['removableMessageIDs'][] = $message['id'];
425
+	}
413 426
 
414 427
 	// Are we ignoring this message?
415 428
 	if (!empty($message['is_ignored']))
@@ -435,9 +448,10 @@  discard block
 block discarded – undo
435 448
 							<div class="custom_fields_above_member">
436 449
 								<ul class="nolist">';
437 450
 
438
-		foreach ($message['custom_fields']['above_member'] as $custom)
439
-			echo '
451
+		foreach ($message['custom_fields']['above_member'] as $custom) {
452
+					echo '
440 453
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
454
+		}
441 455
 
442 456
 		echo '
443 457
 								</ul>
@@ -448,9 +462,10 @@  discard block
 block discarded – undo
448 462
 									<h4>';
449 463
 
450 464
 	// Show online and offline buttons?
451
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
452
-		echo '
465
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
466
+			echo '
453 467
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
468
+	}
454 469
 
455 470
 
456 471
 	// Show a link to the member's profile.
@@ -463,51 +478,59 @@  discard block
 block discarded – undo
463 478
 
464 479
 
465 480
 	// Show the user's avatar.
466
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
467
-		echo '
481
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
482
+			echo '
468 483
 								<li class="avatar">
469 484
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
470 485
 								</li>';
486
+	}
471 487
 
472 488
 	// Are there any custom fields below the avatar?
473
-	if (!empty($message['custom_fields']['below_avatar']))
474
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
489
+	if (!empty($message['custom_fields']['below_avatar'])) {
490
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
475 491
 			echo '
476 492
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
493
+	}
477 494
 
478 495
 	// Show the post group icons, but not for guests.
479
-	if (!$message['member']['is_guest'])
480
-		echo '
496
+	if (!$message['member']['is_guest']) {
497
+			echo '
481 498
 								<li class="icons">', $message['member']['group_icons'], '</li>';
499
+	}
482 500
 
483 501
 	// Show the member's primary group (like 'Administrator') if they have one.
484
-	if (!empty($message['member']['group']))
485
-		echo '
502
+	if (!empty($message['member']['group'])) {
503
+			echo '
486 504
 								<li class="membergroup">', $message['member']['group'], '</li>';
505
+	}
487 506
 
488 507
 	// Show the member's custom title, if they have one.
489
-	if (!empty($message['member']['title']))
490
-		echo '
508
+	if (!empty($message['member']['title'])) {
509
+			echo '
491 510
 								<li class="title">', $message['member']['title'], '</li>';
511
+	}
492 512
 
493 513
 	// Don't show these things for guests.
494 514
 	if (!$message['member']['is_guest'])
495 515
 	{
496 516
 
497 517
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
498
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
499
-			echo '
518
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
519
+					echo '
500 520
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
521
+		}
501 522
 
502 523
 		// Show how many posts they have made.
503
-		if (!isset($context['disabled_fields']['posts']))
504
-			echo '
524
+		if (!isset($context['disabled_fields']['posts'])) {
525
+					echo '
505 526
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
527
+		}
506 528
 
507 529
 		// Show their personal text?
508
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
509
-			echo '
530
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
531
+					echo '
510 532
 								<li class="blurb">', $message['member']['blurb'], '</li>';
533
+		}
511 534
 
512 535
 		// Any custom fields to show as icons?
513 536
 		if (!empty($message['custom_fields']['icons']))
@@ -516,9 +539,10 @@  discard block
 block discarded – undo
516 539
 								<li class="im_icons">
517 540
 									<ol>';
518 541
 
519
-			foreach ($message['custom_fields']['icons'] as $custom)
520
-				echo '
542
+			foreach ($message['custom_fields']['icons'] as $custom) {
543
+							echo '
521 544
 										<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
545
+			}
522 546
 
523 547
 			echo '
524 548
 									</ol>
@@ -533,19 +557,22 @@  discard block
 block discarded – undo
533 557
 									<ol class="profile_icons">';
534 558
 
535 559
 			// Don't show an icon if they haven't specified a website.
536
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
537
-				echo '
560
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
561
+							echo '
538 562
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
563
+			}
539 564
 
540 565
 			// Since we know this person isn't a guest, you *can* message them.
541
-			if ($context['can_send_pm'])
542
-				echo '
566
+			if ($context['can_send_pm']) {
567
+							echo '
543 568
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
569
+			}
544 570
 
545 571
 			// Show the email if necessary
546
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
547
-				echo '
572
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
573
+							echo '
548 574
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
575
+			}
549 576
 
550 577
 				echo '
551 578
 									</ol>
@@ -553,48 +580,56 @@  discard block
 block discarded – undo
553 580
 		}
554 581
 
555 582
 		// Any custom fields for standard placement?
556
-		if (!empty($message['custom_fields']['standard']))
557
-			foreach ($message['custom_fields']['standard'] as $custom)
583
+		if (!empty($message['custom_fields']['standard'])) {
584
+					foreach ($message['custom_fields']['standard'] as $custom)
558 585
 				echo '
559 586
 								<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
587
+		}
560 588
 
561 589
 	}
562 590
 	// Otherwise, show the guest's email.
563
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
564
-		echo '
591
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
592
+			echo '
565 593
 								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
594
+	}
566 595
 
567 596
 	// Show the IP to this user for this post - because you can moderate?
568
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
569
-		echo '
597
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
598
+			echo '
570 599
 								<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
600
+	}
571 601
 
572 602
 	// Or, should we show it because this is you?
573
-	elseif ($message['can_see_ip'])
574
-		echo '
603
+	elseif ($message['can_see_ip']) {
604
+			echo '
575 605
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
606
+	}
576 607
 
577 608
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
578
-	elseif (!$context['user']['is_guest'])
579
-		echo '
609
+	elseif (!$context['user']['is_guest']) {
610
+			echo '
580 611
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
612
+	}
581 613
 
582 614
 	// Otherwise, you see NOTHING!
583
-	else
584
-		echo '
615
+	else {
616
+			echo '
585 617
 								<li class="poster_ip">', $txt['logged'], '</li>';
618
+	}
586 619
 
587 620
 	// Are we showing the warning status?
588 621
 	// Don't show these things for guests.
589
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
590
-		echo '
622
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
623
+			echo '
591 624
 								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
625
+	}
592 626
 
593 627
 	// Are there any custom fields to show at the bottom of the poster info?
594
-	if (!empty($message['custom_fields']['bottom_poster']))
595
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
628
+	if (!empty($message['custom_fields']['bottom_poster'])) {
629
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
596 630
 			echo '
597 631
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
632
+	}
598 633
 
599 634
 	// Poster info ends.
600 635
 	echo '
@@ -623,9 +658,10 @@  discard block
 block discarded – undo
623 658
 	echo '
624 659
 									<span class="smalltext modified" id="modified_', $message['id'], '">';
625 660
 
626
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
627
-		echo
661
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
662
+			echo
628 663
 										$message['modified']['last_edit_text'];
664
+	}
629 665
 
630 666
 	echo '
631 667
 									</span>';
@@ -636,22 +672,24 @@  discard block
 block discarded – undo
636 672
 							</div>';
637 673
 
638 674
 	// Ignoring this user? Hide the post.
639
-	if ($ignoring)
640
-		echo '
675
+	if ($ignoring) {
676
+			echo '
641 677
 							<div id="msg_', $message['id'], '_ignored_prompt">
642 678
 								', $txt['ignoring_user'], '
643 679
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
644 680
 							</div>';
681
+	}
645 682
 
646 683
 	// Show the post itself, finally!
647 684
 	echo '
648 685
 							<div class="post">';
649 686
 
650
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
651
-		echo '
687
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
688
+			echo '
652 689
 								<div class="approve_post">
653 690
 									', $txt['post_awaiting_approval'], '
654 691
 								</div>';
692
+	}
655 693
 	echo '
656 694
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
657 695
 							</div>';
@@ -668,9 +706,9 @@  discard block
 block discarded – undo
668 706
 		foreach ($message['attachment'] as $attachment)
669 707
 		{
670 708
 			// Do we want this attachment to not be showed here?
671
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
672
-				continue;
673
-			elseif (!$div_output)
709
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
710
+							continue;
711
+			} elseif (!$div_output)
674 712
 			{
675 713
 				$div_output = true;
676 714
 
@@ -686,9 +724,10 @@  discard block
 block discarded – undo
686 724
 								<fieldset>
687 725
 									<legend>', $txt['attach_awaiting_approve'];
688 726
 
689
-				if ($context['can_approve'])
690
-					echo '
727
+				if ($context['can_approve']) {
728
+									echo '
691 729
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
730
+				}
692 731
 
693 732
 				echo '
694 733
 									</legend>';
@@ -702,12 +741,13 @@  discard block
 block discarded – undo
702 741
 				echo '
703 742
 										<div class="attachments_top">';
704 743
 
705
-				if ($attachment['thumbnail']['has_thumb'])
706
-					echo '
744
+				if ($attachment['thumbnail']['has_thumb']) {
745
+									echo '
707 746
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
708
-				else
709
-					echo '
747
+				} else {
748
+									echo '
710 749
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
750
+				}
711 751
 
712 752
 				echo '
713 753
 										</div>';
@@ -717,9 +757,10 @@  discard block
 block discarded – undo
717 757
 										<div class="attachments_bot">
718 758
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
719 759
 
720
-			if (!$attachment['is_approved'] && $context['can_approve'])
721
-				echo '
760
+			if (!$attachment['is_approved'] && $context['can_approve']) {
761
+							echo '
722 762
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
763
+			}
723 764
 			echo '
724 765
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
725 766
 										</div>';
@@ -728,33 +769,38 @@  discard block
 block discarded – undo
728 769
 									</div>';
729 770
 
730 771
 			// Next attachment line ?
731
-			if (++$i % $attachments_per_line === 0)
732
-				echo '
772
+			if (++$i % $attachments_per_line === 0) {
773
+							echo '
733 774
 									<br>';
775
+			}
734 776
 		}
735 777
 
736 778
 		// If we had unapproved attachments clean up.
737
-		if ($last_approved_state == 0)
738
-			echo '
779
+		if ($last_approved_state == 0) {
780
+					echo '
739 781
 								</fieldset>';
782
+		}
740 783
 
741 784
 		// Only do this if we output a div above - otherwise it'll break things
742
-		if ($div_output)
743
-			echo '
785
+		if ($div_output) {
786
+					echo '
744 787
 							</div>';
788
+		}
745 789
 	}
746 790
 
747 791
 	// And stuff below the attachments.
748
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
749
-	echo '
792
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
793
+		echo '
750 794
 							<div class="under_message">';
795
+	}
751 796
 
752 797
 	// Maybe they want to report this post to the moderator(s)?
753
-	if ($context['can_report_moderator'])
754
-		echo '
798
+	if ($context['can_report_moderator']) {
799
+			echo '
755 800
 								<ul class="floatright smalltext">
756 801
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
757 802
 								</ul>';
803
+	}
758 804
 
759 805
 	// What about likes?
760 806
 	if (!empty($modSettings['enable_likes']))
@@ -795,78 +841,91 @@  discard block
 block discarded – undo
795 841
 								<ul class="quickbuttons">';
796 842
 
797 843
 		// Can they quote? if so they can select and quote as well!
798
-		if ($context['can_quote'])
799
-			echo '
844
+		if ($context['can_quote']) {
845
+					echo '
800 846
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
801 847
 									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>';
848
+		}
802 849
 
803 850
 		// Can the user modify the contents of this post? Show the modify inline image.
804
-		if ($message['can_modify'])
805
-			echo '
851
+		if ($message['can_modify']) {
852
+					echo '
806 853
 									<li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>';
854
+		}
807 855
 
808
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
809
-			echo '
856
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
857
+					echo '
810 858
 									<li class="post_options">', $txt['post_options'];
859
+		}
811 860
 
812 861
 		echo '
813 862
 										<ul>';
814 863
 
815 864
 		// Can the user modify the contents of this post?
816
-		if ($message['can_modify'])
817
-			echo '
865
+		if ($message['can_modify']) {
866
+					echo '
818 867
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
868
+		}
819 869
 
820 870
 		// How about... even... remove it entirely?!
821
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
822
-			echo '
871
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
872
+					echo '
823 873
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>';
824
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
825
-			echo '
874
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
875
+					echo '
826 876
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
877
+		}
827 878
 
828 879
 		// What about splitting it off the rest of the topic?
829
-		if ($context['can_split'] && !empty($context['real_num_replies']))
830
-			echo '
880
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
881
+					echo '
831 882
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
883
+		}
832 884
 
833 885
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
834
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
835
-			echo '
886
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
887
+					echo '
836 888
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
889
+		}
837 890
 
838 891
 		// Can we restore topics?
839
-		if ($context['can_restore_msg'])
840
-			echo '
892
+		if ($context['can_restore_msg']) {
893
+					echo '
841 894
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
895
+		}
842 896
 
843 897
 		// Maybe we can approve it, maybe we should?
844
-		if ($message['can_approve'])
845
-			echo '
898
+		if ($message['can_approve']) {
899
+					echo '
846 900
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
901
+		}
847 902
 
848 903
 		// Maybe we can unapprove it?
849
-		if ($message['can_unapprove'])
850
-			echo '
904
+		if ($message['can_unapprove']) {
905
+					echo '
851 906
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
907
+		}
852 908
 
853 909
 		echo '
854 910
 										</ul>
855 911
 									</li>';
856 912
 
857 913
 		// Show a checkbox for quick moderation?
858
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
859
-			echo '
914
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
915
+					echo '
860 916
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
917
+		}
861 918
 
862
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
863
-			echo '
919
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
920
+					echo '
864 921
 								</ul>';
922
+		}
865 923
 	}
866 924
 
867
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
868
-	echo '
925
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
926
+		echo '
869 927
 							</div>';
928
+	}
870 929
 
871 930
 	echo '
872 931
 						</div>
@@ -879,9 +938,10 @@  discard block
 block discarded – undo
879 938
 							<div class="custom_fields_above_signature">
880 939
 								<ul class="nolist">';
881 940
 
882
-		foreach ($message['custom_fields']['above_signature'] as $custom)
883
-			echo '
941
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
942
+					echo '
884 943
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
944
+		}
885 945
 
886 946
 		echo '
887 947
 								</ul>
@@ -889,9 +949,10 @@  discard block
 block discarded – undo
889 949
 	}
890 950
 
891 951
 	// Show the member's signature?
892
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
893
-		echo '
952
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
953
+			echo '
894 954
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
955
+	}
895 956
 
896 957
 
897 958
 	// Are there any custom profile fields for below the signature?
@@ -901,9 +962,10 @@  discard block
 block discarded – undo
901 962
 							<div class="custom_fields_below_signature">
902 963
 								<ul class="nolist">';
903 964
 
904
-		foreach ($message['custom_fields']['below_signature'] as $custom)
905
-			echo '
965
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
966
+					echo '
906 967
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
968
+		}
907 969
 
908 970
 		echo '
909 971
 								</ul>
@@ -951,8 +1013,8 @@  discard block
 block discarded – undo
951 1013
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
952 1014
 
953 1015
 		// Guests just need more.
954
-		if ($context['user']['is_guest'])
955
-			echo '
1016
+		if ($context['user']['is_guest']) {
1017
+					echo '
956 1018
 						<dl id="post_header">
957 1019
 							<dt>
958 1020
 								', $txt['name'], ':
@@ -967,6 +1029,7 @@  discard block
 block discarded – undo
967 1029
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
968 1030
 							</dd>
969 1031
 						</dl>';
1032
+		}
970 1033
 
971 1034
 		echo '
972 1035
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1014,8 +1077,8 @@  discard block
 block discarded – undo
1014 1077
 		<br class="clear">';
1015 1078
 
1016 1079
 	// draft autosave available and the user has it enabled?
1017
-	if (!empty($context['drafts_autosave']))
1018
-		echo '
1080
+	if (!empty($context['drafts_autosave'])) {
1081
+			echo '
1019 1082
 			<script>
1020 1083
 				var oDraftAutoSave = new smf_DraftAutoSave({
1021 1084
 					sSelf: \'oDraftAutoSave\',
@@ -1027,10 +1090,12 @@  discard block
 block discarded – undo
1027 1090
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1028 1091
 				});
1029 1092
 			</script>';
1093
+	}
1030 1094
 
1031
-	if ($context['show_spellchecking'])
1032
-		echo '
1095
+	if ($context['show_spellchecking']) {
1096
+			echo '
1033 1097
 			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
1098
+	}
1034 1099
 
1035 1100
 	echo '
1036 1101
 				<script>
Please login to merge, or discard this patch.