Completed
Pull Request — release-2.1 (#3761)
by Rick
14:55 queued 08:11
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;
@@ -2128,6 +2134,9 @@  discard block
 block discarded – undo
2128 2134
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
2129 2135
 }
2130 2136
 
2137
+/**
2138
+ * @param string $filename
2139
+ */
2131 2140
 function parse_sql($filename)
2132 2141
 {
2133 2142
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -2414,6 +2423,9 @@  discard block
 block discarded – undo
2414 2423
 	return true;
2415 2424
 }
2416 2425
 
2426
+/**
2427
+ * @param string $string
2428
+ */
2417 2429
 function upgrade_query($string, $unbuffered = false)
2418 2430
 {
2419 2431
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -3043,6 +3055,9 @@  discard block
 block discarded – undo
3043 3055
 	$upcontext['current_step'] = 1;
3044 3056
 }
3045 3057
 
3058
+/**
3059
+ * @param string $message
3060
+ */
3046 3061
 function print_error($message, $fatal = false)
3047 3062
 {
3048 3063
 	static $fp = null;
@@ -3056,6 +3071,9 @@  discard block
 block discarded – undo
3056 3071
 		exit;
3057 3072
 }
3058 3073
 
3074
+/**
3075
+ * @param string $message
3076
+ */
3059 3077
 function throw_error($message)
3060 3078
 {
3061 3079
 	global $upcontext;
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -3489,95 +3489,95 @@
 block discarded – undo
3489 3489
 		// Translation table for the character sets not native for MySQL.
3490 3490
 		$translation_tables = array(
3491 3491
 			'windows-1255' => array(
3492
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
3493
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
3494
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
3495
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
3496
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
3497
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
3498
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '\'\'',
3499
-				'0xFC' => '\'\'',		'0xFF' => '\'\'',		'0xC2' => '0xFF',
3500
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
3501
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
3502
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3503
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3504
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3505
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
3506
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
3507
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3508
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
3509
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
3510
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
3511
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
3512
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
3513
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
3514
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
3515
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
3516
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
3517
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3518
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
3519
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3520
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
3521
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
3522
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
3523
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
3524
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
3525
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
3526
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
3527
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
3528
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
3529
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
3530
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
3531
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
3532
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
3533
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
3534
-				'0xFA' => '0xD7AA',		'0xFF' => '0xD6B2',		'0xFC' => '0xE282AC',
3492
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
3493
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
3494
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
3495
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
3496
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
3497
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
3498
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '\'\'',
3499
+				'0xFC' => '\'\'', '0xFF' => '\'\'', '0xC2' => '0xFF',
3500
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
3501
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
3502
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3503
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3504
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3505
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
3506
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
3507
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3508
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
3509
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
3510
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
3511
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
3512
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
3513
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
3514
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
3515
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
3516
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
3517
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3518
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
3519
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3520
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
3521
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
3522
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
3523
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
3524
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
3525
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
3526
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
3527
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
3528
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
3529
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
3530
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
3531
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
3532
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
3533
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
3534
+				'0xFA' => '0xD7AA', '0xFF' => '0xD6B2', '0xFC' => '0xE282AC',
3535 3535
 				'0xFB' => '0xD792',
3536 3536
 			),
3537 3537
 			'windows-1253' => array(
3538
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
3539
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
3540
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
3541
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
3542
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
3543
-				'0xD2' => '\'\'',			'0xFF' => '\'\'',			'0xCE' => '0xCE9E',
3544
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
3545
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
3546
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
3547
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
3548
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
3549
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
3550
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
3551
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
3552
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3553
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3554
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3555
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
3556
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3557
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
3558
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3559
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
3560
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
3561
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
3562
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3563
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
3564
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
3565
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
3566
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
3567
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
3568
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
3569
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
3570
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
3571
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
3572
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
3573
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
3574
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
3575
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
3576
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
3577
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
3578
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
3579
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
3580
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',		'0xFF' => '0xCE92',
3538
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
3539
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
3540
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
3541
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
3542
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
3543
+				'0xD2' => '\'\'', '0xFF' => '\'\'', '0xCE' => '0xCE9E',
3544
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
3545
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
3546
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
3547
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
3548
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
3549
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
3550
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
3551
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
3552
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3553
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3554
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3555
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
3556
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3557
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
3558
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3559
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
3560
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
3561
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
3562
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3563
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
3564
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
3565
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
3566
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
3567
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
3568
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
3569
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
3570
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
3571
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
3572
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
3573
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
3574
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
3575
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
3576
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
3577
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
3578
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
3579
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
3580
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E', '0xFF' => '0xCE92',
3581 3581
 				'0xD2' => '0xE282AC',
3582 3582
 			),
3583 3583
 		);
Please login to merge, or discard this patch.
Braces   +1107 added lines, -811 removed lines patch added patch discarded remove patch
@@ -68,11 +68,14 @@  discard block
 block discarded – undo
68 68
 	ini_set('default_socket_timeout', 900);
69 69
 }
70 70
 // Clean the upgrade path if this is from the client.
71
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
72
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
71
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
72
+	for ($i = 1;
73
+}
74
+$i < $_SERVER['argc']; $i++)
73 75
 	{
74
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
75
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
76
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
77
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
78
+		}
76 79
 	}
77 80
 
78 81
 // Are we from the client?
@@ -80,9 +83,9 @@  discard block
 block discarded – undo
80 83
 {
81 84
 	$command_line = true;
82 85
 	$disable_security = 1;
83
-}
84
-else
86
+} else {
85 87
 	$command_line = false;
88
+}
86 89
 
87 90
 // Load this now just because we can.
88 91
 require_once($upgrade_path . '/Settings.php');
@@ -93,10 +96,12 @@  discard block
 block discarded – undo
93 96
 	$upcontext['user'] = unserialize(base64_decode($upgradeData));
94 97
 
95 98
 	// Check for sensible values.
96
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
97
-		$upcontext['user']['started'] = time();
98
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
99
-		$upcontext['user']['updated'] = 0;
99
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
100
+			$upcontext['user']['started'] = time();
101
+	}
102
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
103
+			$upcontext['user']['updated'] = 0;
104
+	}
100 105
 
101 106
 	$upcontext['started'] = $upcontext['user']['started'];
102 107
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -159,8 +164,9 @@  discard block
 block discarded – undo
159 164
 		{
160 165
 			$word = trim($word, '-_\'');
161 166
 
162
-			if ($word != '')
163
-				$returned_words[] = substr($word, 0, 20);
167
+			if ($word != '') {
168
+							$returned_words[] = substr($word, 0, 20);
169
+			}
164 170
 		}
165 171
 
166 172
 		return array_unique($returned_words);
@@ -187,8 +193,9 @@  discard block
 block discarded – undo
187 193
 {
188 194
 	function md5_hmac($data, $key)
189 195
 	{
190
-		if (strlen($key) > 64)
191
-			$key = pack('H*', md5($key));
196
+		if (strlen($key) > 64) {
197
+					$key = pack('H*', md5($key));
198
+		}
192 199
 		$key = str_pad($key, 64, chr(0x00));
193 200
 
194 201
 		$k_ipad = $key ^ str_repeat(chr(0x36), 64);
@@ -199,8 +206,9 @@  discard block
 block discarded – undo
199 206
 }
200 207
 
201 208
 // Don't do security check if on Yabbse
202
-if (!isset($modSettings['smfVersion']))
209
+if (!isset($modSettings['smfVersion'])) {
203 210
 	$disable_security = true;
211
+}
204 212
 
205 213
 // This only exists if we're on SMF ;)
206 214
 if (isset($modSettings['smfVersion']))
@@ -218,8 +226,9 @@  discard block
 block discarded – undo
218 226
 			'db_error_skip' => true,
219 227
 		)
220 228
 	);
221
-	while ($row = $smcFunc['db_fetch_assoc']($request))
222
-		$modSettings[$row['variable']] = $row['value'];
229
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
230
+			$modSettings[$row['variable']] = $row['value'];
231
+	}
223 232
 	$smcFunc['db_free_result']($request);
224 233
 }
225 234
 
@@ -229,10 +238,12 @@  discard block
 block discarded – undo
229 238
 	$modSettings['theme_url'] = 'Themes/default';
230 239
 	$modSettings['images_url'] = 'Themes/default/images';
231 240
 }
232
-if (!isset($settings['default_theme_url']))
241
+if (!isset($settings['default_theme_url'])) {
233 242
 	$settings['default_theme_url'] = $modSettings['theme_url'];
234
-if (!isset($settings['default_theme_dir']))
243
+}
244
+if (!isset($settings['default_theme_dir'])) {
235 245
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
246
+}
236 247
 
237 248
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
238 249
 // Default title...
@@ -250,13 +261,15 @@  discard block
 block discarded – undo
250 261
 	$support_js = $upcontext['upgrade_status']['js'];
251 262
 
252 263
 	// Only set this if the upgrader status says so.
253
-	if (empty($is_debug))
254
-		$is_debug = $upcontext['upgrade_status']['debug'];
264
+	if (empty($is_debug)) {
265
+			$is_debug = $upcontext['upgrade_status']['debug'];
266
+	}
255 267
 
256 268
 	// Load the language.
257
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
258
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
259
-}
269
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
270
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
271
+	}
272
+	}
260 273
 // Set the defaults.
261 274
 else
262 275
 {
@@ -274,15 +287,18 @@  discard block
 block discarded – undo
274 287
 }
275 288
 
276 289
 // If this isn't the first stage see whether they are logging in and resuming.
277
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
290
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
278 291
 	checkLogin();
292
+}
279 293
 
280
-if ($command_line)
294
+if ($command_line) {
281 295
 	cmdStep0();
296
+}
282 297
 
283 298
 // Don't error if we're using xml.
284
-if (isset($_GET['xml']))
299
+if (isset($_GET['xml'])) {
285 300
 	$upcontext['return_error'] = true;
301
+}
286 302
 
287 303
 // Loop through all the steps doing each one as required.
288 304
 $upcontext['overall_percent'] = 0;
@@ -303,10 +319,11 @@  discard block
 block discarded – undo
303 319
 		}
304 320
 
305 321
 		// Call the step and if it returns false that means pause!
306
-		if (function_exists($step[2]) && $step[2]() === false)
307
-			break;
308
-		elseif (function_exists($step[2]))
309
-			$upcontext['current_step']++;
322
+		if (function_exists($step[2]) && $step[2]() === false) {
323
+					break;
324
+		} elseif (function_exists($step[2])) {
325
+					$upcontext['current_step']++;
326
+		}
310 327
 	}
311 328
 	$upcontext['overall_percent'] += $step[3];
312 329
 }
@@ -345,17 +362,18 @@  discard block
 block discarded – undo
345 362
 		// This should not happen my dear... HELP ME DEVELOPERS!!
346 363
 		if (!empty($command_line))
347 364
 		{
348
-			if (function_exists('debug_print_backtrace'))
349
-				debug_print_backtrace();
365
+			if (function_exists('debug_print_backtrace')) {
366
+							debug_print_backtrace();
367
+			}
350 368
 
351 369
 			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.';
352 370
 			flush();
353 371
 			die();
354 372
 		}
355 373
 
356
-		if (!isset($_GET['xml']))
357
-			template_upgrade_above();
358
-		else
374
+		if (!isset($_GET['xml'])) {
375
+					template_upgrade_above();
376
+		} else
359 377
 		{
360 378
 			header('Content-Type: text/xml; charset=UTF-8');
361 379
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -377,21 +395,24 @@  discard block
 block discarded – undo
377 395
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(safe_serialize($upcontext['upgrade_status']));
378 396
 
379 397
 			// Custom stuff to pass back?
380
-			if (!empty($upcontext['query_string']))
381
-				$upcontext['form_url'] .= $upcontext['query_string'];
398
+			if (!empty($upcontext['query_string'])) {
399
+							$upcontext['form_url'] .= $upcontext['query_string'];
400
+			}
382 401
 
383 402
 			call_user_func('template_' . $upcontext['sub_template']);
384 403
 		}
385 404
 
386 405
 		// Was there an error?
387
-		if (!empty($upcontext['forced_error_message']))
388
-			echo $upcontext['forced_error_message'];
406
+		if (!empty($upcontext['forced_error_message'])) {
407
+					echo $upcontext['forced_error_message'];
408
+		}
389 409
 
390 410
 		// Show the footer.
391
-		if (!isset($_GET['xml']))
392
-			template_upgrade_below();
393
-		else
394
-			template_xml_below();
411
+		if (!isset($_GET['xml'])) {
412
+					template_upgrade_below();
413
+		} else {
414
+					template_xml_below();
415
+		}
395 416
 	}
396 417
 
397 418
 
@@ -403,15 +424,19 @@  discard block
 block discarded – undo
403 424
 		$seconds = intval($active % 60);
404 425
 
405 426
 		$totalTime = '';
406
-		if ($hours > 0)
407
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
408
-		if ($minutes > 0)
409
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
410
-		if ($seconds > 0)
411
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
427
+		if ($hours > 0) {
428
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
429
+		}
430
+		if ($minutes > 0) {
431
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
432
+		}
433
+		if ($seconds > 0) {
434
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
435
+		}
412 436
 
413
-		if (!empty($totalTime))
414
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
437
+		if (!empty($totalTime)) {
438
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
439
+		}
415 440
 	}
416 441
 
417 442
 	// Bang - gone!
@@ -424,8 +449,9 @@  discard block
 block discarded – undo
424 449
 	global $upgradeurl, $upcontext, $command_line;
425 450
 
426 451
 	// Command line users can't be redirected.
427
-	if ($command_line)
428
-		upgradeExit(true);
452
+	if ($command_line) {
453
+			upgradeExit(true);
454
+	}
429 455
 
430 456
 	// Are we providing the core info?
431 457
 	if ($addForm)
@@ -448,19 +474,22 @@  discard block
 block discarded – undo
448 474
 	global $modSettings, $sourcedir, $smcFunc;
449 475
 
450 476
 	// Do the non-SSI stuff...
451
-	if (function_exists('set_magic_quotes_runtime'))
452
-		@set_magic_quotes_runtime(0);
477
+	if (function_exists('set_magic_quotes_runtime')) {
478
+			@set_magic_quotes_runtime(0);
479
+	}
453 480
 
454 481
 	error_reporting(E_ALL);
455 482
 	define('SMF', 1);
456 483
 
457 484
 	// Start the session.
458
-	if (@ini_get('session.save_handler') == 'user')
459
-		@ini_set('session.save_handler', 'files');
485
+	if (@ini_get('session.save_handler') == 'user') {
486
+			@ini_set('session.save_handler', 'files');
487
+	}
460 488
 	@session_start();
461 489
 
462
-	if (empty($smcFunc))
463
-		$smcFunc = array();
490
+	if (empty($smcFunc)) {
491
+			$smcFunc = array();
492
+	}
464 493
 
465 494
 	// We need this for authentication and some upgrade code
466 495
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -473,8 +502,9 @@  discard block
 block discarded – undo
473 502
 	initialize_inputs();
474 503
 
475 504
 	// Get the database going!
476
-	if (empty($db_type))
477
-		$db_type = 'mysql';
505
+	if (empty($db_type)) {
506
+			$db_type = 'mysql';
507
+	}
478 508
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
479 509
 	{
480 510
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -483,17 +513,19 @@  discard block
 block discarded – undo
483 513
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
484 514
 
485 515
 		// Oh dear god!!
486
-		if ($db_connection === null)
487
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
516
+		if ($db_connection === null) {
517
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
518
+		}
488 519
 
489
-		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
490
-			$smcFunc['db_query']('', '
520
+		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
521
+					$smcFunc['db_query']('', '
491 522
 			SET NAMES {string:db_character_set}',
492 523
 			array(
493 524
 				'db_error_skip' => true,
494 525
 				'db_character_set' => $db_character_set,
495 526
 			)
496 527
 		);
528
+		}
497 529
 
498 530
 		// Load the modSettings data...
499 531
 		$request = $smcFunc['db_query']('', '
@@ -504,11 +536,11 @@  discard block
 block discarded – undo
504 536
 			)
505 537
 		);
506 538
 		$modSettings = array();
507
-		while ($row = $smcFunc['db_fetch_assoc']($request))
508
-			$modSettings[$row['variable']] = $row['value'];
539
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+					$modSettings[$row['variable']] = $row['value'];
541
+		}
509 542
 		$smcFunc['db_free_result']($request);
510
-	}
511
-	else
543
+	} else
512 544
 	{
513 545
 		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.');
514 546
 	}
@@ -522,9 +554,10 @@  discard block
 block discarded – undo
522 554
 		cleanRequest();
523 555
 	}
524 556
 
525
-	if (!isset($_GET['substep']))
526
-		$_GET['substep'] = 0;
527
-}
557
+	if (!isset($_GET['substep'])) {
558
+			$_GET['substep'] = 0;
559
+	}
560
+	}
528 561
 
529 562
 function initialize_inputs()
530 563
 {
@@ -562,8 +595,9 @@  discard block
 block discarded – undo
562 595
 		$dh = opendir(dirname(__FILE__));
563 596
 		while ($file = readdir($dh))
564 597
 		{
565
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
566
-				@unlink(dirname(__FILE__) . '/' . $file);
598
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
599
+							@unlink(dirname(__FILE__) . '/' . $file);
600
+			}
567 601
 		}
568 602
 		closedir($dh);
569 603
 
@@ -593,8 +627,9 @@  discard block
 block discarded – undo
593 627
 	{
594 628
 		$upcontext['remote_files_available'] = false;
595 629
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
596
-		if ($test)
597
-			$upcontext['remote_files_available'] = true;
630
+		if ($test) {
631
+					$upcontext['remote_files_available'] = true;
632
+		}
598 633
 		@fclose($test);
599 634
 	}
600 635
 
@@ -602,8 +637,9 @@  discard block
 block discarded – undo
602 637
 	$temp = 'upgrade_php?step';
603 638
 	while (strlen($temp) > 4)
604 639
 	{
605
-		if (isset($_GET[$temp]))
606
-			unset($_GET[$temp]);
640
+		if (isset($_GET[$temp])) {
641
+					unset($_GET[$temp]);
642
+		}
607 643
 		$temp = substr($temp, 1);
608 644
 	}
609 645
 
@@ -629,29 +665,36 @@  discard block
 block discarded – undo
629 665
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql');
630 666
 
631 667
 	// Need legacy scripts?
632
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
633
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
634
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
635
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
636
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
637
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
668
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
669
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
670
+	}
671
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
672
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
673
+	}
674
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
675
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
676
+	}
638 677
 
639 678
 	// This needs to exist!
640
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
641
-		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>]');
642
-	else
643
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
679
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
680
+			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>]');
681
+	} else {
682
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
683
+	}
644 684
 
645
-	if (!$check)
646
-		// 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.
685
+	if (!$check) {
686
+			// 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.
647 687
 		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.');
688
+	}
648 689
 
649 690
 	// Do they meet the install requirements?
650
-	if (!php_version_check())
651
-		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.');
691
+	if (!php_version_check()) {
692
+			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.');
693
+	}
652 694
 
653
-	if (!db_version_check())
654
-		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.');
695
+	if (!db_version_check()) {
696
+			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.');
697
+	}
655 698
 
656 699
 	// Do some checks to make sure they have proper privileges
657 700
 	db_extend('packages');
@@ -666,14 +709,16 @@  discard block
 block discarded – undo
666 709
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
667 710
 
668 711
 	// Sorry... we need CREATE, ALTER and DROP
669
-	if (!$create || !$alter || !$drop)
670
-		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.');
712
+	if (!$create || !$alter || !$drop) {
713
+			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.');
714
+	}
671 715
 
672 716
 	// Do a quick version spot check.
673 717
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
674 718
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
675
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
676
-		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.');
719
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
720
+			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.');
721
+	}
677 722
 
678 723
 	// What absolutely needs to be writable?
679 724
 	$writable_files = array(
@@ -695,12 +740,13 @@  discard block
 block discarded – undo
695 740
 	quickFileWritable($custom_av_dir);
696 741
 
697 742
 	// Are we good now?
698
-	if (!is_writable($custom_av_dir))
699
-		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));
700
-	elseif ($need_settings_update)
743
+	if (!is_writable($custom_av_dir)) {
744
+			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));
745
+	} elseif ($need_settings_update)
701 746
 	{
702
-		if (!function_exists('cache_put_data'))
703
-			require_once($sourcedir . '/Load.php');
747
+		if (!function_exists('cache_put_data')) {
748
+					require_once($sourcedir . '/Load.php');
749
+		}
704 750
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
705 751
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
706 752
 	}
@@ -709,28 +755,33 @@  discard block
 block discarded – undo
709 755
 
710 756
 	// Check the cache directory.
711 757
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
712
-	if (!file_exists($cachedir_temp))
713
-		@mkdir($cachedir_temp);
714
-	if (!file_exists($cachedir_temp))
715
-		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.');
716
-
717
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
718
-		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>.');
719
-	elseif (!isset($_GET['skiplang']))
758
+	if (!file_exists($cachedir_temp)) {
759
+			@mkdir($cachedir_temp);
760
+	}
761
+	if (!file_exists($cachedir_temp)) {
762
+			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.');
763
+	}
764
+
765
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
766
+			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>.');
767
+	} elseif (!isset($_GET['skiplang']))
720 768
 	{
721 769
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
722 770
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
723 771
 
724
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
725
-			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>]');
772
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
773
+					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>]');
774
+		}
726 775
 	}
727 776
 
728
-	if (!makeFilesWritable($writable_files))
729
-		return false;
777
+	if (!makeFilesWritable($writable_files)) {
778
+			return false;
779
+	}
730 780
 
731 781
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
732
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
733
-		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.');
782
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
783
+			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.');
784
+	}
734 785
 
735 786
 	// Upgrade the agreement.
736 787
 	elseif (isset($modSettings['agreement']))
@@ -741,8 +792,8 @@  discard block
 block discarded – undo
741 792
 	}
742 793
 
743 794
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
744
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
745
-		$upcontext['warning'] = '
795
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
796
+			$upcontext['warning'] = '
746 797
 			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>
747 798
 			<ul>
748 799
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -750,10 +801,12 @@  discard block
 block discarded – undo
750 801
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
751 802
 			</ul>
752 803
 			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.';
804
+	}
753 805
 
754 806
 	// Either we're logged in or we're going to present the login.
755
-	if (checkLogin())
756
-		return true;
807
+	if (checkLogin()) {
808
+			return true;
809
+	}
757 810
 
758 811
 	$upcontext += createToken('login');
759 812
 
@@ -770,8 +823,9 @@  discard block
 block discarded – undo
770 823
 	if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security))
771 824
 	{
772 825
 		// If we've disabled security pick a suitable name!
773
-		if (empty($_POST['user']))
774
-			$_POST['user'] = 'Administrator';
826
+		if (empty($_POST['user'])) {
827
+					$_POST['user'] = 'Administrator';
828
+		}
775 829
 
776 830
 		// Before 2.0 these column names were different!
777 831
 		$oldDB = false;
@@ -786,16 +840,17 @@  discard block
 block discarded – undo
786 840
 					'db_error_skip' => true,
787 841
 				)
788 842
 			);
789
-			if ($smcFunc['db_num_rows']($request) != 0)
790
-				$oldDB = true;
843
+			if ($smcFunc['db_num_rows']($request) != 0) {
844
+							$oldDB = true;
845
+			}
791 846
 			$smcFunc['db_free_result']($request);
792 847
 		}
793 848
 
794 849
 		// Get what we believe to be their details.
795 850
 		if (!$disable_security)
796 851
 		{
797
-			if ($oldDB)
798
-				$request = $smcFunc['db_query']('', '
852
+			if ($oldDB) {
853
+							$request = $smcFunc['db_query']('', '
799 854
 					SELECT id_member, memberName AS member_name, passwd, id_group,
800 855
 					additionalGroups AS additional_groups, lngfile
801 856
 					FROM {db_prefix}members
@@ -805,8 +860,8 @@  discard block
 block discarded – undo
805 860
 						'db_error_skip' => true,
806 861
 					)
807 862
 				);
808
-			else
809
-				$request = $smcFunc['db_query']('', '
863
+			} else {
864
+							$request = $smcFunc['db_query']('', '
810 865
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
811 866
 					FROM {db_prefix}members
812 867
 					WHERE member_name = {string:member_name}',
@@ -815,6 +870,7 @@  discard block
 block discarded – undo
815 870
 						'db_error_skip' => true,
816 871
 					)
817 872
 				);
873
+			}
818 874
 			if ($smcFunc['db_num_rows']($request) != 0)
819 875
 			{
820 876
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -822,13 +878,14 @@  discard block
 block discarded – undo
822 878
 				$groups = explode(',', $addGroups);
823 879
 				$groups[] = $id_group;
824 880
 
825
-				foreach ($groups as $k => $v)
826
-					$groups[$k] = (int) $v;
881
+				foreach ($groups as $k => $v) {
882
+									$groups[$k] = (int) $v;
883
+				}
827 884
 
828 885
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
886
+			} else {
887
+							$upcontext['username_incorrect'] = true;
829 888
 			}
830
-			else
831
-				$upcontext['username_incorrect'] = true;
832 889
 			$smcFunc['db_free_result']($request);
833 890
 		}
834 891
 		$upcontext['username'] = $_POST['user'];
@@ -838,13 +895,14 @@  discard block
 block discarded – undo
838 895
 		{
839 896
 			$upcontext['upgrade_status']['js'] = 1;
840 897
 			$support_js = 1;
898
+		} else {
899
+					$support_js = 0;
841 900
 		}
842
-		else
843
-			$support_js = 0;
844 901
 
845 902
 		// Note down the version we are coming from.
846
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
847
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
903
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
904
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
905
+		}
848 906
 
849 907
 		// Didn't get anywhere?
850 908
 		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']))
@@ -878,15 +936,15 @@  discard block
 block discarded – undo
878 936
 							'db_error_skip' => true,
879 937
 						)
880 938
 					);
881
-					if ($smcFunc['db_num_rows']($request) == 0)
882
-						return throw_error('You need to be an admin to perform an upgrade!');
939
+					if ($smcFunc['db_num_rows']($request) == 0) {
940
+											return throw_error('You need to be an admin to perform an upgrade!');
941
+					}
883 942
 					$smcFunc['db_free_result']($request);
884 943
 				}
885 944
 
886 945
 				$upcontext['user']['id'] = $id_member;
887 946
 				$upcontext['user']['name'] = $name;
888
-			}
889
-			else
947
+			} else
890 948
 			{
891 949
 				$upcontext['user']['id'] = 1;
892 950
 				$upcontext['user']['name'] = 'Administrator';
@@ -902,11 +960,11 @@  discard block
 block discarded – undo
902 960
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
903 961
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
904 962
 
905
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
906
-					$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'] . '.';
907
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
908
-					$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'] . '.';
909
-				else
963
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
964
+									$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'] . '.';
965
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
966
+									$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'] . '.';
967
+				} else
910 968
 				{
911 969
 					// Set this as the new language.
912 970
 					$upcontext['language'] = $user_language;
@@ -950,8 +1008,9 @@  discard block
 block discarded – undo
950 1008
 	unset($member_columns);
951 1009
 
952 1010
 	// If we've not submitted then we're done.
953
-	if (empty($_POST['upcont']))
954
-		return false;
1011
+	if (empty($_POST['upcont'])) {
1012
+			return false;
1013
+	}
955 1014
 
956 1015
 	require_once($sourcedir . '/Subs-Admin.php');
957 1016
 	updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\''));
@@ -969,25 +1028,26 @@  discard block
 block discarded – undo
969 1028
 			fwrite($fp, $out);
970 1029
 
971 1030
 			$return_data = '';
972
-			while (!feof($fp))
973
-				$return_data .= fgets($fp, 128);
1031
+			while (!feof($fp)) {
1032
+							$return_data .= fgets($fp, 128);
1033
+			}
974 1034
 
975 1035
 			fclose($fp);
976 1036
 
977 1037
 			// Get the unique site ID.
978 1038
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
979 1039
 
980
-			if (!empty($ID[1]))
981
-				$smcFunc['db_insert']('replace',
1040
+			if (!empty($ID[1])) {
1041
+							$smcFunc['db_insert']('replace',
982 1042
 					$db_prefix . 'settings',
983 1043
 					array('variable' => 'string', 'value' => 'string'),
984 1044
 					array('allow_sm_stats', $ID[1]),
985 1045
 					array('variable')
986 1046
 				);
1047
+			}
987 1048
 		}
988
-	}
989
-	else
990
-		$smcFunc['db_query']('', '
1049
+	} else {
1050
+			$smcFunc['db_query']('', '
991 1051
 			DELETE FROM {db_prefix}settings
992 1052
 			WHERE variable = {string:allow_sm_stats}',
993 1053
 			array(
@@ -995,6 +1055,7 @@  discard block
 block discarded – undo
995 1055
 				'db_error_skip' => true,
996 1056
 			)
997 1057
 		);
1058
+	}
998 1059
 
999 1060
 	// Deleting old karma stuff?
1000 1061
 	if (!empty($_POST['delete_karma']))
@@ -1009,20 +1070,22 @@  discard block
 block discarded – undo
1009 1070
 		);
1010 1071
 
1011 1072
 		// Cleaning up old karma member settings.
1012
-		if ($upcontext['karma_installed']['good'])
1013
-			$smcFunc['db_query']('', '
1073
+		if ($upcontext['karma_installed']['good']) {
1074
+					$smcFunc['db_query']('', '
1014 1075
 				ALTER TABLE {db_prefix}members
1015 1076
 				DROP karma_good',
1016 1077
 				array()
1017 1078
 			);
1079
+		}
1018 1080
 
1019 1081
 		// Does karma bad was enable?
1020
-		if ($upcontext['karma_installed']['bad'])
1021
-			$smcFunc['db_query']('', '
1082
+		if ($upcontext['karma_installed']['bad']) {
1083
+					$smcFunc['db_query']('', '
1022 1084
 				ALTER TABLE {db_prefix}members
1023 1085
 				DROP karma_bad',
1024 1086
 				array()
1025 1087
 			);
1088
+		}
1026 1089
 
1027 1090
 		// Cleaning up old karma permissions.
1028 1091
 		$smcFunc['db_query']('', '
@@ -1035,18 +1098,20 @@  discard block
 block discarded – undo
1035 1098
 	}
1036 1099
 
1037 1100
 	// Emptying the error log?
1038
-	if (!empty($_POST['empty_error']))
1039
-		$smcFunc['db_query']('truncate_table', '
1101
+	if (!empty($_POST['empty_error'])) {
1102
+			$smcFunc['db_query']('truncate_table', '
1040 1103
 			TRUNCATE {db_prefix}log_errors',
1041 1104
 			array(
1042 1105
 			)
1043 1106
 		);
1107
+	}
1044 1108
 
1045 1109
 	$changes = array();
1046 1110
 
1047 1111
 	// If we're overriding the language follow it through.
1048
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1049
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1112
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1113
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1114
+	}
1050 1115
 
1051 1116
 	if (!empty($_POST['maint']))
1052 1117
 	{
@@ -1058,37 +1123,42 @@  discard block
 block discarded – undo
1058 1123
 		{
1059 1124
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1060 1125
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1061
-		}
1062
-		else
1126
+		} else
1063 1127
 		{
1064 1128
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1065 1129
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1066 1130
 		}
1067 1131
 	}
1068 1132
 
1069
-	if ($command_line)
1070
-		echo ' * Updating Settings.php...';
1133
+	if ($command_line) {
1134
+			echo ' * Updating Settings.php...';
1135
+	}
1071 1136
 
1072 1137
 	// Backup the current one first.
1073 1138
 	copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
1074 1139
 
1075 1140
 	// Fix some old paths.
1076
-	if (substr($boarddir, 0, 1) == '.')
1077
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1141
+	if (substr($boarddir, 0, 1) == '.') {
1142
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1143
+	}
1078 1144
 
1079
-	if (substr($sourcedir, 0, 1) == '.')
1080
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1145
+	if (substr($sourcedir, 0, 1) == '.') {
1146
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1147
+	}
1081 1148
 
1082
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1083
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1149
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1150
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1151
+	}
1084 1152
 
1085 1153
 	// Not had the database type added before?
1086
-	if (empty($db_type))
1087
-		$changes['db_type'] = 'mysql';
1154
+	if (empty($db_type)) {
1155
+			$changes['db_type'] = 'mysql';
1156
+	}
1088 1157
 
1089 1158
 	// For now we offer a option, this may change in future versions when mysql is completely removed.
1090
-	if (!empty($_POST['convertMysql']) && $db_type == 'mysql')
1091
-		$changes['db_type'] = '\'mysqli\'';
1159
+	if (!empty($_POST['convertMysql']) && $db_type == 'mysql') {
1160
+			$changes['db_type'] = '\'mysqli\'';
1161
+	}
1092 1162
 
1093 1163
 	// If they have a "host:port" setup for the host, split that into separate values
1094 1164
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1099,28 +1169,31 @@  discard block
 block discarded – undo
1099 1169
 		$changes['db_server'] = '\'' . $db_server . '\'';
1100 1170
 
1101 1171
 		// Only set this if we're not using the default port
1102
-		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1103
-			$changes['db_port'] = (int) $db_port;
1104
-	}
1105
-	elseif (!empty($db_port))
1172
+		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1173
+					$changes['db_port'] = (int) $db_port;
1174
+		}
1175
+	} elseif (!empty($db_port))
1106 1176
 	{
1107 1177
 		// If db_port is set and is the same as the default, set it to ''
1108 1178
 		if ($db_type == 'mysql' || $db_type == 'mysqli')
1109 1179
 		{
1110
-			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1111
-				$changes['db_port'] = '\'\'';
1112
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1113
-				$changes['db_port'] = '\'\'';
1180
+			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1181
+							$changes['db_port'] = '\'\'';
1182
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1183
+							$changes['db_port'] = '\'\'';
1184
+			}
1114 1185
 		}
1115 1186
 	}
1116 1187
 
1117 1188
 	// Maybe we haven't had this option yet?
1118
-	if (empty($packagesdir))
1119
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1189
+	if (empty($packagesdir)) {
1190
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1191
+	}
1120 1192
 
1121 1193
 	// Add support for $tasksdir var.
1122
-	if (empty($tasksdir))
1123
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1194
+	if (empty($tasksdir)) {
1195
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1196
+	}
1124 1197
 
1125 1198
 	// @todo Maybe change the cookie name if going to 1.1, too?
1126 1199
 
@@ -1165,8 +1238,7 @@  discard block
 block discarded – undo
1165 1238
 			$found_old = true;
1166 1239
 			// Replace the old line with the new code
1167 1240
 			$settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file);
1168
-		}
1169
-		else
1241
+		} else
1170 1242
 		{
1171 1243
 			$found_old = false;
1172 1244
 			// We want the comments as well as the code...
@@ -1197,8 +1269,9 @@  discard block
 block discarded – undo
1197 1269
 		fclose($file);
1198 1270
 	}
1199 1271
 
1200
-	if ($command_line)
1201
-		echo ' Successful.' . "\n";
1272
+	if ($command_line) {
1273
+			echo ' Successful.' . "\n";
1274
+	}
1202 1275
 
1203 1276
 	// Are we doing debug?
1204 1277
 	if (isset($_POST['debug']))
@@ -1208,8 +1281,9 @@  discard block
 block discarded – undo
1208 1281
 	}
1209 1282
 
1210 1283
 	// If we're not backing up then jump one.
1211
-	if (empty($_POST['backup']))
1212
-		$upcontext['current_step']++;
1284
+	if (empty($_POST['backup'])) {
1285
+			$upcontext['current_step']++;
1286
+	}
1213 1287
 
1214 1288
 	// If we've got here then let's proceed to the next step!
1215 1289
 	return true;
@@ -1224,8 +1298,9 @@  discard block
 block discarded – undo
1224 1298
 	$upcontext['page_title'] = 'Backup Database';
1225 1299
 
1226 1300
 	// Done it already - js wise?
1227
-	if (!empty($_POST['backup_done']))
1228
-		return true;
1301
+	if (!empty($_POST['backup_done'])) {
1302
+			return true;
1303
+	}
1229 1304
 
1230 1305
 	// Some useful stuff here.
1231 1306
 	db_extend();
@@ -1239,9 +1314,10 @@  discard block
 block discarded – undo
1239 1314
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1240 1315
 
1241 1316
 	$table_names = array();
1242
-	foreach ($tables as $table)
1243
-		if (substr($table, 0, 7) !== 'backup_')
1317
+	foreach ($tables as $table) {
1318
+			if (substr($table, 0, 7) !== 'backup_')
1244 1319
 			$table_names[] = $table;
1320
+	}
1245 1321
 
1246 1322
 	$upcontext['table_count'] = count($table_names);
1247 1323
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1251,12 +1327,14 @@  discard block
 block discarded – undo
1251 1327
 	$file_steps = $upcontext['table_count'];
1252 1328
 
1253 1329
 	// What ones have we already done?
1254
-	foreach ($table_names as $id => $table)
1255
-		if ($id < $_GET['substep'])
1330
+	foreach ($table_names as $id => $table) {
1331
+			if ($id < $_GET['substep'])
1256 1332
 			$upcontext['previous_tables'][] = $table;
1333
+	}
1257 1334
 
1258
-	if ($command_line)
1259
-		echo 'Backing Up Tables.';
1335
+	if ($command_line) {
1336
+			echo 'Backing Up Tables.';
1337
+	}
1260 1338
 
1261 1339
 	// If we don't support javascript we backup here.
1262 1340
 	if (!$support_js || isset($_GET['xml']))
@@ -1275,8 +1353,9 @@  discard block
 block discarded – undo
1275 1353
 			backupTable($table_names[$substep]);
1276 1354
 
1277 1355
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1278
-			if (isset($_GET['xml']))
1279
-				return upgradeExit();
1356
+			if (isset($_GET['xml'])) {
1357
+							return upgradeExit();
1358
+			}
1280 1359
 		}
1281 1360
 
1282 1361
 		if ($command_line)
@@ -1309,9 +1388,10 @@  discard block
 block discarded – undo
1309 1388
 
1310 1389
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1311 1390
 
1312
-	if ($command_line)
1313
-		echo ' done.';
1314
-}
1391
+	if ($command_line) {
1392
+			echo ' done.';
1393
+	}
1394
+	}
1315 1395
 
1316 1396
 // Step 2: Everything.
1317 1397
 function DatabaseChanges()
@@ -1320,8 +1400,9 @@  discard block
 block discarded – undo
1320 1400
 	global $upcontext, $support_js, $db_type;
1321 1401
 
1322 1402
 	// Have we just completed this?
1323
-	if (!empty($_POST['database_done']))
1324
-		return true;
1403
+	if (!empty($_POST['database_done'])) {
1404
+			return true;
1405
+	}
1325 1406
 
1326 1407
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1327 1408
 	$upcontext['page_title'] = 'Database Changes';
@@ -1338,15 +1419,16 @@  discard block
 block discarded – undo
1338 1419
 	);
1339 1420
 
1340 1421
 	// How many files are there in total?
1341
-	if (isset($_GET['filecount']))
1342
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1343
-	else
1422
+	if (isset($_GET['filecount'])) {
1423
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1424
+	} else
1344 1425
 	{
1345 1426
 		$upcontext['file_count'] = 0;
1346 1427
 		foreach ($files as $file)
1347 1428
 		{
1348
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1349
-				$upcontext['file_count']++;
1429
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1430
+							$upcontext['file_count']++;
1431
+			}
1350 1432
 		}
1351 1433
 	}
1352 1434
 
@@ -1356,9 +1438,9 @@  discard block
 block discarded – undo
1356 1438
 	$upcontext['cur_file_num'] = 0;
1357 1439
 	foreach ($files as $file)
1358 1440
 	{
1359
-		if ($did_not_do)
1360
-			$did_not_do--;
1361
-		else
1441
+		if ($did_not_do) {
1442
+					$did_not_do--;
1443
+		} else
1362 1444
 		{
1363 1445
 			$upcontext['cur_file_num']++;
1364 1446
 			$upcontext['cur_file_name'] = $file[0];
@@ -1385,12 +1467,13 @@  discard block
 block discarded – undo
1385 1467
 					// Flag to move on to the next.
1386 1468
 					$upcontext['completed_step'] = true;
1387 1469
 					// Did we complete the whole file?
1388
-					if ($nextFile)
1389
-						$upcontext['current_debug_item_num'] = -1;
1470
+					if ($nextFile) {
1471
+											$upcontext['current_debug_item_num'] = -1;
1472
+					}
1390 1473
 					return upgradeExit();
1474
+				} elseif ($support_js) {
1475
+									break;
1391 1476
 				}
1392
-				elseif ($support_js)
1393
-					break;
1394 1477
 			}
1395 1478
 			// Set the progress bar to be right as if we had - even if we hadn't...
1396 1479
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1414,8 +1497,9 @@  discard block
 block discarded – undo
1414 1497
 	global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line;
1415 1498
 
1416 1499
 	// Sorry. Not supported for command line users.
1417
-	if ($command_line)
1418
-		return true;
1500
+	if ($command_line) {
1501
+			return true;
1502
+	}
1419 1503
 
1420 1504
 	// Skipping first?
1421 1505
 	if (!empty($_POST['skip']))
@@ -1425,8 +1509,9 @@  discard block
 block discarded – undo
1425 1509
 	}
1426 1510
 
1427 1511
 	// If we get here withOUT SSI we need to redirect to ensure we get it!
1428
-	if (!isset($_GET['ssi']) || !function_exists('mktree'))
1429
-		redirectLocation('&ssi=1');
1512
+	if (!isset($_GET['ssi']) || !function_exists('mktree')) {
1513
+			redirectLocation('&ssi=1');
1514
+	}
1430 1515
 
1431 1516
 	$upcontext['sub_template'] = 'clean_mods';
1432 1517
 	$upcontext['page_title'] = 'Cleanup Modifications';
@@ -1435,8 +1520,9 @@  discard block
 block discarded – undo
1435 1520
 	$upcontext['skip'] = true;
1436 1521
 
1437 1522
 	// If we're on the second redirect continue...
1438
-	if (isset($_POST['cleandone2']))
1439
-		return true;
1523
+	if (isset($_POST['cleandone2'])) {
1524
+			return true;
1525
+	}
1440 1526
 
1441 1527
 	// Do we already know about some writable files?
1442 1528
 	if (isset($_POST['writable_files']))
@@ -1451,8 +1537,9 @@  discard block
 block discarded – undo
1451 1537
 	}
1452 1538
 
1453 1539
 	// Make sure we have some sort of packages directory.
1454
-	if (!isset($packagesdir))
1455
-		$packagesdir = $boarddir . '/Packages';
1540
+	if (!isset($packagesdir)) {
1541
+			$packagesdir = $boarddir . '/Packages';
1542
+	}
1456 1543
 
1457 1544
 	// Load all theme paths....
1458 1545
 	$request = $smcFunc['db_query']('', '
@@ -1470,10 +1557,11 @@  discard block
 block discarded – undo
1470 1557
 	$theme_paths = array();
1471 1558
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1472 1559
 	{
1473
-		if ($row['id_theme'] == 1)
1474
-			$settings['default_' . $row['variable']] = $row['value'];
1475
-		elseif ($row['variable'] == 'theme_dir')
1476
-			$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1560
+		if ($row['id_theme'] == 1) {
1561
+					$settings['default_' . $row['variable']] = $row['value'];
1562
+		} elseif ($row['variable'] == 'theme_dir') {
1563
+					$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1564
+		}
1477 1565
 	}
1478 1566
 	$smcFunc['db_free_result']($request);
1479 1567
 
@@ -1497,8 +1585,7 @@  discard block
 block discarded – undo
1497 1585
 			$status = 'Missing';
1498 1586
 			$status_color = 'red';
1499 1587
 			$result = 'Removed';
1500
-		}
1501
-		else
1588
+		} else
1502 1589
 		{
1503 1590
 			$status = 'Installed';
1504 1591
 			$status_color = 'green';
@@ -1523,12 +1610,14 @@  discard block
 block discarded – undo
1523 1610
 	$smcFunc['db_free_result']($request);
1524 1611
 
1525 1612
 	// Don't carry on if there are none.
1526
-	if (empty($upcontext['packages']))
1527
-		return true;
1613
+	if (empty($upcontext['packages'])) {
1614
+			return true;
1615
+	}
1528 1616
 
1529 1617
 	// Setup some basics.
1530
-	if (!empty($upcontext['user']['version']))
1531
-		$_SESSION['version_emulate'] = $upcontext['user']['version'];
1618
+	if (!empty($upcontext['user']['version'])) {
1619
+			$_SESSION['version_emulate'] = $upcontext['user']['version'];
1620
+	}
1532 1621
 
1533 1622
 	// Before we get started, don't report notice errors.
1534 1623
 	$oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE);
@@ -1551,34 +1640,40 @@  discard block
 block discarded – undo
1551 1640
 	foreach ($upcontext['packages'] as $id => $package)
1552 1641
 	{
1553 1642
 		// Can't do anything about this....
1554
-		if ($package['missing_file'])
1555
-			continue;
1643
+		if ($package['missing_file']) {
1644
+					continue;
1645
+		}
1556 1646
 
1557 1647
 		// Not testing *and* this wasn't checked?
1558
-		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id])))
1559
-			continue;
1648
+		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) {
1649
+					continue;
1650
+		}
1560 1651
 
1561 1652
 		// What are the themes this was installed into?
1562 1653
 		$cur_theme_paths = array();
1563
-		foreach ($theme_paths as $tid => $data)
1564
-			if ($tid != 1 && in_array($tid, $package['themes']))
1654
+		foreach ($theme_paths as $tid => $data) {
1655
+					if ($tid != 1 && in_array($tid, $package['themes']))
1565 1656
 				$cur_theme_paths[$tid] = $data;
1657
+		}
1566 1658
 
1567 1659
 		// Get the modifications data if applicable.
1568 1660
 		$filename = $package['filename'];
1569 1661
 		$packageInfo = getPackageInfo($filename);
1570
-		if (!is_array($packageInfo))
1571
-			continue;
1662
+		if (!is_array($packageInfo)) {
1663
+					continue;
1664
+		}
1572 1665
 
1573 1666
 		$info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall');
1574 1667
 		// Also get the reinstall details...
1575
-		if (isset($_POST['remove']))
1576
-			$infoInstall = parsePackageInfo($packageInfo['xml'], true);
1668
+		if (isset($_POST['remove'])) {
1669
+					$infoInstall = parsePackageInfo($packageInfo['xml'], true);
1670
+		}
1577 1671
 
1578
-		if (is_file($packagesdir . '/' . $filename))
1579
-			read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1580
-		else
1581
-			copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1672
+		if (is_file($packagesdir . '/' . $filename)) {
1673
+					read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1674
+		} else {
1675
+					copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1676
+		}
1582 1677
 
1583 1678
 		// Work out how we uninstall...
1584 1679
 		$files = array();
@@ -1590,16 +1685,18 @@  discard block
 block discarded – undo
1590 1685
 			if ($change['type'] == 'modification')
1591 1686
 			{
1592 1687
 				$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1593
-				if ($change['boardmod'])
1594
-					$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
1595
-				else
1596
-					$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
1688
+				if ($change['boardmod']) {
1689
+									$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
1690
+				} else {
1691
+									$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
1692
+				}
1597 1693
 
1598 1694
 				foreach ($results as $action)
1599 1695
 				{
1600 1696
 					// Something we can remove? Probably means it existed!
1601
-					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files))
1602
-						$files[] = $action['filename'];
1697
+					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) {
1698
+											$files[] = $action['filename'];
1699
+					}
1603 1700
 					if ($action['type'] == 'failure')
1604 1701
 					{
1605 1702
 						$upcontext['packages'][$id]['needs_removing'] = true;
@@ -1615,17 +1712,19 @@  discard block
 block discarded – undo
1615 1712
 		$upcontext['packages'][$id]['file_count'] = count($files);
1616 1713
 
1617 1714
 		// If we've done something save the changes!
1618
-		if (!$test)
1619
-			package_flush_cache();
1715
+		if (!$test) {
1716
+					package_flush_cache();
1717
+		}
1620 1718
 
1621 1719
 		// Are we attempting to reinstall this thing?
1622 1720
 		if (isset($_POST['remove']) && !$test && isset($infoInstall))
1623 1721
 		{
1624 1722
 			// Need to extract again I'm afraid.
1625
-			if (is_file($packagesdir . '/' . $filename))
1626
-				read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1627
-			else
1628
-				copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1723
+			if (is_file($packagesdir . '/' . $filename)) {
1724
+							read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1725
+			} else {
1726
+							copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
1727
+			}
1629 1728
 
1630 1729
 			$errors = false;
1631 1730
 			$upcontext['packages'][$id]['result'] = 'Removed';
@@ -1634,15 +1733,17 @@  discard block
 block discarded – undo
1634 1733
 				if ($change['type'] == 'modification')
1635 1734
 				{
1636 1735
 					$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1637
-					if ($change['boardmod'])
1638
-						$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
1639
-					else
1640
-						$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
1736
+					if ($change['boardmod']) {
1737
+											$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
1738
+					} else {
1739
+											$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
1740
+					}
1641 1741
 
1642 1742
 					// Are there any errors?
1643
-					foreach ($results as $action)
1644
-						if ($action['type'] == 'failure')
1743
+					foreach ($results as $action) {
1744
+											if ($action['type'] == 'failure')
1645 1745
 							$errors = true;
1746
+					}
1646 1747
 				}
1647 1748
 			}
1648 1749
 			if (!$errors)
@@ -1655,10 +1756,11 @@  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, false, $change['reverse'], $cur_theme_paths);
1660
-						else
1661
-							$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
1759
+						if ($change['boardmod']) {
1760
+													$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
1761
+						} else {
1762
+													$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
1763
+						}
1662 1764
 					}
1663 1765
 				}
1664 1766
 
@@ -1677,9 +1779,10 @@  discard block
 block discarded – undo
1677 1779
 		$writable_files = array();
1678 1780
 		foreach ($upcontext['packages'] as $package)
1679 1781
 		{
1680
-			if (!empty($package['files']))
1681
-				foreach ($package['files'] as $file)
1782
+			if (!empty($package['files'])) {
1783
+							foreach ($package['files'] as $file)
1682 1784
 					$writable_files[] = $file;
1785
+			}
1683 1786
 		}
1684 1787
 
1685 1788
 		if (!empty($writable_files))
@@ -1687,13 +1790,15 @@  discard block
 block discarded – undo
1687 1790
 			$writable_files = array_unique($writable_files);
1688 1791
 			$upcontext['writable_files'] = $writable_files;
1689 1792
 
1690
-			if (!makeFilesWritable($writable_files))
1691
-				return false;
1793
+			if (!makeFilesWritable($writable_files)) {
1794
+							return false;
1795
+			}
1692 1796
 		}
1693 1797
 	}
1694 1798
 
1695
-	if (file_exists($packagesdir . '/temp'))
1696
-		deltree($packagesdir . '/temp');
1799
+	if (file_exists($packagesdir . '/temp')) {
1800
+			deltree($packagesdir . '/temp');
1801
+	}
1697 1802
 
1698 1803
 	// Removing/Reinstalling any packages?
1699 1804
 	if (isset($_POST['remove']))
@@ -1701,32 +1806,35 @@  discard block
 block discarded – undo
1701 1806
 		$deletes = array();
1702 1807
 		foreach ($_POST['remove'] as $id => $dummy)
1703 1808
 		{
1704
-			if (!in_array((int) $id, $reinstall_worked))
1705
-				$deletes[] = (int) $id;
1809
+			if (!in_array((int) $id, $reinstall_worked)) {
1810
+							$deletes[] = (int) $id;
1811
+			}
1706 1812
 		}
1707 1813
 
1708
-		if (!empty($deletes))
1709
-			upgrade_query('
1814
+		if (!empty($deletes)) {
1815
+					upgrade_query('
1710 1816
 				UPDATE ' . $db_prefix . 'log_packages
1711 1817
 				SET install_state = 0
1712 1818
 				WHERE id_install IN (' . implode(',', $deletes) . ')');
1819
+		}
1713 1820
 
1714 1821
 		// Ensure we don't lose our changes!
1715 1822
 		package_put_contents($packagesdir . '/installed.list', time());
1716 1823
 
1717 1824
 		$upcontext['sub_template'] = 'cleanup_done';
1718 1825
 		return false;
1719
-	}
1720
-	else
1826
+	} else
1721 1827
 	{
1722 1828
 		$allgood = true;
1723 1829
 		// Is there actually anything that needs our attention?
1724
-		foreach ($upcontext['packages'] as $package)
1725
-			if ($package['color'] != 'green')
1830
+		foreach ($upcontext['packages'] as $package) {
1831
+					if ($package['color'] != 'green')
1726 1832
 				$allgood = false;
1833
+		}
1727 1834
 
1728
-		if ($allgood)
1729
-			return true;
1835
+		if ($allgood) {
1836
+					return true;
1837
+		}
1730 1838
 	}
1731 1839
 
1732 1840
 	$_GET['substep'] = 0;
@@ -1740,8 +1848,9 @@  discard block
 block discarded – undo
1740 1848
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1741 1849
 
1742 1850
 	// Now it's nice to have some of the basic SMF source files.
1743
-	if (!isset($_GET['ssi']) && !$command_line)
1744
-		redirectLocation('&ssi=1');
1851
+	if (!isset($_GET['ssi']) && !$command_line) {
1852
+			redirectLocation('&ssi=1');
1853
+	}
1745 1854
 
1746 1855
 	$upcontext['sub_template'] = 'upgrade_complete';
1747 1856
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1757,14 +1866,16 @@  discard block
 block discarded – undo
1757 1866
 	// Are we in maintenance mode?
1758 1867
 	if (isset($upcontext['user']['main']))
1759 1868
 	{
1760
-		if ($command_line)
1761
-			echo ' * ';
1869
+		if ($command_line) {
1870
+					echo ' * ';
1871
+		}
1762 1872
 		$upcontext['removed_maintenance'] = true;
1763 1873
 		$changes['maintenance'] = $upcontext['user']['main'];
1764 1874
 	}
1765 1875
 	// Otherwise if somehow we are in 2 let's go to 1.
1766
-	elseif (!empty($maintenance) && $maintenance == 2)
1767
-		$changes['maintenance'] = 1;
1876
+	elseif (!empty($maintenance) && $maintenance == 2) {
1877
+			$changes['maintenance'] = 1;
1878
+	}
1768 1879
 
1769 1880
 	// Wipe this out...
1770 1881
 	$upcontext['user'] = array();
@@ -1780,9 +1891,9 @@  discard block
 block discarded – undo
1780 1891
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1781 1892
 
1782 1893
 	// Now is the perfect time to fetch the SM files.
1783
-	if ($command_line)
1784
-		cli_scheduled_fetchSMfiles();
1785
-	else
1894
+	if ($command_line) {
1895
+			cli_scheduled_fetchSMfiles();
1896
+	} else
1786 1897
 	{
1787 1898
 		require_once($sourcedir . '/ScheduledTasks.php');
1788 1899
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1790,8 +1901,9 @@  discard block
 block discarded – undo
1790 1901
 	}
1791 1902
 
1792 1903
 	// Log what we've done.
1793
-	if (empty($user_info['id']))
1794
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1904
+	if (empty($user_info['id'])) {
1905
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1906
+	}
1795 1907
 
1796 1908
 	// Log the action manually, so CLI still works.
1797 1909
 	$smcFunc['db_insert']('',
@@ -1810,8 +1922,9 @@  discard block
 block discarded – undo
1810 1922
 
1811 1923
 	// Save the current database version.
1812 1924
 	$server_version = $smcFunc['db_server_info']();
1813
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1814
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1925
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1926
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1927
+	}
1815 1928
 
1816 1929
 	if ($command_line)
1817 1930
 	{
@@ -1823,8 +1936,9 @@  discard block
 block discarded – undo
1823 1936
 
1824 1937
 	// Make sure it says we're done.
1825 1938
 	$upcontext['overall_percent'] = 100;
1826
-	if (isset($upcontext['step_progress']))
1827
-		unset($upcontext['step_progress']);
1939
+	if (isset($upcontext['step_progress'])) {
1940
+			unset($upcontext['step_progress']);
1941
+	}
1828 1942
 
1829 1943
 	$_GET['substep'] = 0;
1830 1944
 	return false;
@@ -1835,8 +1949,9 @@  discard block
 block discarded – undo
1835 1949
 {
1836 1950
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1837 1951
 
1838
-	if (empty($modSettings['time_format']))
1839
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1952
+	if (empty($modSettings['time_format'])) {
1953
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1954
+	}
1840 1955
 
1841 1956
 	// What files do we want to get
1842 1957
 	$request = $smcFunc['db_query']('', '
@@ -1870,8 +1985,9 @@  discard block
 block discarded – undo
1870 1985
 		$file_data = fetch_web_data($url);
1871 1986
 
1872 1987
 		// If we got an error - give up - the site might be down.
1873
-		if ($file_data === false)
1874
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1988
+		if ($file_data === false) {
1989
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1990
+		}
1875 1991
 
1876 1992
 		// Save the file to the database.
1877 1993
 		$smcFunc['db_query']('substring', '
@@ -1913,8 +2029,9 @@  discard block
 block discarded – undo
1913 2029
 	$themeData = array();
1914 2030
 	foreach ($values as $variable => $value)
1915 2031
 	{
1916
-		if (!isset($value) || $value === null)
1917
-			$value = 0;
2032
+		if (!isset($value) || $value === null) {
2033
+					$value = 0;
2034
+		}
1918 2035
 
1919 2036
 		$themeData[] = array(0, 1, $variable, $value);
1920 2037
 	}
@@ -1943,8 +2060,9 @@  discard block
 block discarded – undo
1943 2060
 
1944 2061
 	foreach ($values as $variable => $value)
1945 2062
 	{
1946
-		if (empty($modSettings[$value[0]]))
1947
-			continue;
2063
+		if (empty($modSettings[$value[0]])) {
2064
+					continue;
2065
+		}
1948 2066
 
1949 2067
 		$smcFunc['db_query']('', '
1950 2068
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1977,8 +2095,9 @@  discard block
 block discarded – undo
1977 2095
 
1978 2096
 	$settingsArray = file($boarddir . '/Settings_bak.php');
1979 2097
 
1980
-	if (count($settingsArray) == 1)
1981
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2098
+	if (count($settingsArray) == 1) {
2099
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2100
+	}
1982 2101
 
1983 2102
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1984 2103
 	{
@@ -1991,9 +2110,9 @@  discard block
 block discarded – undo
1991 2110
 			{
1992 2111
 				if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1993 2112
 				{
1994
-					if ($val == '#remove#')
1995
-						unset($settingsArray[$i]);
1996
-					else
2113
+					if ($val == '#remove#') {
2114
+											unset($settingsArray[$i]);
2115
+					} else
1997 2116
 					{
1998 2117
 						$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
1999 2118
 						$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n");
@@ -2005,22 +2124,25 @@  discard block
 block discarded – undo
2005 2124
 		}
2006 2125
 		if (isset($settingsArray[$i]))
2007 2126
 		{
2008
-			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>')
2009
-				$end = $i;
2127
+			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') {
2128
+							$end = $i;
2129
+			}
2010 2130
 		}
2011 2131
 	}
2012 2132
 
2013 2133
 	// Assume end-of-file if the end wasn't found.
2014
-	if (empty($end) || $end < 10)
2015
-		$end = count($settingsArray);
2134
+	if (empty($end) || $end < 10) {
2135
+			$end = count($settingsArray);
2136
+	}
2016 2137
 
2017 2138
 	if (!empty($config_vars))
2018 2139
 	{
2019 2140
 		$settingsArray[$end++] = '';
2020 2141
 		foreach ($config_vars as $var => $val)
2021 2142
 		{
2022
-			if ($val != '#remove#')
2023
-				$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2143
+			if ($val != '#remove#') {
2144
+							$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2145
+			}
2024 2146
 		}
2025 2147
 	}
2026 2148
 	// This should be the last line and even last bytes of the file.
@@ -2033,8 +2155,9 @@  discard block
 block discarded – undo
2033 2155
 	$fp = fopen($boarddir . '/Settings.php', 'r+');
2034 2156
 	for ($i = 0; $i < $end; $i++)
2035 2157
 	{
2036
-		if (isset($settingsArray[$i]))
2037
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2158
+		if (isset($settingsArray[$i])) {
2159
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2160
+		}
2038 2161
 	}
2039 2162
 	fwrite($fp, rtrim($settingsArray[$i]));
2040 2163
 	fclose($fp);
@@ -2065,8 +2188,9 @@  discard block
 block discarded – undo
2065 2188
 	global $smcFunc;
2066 2189
 	static $member_groups = array();
2067 2190
 
2068
-	if (!empty($member_groups))
2069
-		return $member_groups;
2191
+	if (!empty($member_groups)) {
2192
+			return $member_groups;
2193
+	}
2070 2194
 
2071 2195
 	$request = $smcFunc['db_query']('', '
2072 2196
 		SELECT group_name, id_group
@@ -2091,8 +2215,9 @@  discard block
 block discarded – undo
2091 2215
 			)
2092 2216
 		);
2093 2217
 	}
2094
-	while ($row = $smcFunc['db_fetch_row']($request))
2095
-		$member_groups[trim($row[0])] = $row[1];
2218
+	while ($row = $smcFunc['db_fetch_row']($request)) {
2219
+			$member_groups[trim($row[0])] = $row[1];
2220
+	}
2096 2221
 	$smcFunc['db_free_result']($request);
2097 2222
 
2098 2223
 	return $member_groups;
@@ -2145,10 +2270,11 @@  discard block
 block discarded – undo
2145 2270
 		{
2146 2271
 			global $support_js;
2147 2272
 
2148
-			if ($support_js)
2149
-				return true;
2150
-			else
2151
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2273
+			if ($support_js) {
2274
+							return true;
2275
+			} else {
2276
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2277
+			}
2152 2278
 		}
2153 2279
 	}
2154 2280
 
@@ -2166,8 +2292,9 @@  discard block
 block discarded – undo
2166 2292
 				'db_error_skip' => true,
2167 2293
 			)
2168 2294
 		);
2169
-		if ($smcFunc['db_num_rows']($request) === 0)
2170
-			die('Unable to find members table!');
2295
+		if ($smcFunc['db_num_rows']($request) === 0) {
2296
+					die('Unable to find members table!');
2297
+		}
2171 2298
 		$table_status = $smcFunc['db_fetch_assoc']($request);
2172 2299
 		$smcFunc['db_free_result']($request);
2173 2300
 
@@ -2182,17 +2309,20 @@  discard block
 block discarded – undo
2182 2309
 				)
2183 2310
 			);
2184 2311
 			// Got something?
2185
-			if ($smcFunc['db_num_rows']($request) !== 0)
2186
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
2312
+			if ($smcFunc['db_num_rows']($request) !== 0) {
2313
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
2314
+			}
2187 2315
 			$smcFunc['db_free_result']($request);
2188 2316
 
2189 2317
 			// Excellent!
2190
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
2191
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2318
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
2319
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2320
+			}
2192 2321
 		}
2193 2322
 	}
2194
-	if (empty($db_collation))
2195
-		$db_collation = '';
2323
+	if (empty($db_collation)) {
2324
+			$db_collation = '';
2325
+	}
2196 2326
 
2197 2327
 	$endl = $command_line ? "\n" : '<br>' . "\n";
2198 2328
 
@@ -2204,8 +2334,9 @@  discard block
 block discarded – undo
2204 2334
 	$last_step = '';
2205 2335
 
2206 2336
 	// Make sure all newly created tables will have the proper characters set.
2207
-	if (isset($db_character_set) && $db_character_set === 'utf8')
2208
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2337
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
2338
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2339
+	}
2209 2340
 
2210 2341
 	// Count the total number of steps within this file - for progress.
2211 2342
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -2225,15 +2356,18 @@  discard block
 block discarded – undo
2225 2356
 		$do_current = $substep >= $_GET['substep'];
2226 2357
 
2227 2358
 		// Get rid of any comments in the beginning of the line...
2228
-		if (substr(trim($line), 0, 2) === '/*')
2229
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
2359
+		if (substr(trim($line), 0, 2) === '/*') {
2360
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
2361
+		}
2230 2362
 
2231 2363
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
2232
-		if ($is_debug && !$support_js && $command_line)
2233
-			flush();
2364
+		if ($is_debug && !$support_js && $command_line) {
2365
+					flush();
2366
+		}
2234 2367
 
2235
-		if (trim($line) === '')
2236
-			continue;
2368
+		if (trim($line) === '') {
2369
+					continue;
2370
+		}
2237 2371
 
2238 2372
 		if (trim(substr($line, 0, 3)) === '---')
2239 2373
 		{
@@ -2243,8 +2377,9 @@  discard block
 block discarded – undo
2243 2377
 			if (trim($current_data) != '' && $type !== '}')
2244 2378
 			{
2245 2379
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
2246
-				if ($command_line)
2247
-					echo $upcontext['error_message'];
2380
+				if ($command_line) {
2381
+									echo $upcontext['error_message'];
2382
+				}
2248 2383
 			}
2249 2384
 
2250 2385
 			if ($type == ' ')
@@ -2262,17 +2397,18 @@  discard block
 block discarded – undo
2262 2397
 				if ($do_current)
2263 2398
 				{
2264 2399
 					$upcontext['actioned_items'][] = $last_step;
2265
-					if ($command_line)
2266
-						echo ' * ';
2400
+					if ($command_line) {
2401
+											echo ' * ';
2402
+					}
2267 2403
 				}
2268
-			}
2269
-			elseif ($type == '#')
2404
+			} elseif ($type == '#')
2270 2405
 			{
2271 2406
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
2272 2407
 
2273 2408
 				$upcontext['current_debug_item_num']++;
2274
-				if (trim($line) != '---#')
2275
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2409
+				if (trim($line) != '---#') {
2410
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2411
+				}
2276 2412
 
2277 2413
 				// Have we already done something?
2278 2414
 				if (isset($_GET['xml']) && $done_something)
@@ -2283,34 +2419,36 @@  discard block
 block discarded – undo
2283 2419
 
2284 2420
 				if ($do_current)
2285 2421
 				{
2286
-					if (trim($line) == '---#' && $command_line)
2287
-						echo ' done.', $endl;
2288
-					elseif ($command_line)
2289
-						echo ' +++ ', rtrim(substr($line, 4));
2290
-					elseif (trim($line) != '---#')
2422
+					if (trim($line) == '---#' && $command_line) {
2423
+											echo ' done.', $endl;
2424
+					} elseif ($command_line) {
2425
+											echo ' +++ ', rtrim(substr($line, 4));
2426
+					} elseif (trim($line) != '---#')
2291 2427
 					{
2292
-						if ($is_debug)
2293
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2428
+						if ($is_debug) {
2429
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2430
+						}
2294 2431
 					}
2295 2432
 				}
2296 2433
 
2297 2434
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
2298 2435
 				{
2299
-					if ($command_line)
2300
-						echo ' * ';
2301
-					else
2302
-						$upcontext['actioned_items'][] = $last_step;
2436
+					if ($command_line) {
2437
+											echo ' * ';
2438
+					} else {
2439
+											$upcontext['actioned_items'][] = $last_step;
2440
+					}
2303 2441
 				}
2304 2442
 
2305 2443
 				// Small step - only if we're actually doing stuff.
2306
-				if ($do_current)
2307
-					nextSubstep(++$substep);
2308
-				else
2309
-					$substep++;
2310
-			}
2311
-			elseif ($type == '{')
2312
-				$current_type = 'code';
2313
-			elseif ($type == '}')
2444
+				if ($do_current) {
2445
+									nextSubstep(++$substep);
2446
+				} else {
2447
+									$substep++;
2448
+				}
2449
+			} elseif ($type == '{') {
2450
+							$current_type = 'code';
2451
+			} elseif ($type == '}')
2314 2452
 			{
2315 2453
 				$current_type = 'sql';
2316 2454
 
@@ -2323,8 +2461,9 @@  discard block
 block discarded – undo
2323 2461
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
2324 2462
 				{
2325 2463
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
2326
-					if ($command_line)
2327
-						echo $upcontext['error_message'];
2464
+					if ($command_line) {
2465
+											echo $upcontext['error_message'];
2466
+					}
2328 2467
 				}
2329 2468
 
2330 2469
 				// Done with code!
@@ -2404,8 +2543,9 @@  discard block
 block discarded – undo
2404 2543
 	$db_unbuffered = false;
2405 2544
 
2406 2545
 	// Failure?!
2407
-	if ($result !== false)
2408
-		return $result;
2546
+	if ($result !== false) {
2547
+			return $result;
2548
+	}
2409 2549
 
2410 2550
 	$db_error_message = $smcFunc['db_error']($db_connection);
2411 2551
 	// If MySQL we do something more clever.
@@ -2433,54 +2573,61 @@  discard block
 block discarded – undo
2433 2573
 			{
2434 2574
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2435 2575
 				$result = mysqli_query($db_connection, $string);
2436
-				if ($result !== false)
2437
-					return $result;
2576
+				if ($result !== false) {
2577
+									return $result;
2578
+				}
2438 2579
 			}
2439
-		}
2440
-		elseif ($mysqli_errno == 2013)
2580
+		} elseif ($mysqli_errno == 2013)
2441 2581
 		{
2442 2582
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2443 2583
 			mysqli_select_db($db_connection, $db_name);
2444 2584
 			if ($db_connection)
2445 2585
 			{
2446 2586
 				$result = mysqli_query($db_connection, $string);
2447
-				if ($result !== false)
2448
-					return $result;
2587
+				if ($result !== false) {
2588
+									return $result;
2589
+				}
2449 2590
 			}
2450 2591
 		}
2451 2592
 		// Duplicate column name... should be okay ;).
2452
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2453
-			return false;
2593
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2594
+					return false;
2595
+		}
2454 2596
 		// Duplicate insert... make sure it's the proper type of query ;).
2455
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2456
-			return false;
2597
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2598
+					return false;
2599
+		}
2457 2600
 		// Creating an index on a non-existent column.
2458
-		elseif ($mysqli_errno == 1072)
2459
-			return false;
2460
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2461
-			return false;
2601
+		elseif ($mysqli_errno == 1072) {
2602
+					return false;
2603
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2604
+					return false;
2605
+		}
2462 2606
 	}
2463 2607
 	// If a table already exists don't go potty.
2464 2608
 	else
2465 2609
 	{
2466 2610
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2467 2611
 		{
2468
-			if (strpos($db_error_message, 'exist') !== false)
2469
-				return true;
2470
-		}
2471
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2612
+			if (strpos($db_error_message, 'exist') !== false) {
2613
+							return true;
2614
+			}
2615
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2472 2616
 		{
2473
-			if (strpos($db_error_message, 'duplicate') !== false)
2474
-				return true;
2617
+			if (strpos($db_error_message, 'duplicate') !== false) {
2618
+							return true;
2619
+			}
2475 2620
 		}
2476 2621
 	}
2477 2622
 
2478 2623
 	// Get the query string so we pass everything.
2479 2624
 	$query_string = '';
2480
-	foreach ($_GET as $k => $v)
2481
-		$query_string .= ';' . $k . '=' . $v;
2482
-	if (strlen($query_string) != 0)
2483
-		$query_string = '?' . substr($query_string, 1);
2625
+	foreach ($_GET as $k => $v) {
2626
+			$query_string .= ';' . $k . '=' . $v;
2627
+	}
2628
+	if (strlen($query_string) != 0) {
2629
+			$query_string = '?' . substr($query_string, 1);
2630
+	}
2484 2631
 
2485 2632
 	if ($command_line)
2486 2633
 	{
@@ -2566,16 +2713,18 @@  discard block
 block discarded – undo
2566 2713
 			{
2567 2714
 				$found |= 1;
2568 2715
 				// Do some checks on the data if we have it set.
2569
-				if (isset($change['col_type']))
2570
-					$found &= $change['col_type'] === $column['type'];
2571
-				if (isset($change['null_allowed']))
2572
-					$found &= $column['null'] == $change['null_allowed'];
2573
-				if (isset($change['default']))
2574
-					$found &= $change['default'] === $column['default'];
2716
+				if (isset($change['col_type'])) {
2717
+									$found &= $change['col_type'] === $column['type'];
2718
+				}
2719
+				if (isset($change['null_allowed'])) {
2720
+									$found &= $column['null'] == $change['null_allowed'];
2721
+				}
2722
+				if (isset($change['default'])) {
2723
+									$found &= $change['default'] === $column['default'];
2724
+				}
2575 2725
 			}
2576 2726
 		}
2577
-	}
2578
-	elseif ($change['type'] === 'index')
2727
+	} elseif ($change['type'] === 'index')
2579 2728
 	{
2580 2729
 		$request = upgrade_query('
2581 2730
 			SHOW INDEX
@@ -2584,9 +2733,10 @@  discard block
 block discarded – undo
2584 2733
 		{
2585 2734
 			$cur_index = array();
2586 2735
 
2587
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2588
-				if ($row['Key_name'] === $change['name'])
2736
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2737
+							if ($row['Key_name'] === $change['name'])
2589 2738
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2739
+			}
2590 2740
 
2591 2741
 			ksort($cur_index, SORT_NUMERIC);
2592 2742
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2596,14 +2746,17 @@  discard block
 block discarded – undo
2596 2746
 	}
2597 2747
 
2598 2748
 	// If we're trying to add and it's added, we're done.
2599
-	if ($found && in_array($change['method'], array('add', 'change')))
2600
-		return true;
2749
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2750
+			return true;
2751
+	}
2601 2752
 	// Otherwise if we're removing and it wasn't found we're also done.
2602
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2603
-		return true;
2753
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2754
+			return true;
2755
+	}
2604 2756
 	// Otherwise is it just a test?
2605
-	elseif ($is_test)
2606
-		return false;
2757
+	elseif ($is_test) {
2758
+			return false;
2759
+	}
2607 2760
 
2608 2761
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2609 2762
 	$running = false;
@@ -2614,8 +2767,9 @@  discard block
 block discarded – undo
2614 2767
 			SHOW FULL PROCESSLIST');
2615 2768
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2616 2769
 		{
2617
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2618
-				$found = true;
2770
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2771
+							$found = true;
2772
+			}
2619 2773
 		}
2620 2774
 
2621 2775
 		// Can't find it? Then we need to run it fools!
@@ -2627,8 +2781,9 @@  discard block
 block discarded – undo
2627 2781
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2628 2782
 				' . $change['text'], true) !== false;
2629 2783
 
2630
-			if (!$success)
2631
-				return false;
2784
+			if (!$success) {
2785
+							return false;
2786
+			}
2632 2787
 
2633 2788
 			// Return
2634 2789
 			$running = true;
@@ -2661,8 +2816,7 @@  discard block
 block discarded – undo
2661 2816
 	{
2662 2817
 		$column_fix = true;
2663 2818
 		$null_fix = !$change['null_allowed'];
2664
-	}
2665
-	else
2819
+	} else
2666 2820
 	{
2667 2821
 		$request = $smcFunc['db_query']('', '
2668 2822
 			SHOW FULL COLUMNS
@@ -2673,8 +2827,9 @@  discard block
 block discarded – undo
2673 2827
 				'db_error_skip' => true,
2674 2828
 			)
2675 2829
 		);
2676
-		if ($smcFunc['db_num_rows']($request) === 0)
2677
-			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2830
+		if ($smcFunc['db_num_rows']($request) === 0) {
2831
+					die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2832
+		}
2678 2833
 		$table_row = $smcFunc['db_fetch_assoc']($request);
2679 2834
 		$smcFunc['db_free_result']($request);
2680 2835
 
@@ -2696,10 +2851,11 @@  discard block
 block discarded – undo
2696 2851
 				)
2697 2852
 			);
2698 2853
 			// No results? Just forget it all together.
2699
-			if ($smcFunc['db_num_rows']($request) === 0)
2700
-				unset($table_row['Collation']);
2701
-			else
2702
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
2854
+			if ($smcFunc['db_num_rows']($request) === 0) {
2855
+							unset($table_row['Collation']);
2856
+			} else {
2857
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
2858
+			}
2703 2859
 			$smcFunc['db_free_result']($request);
2704 2860
 		}
2705 2861
 	}
@@ -2707,8 +2863,8 @@  discard block
 block discarded – undo
2707 2863
 	if ($column_fix)
2708 2864
 	{
2709 2865
 		// Make sure there are no NULL's left.
2710
-		if ($null_fix)
2711
-			$smcFunc['db_query']('', '
2866
+		if ($null_fix) {
2867
+					$smcFunc['db_query']('', '
2712 2868
 				UPDATE {db_prefix}' . $change['table'] . '
2713 2869
 				SET ' . $change['column'] . ' = {string:default}
2714 2870
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2717,6 +2873,7 @@  discard block
 block discarded – undo
2717 2873
 					'db_error_skip' => true,
2718 2874
 				)
2719 2875
 			);
2876
+		}
2720 2877
 
2721 2878
 		// Do the actual alteration.
2722 2879
 		$smcFunc['db_query']('', '
@@ -2745,8 +2902,9 @@  discard block
 block discarded – undo
2745 2902
 	}
2746 2903
 
2747 2904
 	// Not a column we need to check on?
2748
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2749
-		return;
2905
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2906
+			return;
2907
+	}
2750 2908
 
2751 2909
 	// Break it up you (six|seven).
2752 2910
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2765,13 +2923,13 @@  discard block
 block discarded – undo
2765 2923
 				'new_name' => $temp[2],
2766 2924
 		));
2767 2925
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2768
-		if ($smcFunc['db_num_rows'] != 1)
2769
-			return;
2926
+		if ($smcFunc['db_num_rows'] != 1) {
2927
+					return;
2928
+		}
2770 2929
 
2771 2930
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2772 2931
 		$smcFunc['db_free_result']($request);
2773
-	}
2774
-	else
2932
+	} else
2775 2933
 	{
2776 2934
 		// Do this the old fashion, sure method way.
2777 2935
 		$request = $smcFunc['db_query']('', '
@@ -2782,21 +2940,24 @@  discard block
 block discarded – undo
2782 2940
 		));
2783 2941
 		// Mayday!
2784 2942
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2785
-		if ($smcFunc['db_num_rows'] == 0)
2786
-			return;
2943
+		if ($smcFunc['db_num_rows'] == 0) {
2944
+					return;
2945
+		}
2787 2946
 
2788 2947
 		// Oh where, oh where has my little field gone. Oh where can it be...
2789
-		while ($row = $smcFunc['db_query']($request))
2790
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2948
+		while ($row = $smcFunc['db_query']($request)) {
2949
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2791 2950
 			{
2792 2951
 				$current_type = $row['Type'];
2952
+		}
2793 2953
 				break;
2794 2954
 			}
2795 2955
 	}
2796 2956
 
2797 2957
 	// If this doesn't match, the column may of been altered for a reason.
2798
-	if (trim($current_type) != trim($temp[3]))
2799
-		$temp[3] = $current_type;
2958
+	if (trim($current_type) != trim($temp[3])) {
2959
+			$temp[3] = $current_type;
2960
+	}
2800 2961
 
2801 2962
 	// Piece this back together.
2802 2963
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2808,8 +2969,9 @@  discard block
 block discarded – undo
2808 2969
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2809 2970
 	global $step_progress, $is_debug, $upcontext;
2810 2971
 
2811
-	if ($_GET['substep'] < $substep)
2812
-		$_GET['substep'] = $substep;
2972
+	if ($_GET['substep'] < $substep) {
2973
+			$_GET['substep'] = $substep;
2974
+	}
2813 2975
 
2814 2976
 	if ($command_line)
2815 2977
 	{
@@ -2822,29 +2984,33 @@  discard block
 block discarded – undo
2822 2984
 	}
2823 2985
 
2824 2986
 	@set_time_limit(300);
2825
-	if (function_exists('apache_reset_timeout'))
2826
-		@apache_reset_timeout();
2987
+	if (function_exists('apache_reset_timeout')) {
2988
+			@apache_reset_timeout();
2989
+	}
2827 2990
 
2828
-	if (time() - $start_time <= $timeLimitThreshold)
2829
-		return;
2991
+	if (time() - $start_time <= $timeLimitThreshold) {
2992
+			return;
2993
+	}
2830 2994
 
2831 2995
 	// Do we have some custom step progress stuff?
2832 2996
 	if (!empty($step_progress))
2833 2997
 	{
2834 2998
 		$upcontext['substep_progress'] = 0;
2835 2999
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2836
-		if ($step_progress['current'] > $step_progress['total'])
2837
-			$upcontext['substep_progress'] = 99.9;
2838
-		else
2839
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3000
+		if ($step_progress['current'] > $step_progress['total']) {
3001
+					$upcontext['substep_progress'] = 99.9;
3002
+		} else {
3003
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3004
+		}
2840 3005
 
2841 3006
 		// Make it nicely rounded.
2842 3007
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2843 3008
 	}
2844 3009
 
2845 3010
 	// If this is XML we just exit right away!
2846
-	if (isset($_GET['xml']))
2847
-		return upgradeExit();
3011
+	if (isset($_GET['xml'])) {
3012
+			return upgradeExit();
3013
+	}
2848 3014
 
2849 3015
 	// We're going to pause after this!
2850 3016
 	$upcontext['pause'] = true;
@@ -2852,13 +3018,15 @@  discard block
 block discarded – undo
2852 3018
 	$upcontext['query_string'] = '';
2853 3019
 	foreach ($_GET as $k => $v)
2854 3020
 	{
2855
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2856
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
3021
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
3022
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
3023
+		}
2857 3024
 	}
2858 3025
 
2859 3026
 	// Custom warning?
2860
-	if (!empty($custom_warning))
2861
-		$upcontext['custom_warning'] = $custom_warning;
3027
+	if (!empty($custom_warning)) {
3028
+			$upcontext['custom_warning'] = $custom_warning;
3029
+	}
2862 3030
 
2863 3031
 	upgradeExit();
2864 3032
 }
@@ -2873,25 +3041,26 @@  discard block
 block discarded – undo
2873 3041
 	ob_implicit_flush(true);
2874 3042
 	@set_time_limit(600);
2875 3043
 
2876
-	if (!isset($_SERVER['argv']))
2877
-		$_SERVER['argv'] = array();
3044
+	if (!isset($_SERVER['argv'])) {
3045
+			$_SERVER['argv'] = array();
3046
+	}
2878 3047
 	$_GET['maint'] = 1;
2879 3048
 
2880 3049
 	foreach ($_SERVER['argv'] as $i => $arg)
2881 3050
 	{
2882
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2883
-			$_GET['lang'] = $match[1];
2884
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2885
-			continue;
2886
-		elseif ($arg == '--no-maintenance')
2887
-			$_GET['maint'] = 0;
2888
-		elseif ($arg == '--debug')
2889
-			$is_debug = true;
2890
-		elseif ($arg == '--backup')
2891
-			$_POST['backup'] = 1;
2892
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2893
-			$_GET['conv'] = 1;
2894
-		elseif ($i != 0)
3051
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
3052
+					$_GET['lang'] = $match[1];
3053
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
3054
+					continue;
3055
+		} elseif ($arg == '--no-maintenance') {
3056
+					$_GET['maint'] = 0;
3057
+		} elseif ($arg == '--debug') {
3058
+					$is_debug = true;
3059
+		} elseif ($arg == '--backup') {
3060
+					$_POST['backup'] = 1;
3061
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
3062
+					$_GET['conv'] = 1;
3063
+		} elseif ($i != 0)
2895 3064
 		{
2896 3065
 			echo 'SMF Command-line Upgrader
2897 3066
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2905,10 +3074,12 @@  discard block
 block discarded – undo
2905 3074
 		}
2906 3075
 	}
2907 3076
 
2908
-	if (!php_version_check())
2909
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2910
-	if (!db_version_check())
2911
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3077
+	if (!php_version_check()) {
3078
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
3079
+	}
3080
+	if (!db_version_check()) {
3081
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3082
+	}
2912 3083
 
2913 3084
 	// Do some checks to make sure they have proper privileges
2914 3085
 	db_extend('packages');
@@ -2923,34 +3094,39 @@  discard block
 block discarded – undo
2923 3094
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2924 3095
 
2925 3096
 	// Sorry... we need CREATE, ALTER and DROP
2926
-	if (!$create || !$alter || !$drop)
2927
-		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);
3097
+	if (!$create || !$alter || !$drop) {
3098
+			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);
3099
+	}
2928 3100
 
2929 3101
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2930 3102
 		&& @file_exists($sourcedir . '/QueryString.php')
2931 3103
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2932
-	if (!$check && !isset($modSettings['smfVersion']))
2933
-		print_error('Error: Some files are missing or out-of-date.', true);
3104
+	if (!$check && !isset($modSettings['smfVersion'])) {
3105
+			print_error('Error: Some files are missing or out-of-date.', true);
3106
+	}
2934 3107
 
2935 3108
 	// Do a quick version spot check.
2936 3109
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2937 3110
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2938
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2939
-		print_error('Error: Some files have not yet been updated properly.');
3111
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
3112
+			print_error('Error: Some files have not yet been updated properly.');
3113
+	}
2940 3114
 
2941 3115
 	// Make sure Settings.php is writable.
2942 3116
 		quickFileWritable($boarddir . '/Settings.php');
2943
-	if (!is_writable($boarddir . '/Settings.php'))
2944
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
3117
+	if (!is_writable($boarddir . '/Settings.php')) {
3118
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
3119
+	}
2945 3120
 
2946 3121
 	// Make sure Settings_bak.php is writable.
2947 3122
 		quickFileWritable($boarddir . '/Settings_bak.php');
2948
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2949
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3123
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
3124
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3125
+	}
2950 3126
 
2951
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2952
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2953
-	elseif (isset($modSettings['agreement']))
3127
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
3128
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
3129
+	} elseif (isset($modSettings['agreement']))
2954 3130
 	{
2955 3131
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2956 3132
 		fwrite($fp, $modSettings['agreement']);
@@ -2960,31 +3136,36 @@  discard block
 block discarded – undo
2960 3136
 	// Make sure Themes is writable.
2961 3137
 	quickFileWritable($modSettings['theme_dir']);
2962 3138
 
2963
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2964
-		print_error('Error: Unable to obtain write access to "Themes".');
3139
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
3140
+			print_error('Error: Unable to obtain write access to "Themes".');
3141
+	}
2965 3142
 
2966 3143
 	// Make sure cache directory exists and is writable!
2967 3144
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2968
-	if (!file_exists($cachedir_temp))
2969
-		@mkdir($cachedir_temp);
3145
+	if (!file_exists($cachedir_temp)) {
3146
+			@mkdir($cachedir_temp);
3147
+	}
2970 3148
 
2971 3149
 	// Make sure the cache temp dir is writable.
2972 3150
 	quickFileWritable($cachedir_temp);
2973 3151
 
2974
-	if (!is_writable($cachedir_temp))
2975
-		print_error('Error: Unable to obtain write access to "cache".', true);
3152
+	if (!is_writable($cachedir_temp)) {
3153
+			print_error('Error: Unable to obtain write access to "cache".', true);
3154
+	}
2976 3155
 
2977
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2978
-		print_error('Error: Unable to find language files!', true);
2979
-	else
3156
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
3157
+			print_error('Error: Unable to find language files!', true);
3158
+	} else
2980 3159
 	{
2981 3160
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2982 3161
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2983 3162
 
2984
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2985
-			print_error('Error: Language files out of date.', true);
2986
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2987
-			print_error('Error: Install language is missing for selected language.', true);
3163
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
3164
+					print_error('Error: Language files out of date.', true);
3165
+		}
3166
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
3167
+					print_error('Error: Install language is missing for selected language.', true);
3168
+		}
2988 3169
 
2989 3170
 		// Otherwise include it!
2990 3171
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2999,14 +3180,16 @@  discard block
 block discarded – undo
2999 3180
 {
3000 3181
 	static $fp = null;
3001 3182
 
3002
-	if ($fp === null)
3003
-		$fp = fopen('php://stderr', 'wb');
3183
+	if ($fp === null) {
3184
+			$fp = fopen('php://stderr', 'wb');
3185
+	}
3004 3186
 
3005 3187
 	fwrite($fp, $message . "\n");
3006 3188
 
3007
-	if ($fatal)
3008
-		exit;
3009
-}
3189
+	if ($fatal) {
3190
+			exit;
3191
+	}
3192
+	}
3010 3193
 
3011 3194
 function throw_error($message)
3012 3195
 {
@@ -3023,8 +3206,9 @@  discard block
 block discarded – undo
3023 3206
 {
3024 3207
 	global $upcontext, $boarddir;
3025 3208
 
3026
-	if (empty($files))
3027
-		return true;
3209
+	if (empty($files)) {
3210
+			return true;
3211
+	}
3028 3212
 
3029 3213
 	$failure = false;
3030 3214
 	// On linux, it's easy - just use is_writable!
@@ -3039,14 +3223,16 @@  discard block
 block discarded – undo
3039 3223
 				@chmod($file, 0755);
3040 3224
 
3041 3225
 				// Well, 755 hopefully worked... if not, try 777.
3042
-				if (!is_writable($file) && !@chmod($file, 0777))
3043
-					$failure = true;
3226
+				if (!is_writable($file) && !@chmod($file, 0777)) {
3227
+									$failure = true;
3228
+				}
3044 3229
 				// Otherwise remove it as it's good!
3045
-				else
3046
-					unset($files[$k]);
3230
+				else {
3231
+									unset($files[$k]);
3232
+				}
3233
+			} else {
3234
+							unset($files[$k]);
3047 3235
 			}
3048
-			else
3049
-				unset($files[$k]);
3050 3236
 		}
3051 3237
 	}
3052 3238
 	// Windows is trickier.  Let's try opening for r+...
@@ -3057,30 +3243,35 @@  discard block
 block discarded – undo
3057 3243
 		foreach ($files as $k => $file)
3058 3244
 		{
3059 3245
 			// Folders can't be opened for write... but the index.php in them can ;).
3060
-			if (is_dir($file))
3061
-				$file .= '/index.php';
3246
+			if (is_dir($file)) {
3247
+							$file .= '/index.php';
3248
+			}
3062 3249
 
3063 3250
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
3064 3251
 			@chmod($file, 0777);
3065 3252
 			$fp = @fopen($file, 'r+');
3066 3253
 
3067 3254
 			// Hmm, okay, try just for write in that case...
3068
-			if (!$fp)
3069
-				$fp = @fopen($file, 'w');
3255
+			if (!$fp) {
3256
+							$fp = @fopen($file, 'w');
3257
+			}
3070 3258
 
3071
-			if (!$fp)
3072
-				$failure = true;
3073
-			else
3074
-				unset($files[$k]);
3259
+			if (!$fp) {
3260
+							$failure = true;
3261
+			} else {
3262
+							unset($files[$k]);
3263
+			}
3075 3264
 			@fclose($fp);
3076 3265
 		}
3077 3266
 	}
3078 3267
 
3079
-	if (empty($files))
3080
-		return true;
3268
+	if (empty($files)) {
3269
+			return true;
3270
+	}
3081 3271
 
3082
-	if (!isset($_SERVER))
3083
-		return !$failure;
3272
+	if (!isset($_SERVER)) {
3273
+			return !$failure;
3274
+	}
3084 3275
 
3085 3276
 	// What still needs to be done?
3086 3277
 	$upcontext['chmod']['files'] = $files;
@@ -3131,36 +3322,40 @@  discard block
 block discarded – undo
3131 3322
 
3132 3323
 		if (!isset($ftp) || $ftp->error !== false)
3133 3324
 		{
3134
-			if (!isset($ftp))
3135
-				$ftp = new ftp_connection(null);
3325
+			if (!isset($ftp)) {
3326
+							$ftp = new ftp_connection(null);
3327
+			}
3136 3328
 			// Save the error so we can mess with listing...
3137
-			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
3138
-				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3329
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) {
3330
+							$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3331
+			}
3139 3332
 
3140 3333
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
3141 3334
 
3142
-			if ($found_path || !isset($upcontext['chmod']['path']))
3143
-				$upcontext['chmod']['path'] = $detect_path;
3335
+			if ($found_path || !isset($upcontext['chmod']['path'])) {
3336
+							$upcontext['chmod']['path'] = $detect_path;
3337
+			}
3144 3338
 
3145
-			if (!isset($upcontext['chmod']['username']))
3146
-				$upcontext['chmod']['username'] = $username;
3339
+			if (!isset($upcontext['chmod']['username'])) {
3340
+							$upcontext['chmod']['username'] = $username;
3341
+			}
3147 3342
 
3148 3343
 			// Don't forget the login token.
3149 3344
 			$upcontext += createToken('login');
3150 3345
 
3151 3346
 			return false;
3152
-		}
3153
-		else
3347
+		} else
3154 3348
 		{
3155 3349
 			// We want to do a relative path for FTP.
3156 3350
 			if (!in_array($upcontext['chmod']['path'], array('', '/')))
3157 3351
 			{
3158 3352
 				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
3159
-				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
3160
-				$ftp_root = substr($ftp_root, 0, -1);
3353
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) {
3354
+								$ftp_root = substr($ftp_root, 0, -1);
3355
+				}
3356
+			} else {
3357
+							$ftp_root = $boarddir;
3161 3358
 			}
3162
-			else
3163
-				$ftp_root = $boarddir;
3164 3359
 
3165 3360
 			// Save the info for next time!
3166 3361
 			$_SESSION['installer_temp_ftp'] = array(
@@ -3174,10 +3369,12 @@  discard block
 block discarded – undo
3174 3369
 
3175 3370
 			foreach ($files as $k => $file)
3176 3371
 			{
3177
-				if (!is_writable($file))
3178
-					$ftp->chmod($file, 0755);
3179
-				if (!is_writable($file))
3180
-					$ftp->chmod($file, 0777);
3372
+				if (!is_writable($file)) {
3373
+									$ftp->chmod($file, 0755);
3374
+				}
3375
+				if (!is_writable($file)) {
3376
+									$ftp->chmod($file, 0777);
3377
+				}
3181 3378
 
3182 3379
 				// Assuming that didn't work calculate the path without the boarddir.
3183 3380
 				if (!is_writable($file))
@@ -3186,19 +3383,23 @@  discard block
 block discarded – undo
3186 3383
 					{
3187 3384
 						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
3188 3385
 						$ftp->chmod($ftp_file, 0755);
3189
-						if (!is_writable($file))
3190
-							$ftp->chmod($ftp_file, 0777);
3386
+						if (!is_writable($file)) {
3387
+													$ftp->chmod($ftp_file, 0777);
3388
+						}
3191 3389
 						// Sometimes an extra slash can help...
3192 3390
 						$ftp_file = '/' . $ftp_file;
3193
-						if (!is_writable($file))
3194
-							$ftp->chmod($ftp_file, 0755);
3195
-						if (!is_writable($file))
3196
-							$ftp->chmod($ftp_file, 0777);
3391
+						if (!is_writable($file)) {
3392
+													$ftp->chmod($ftp_file, 0755);
3393
+						}
3394
+						if (!is_writable($file)) {
3395
+													$ftp->chmod($ftp_file, 0777);
3396
+						}
3197 3397
 					}
3198 3398
 				}
3199 3399
 
3200
-				if (is_writable($file))
3201
-					unset($files[$k]);
3400
+				if (is_writable($file)) {
3401
+									unset($files[$k]);
3402
+				}
3202 3403
 			}
3203 3404
 
3204 3405
 			$ftp->close();
@@ -3208,16 +3409,18 @@  discard block
 block discarded – undo
3208 3409
 	// What remains?
3209 3410
 	$upcontext['chmod']['files'] = $files;
3210 3411
 
3211
-	if (empty($files))
3212
-		return true;
3412
+	if (empty($files)) {
3413
+			return true;
3414
+	}
3213 3415
 
3214 3416
 	return false;
3215 3417
 }
3216 3418
 
3217 3419
 function quickFileWritable($file)
3218 3420
 {
3219
-	if (is_writable($file))
3220
-		return true;
3421
+	if (is_writable($file)) {
3422
+			return true;
3423
+	}
3221 3424
 
3222 3425
 	@chmod($file, 0755);
3223 3426
 
@@ -3227,17 +3430,19 @@  discard block
 block discarded – undo
3227 3430
 	foreach ($chmod_values as $val)
3228 3431
 	{
3229 3432
 		// If it's writable, break out of the loop
3230
-		if (is_writable($file))
3231
-			break;
3232
-		else
3233
-			@chmod($file, $val);
3433
+		if (is_writable($file)) {
3434
+					break;
3435
+		} else {
3436
+					@chmod($file, $val);
3437
+		}
3234 3438
 	}
3235 3439
 }
3236 3440
 function smf_strtolower($string)
3237 3441
 {
3238 3442
 	global $sourcedir;
3239
-	if (function_exists('mb_strtolower'))
3240
-		return mb_strtolower($string, 'UTF-8');
3443
+	if (function_exists('mb_strtolower')) {
3444
+			return mb_strtolower($string, 'UTF-8');
3445
+	}
3241 3446
 	require_once($sourcedir . '/Subs-Charset.php');
3242 3447
 	return utf8_strtolower($string);
3243 3448
 }
@@ -3260,8 +3465,7 @@  discard block
 block discarded – undo
3260 3465
 		);
3261 3466
 		
3262 3467
 		return true;
3263
-	}
3264
-	else
3468
+	} else
3265 3469
 	{
3266 3470
 		$upcontext['page_title'] = 'Converting to UTF8';
3267 3471
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -3305,8 +3509,9 @@  discard block
 block discarded – undo
3305 3509
 			)
3306 3510
 		);
3307 3511
 		$db_charsets = array();
3308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3309
-			$db_charsets[] = $row['Charset'];
3512
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3513
+					$db_charsets[] = $row['Charset'];
3514
+		}
3310 3515
 
3311 3516
 		$smcFunc['db_free_result']($request);
3312 3517
 
@@ -3342,13 +3547,15 @@  discard block
 block discarded – undo
3342 3547
 		// If there's a fulltext index, we need to drop it first...
3343 3548
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
3344 3549
 		{
3345
-			while ($row = $smcFunc['db_fetch_assoc']($request))
3346
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3550
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
3551
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3347 3552
 					$upcontext['fulltext_index'][] = $row['Key_name'];
3553
+			}
3348 3554
 			$smcFunc['db_free_result']($request);
3349 3555
 
3350
-			if (isset($upcontext['fulltext_index']))
3351
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3556
+			if (isset($upcontext['fulltext_index'])) {
3557
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3558
+			}
3352 3559
 		}
3353 3560
 
3354 3561
 		// Drop it and make a note...
@@ -3540,8 +3747,9 @@  discard block
 block discarded – undo
3540 3747
 			$replace = '%field%';
3541 3748
 
3542 3749
 			// Build a huge REPLACE statement...
3543
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
3544
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3750
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3751
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3752
+			}
3545 3753
 		}
3546 3754
 
3547 3755
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -3575,8 +3783,9 @@  discard block
 block discarded – undo
3575 3783
 			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3576 3784
 
3577 3785
 			// Just to make sure it doesn't time out.
3578
-			if (function_exists('apache_reset_timeout'))
3579
-				@apache_reset_timeout();
3786
+			if (function_exists('apache_reset_timeout')) {
3787
+							@apache_reset_timeout();
3788
+			}
3580 3789
 
3581 3790
 			$table_charsets = array();
3582 3791
 
@@ -3597,8 +3806,9 @@  discard block
 block discarded – undo
3597 3806
 					{
3598 3807
 						list($charset) = explode('_', $collation);
3599 3808
 
3600
-						if (!isset($table_charsets[$charset]))
3601
-							$table_charsets[$charset] = array();
3809
+						if (!isset($table_charsets[$charset])) {
3810
+													$table_charsets[$charset] = array();
3811
+						}
3602 3812
 
3603 3813
 						$table_charsets[$charset][] = $column_info;
3604 3814
 					}
@@ -3638,10 +3848,11 @@  discard block
 block discarded – undo
3638 3848
 				if (isset($translation_tables[$upcontext['charset_detected']]))
3639 3849
 				{
3640 3850
 					$update = '';
3641
-					foreach ($table_charsets as $charset => $columns)
3642
-						foreach ($columns as $column)
3851
+					foreach ($table_charsets as $charset => $columns) {
3852
+											foreach ($columns as $column)
3643 3853
 							$update .= '
3644 3854
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3855
+					}
3645 3856
 
3646 3857
 					$smcFunc['db_query']('', '
3647 3858
 						UPDATE {raw:table_name}
@@ -3666,8 +3877,9 @@  discard block
 block discarded – undo
3666 3877
 			// Now do the actual conversion (if still needed).
3667 3878
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3668 3879
 			{
3669
-				if ($command_line)
3670
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3880
+				if ($command_line) {
3881
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3882
+				}
3671 3883
 
3672 3884
 				$smcFunc['db_query']('', '
3673 3885
 					ALTER TABLE {raw:table_name}
@@ -3677,8 +3889,9 @@  discard block
 block discarded – undo
3677 3889
 						)
3678 3890
 				);
3679 3891
 
3680
-				if ($command_line)
3681
-					echo " done.\n";
3892
+				if ($command_line) {
3893
+									echo " done.\n";
3894
+				}
3682 3895
 			}
3683 3896
 		}
3684 3897
 
@@ -3708,8 +3921,8 @@  discard block
 block discarded – undo
3708 3921
 		);
3709 3922
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3710 3923
 		{
3711
-			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)
3712
-				$smcFunc['db_query']('', '
3924
+			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) {
3925
+							$smcFunc['db_query']('', '
3713 3926
 					UPDATE {db_prefix}log_actions
3714 3927
 					SET extra = {string:extra}
3715 3928
 					WHERE id_action = {int:current_action}',
@@ -3718,6 +3931,7 @@  discard block
 block discarded – undo
3718 3931
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3719 3932
 					)
3720 3933
 				);
3934
+			}
3721 3935
 		}
3722 3936
 		$smcFunc['db_free_result']($request);
3723 3937
 
@@ -3739,15 +3953,17 @@  discard block
 block discarded – undo
3739 3953
 	// First thing's first - did we already do this?
3740 3954
 	if (!empty($modSettings['json_done']))
3741 3955
 	{
3742
-		if ($command_line)
3743
-			return DeleteUpgrade();
3744
-		else
3745
-			return true;
3956
+		if ($command_line) {
3957
+					return DeleteUpgrade();
3958
+		} else {
3959
+					return true;
3960
+		}
3746 3961
 	}
3747 3962
 
3748 3963
 	// Done it already - js wise?
3749
-	if (!empty($_POST['json_done']))
3750
-		return true;
3964
+	if (!empty($_POST['json_done'])) {
3965
+			return true;
3966
+	}
3751 3967
 
3752 3968
 	// List of tables affected by this function
3753 3969
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3779,12 +3995,14 @@  discard block
 block discarded – undo
3779 3995
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3780 3996
 	$file_steps = $upcontext['table_count'];
3781 3997
 
3782
-	foreach ($keys as $id => $table)
3783
-		if ($id < $_GET['substep'])
3998
+	foreach ($keys as $id => $table) {
3999
+			if ($id < $_GET['substep'])
3784 4000
 			$upcontext['previous_tables'][] = $table;
4001
+	}
3785 4002
 
3786
-	if ($command_line)
3787
-		echo 'Converting data from serialize() to json_encode().';
4003
+	if ($command_line) {
4004
+			echo 'Converting data from serialize() to json_encode().';
4005
+	}
3788 4006
 
3789 4007
 	if (!$support_js || isset($_GET['xml']))
3790 4008
 	{
@@ -3824,8 +4042,9 @@  discard block
 block discarded – undo
3824 4042
 
3825 4043
 				// Loop through and fix these...
3826 4044
 				$new_settings = array();
3827
-				if ($command_line)
3828
-					echo "\n" . 'Fixing some settings...';
4045
+				if ($command_line) {
4046
+									echo "\n" . 'Fixing some settings...';
4047
+				}
3829 4048
 
3830 4049
 				foreach ($serialized_settings as $var)
3831 4050
 				{
@@ -3833,22 +4052,24 @@  discard block
 block discarded – undo
3833 4052
 					{
3834 4053
 						// Attempt to unserialize the setting
3835 4054
 						$temp = @safe_unserialize($modSettings[$var]);
3836
-						if (!$temp && $command_line)
3837
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3838
-						elseif ($temp !== false)
3839
-							$new_settings[$var] = json_encode($temp);
4055
+						if (!$temp && $command_line) {
4056
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
4057
+						} elseif ($temp !== false) {
4058
+													$new_settings[$var] = json_encode($temp);
4059
+						}
3840 4060
 					}
3841 4061
 				}
3842 4062
 
3843 4063
 				// Update everything at once
3844
-				if (!function_exists('cache_put_data'))
3845
-					require_once($sourcedir . '/Load.php');
4064
+				if (!function_exists('cache_put_data')) {
4065
+									require_once($sourcedir . '/Load.php');
4066
+				}
3846 4067
 				updateSettings($new_settings, true);
3847 4068
 
3848
-				if ($command_line)
3849
-					echo ' done.';
3850
-			}
3851
-			elseif ($table == 'themes')
4069
+				if ($command_line) {
4070
+									echo ' done.';
4071
+				}
4072
+			} elseif ($table == 'themes')
3852 4073
 			{
3853 4074
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3854 4075
 				$query = $smcFunc['db_query']('', '
@@ -3867,10 +4088,11 @@  discard block
 block discarded – undo
3867 4088
 
3868 4089
 						if ($command_line)
3869 4090
 						{
3870
-							if ($temp === false)
3871
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3872
-							else
3873
-								echo "\n" . 'Fixing admin preferences...';
4091
+							if ($temp === false) {
4092
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
4093
+							} else {
4094
+															echo "\n" . 'Fixing admin preferences...';
4095
+							}
3874 4096
 						}
3875 4097
 
3876 4098
 						if ($temp !== false)
@@ -3890,15 +4112,15 @@  discard block
 block discarded – undo
3890 4112
 								)
3891 4113
 							);
3892 4114
 
3893
-							if ($command_line)
3894
-								echo ' done.';
4115
+							if ($command_line) {
4116
+															echo ' done.';
4117
+							}
3895 4118
 						}
3896 4119
 					}
3897 4120
 
3898 4121
 					$smcFunc['db_free_result']($query);
3899 4122
 				}
3900
-			}
3901
-			else
4123
+			} else
3902 4124
 			{
3903 4125
 				// First item is always the key...
3904 4126
 				$key = $info[0];
@@ -3909,8 +4131,7 @@  discard block
 block discarded – undo
3909 4131
 				{
3910 4132
 					$col_select = $info[1];
3911 4133
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3912
-				}
3913
-				else
4134
+				} else
3914 4135
 				{
3915 4136
 					$col_select = implode(', ', $info);
3916 4137
 				}
@@ -3943,8 +4164,7 @@  discard block
 block discarded – undo
3943 4164
 								if ($temp === false && $command_line)
3944 4165
 								{
3945 4166
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3946
-								}
3947
-								else
4167
+								} else
3948 4168
 								{
3949 4169
 									$row[$col] = json_encode($temp);
3950 4170
 
@@ -3969,16 +4189,18 @@  discard block
 block discarded – undo
3969 4189
 						}
3970 4190
 					}
3971 4191
 
3972
-					if ($command_line)
3973
-						echo ' done.';
4192
+					if ($command_line) {
4193
+											echo ' done.';
4194
+					}
3974 4195
 
3975 4196
 					// Free up some memory...
3976 4197
 					$smcFunc['db_free_result']($query);
3977 4198
 				}
3978 4199
 			}
3979 4200
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3980
-			if (isset($_GET['xml']))
3981
-				return upgradeExit();
4201
+			if (isset($_GET['xml'])) {
4202
+							return upgradeExit();
4203
+			}
3982 4204
 		}
3983 4205
 
3984 4206
 		if ($command_line)
@@ -3993,8 +4215,9 @@  discard block
 block discarded – undo
3993 4215
 
3994 4216
 		$_GET['substep'] = 0;
3995 4217
 		// Make sure we move on!
3996
-		if ($command_line)
3997
-			return DeleteUpgrade();
4218
+		if ($command_line) {
4219
+					return DeleteUpgrade();
4220
+		}
3998 4221
 
3999 4222
 		return true;
4000 4223
 	}
@@ -4014,14 +4237,16 @@  discard block
 block discarded – undo
4014 4237
 	global $upcontext, $txt, $settings;
4015 4238
 
4016 4239
 	// Don't call me twice!
4017
-	if (!empty($upcontext['chmod_called']))
4018
-		return;
4240
+	if (!empty($upcontext['chmod_called'])) {
4241
+			return;
4242
+	}
4019 4243
 
4020 4244
 	$upcontext['chmod_called'] = true;
4021 4245
 
4022 4246
 	// Nothing?
4023
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
4024
-		return;
4247
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
4248
+			return;
4249
+	}
4025 4250
 
4026 4251
 	// Was it a problem with Windows?
4027 4252
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -4053,11 +4278,12 @@  discard block
 block discarded – undo
4053 4278
 					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\');
4054 4279
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
4055 4280
 
4056
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
4057
-		echo '
4281
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
4282
+			echo '
4058 4283
 					content.write(\'<hr>\n\t\t\t\');
4059 4284
 					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\');
4060 4285
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
4286
+	}
4061 4287
 
4062 4288
 	echo '
4063 4289
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -4065,17 +4291,19 @@  discard block
 block discarded – undo
4065 4291
 				}
4066 4292
 		</script>';
4067 4293
 
4068
-	if (!empty($upcontext['chmod']['ftp_error']))
4069
-		echo '
4294
+	if (!empty($upcontext['chmod']['ftp_error'])) {
4295
+			echo '
4070 4296
 			<div class="error_message red">
4071 4297
 				The following error was encountered when trying to connect:<br><br>
4072 4298
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
4073 4299
 			</div>
4074 4300
 			<br>';
4301
+	}
4075 4302
 
4076
-	if (empty($upcontext['chmod_in_form']))
4077
-		echo '
4303
+	if (empty($upcontext['chmod_in_form'])) {
4304
+			echo '
4078 4305
 	<form action="', $upcontext['form_url'], '" method="post">';
4306
+	}
4079 4307
 
4080 4308
 	echo '
4081 4309
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -4110,10 +4338,11 @@  discard block
 block discarded – undo
4110 4338
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
4111 4339
 	</div>';
4112 4340
 
4113
-	if (empty($upcontext['chmod_in_form']))
4114
-		echo '
4341
+	if (empty($upcontext['chmod_in_form'])) {
4342
+			echo '
4115 4343
 	</form>';
4116
-}
4344
+	}
4345
+	}
4117 4346
 
4118 4347
 function template_upgrade_above()
4119 4348
 {
@@ -4173,9 +4402,10 @@  discard block
 block discarded – undo
4173 4402
 				<h2>', $txt['upgrade_progress'], '</h2>
4174 4403
 				<ul>';
4175 4404
 
4176
-	foreach ($upcontext['steps'] as $num => $step)
4177
-		echo '
4405
+	foreach ($upcontext['steps'] as $num => $step) {
4406
+			echo '
4178 4407
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
4408
+	}
4179 4409
 
4180 4410
 	echo '
4181 4411
 					</ul>
@@ -4188,8 +4418,8 @@  discard block
 block discarded – undo
4188 4418
 				</div>
4189 4419
 			</div>';
4190 4420
 
4191
-	if (isset($upcontext['step_progress']))
4192
-		echo '
4421
+	if (isset($upcontext['step_progress'])) {
4422
+			echo '
4193 4423
 				<br>
4194 4424
 				<br>
4195 4425
 				<div id="progress_bar_step">
@@ -4198,6 +4428,7 @@  discard block
 block discarded – undo
4198 4428
 						<span>', $txt['upgrade_step_progress'], '</span>
4199 4429
 					</div>
4200 4430
 				</div>';
4431
+	}
4201 4432
 
4202 4433
 	echo '
4203 4434
 				<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>
@@ -4228,32 +4459,36 @@  discard block
 block discarded – undo
4228 4459
 {
4229 4460
 	global $upcontext, $txt;
4230 4461
 
4231
-	if (!empty($upcontext['pause']))
4232
-		echo '
4462
+	if (!empty($upcontext['pause'])) {
4463
+			echo '
4233 4464
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
4234 4465
 
4235 4466
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
4236 4467
 								<h3>
4237 4468
 									', $txt['upgrade_paused_overload'], '
4238 4469
 								</h3>';
4470
+	}
4239 4471
 
4240
-	if (!empty($upcontext['custom_warning']))
4241
-		echo '
4472
+	if (!empty($upcontext['custom_warning'])) {
4473
+			echo '
4242 4474
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4243 4475
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4244 4476
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
4245 4477
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
4246 4478
 								</div>';
4479
+	}
4247 4480
 
4248 4481
 	echo '
4249 4482
 								<div class="righttext" style="margin: 1ex;">';
4250 4483
 
4251
-	if (!empty($upcontext['continue']))
4252
-		echo '
4484
+	if (!empty($upcontext['continue'])) {
4485
+			echo '
4253 4486
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
4254
-	if (!empty($upcontext['skip']))
4255
-		echo '
4487
+	}
4488
+	if (!empty($upcontext['skip'])) {
4489
+			echo '
4256 4490
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
4491
+	}
4257 4492
 
4258 4493
 	echo '
4259 4494
 								</div>
@@ -4303,11 +4538,12 @@  discard block
 block discarded – undo
4303 4538
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
4304 4539
 	<smf>';
4305 4540
 
4306
-	if (!empty($upcontext['get_data']))
4307
-		foreach ($upcontext['get_data'] as $k => $v)
4541
+	if (!empty($upcontext['get_data'])) {
4542
+			foreach ($upcontext['get_data'] as $k => $v)
4308 4543
 			echo '
4309 4544
 		<get key="', $k, '">', $v, '</get>';
4310
-}
4545
+	}
4546
+	}
4311 4547
 
4312 4548
 function template_xml_below()
4313 4549
 {
@@ -4348,8 +4584,8 @@  discard block
 block discarded – undo
4348 4584
 	template_chmod();
4349 4585
 
4350 4586
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
4351
-	if ($upcontext['is_large_forum'])
4352
-		echo '
4587
+	if ($upcontext['is_large_forum']) {
4588
+			echo '
4353 4589
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4354 4590
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4355 4591
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4357,10 +4593,11 @@  discard block
 block discarded – undo
4357 4593
 				', $txt['upgrade_warning_lots_data'], '
4358 4594
 			</div>
4359 4595
 		</div>';
4596
+	}
4360 4597
 
4361 4598
 	// A warning message?
4362
-	if (!empty($upcontext['warning']))
4363
-		echo '
4599
+	if (!empty($upcontext['warning'])) {
4600
+			echo '
4364 4601
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4365 4602
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4366 4603
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4368,6 +4605,7 @@  discard block
 block discarded – undo
4368 4605
 				', $upcontext['warning'], '
4369 4606
 			</div>
4370 4607
 		</div>';
4608
+	}
4371 4609
 
4372 4610
 	// Paths are incorrect?
4373 4611
 	echo '
@@ -4383,20 +4621,22 @@  discard block
 block discarded – undo
4383 4621
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
4384 4622
 	{
4385 4623
 		$ago = time() - $upcontext['started'];
4386
-		if ($ago < 60)
4387
-			$ago = $ago . ' seconds';
4388
-		elseif ($ago < 3600)
4389
-			$ago = (int) ($ago / 60) . ' minutes';
4390
-		else
4391
-			$ago = (int) ($ago / 3600) . ' hours';
4624
+		if ($ago < 60) {
4625
+					$ago = $ago . ' seconds';
4626
+		} elseif ($ago < 3600) {
4627
+					$ago = (int) ($ago / 60) . ' minutes';
4628
+		} else {
4629
+					$ago = (int) ($ago / 3600) . ' hours';
4630
+		}
4392 4631
 
4393 4632
 		$active = time() - $upcontext['updated'];
4394
-		if ($active < 60)
4395
-			$updated = $active . ' seconds';
4396
-		elseif ($active < 3600)
4397
-			$updated = (int) ($active / 60) . ' minutes';
4398
-		else
4399
-			$updated = (int) ($active / 3600) . ' hours';
4633
+		if ($active < 60) {
4634
+					$updated = $active . ' seconds';
4635
+		} elseif ($active < 3600) {
4636
+					$updated = (int) ($active / 60) . ' minutes';
4637
+		} else {
4638
+					$updated = (int) ($active / 3600) . ' hours';
4639
+		}
4400 4640
 
4401 4641
 		echo '
4402 4642
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -4405,16 +4645,18 @@  discard block
 block discarded – undo
4405 4645
 			<div style="padding-left: 6ex;">
4406 4646
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
4407 4647
 
4408
-		if ($active < 600)
4409
-			echo '
4648
+		if ($active < 600) {
4649
+					echo '
4410 4650
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
4651
+		}
4411 4652
 
4412
-		if ($active > $upcontext['inactive_timeout'])
4413
-			echo '
4653
+		if ($active > $upcontext['inactive_timeout']) {
4654
+					echo '
4414 4655
 				<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.';
4415
-		else
4416
-			echo '
4656
+		} else {
4657
+					echo '
4417 4658
 				<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!');
4659
+		}
4418 4660
 
4419 4661
 		echo '
4420 4662
 			</div>
@@ -4430,9 +4672,10 @@  discard block
 block discarded – undo
4430 4672
 					<td>
4431 4673
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
4432 4674
 
4433
-	if (!empty($upcontext['username_incorrect']))
4434
-		echo '
4675
+	if (!empty($upcontext['username_incorrect'])) {
4676
+			echo '
4435 4677
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
4678
+	}
4436 4679
 
4437 4680
 	echo '
4438 4681
 					</td>
@@ -4443,9 +4686,10 @@  discard block
 block discarded – undo
4443 4686
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
4444 4687
 						<input type="hidden" name="hash_passwrd" value="">';
4445 4688
 
4446
-	if (!empty($upcontext['password_failed']))
4447
-		echo '
4689
+	if (!empty($upcontext['password_failed'])) {
4690
+			echo '
4448 4691
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
4692
+	}
4449 4693
 
4450 4694
 	echo '
4451 4695
 					</td>
@@ -4516,8 +4760,8 @@  discard block
 block discarded – undo
4516 4760
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
4517 4761
 
4518 4762
 	// Warning message?
4519
-	if (!empty($upcontext['upgrade_options_warning']))
4520
-		echo '
4763
+	if (!empty($upcontext['upgrade_options_warning'])) {
4764
+			echo '
4521 4765
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
4522 4766
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4523 4767
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -4525,6 +4769,7 @@  discard block
 block discarded – undo
4525 4769
 				', $upcontext['upgrade_options_warning'], '
4526 4770
 			</div>
4527 4771
 		</div>';
4772
+	}
4528 4773
 
4529 4774
 	echo '
4530 4775
 				<table>
@@ -4552,8 +4797,8 @@  discard block
 block discarded – undo
4552 4797
 					</tr>';
4553 4798
 
4554 4799
 	// Offer mysql users to switch to mysqli
4555
-	if ($db_type == 'mysql' && function_exists('mysqli_query'))
4556
-		echo '
4800
+	if ($db_type == 'mysql' && function_exists('mysqli_query')) {
4801
+			echo '
4557 4802
 					<tr valign="top">
4558 4803
 						<td width="2%">
4559 4804
 							<input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check">
@@ -4563,6 +4808,7 @@  discard block
 block discarded – undo
4563 4808
 							<strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br>
4564 4809
 						</td>
4565 4810
 					</tr>';
4811
+	}
4566 4812
 
4567 4813
 	echo '
4568 4814
 					<tr valign="top">
@@ -4582,8 +4828,8 @@  discard block
 block discarded – undo
4582 4828
 						</td>
4583 4829
 					</tr>';
4584 4830
 
4585
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
4586
-		echo '
4831
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4832
+			echo '
4587 4833
 					<tr valign="top">
4588 4834
 						<td width="2%">
4589 4835
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -4592,6 +4838,7 @@  discard block
 block discarded – undo
4592 4838
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
4593 4839
 						</td>
4594 4840
 					</tr>';
4841
+	}
4595 4842
 
4596 4843
 	echo '
4597 4844
 					<tr valign="top">
@@ -4627,10 +4874,11 @@  discard block
 block discarded – undo
4627 4874
 			<span id="debuginfo"></span>';
4628 4875
 
4629 4876
 	// Dont any tables so far?
4630
-	if (!empty($upcontext['previous_tables']))
4631
-		foreach ($upcontext['previous_tables'] as $table)
4877
+	if (!empty($upcontext['previous_tables'])) {
4878
+			foreach ($upcontext['previous_tables'] as $table)
4632 4879
 			echo '
4633 4880
 			<br>Completed Table: &quot;', $table, '&quot;.';
4881
+	}
4634 4882
 
4635 4883
 	echo '
4636 4884
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -4667,12 +4915,13 @@  discard block
 block discarded – undo
4667 4915
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4668 4916
 
4669 4917
 		// If debug flood the screen.
4670
-		if ($is_debug)
4671
-			echo '
4918
+		if ($is_debug) {
4919
+					echo '
4672 4920
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4673 4921
 
4674 4922
 				if (document.getElementById(\'debuginfo\').scrollHeight)
4675 4923
 					document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;';
4924
+		}
4676 4925
 
4677 4926
 		echo '
4678 4927
 				// Get the next update...
@@ -4704,8 +4953,9 @@  discard block
 block discarded – undo
4704 4953
 {
4705 4954
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
4706 4955
 
4707
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4708
-		$is_debug = true;
4956
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4957
+			$is_debug = true;
4958
+	}
4709 4959
 
4710 4960
 	echo '
4711 4961
 		<h3>Executing database changes</h3>
@@ -4720,8 +4970,9 @@  discard block
 block discarded – undo
4720 4970
 	{
4721 4971
 		foreach ($upcontext['actioned_items'] as $num => $item)
4722 4972
 		{
4723
-			if ($num != 0)
4724
-				echo ' Successful!';
4973
+			if ($num != 0) {
4974
+							echo ' Successful!';
4975
+			}
4725 4976
 			echo '<br>' . $item;
4726 4977
 		}
4727 4978
 		if (!empty($upcontext['changes_complete']))
@@ -4734,28 +4985,32 @@  discard block
 block discarded – undo
4734 4985
 				$seconds = intval($active % 60);
4735 4986
 
4736 4987
 				$totalTime = '';
4737
-				if ($hours > 0)
4738
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4739
-				if ($minutes > 0)
4740
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4741
-				if ($seconds > 0)
4742
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4988
+				if ($hours > 0) {
4989
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4990
+				}
4991
+				if ($minutes > 0) {
4992
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4993
+				}
4994
+				if ($seconds > 0) {
4995
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4996
+				}
4743 4997
 			}
4744 4998
 
4745
-			if ($is_debug && !empty($totalTime))
4746
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
4747
-			else
4748
-				echo ' Successful!<br><br>';
4999
+			if ($is_debug && !empty($totalTime)) {
5000
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
5001
+			} else {
5002
+							echo ' Successful!<br><br>';
5003
+			}
4749 5004
 
4750 5005
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
4751 5006
 		}
4752
-	}
4753
-	else
5007
+	} else
4754 5008
 	{
4755 5009
 		// Tell them how many files we have in total.
4756
-		if ($upcontext['file_count'] > 1)
4757
-			echo '
5010
+		if ($upcontext['file_count'] > 1) {
5011
+					echo '
4758 5012
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
5013
+		}
4759 5014
 
4760 5015
 		echo '
4761 5016
 		<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>
@@ -4771,19 +5026,23 @@  discard block
 block discarded – undo
4771 5026
 				$seconds = intval($active % 60);
4772 5027
 
4773 5028
 				$totalTime = '';
4774
-				if ($hours > 0)
4775
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4776
-				if ($minutes > 0)
4777
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4778
-				if ($seconds > 0)
4779
-					$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
+				}
4780 5038
 			}
4781 5039
 
4782 5040
 			echo '
4783 5041
 			<br><span id="upgradeCompleted">';
4784 5042
 
4785
-			if (!empty($totalTime))
4786
-				echo 'Completed in ', $totalTime, '<br>';
5043
+			if (!empty($totalTime)) {
5044
+							echo 'Completed in ', $totalTime, '<br>';
5045
+			}
4787 5046
 
4788 5047
 			echo '</span>
4789 5048
 			<div id="debug_section" style="height: 200px; overflow: auto;">
@@ -4820,9 +5079,10 @@  discard block
 block discarded – undo
4820 5079
 			var getData = "";
4821 5080
 			var debugItems = ', $upcontext['debug_items'], ';';
4822 5081
 
4823
-		if ($is_debug)
4824
-			echo '
5082
+		if ($is_debug) {
5083
+					echo '
4825 5084
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
5085
+		}
4826 5086
 
4827 5087
 		echo '
4828 5088
 			function getNextItem()
@@ -4862,9 +5122,10 @@  discard block
 block discarded – undo
4862 5122
 						document.getElementById("error_block").style.display = "";
4863 5123
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4864 5124
 
4865
-	if ($is_debug)
4866
-		echo '
5125
+	if ($is_debug) {
5126
+			echo '
4867 5127
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5128
+	}
4868 5129
 
4869 5130
 	echo '
4870 5131
 					}
@@ -4885,9 +5146,10 @@  discard block
 block discarded – undo
4885 5146
 						document.getElementById("error_block").style.display = "";
4886 5147
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4887 5148
 
4888
-	if ($is_debug)
4889
-		echo '
5149
+	if ($is_debug) {
5150
+			echo '
4890 5151
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5152
+	}
4891 5153
 
4892 5154
 	echo '
4893 5155
 					}
@@ -4946,8 +5208,8 @@  discard block
 block discarded – undo
4946 5208
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4947 5209
 				{';
4948 5210
 
4949
-		if ($is_debug)
4950
-			echo '
5211
+		if ($is_debug) {
5212
+					echo '
4951 5213
 					document.getElementById(\'debug_section\').style.display = "none";
4952 5214
 
4953 5215
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4965,6 +5227,7 @@  discard block
 block discarded – undo
4965 5227
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4966 5228
 
4967 5229
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
5230
+		}
4968 5231
 
4969 5232
 		echo '
4970 5233
 
@@ -4972,9 +5235,10 @@  discard block
 block discarded – undo
4972 5235
 					document.getElementById(\'contbutt\').disabled = 0;
4973 5236
 					document.getElementById(\'database_done\').value = 1;';
4974 5237
 
4975
-		if ($upcontext['file_count'] > 1)
4976
-			echo '
5238
+		if ($upcontext['file_count'] > 1) {
5239
+					echo '
4977 5240
 					document.getElementById(\'info1\').style.display = "none";';
5241
+		}
4978 5242
 
4979 5243
 		echo '
4980 5244
 					document.getElementById(\'info2\').style.display = "none";
@@ -4987,9 +5251,10 @@  discard block
 block discarded – undo
4987 5251
 					lastItem = 0;
4988 5252
 					prevFile = curFile;';
4989 5253
 
4990
-		if ($is_debug)
4991
-			echo '
5254
+		if ($is_debug) {
5255
+					echo '
4992 5256
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
5257
+		}
4993 5258
 
4994 5259
 		echo '
4995 5260
 					getNextItem();
@@ -4997,8 +5262,8 @@  discard block
 block discarded – undo
4997 5262
 				}';
4998 5263
 
4999 5264
 		// If debug scroll the screen.
5000
-		if ($is_debug)
5001
-			echo '
5265
+		if ($is_debug) {
5266
+					echo '
5002 5267
 				if (iLastSubStepProgress == -1)
5003 5268
 				{
5004 5269
 					// Give it consistent dots.
@@ -5017,6 +5282,7 @@  discard block
 block discarded – undo
5017 5282
 
5018 5283
 				if (document.getElementById(\'debug_section\').scrollHeight)
5019 5284
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
5285
+		}
5020 5286
 
5021 5287
 		echo '
5022 5288
 				// Update the page.
@@ -5077,9 +5343,10 @@  discard block
 block discarded – undo
5077 5343
 			}';
5078 5344
 
5079 5345
 		// Start things off assuming we've not errored.
5080
-		if (empty($upcontext['error_message']))
5081
-			echo '
5346
+		if (empty($upcontext['error_message'])) {
5347
+					echo '
5082 5348
 			getNextItem();';
5349
+		}
5083 5350
 
5084 5351
 		echo '
5085 5352
 		</script>';
@@ -5096,18 +5363,21 @@  discard block
 block discarded – undo
5096 5363
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
5097 5364
 	<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>';
5098 5365
 
5099
-	if (!empty($upcontext['error_message']))
5100
-		echo '
5366
+	if (!empty($upcontext['error_message'])) {
5367
+			echo '
5101 5368
 	<error>', $upcontext['error_message'], '</error>';
5369
+	}
5102 5370
 
5103
-	if (!empty($upcontext['error_string']))
5104
-		echo '
5371
+	if (!empty($upcontext['error_string'])) {
5372
+			echo '
5105 5373
 	<sql>', $upcontext['error_string'], '</sql>';
5374
+	}
5106 5375
 
5107
-	if ($is_debug)
5108
-		echo '
5376
+	if ($is_debug) {
5377
+			echo '
5109 5378
 	<curtime>', time(), '</curtime>';
5110
-}
5379
+	}
5380
+	}
5111 5381
 
5112 5382
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
5113 5383
 function template_convert_utf8()
@@ -5124,18 +5394,20 @@  discard block
 block discarded – undo
5124 5394
 			<span id="debuginfo"></span>';
5125 5395
 
5126 5396
 	// Done any tables so far?
5127
-	if (!empty($upcontext['previous_tables']))
5128
-		foreach ($upcontext['previous_tables'] as $table)
5397
+	if (!empty($upcontext['previous_tables'])) {
5398
+			foreach ($upcontext['previous_tables'] as $table)
5129 5399
 			echo '
5130 5400
 			<br>Completed Table: &quot;', $table, '&quot;.';
5401
+	}
5131 5402
 
5132 5403
 	echo '
5133 5404
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
5134 5405
 
5135 5406
 	// If we dropped their index, let's let them know
5136
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
5137
-		echo '
5407
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
5408
+			echo '
5138 5409
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
5410
+	}
5139 5411
 
5140 5412
 	echo '
5141 5413
 			<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>';
@@ -5171,9 +5443,10 @@  discard block
 block discarded – undo
5171 5443
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5172 5444
 
5173 5445
 		// If debug flood the screen.
5174
-		if ($is_debug)
5175
-			echo '
5446
+		if ($is_debug) {
5447
+					echo '
5176 5448
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
5449
+		}
5177 5450
 
5178 5451
 		echo '
5179 5452
 				// Get the next update...
@@ -5242,14 +5515,16 @@  discard block
 block discarded – undo
5242 5515
 		<input type="hidden" name="cleandone" value="1">';
5243 5516
 
5244 5517
 	// Files to make writable?
5245
-	if (!empty($upcontext['writable_files']))
5246
-		echo '
5518
+	if (!empty($upcontext['writable_files'])) {
5519
+			echo '
5247 5520
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5521
+	}
5248 5522
 
5249 5523
 	// We'll want a continue button...
5250
-	if (empty($upcontext['chmod']['files']))
5251
-		$upcontext['continue'] = 1;
5252
-}
5524
+	if (empty($upcontext['chmod']['files'])) {
5525
+			$upcontext['continue'] = 1;
5526
+	}
5527
+	}
5253 5528
 
5254 5529
 // Finished with the mods - let them know what we've done.
5255 5530
 function template_cleanup_done()
@@ -5311,8 +5586,9 @@  discard block
 block discarded – undo
5311 5586
 						&quot;', $language['name'], '&quot; Language Pack
5312 5587
 						<div class="smalltext">(';
5313 5588
 
5314
-			foreach ($language['files'] as $k => $file)
5315
-				echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5589
+			foreach ($language['files'] as $k => $file) {
5590
+							echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5591
+			}
5316 5592
 
5317 5593
 			echo '
5318 5594
 						</div>
@@ -5329,8 +5605,9 @@  discard block
 block discarded – undo
5329 5605
 						&quot;', $theme['name'], '&quot; Theme
5330 5606
 						<div class="smalltext">(';
5331 5607
 
5332
-			foreach ($theme['files'] as $k => $file)
5333
-				echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5608
+			foreach ($theme['files'] as $k => $file) {
5609
+							echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5610
+			}
5334 5611
 
5335 5612
 			echo '
5336 5613
 						</div>
@@ -5341,47 +5618,54 @@  discard block
 block discarded – undo
5341 5618
 
5342 5619
 		echo '
5343 5620
 		</table>';
5344
-	}
5345
-	else
5621
+	} else
5346 5622
 	{
5347 5623
 		$langFiles = 0;
5348 5624
 		$themeFiles = 0;
5349
-		if (!empty($upcontext['languages']))
5350
-			foreach ($upcontext['languages'] as $lang)
5625
+		if (!empty($upcontext['languages'])) {
5626
+					foreach ($upcontext['languages'] as $lang)
5351 5627
 				$langFiles += count($lang['files']);
5352
-		if (!empty($upcontext['themes']))
5353
-			foreach ($upcontext['themes'] as $theme)
5628
+		}
5629
+		if (!empty($upcontext['themes'])) {
5630
+					foreach ($upcontext['themes'] as $theme)
5354 5631
 				$themeFiles += count($theme['files']);
5632
+		}
5355 5633
 		echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>';
5356 5634
 
5357 5635
 		// What we're currently doing?
5358
-		if (!empty($upcontext['current_message']))
5359
-			echo '
5636
+		if (!empty($upcontext['current_message'])) {
5637
+					echo '
5360 5638
 				', $upcontext['current_message'];
5639
+		}
5361 5640
 	}
5362 5641
 
5363 5642
 	echo '
5364 5643
 		<input type="hidden" name="uptempdone" value="1">';
5365 5644
 
5366
-	if (!empty($upcontext['languages']))
5367
-		echo '
5645
+	if (!empty($upcontext['languages'])) {
5646
+			echo '
5368 5647
 		<input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">';
5369
-	if (!empty($upcontext['themes']))
5370
-		echo '
5648
+	}
5649
+	if (!empty($upcontext['themes'])) {
5650
+			echo '
5371 5651
 		<input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">';
5372
-	if (!empty($upcontext['writable_files']))
5373
-		echo '
5652
+	}
5653
+	if (!empty($upcontext['writable_files'])) {
5654
+			echo '
5374 5655
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5656
+	}
5375 5657
 
5376 5658
 	// Offer them the option to upgrade from YaBB SE?
5377
-	if (!empty($upcontext['can_upgrade_yabbse']))
5378
-		echo '
5659
+	if (!empty($upcontext['can_upgrade_yabbse'])) {
5660
+			echo '
5379 5661
 		<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>';
5662
+	}
5380 5663
 
5381 5664
 	// We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!)
5382
-	if (empty($upcontext['chmod']['files']) || $upcontext['is_test'])
5383
-		$upcontext['continue'] = 1;
5384
-}
5665
+	if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) {
5666
+			$upcontext['continue'] = 1;
5667
+	}
5668
+	}
5385 5669
 
5386 5670
 // Template for the database backup tool/
5387 5671
 function template_serialize_json()
@@ -5398,19 +5682,21 @@  discard block
 block discarded – undo
5398 5682
 			<span id="debuginfo"></span>';
5399 5683
 
5400 5684
 	// Dont any tables so far?
5401
-	if (!empty($upcontext['previous_tables']))
5402
-		foreach ($upcontext['previous_tables'] as $table)
5685
+	if (!empty($upcontext['previous_tables'])) {
5686
+			foreach ($upcontext['previous_tables'] as $table)
5403 5687
 			echo '
5404 5688
 			<br>Completed Table: &quot;', $table, '&quot;.';
5689
+	}
5405 5690
 
5406 5691
 	echo '
5407 5692
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
5408 5693
 			<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>';
5409 5694
 
5410 5695
 	// Try to make sure substep was reset.
5411
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
5412
-		echo '
5696
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
5697
+			echo '
5413 5698
 			<input type="hidden" name="substep" id="substep" value="0">';
5699
+	}
5414 5700
 
5415 5701
 	// Continue please!
5416 5702
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -5443,9 +5729,10 @@  discard block
 block discarded – undo
5443 5729
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5444 5730
 
5445 5731
 		// If debug flood the screen.
5446
-		if ($is_debug)
5447
-			echo '
5732
+		if ($is_debug) {
5733
+					echo '
5448 5734
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
5735
+		}
5449 5736
 
5450 5737
 		echo '
5451 5738
 				// Get the next update...
@@ -5480,8 +5767,8 @@  discard block
 block discarded – undo
5480 5767
 	<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>
5481 5768
 	<form action="', $boardurl, '/index.php">';
5482 5769
 
5483
-	if (!empty($upcontext['can_delete_script']))
5484
-		echo '
5770
+	if (!empty($upcontext['can_delete_script'])) {
5771
+			echo '
5485 5772
 			<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>
5486 5773
 			<script>
5487 5774
 				function doTheDelete(theCheck)
@@ -5493,6 +5780,7 @@  discard block
 block discarded – undo
5493 5780
 				}
5494 5781
 			</script>
5495 5782
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
5783
+	}
5496 5784
 
5497 5785
 	$active = time() - $upcontext['started'];
5498 5786
 	$hours = floor($active / 3600);
@@ -5502,16 +5790,20 @@  discard block
 block discarded – undo
5502 5790
 	if ($is_debug)
5503 5791
 	{
5504 5792
 		$totalTime = '';
5505
-		if ($hours > 0)
5506
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
5507
-		if ($minutes > 0)
5508
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
5509
-		if ($seconds > 0)
5510
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
5793
+		if ($hours > 0) {
5794
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
5795
+		}
5796
+		if ($minutes > 0) {
5797
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
5798
+		}
5799
+		if ($seconds > 0) {
5800
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
5801
+		}
5511 5802
 	}
5512 5803
 
5513
-	if ($is_debug && !empty($totalTime))
5514
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
5804
+	if ($is_debug && !empty($totalTime)) {
5805
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
5806
+	}
5515 5807
 
5516 5808
 	echo '<br>
5517 5809
 			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>
@@ -5571,16 +5863,19 @@  discard block
 block discarded – undo
5571 5863
 				'empty' => '',
5572 5864
 				'limit' => $limit,
5573 5865
 		));
5574
-		while ($row = $smcFunc['db_fetch_assoc']($request))
5575
-			$arIp[] = $row[$oldCol];
5866
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5867
+					$arIp[] = $row[$oldCol];
5868
+		}
5576 5869
 		$smcFunc['db_free_result']($request);
5577 5870
 
5578 5871
 		// Special case, null ip could keep us in a loop.
5579
-		if (is_null($arIp[0]))
5580
-			unset($arIp[0]);
5872
+		if (is_null($arIp[0])) {
5873
+					unset($arIp[0]);
5874
+		}
5581 5875
 
5582
-		if (empty($arIp))
5583
-			$is_done = true;
5876
+		if (empty($arIp)) {
5877
+					$is_done = true;
5878
+		}
5584 5879
 
5585 5880
 		$updates = array();
5586 5881
 		$cases = array();
@@ -5589,16 +5884,18 @@  discard block
 block discarded – undo
5589 5884
 		{
5590 5885
 			$arIp[$i] = trim($arIp[$i]);
5591 5886
 
5592
-			if (empty($arIp[$i]))
5593
-				continue;
5887
+			if (empty($arIp[$i])) {
5888
+							continue;
5889
+			}
5594 5890
 
5595 5891
 			$updates['ip' . $i] = $arIp[$i];
5596 5892
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
5597 5893
 
5598 5894
 			if ($setSize > 0 && $i % $setSize === 0)
5599 5895
 			{
5600
-				if (count($updates) == 1)
5601
-					continue;
5896
+				if (count($updates) == 1) {
5897
+									continue;
5898
+				}
5602 5899
 
5603 5900
 				$updates['whereSet'] = array_values($updates);
5604 5901
 				$smcFunc['db_query']('', '
@@ -5632,8 +5929,7 @@  discard block
 block discarded – undo
5632 5929
 							'ip' => $ip
5633 5930
 					));
5634 5931
 				}
5635
-			}
5636
-			else
5932
+			} else
5637 5933
 			{
5638 5934
 				$updates['whereSet'] = array_values($updates);
5639 5935
 				$request = $smcFunc['db_query']('', '
@@ -5647,9 +5943,9 @@  discard block
 block discarded – undo
5647 5943
 					$updates
5648 5944
 				);
5649 5945
 			}
5946
+		} else {
5947
+					$is_done = true;
5650 5948
 		}
5651
-		else
5652
-			$is_done = true;
5653 5949
 
5654 5950
 		$_GET['a'] += $limit;
5655 5951
 		$step_progress['current'] = $_GET['a'];
Please login to merge, or discard this patch.
Sources/CacheAPI-smf.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
 	 *
181 181
 	 * @access public
182 182
 	 * @param string $dir A valid path
183
-	 * @return boolean If this was successful or not.
183
+	 * @return boolean|null If this was successful or not.
184 184
 	 */
185 185
 	public function setCachedir($dir = null)
186 186
 	{
Please login to merge, or discard this patch.
Braces   +36 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -43,8 +44,9 @@  discard block
 block discarded – undo
43 44
 	{
44 45
 		$supported = is_writable($this->cachedir);
45 46
 
46
-		if ($test)
47
-			return $supported;
47
+		if ($test) {
48
+					return $supported;
49
+		}
48 50
 		return parent::isSupported() && $supported;
49 51
 	}
50 52
 
@@ -61,11 +63,13 @@  discard block
 block discarded – undo
61 63
 		{
62 64
 			// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
63 65
 			// causing newer files to take effect a while later.
64
-			if (function_exists('opcache_invalidate'))
65
-				opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
66
+			if (function_exists('opcache_invalidate')) {
67
+							opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
68
+			}
66 69
 
67
-			if (function_exists('apc_delete_file'))
68
-				@apc_delete_file($cachedir . '/data_' . $key . '.php');
70
+			if (function_exists('apc_delete_file')) {
71
+							@apc_delete_file($cachedir . '/data_' . $key . '.php');
72
+			}
69 73
 
70 74
 			// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
71 75
 			@include($cachedir . '/data_' . $key . '.php');
@@ -89,16 +93,18 @@  discard block
 block discarded – undo
89 93
 
90 94
 		// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
91 95
 		// causing newer files to take effect a while later.
92
-		if (function_exists('opcache_invalidate'))
93
-			opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
96
+		if (function_exists('opcache_invalidate')) {
97
+					opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
98
+		}
94 99
 
95
-		if (function_exists('apc_delete_file'))
96
-			@apc_delete_file($cachedir . '/data_' . $key . '.php');
100
+		if (function_exists('apc_delete_file')) {
101
+					@apc_delete_file($cachedir . '/data_' . $key . '.php');
102
+		}
97 103
 
98 104
 		// Otherwise custom cache?
99
-		if ($value === null)
100
-			@unlink($cachedir . '/data_' . $key . '.php');
101
-		else
105
+		if ($value === null) {
106
+					@unlink($cachedir . '/data_' . $key . '.php');
107
+		} else
102 108
 		{
103 109
 			$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
104 110
 
@@ -109,9 +115,9 @@  discard block
 block discarded – undo
109 115
 			{
110 116
 				@unlink($cachedir . '/data_' . $key . '.php');
111 117
 				return false;
118
+			} else {
119
+							return true;
112 120
 			}
113
-			else
114
-				return true;
115 121
 		}
116 122
 	}
117 123
 
@@ -123,15 +129,17 @@  discard block
 block discarded – undo
123 129
 		$cachedir = $this->cachedir;
124 130
 
125 131
 		// No directory = no game.
126
-		if (!is_dir($cachedir))
127
-			return;
132
+		if (!is_dir($cachedir)) {
133
+					return;
134
+		}
128 135
 
129 136
 		// Remove the files in SMF's own disk cache, if any
130 137
 		$dh = opendir($cachedir);
131 138
 		while ($file = readdir($dh))
132 139
 		{
133
-			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
134
-				@unlink($cachedir . '/' . $file);
140
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
141
+							@unlink($cachedir . '/' . $file);
142
+			}
135 143
 		}
136 144
 		closedir($dh);
137 145
 
@@ -165,8 +173,9 @@  discard block
 block discarded – undo
165 173
 		$config_vars[] = $txt['cache_smf_settings'];
166 174
 		$config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir');
167 175
 
168
-		if (!isset($context['settings_post_javascript']))
169
-			$context['settings_post_javascript'] = '';
176
+		if (!isset($context['settings_post_javascript'])) {
177
+					$context['settings_post_javascript'] = '';
178
+		}
170 179
 
171 180
 		$context['settings_post_javascript'] .= '
172 181
 			$("#cache_accelerator").change(function (e) {
@@ -187,10 +196,11 @@  discard block
 block discarded – undo
187 196
 		global $cachedir;
188 197
 
189 198
 		// If its invalid, use SMF's.
190
-		if (is_null($dir) || !is_writable($dir))
191
-			$this->cachedir = $cachedir;
192
-		else
193
-			$this->cachedir = $dir;
199
+		if (is_null($dir) || !is_writable($dir)) {
200
+					$this->cachedir = $cachedir;
201
+		} else {
202
+					$this->cachedir = $dir;
203
+		}
194 204
 	}
195 205
 
196 206
 	/**
Please login to merge, or discard this patch.
Sources/Class-CurlFetchWeb.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	* Start the curl object
63 63
 	* - allow for user override values
64 64
 	*
65
-	* @param array $options An array of cURL options
65
+	* @param integer[] $options An array of cURL options
66 66
 	* @param int $max_redirect Maximum number of redirects
67 67
 	* @return void
68 68
 	*/
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	*  - calls set_options to set the curl opts array values based on the defaults and user input
82 82
 	*
83 83
 	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
84
+	* @param string $post_data any post data as form name => value
85
+	* @return curl_fetch_web_data An instance of the curl_fetch_web_data class
86 86
 	*/
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	*
107 107
 	* @param string $url The site to fetch
108 108
 	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
109
+	* @return false|null Sets various properties of the class or returns false if the URL isn't specified
110 110
 	*/
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	);
60 60
 
61 61
 	/**
62
-	* Start the curl object
63
-	* - allow for user override values
64
-	*
65
-	* @param array $options An array of cURL options
66
-	* @param int $max_redirect Maximum number of redirects
67
-	* @return void
68
-	*/
62
+	 * Start the curl object
63
+	 * - allow for user override values
64
+	 *
65
+	 * @param array $options An array of cURL options
66
+	 * @param int $max_redirect Maximum number of redirects
67
+	 * @return void
68
+	 */
69 69
 	public function __construct($options = array(), $max_redirect = 3)
70 70
 	{
71 71
 		// Initialize class variables
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Main calling function,
78
-	*  - will request the page data from a given $url
79
-	*  - optionally will post data to the page form if post data is supplied
80
-	*  - passed arrays will be converted to a post string joined with &'s
81
-	*  - calls set_options to set the curl opts array values based on the defaults and user input
82
-	*
83
-	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
86
-	*/
77
+	 * Main calling function,
78
+	 *  - will request the page data from a given $url
79
+	 *  - optionally will post data to the page form if post data is supplied
80
+	 *  - passed arrays will be converted to a post string joined with &'s
81
+	 *  - calls set_options to set the curl opts array values based on the defaults and user input
82
+	 *
83
+	 * @param string $url the site we are going to fetch
84
+	 * @param array $post_data any post data as form name => value
85
+	 * @return object An instance of the curl_fetch_web_data class
86
+	 */
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
89 89
 		// POSTing some data perhaps?
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	* Makes the actual cURL call
104
-	*  - stores responses (url, code, error, headers, body) in the response array
105
-	*  - detects 301, 302, 307 codes and will redirect to the given response header location
106
-	*
107
-	* @param string $url The site to fetch
108
-	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
-	*/
103
+	 * Makes the actual cURL call
104
+	 *  - stores responses (url, code, error, headers, body) in the response array
105
+	 *  - detects 301, 302, 307 codes and will redirect to the given response header location
106
+	 *
107
+	 * @param string $url The site to fetch
108
+	 * @param bool $redirect Whether or not this was a redirect request
109
+	 * @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
+	 */
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
113 113
 		// we do have a url I hope
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 
161 161
 	/**
162
-	* Used if being redirected to ensure we have a fully qualified address
163
-	*
164
-	* @param string $last_url The URL we went to
165
-	* @param string $new_url The URL we were redirected to
166
-	* @return string The new URL that was in the HTTP header
167
-	*/
162
+	 * Used if being redirected to ensure we have a fully qualified address
163
+	 *
164
+	 * @param string $last_url The URL we went to
165
+	 * @param string $new_url The URL we were redirected to
166
+	 * @return string The new URL that was in the HTTP header
167
+	 */
168 168
 	private function get_redirect_url($last_url = '', $new_url = '')
169 169
 	{
170 170
 		// Get the elements for these urls
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Used to return the results to the calling program
186
-	*  - called as ->result() will return the full final array
187
-	*  - called as ->result('body') to just return the page source of the result
188
-	*
189
-	* @param string $area Used to return an area such as body, header, error
190
-	* @return string The response
191
-	*/
185
+	 * Used to return the results to the calling program
186
+	 *  - called as ->result() will return the full final array
187
+	 *  - called as ->result('body') to just return the page source of the result
188
+	 *
189
+	 * @param string $area Used to return an area such as body, header, error
190
+	 * @return string The response
191
+	 */
192 192
 	public function result($area = '')
193 193
 	{
194 194
 		$max_result = count($this->response) - 1;
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Will return all results from all loops (redirects)
205
-	*  - Can be called as ->result_raw(x) where x is a specific loop results.
206
-	*  - Call as ->result_raw() for everything.
207
-	*
208
-	* @param string $response_number Which response we want to get
209
-	* @return array|string The entire response array or just the specified response
210
-	*/
204
+	 * Will return all results from all loops (redirects)
205
+	 *  - Can be called as ->result_raw(x) where x is a specific loop results.
206
+	 *  - Call as ->result_raw() for everything.
207
+	 *
208
+	 * @param string $response_number Which response we want to get
209
+	 * @return array|string The entire response array or just the specified response
210
+	 */
211 211
 	public function result_raw($response_number = '')
212 212
 	{
213 213
 		if (!is_numeric($response_number))
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	/**
223
-	* Takes supplied POST data and url encodes it
224
-	*  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
-	*  - drops vars with @ since we don't support sending files (uploading)
226
-	*
227
-	* @param array|string $post_data The raw POST data
228
-	* @return string A string of post data
229
-	*/
223
+	 * Takes supplied POST data and url encodes it
224
+	 *  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
+	 *  - drops vars with @ since we don't support sending files (uploading)
226
+	 *
227
+	 * @param array|string $post_data The raw POST data
228
+	 * @return string A string of post data
229
+	 */
230 230
 	private function build_post_data($post_data)
231 231
 	{
232 232
 		if (is_array($post_data))
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 
247 247
 	/**
248
-	* Sets the final cURL options for the current call
249
-	*  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
-	*  - sets the callback function now that $this is existing
251
-	* @return void
252
-	*/
248
+	 * Sets the final cURL options for the current call
249
+	 *  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
+	 *  - sets the callback function now that $this is existing
251
+	 * @return void
252
+	 */
253 253
 	private function set_options()
254 254
 	{
255 255
 		// Callback to parse the returned headers, if any
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Called to initiate a redirect from a 301, 302 or 307 header
278
-	*  - resets the cURL options for the loop, sets the referrer flag
279
-	*
280
-	* @param string $target_url The URL we want to redirect to
281
-	* @param string $referer_url The URL that we're redirecting from
282
-	*/
277
+	 * Called to initiate a redirect from a 301, 302 or 307 header
278
+	 *  - resets the cURL options for the loop, sets the referrer flag
279
+	 *
280
+	 * @param string $target_url The URL we want to redirect to
281
+	 * @param string $referer_url The URL that we're redirecting from
282
+	 */
283 283
 	private function redirect($target_url, $referer_url)
284 284
 	{
285 285
 		// no no I last saw that over there ... really, 301, 302, 307
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 	/**
292
-	* Callback function to parse returned headers
293
-	*  - lowercases everything to make it consistent
294
-	*
295
-	* @param type $cr Not sure what this is used for?
296
-	* @param string $header The header
297
-	* @return int The length of the header
298
-	*/
292
+	 * Callback function to parse returned headers
293
+	 *  - lowercases everything to make it consistent
294
+	 *
295
+	 * @param type $cr Not sure what this is used for?
296
+	 * @param string $header The header
297
+	 * @return int The length of the header
298
+	 */
299 299
 	private function header_callback($cr, $header)
300 300
 	{
301 301
 		$_header = trim($header);
Please login to merge, or discard this patch.
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
  * @version 2.1 Beta 3
11 11
  */
12 12
 
13
-if (!defined('SMF'))
13
+if (!defined('SMF')) {
14 14
 	die('No direct access...');
15
+}
15 16
 
16 17
 /**
17 18
  * Class curl_fetch_web_data
@@ -87,10 +88,11 @@  discard block
 block discarded – undo
87 88
 	public function get_url_data($url, $post_data = array())
88 89
 	{
89 90
 		// POSTing some data perhaps?
90
-		if (!empty($post_data) && is_array($post_data))
91
-			$this->post_data = $this->build_post_data($post_data);
92
-		elseif (!empty($post_data))
93
-			$this->post_data = trim($post_data);
91
+		if (!empty($post_data) && is_array($post_data)) {
92
+					$this->post_data = $this->build_post_data($post_data);
93
+		} elseif (!empty($post_data)) {
94
+					$this->post_data = trim($post_data);
95
+		}
94 96
 
95 97
 		// set the options and get it
96 98
 		$this->set_options();
@@ -111,10 +113,11 @@  discard block
 block discarded – undo
111 113
 	private function curl_request($url, $redirect = false)
112 114
 	{
113 115
 		// we do have a url I hope
114
-		if ($url == '')
115
-			return false;
116
-		else
117
-			$this->options[CURLOPT_URL] = $url;
116
+		if ($url == '') {
117
+					return false;
118
+		} else {
119
+					$this->options[CURLOPT_URL] = $url;
120
+		}
118 121
 
119 122
 		// if we have not already been redirected, set it up so we can if needed
120 123
 		if (!$redirect)
@@ -194,10 +197,11 @@  discard block
 block discarded – undo
194 197
 		$max_result = count($this->response) - 1;
195 198
 
196 199
 		// just return a specifed area or the entire result?
197
-		if ($area == '')
198
-			return $this->response[$max_result];
199
-		else
200
-			return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
200
+		if ($area == '') {
201
+					return $this->response[$max_result];
202
+		} else {
203
+					return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
204
+		}
201 205
 	}
202 206
 
203 207
 	/**
@@ -210,9 +214,9 @@  discard block
 block discarded – undo
210 214
 	*/
211 215
 	public function result_raw($response_number = '')
212 216
 	{
213
-		if (!is_numeric($response_number))
214
-			return $this->response;
215
-		else
217
+		if (!is_numeric($response_number)) {
218
+					return $this->response;
219
+		} else
216 220
 		{
217 221
 			$response_number = min($response_number, count($this->response) - 1);
218 222
 			return $this->response[$response_number];
@@ -234,13 +238,14 @@  discard block
 block discarded – undo
234 238
 			$postvars = array();
235 239
 
236 240
 			// build the post data, drop ones with leading @'s since those can be used to send files, we don't support that.
237
-			foreach ($post_data as $name => $value)
238
-				$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
241
+			foreach ($post_data as $name => $value) {
242
+							$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
243
+			}
239 244
 
240 245
 			return implode('&', $postvars);
246
+		} else {
247
+					return $post_data;
241 248
 		}
242
-		else
243
-			return $post_data;
244 249
 
245 250
 	}
246 251
 
@@ -261,9 +266,9 @@  discard block
 block discarded – undo
261 266
 			$keys = array_merge(array_keys($this->default_options), array_keys($this->user_options));
262 267
 			$vals = array_merge($this->default_options, $this->user_options);
263 268
 			$this->options = array_combine($keys, $vals);
269
+		} else {
270
+					$this->options = $this->default_options;
264 271
 		}
265
-		else
266
-			$this->options = $this->default_options;
267 272
 
268 273
 		// POST data options, here we don't allow any overide
269 274
 		if (isset($this->post_data))
@@ -302,8 +307,9 @@  discard block
 block discarded – undo
302 307
 		$temp = explode(': ', $_header, 2);
303 308
 
304 309
 		// set proper headers only
305
-		if (isset($temp[0]) && isset($temp[1]))
306
-			$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
310
+		if (isset($temp[0]) && isset($temp[1])) {
311
+					$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
312
+		}
307 313
 
308 314
 		// return the length of what was passed unless you want a Failed writing header error ;)
309 315
 		return strlen($header);
Please login to merge, or discard this patch.
Sources/Class-Graphics.php 3 patches
Doc Comments   +28 added lines patch added patch discarded remove patch
@@ -44,6 +44,10 @@  discard block
 block discarded – undo
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
46 46
 
47
+	/**
48
+	 * @param string $data
49
+	 * @param integer $datLen
50
+	 */
47 51
 	public function decompress($data, &$datLen)
48 52
 	{
49 53
 		$stLen  = strlen($data);
@@ -63,6 +67,11 @@  discard block
 block discarded – undo
63 67
 		return $ret;
64 68
 	}
65 69
 
70
+	/**
71
+	 * @param boolean $bInit
72
+	 *
73
+	 * @return integer
74
+	 */
66 75
 	public function LZWCommand(&$data, $bInit)
67 76
 	{
68 77
 		if ($bInit)
@@ -253,6 +262,10 @@  discard block
 block discarded – undo
253 262
 		unset($this->m_nColors, $this->m_arColors);
254 263
 	}
255 264
 
265
+	/**
266
+	 * @param string $lpData
267
+	 * @param integer $num
268
+	 */
256 269
 	public function load($lpData, $num)
257 270
 	{
258 271
 		$this->m_nColors  = 0;
@@ -324,6 +337,9 @@  discard block
 block discarded – undo
324 337
 		unset($this->m_bSorted, $this->m_nTableSize, $this->m_nBgColor, $this->m_nPixelRatio, $this->m_colorTable);
325 338
 	}
326 339
 
340
+	/**
341
+	 * @param integer $hdrLen
342
+	 */
327 343
 	public function load($lpData, &$hdrLen)
328 344
 	{
329 345
 		$hdrLen = 0;
@@ -370,6 +386,10 @@  discard block
 block discarded – undo
370 386
 		unset($this->m_bInterlace, $this->m_bSorted, $this->m_nTableSize, $this->m_colorTable);
371 387
 	}
372 388
 
389
+	/**
390
+	 * @param string $lpData
391
+	 * @param integer $hdrLen
392
+	 */
373 393
 	public function load($lpData, &$hdrLen)
374 394
 	{
375 395
 		$hdrLen = 0;
@@ -412,6 +432,10 @@  discard block
 block discarded – undo
412 432
 		$this->m_lzw = new gif_lzw_compression();
413 433
 	}
414 434
 
435
+	/**
436
+	 * @param string $data
437
+	 * @param integer $datLen
438
+	 */
415 439
 	public function load($data, &$datLen)
416 440
 	{
417 441
 		$datLen = 0;
@@ -464,6 +488,10 @@  discard block
 block discarded – undo
464 488
 		return false;
465 489
 	}
466 490
 
491
+	/**
492
+	 * @param string $data
493
+	 * @param integer $extLen
494
+	 */
467 495
 	public function skipExt(&$data, &$extLen)
468 496
 	{
469 497
 		$extLen = 0;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		$this->MAX_LZW_BITS = 12;
39 39
 		unset($this->Next, $this->Vals, $this->Stack, $this->Buf);
40 40
 
41
-		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
42
-		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
41
+		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
42
+		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
43 43
 		$this->Stack = range(0, (1 << ($this->MAX_LZW_BITS + 1)) - 1);
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		for ($i = 0; $i < $this->m_nColors; $i++)
279 279
 		{
280 280
 			$ret .=
281
-				chr(($this->m_arColors[$i] & 0x000000FF))       . // R
282
-				chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
283
-				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16);  // B
281
+				chr(($this->m_arColors[$i] & 0x000000FF)) . // R
282
+				chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G
283
+				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B
284 284
 		}
285 285
 
286 286
 		return $ret;
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	{
291 291
 		$rgb  = intval($rgb) & 0xFFFFFF;
292 292
 		$r1   = ($rgb & 0x0000FF);
293
-		$g1   = ($rgb & 0x00FF00) >>  8;
293
+		$g1   = ($rgb & 0x00FF00) >> 8;
294 294
 		$b1   = ($rgb & 0xFF0000) >> 16;
295 295
 		$idx  = -1;
296 296
 
297 297
 		for ($i = 0; $i < $this->m_nColors; $i++)
298 298
 		{
299 299
 			$r2 = ($this->m_arColors[$i] & 0x000000FF);
300
-			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >>  8;
300
+			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8;
301 301
 			$b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16;
302 302
 			$d  = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1);
303 303
 
Please login to merge, or discard this patch.
Braces   +90 added lines, -62 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
  * @version 2.1 Beta 3
20 20
  */
21 21
 
22
-if (!defined('SMF'))
22
+if (!defined('SMF')) {
23 23
 	die('No direct access...');
24
+}
24 25
 
25 26
 /**
26 27
  * Class gif_lzw_compression
@@ -52,13 +53,15 @@  discard block
 block discarded – undo
52 53
 
53 54
 		$this->LZWCommand($data, true);
54 55
 
55
-		while (($iIndex = $this->LZWCommand($data, false)) >= 0)
56
-			$ret .= chr($iIndex);
56
+		while (($iIndex = $this->LZWCommand($data, false)) >= 0) {
57
+					$ret .= chr($iIndex);
58
+		}
57 59
 
58 60
 		$datLen = $stLen - strlen($data);
59 61
 
60
-		if ($iIndex != -2)
61
-			return false;
62
+		if ($iIndex != -2) {
63
+					return false;
64
+		}
62 65
 
63 66
 		return $ret;
64 67
 	}
@@ -140,8 +143,9 @@  discard block
 block discarded – undo
140 143
 				return $this->FirstCode;
141 144
 			}
142 145
 
143
-			if ($Code == $this->EndCode)
144
-				return -2;
146
+			if ($Code == $this->EndCode) {
147
+							return -2;
148
+			}
145 149
 
146 150
 			$InCode = $Code;
147 151
 			if ($Code >= $this->MaxCode)
@@ -156,8 +160,10 @@  discard block
 block discarded – undo
156 160
 				$this->Stack[$this->sp] = $this->Vals[$Code];
157 161
 				$this->sp++;
158 162
 
159
-				if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error!
163
+				if ($Code == $this->Next[$Code]) {
164
+					// Circular table entry, big GIF Error!
160 165
 					return -1;
166
+				}
161 167
 
162 168
 				$Code = $this->Next[$Code];
163 169
 			}
@@ -207,8 +213,9 @@  discard block
 block discarded – undo
207 213
 			if ($this->Done)
208 214
 			{
209 215
 				// Ran off the end of my bits...
210
-				if ($this->CurBit >= $this->LastBit)
211
-					return 0;
216
+				if ($this->CurBit >= $this->LastBit) {
217
+									return 0;
218
+				}
212 219
 
213 220
 				return -1;
214 221
 			}
@@ -221,13 +228,14 @@  discard block
 block discarded – undo
221 228
 
222 229
 			if ($count)
223 230
 			{
224
-				for ($i = 0; $i < $count; $i++)
225
-					$this->Buf[2 + $i] = ord($data{$i});
231
+				for ($i = 0; $i < $count; $i++) {
232
+									$this->Buf[2 + $i] = ord($data{$i});
233
+				}
226 234
 
227 235
 				$data = substr($data, $count);
236
+			} else {
237
+							$this->Done = 1;
228 238
 			}
229
-			else
230
-				$this->Done = 1;
231 239
 
232 240
 			$this->LastByte = 2 + $count;
233 241
 			$this->CurBit = ($this->CurBit - $this->LastBit) + 16;
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 		}
236 244
 
237 245
 		$iRet = 0;
238
-		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++)
239
-			$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
246
+		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) {
247
+					$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
248
+		}
240 249
 
241 250
 		$this->CurBit += $this->CodeSize;
242 251
 		return $iRet;
@@ -261,8 +270,9 @@  discard block
 block discarded – undo
261 270
 		for ($i = 0; $i < $num; $i++)
262 271
 		{
263 272
 			$rgb = substr($lpData, $i * 3, 3);
264
-			if (strlen($rgb) < 3)
265
-				return false;
273
+			if (strlen($rgb) < 3) {
274
+							return false;
275
+			}
266 276
 
267 277
 			$this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]);
268 278
 			$this->m_nColors++;
@@ -329,13 +339,15 @@  discard block
 block discarded – undo
329 339
 		$hdrLen = 0;
330 340
 
331 341
 		$this->m_lpVer = substr($lpData, 0, 6);
332
-		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a'))
333
-			return false;
342
+		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) {
343
+					return false;
344
+		}
334 345
 
335 346
 		list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4)));
336 347
 
337
-		if (!$this->m_nWidth || !$this->m_nHeight)
338
-			return false;
348
+		if (!$this->m_nWidth || !$this->m_nHeight) {
349
+					return false;
350
+		}
339 351
 
340 352
 		$b = ord(substr($lpData, 10, 1));
341 353
 		$this->m_bGlobalClr  = ($b & 0x80) ? true : false;
@@ -349,8 +361,9 @@  discard block
 block discarded – undo
349 361
 		if ($this->m_bGlobalClr)
350 362
 		{
351 363
 			$this->m_colorTable = new gif_color_table();
352
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
353
-				return false;
364
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
365
+							return false;
366
+			}
354 367
 
355 368
 			$hdrLen += 3 * $this->m_nTableSize;
356 369
 		}
@@ -377,8 +390,9 @@  discard block
 block discarded – undo
377 390
 		// Get the width/height/etc. from the header.
378 391
 		list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8)));
379 392
 
380
-		if (!$this->m_nWidth || !$this->m_nHeight)
381
-			return false;
393
+		if (!$this->m_nWidth || !$this->m_nHeight) {
394
+					return false;
395
+		}
382 396
 
383 397
 		$b = ord($lpData[8]);
384 398
 		$this->m_bLocalClr  = ($b & 0x80) ? true : false;
@@ -390,8 +404,9 @@  discard block
 block discarded – undo
390 404
 		if ($this->m_bLocalClr)
391 405
 		{
392 406
 			$this->m_colorTable = new gif_color_table();
393
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
394
-				return false;
407
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
408
+							return false;
409
+			}
395 410
 
396 411
 			$hdrLen += 3 * $this->m_nTableSize;
397 412
 		}
@@ -427,8 +442,9 @@  discard block
 block discarded – undo
427 442
 			// Extension...
428 443
 				case 0x21:
429 444
 					$len = 0;
430
-					if (!$this->skipExt($data, $len))
431
-						return false;
445
+					if (!$this->skipExt($data, $len)) {
446
+											return false;
447
+					}
432 448
 
433 449
 					$datLen += $len;
434 450
 					break;
@@ -437,22 +453,25 @@  discard block
 block discarded – undo
437 453
 				case 0x2C:
438 454
 					// Load the header and color table.
439 455
 					$len = 0;
440
-					if (!$this->m_gih->load($data, $len))
441
-						return false;
456
+					if (!$this->m_gih->load($data, $len)) {
457
+											return false;
458
+					}
442 459
 
443 460
 					$data = substr($data, $len);
444 461
 					$datLen += $len;
445 462
 
446 463
 					// Decompress the data, and ride on home ;).
447 464
 					$len = 0;
448
-					if (!($this->m_data = $this->m_lzw->decompress($data, $len)))
449
-						return false;
465
+					if (!($this->m_data = $this->m_lzw->decompress($data, $len))) {
466
+											return false;
467
+					}
450 468
 
451 469
 					$data = substr($data, $len);
452 470
 					$datLen += $len;
453 471
 
454
-					if ($this->m_gih->m_bInterlace)
455
-						$this->deInterlace();
472
+					if ($this->m_gih->m_bInterlace) {
473
+											$this->deInterlace();
474
+					}
456 475
 
457 476
 					return true;
458 477
 
@@ -572,17 +591,20 @@  discard block
 block discarded – undo
572 591
 
573 592
 	public function loadFile($filename, $iIndex)
574 593
 	{
575
-		if ($iIndex < 0)
576
-			return false;
594
+		if ($iIndex < 0) {
595
+					return false;
596
+		}
577 597
 
578 598
 		$this->data = @file_get_contents($filename);
579
-		if ($this->data === false)
580
-			return false;
599
+		if ($this->data === false) {
600
+					return false;
601
+		}
581 602
 
582 603
 		// Tell the header to load up....
583 604
 		$len = 0;
584
-		if (!$this->header->load($this->data, $len))
585
-			return false;
605
+		if (!$this->header->load($this->data, $len)) {
606
+					return false;
607
+		}
586 608
 
587 609
 		$this->data = substr($this->data, $len);
588 610
 
@@ -590,8 +612,9 @@  discard block
 block discarded – undo
590 612
 		for ($j = 0; $j <= $iIndex; $j++)
591 613
 		{
592 614
 			$imgLen = 0;
593
-			if (!$this->image->load($this->data, $imgLen))
594
-				return false;
615
+			if (!$this->image->load($this->data, $imgLen)) {
616
+							return false;
617
+			}
595 618
 
596 619
 			$this->data = substr($this->data, $imgLen);
597 620
 		}
@@ -602,8 +625,9 @@  discard block
 block discarded – undo
602 625
 
603 626
 	public function get_png_data($background_color)
604 627
 	{
605
-		if (!$this->loaded)
606
-			return false;
628
+		if (!$this->loaded) {
629
+					return false;
630
+		}
607 631
 
608 632
 		// Prepare the color table.
609 633
 		if ($this->image->m_gih->m_bLocalClr)
@@ -611,25 +635,26 @@  discard block
 block discarded – undo
611 635
 			$colors = $this->image->m_gih->m_nTableSize;
612 636
 			$pal = $this->image->m_gih->m_colorTable->toString();
613 637
 
614
-			if ($background_color != -1)
615
-				$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
616
-		}
617
-		elseif ($this->header->m_bGlobalClr)
638
+			if ($background_color != -1) {
639
+							$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
640
+			}
641
+		} elseif ($this->header->m_bGlobalClr)
618 642
 		{
619 643
 			$colors = $this->header->m_nTableSize;
620 644
 			$pal = $this->header->m_colorTable->toString();
621 645
 
622
-			if ($background_color != -1)
623
-				$background_color = $this->header->m_colorTable->colorIndex($background_color);
624
-		}
625
-		else
646
+			if ($background_color != -1) {
647
+							$background_color = $this->header->m_colorTable->colorIndex($background_color);
648
+			}
649
+		} else
626 650
 		{
627 651
 			$colors = 0;
628 652
 			$background_color = -1;
629 653
 		}
630 654
 
631
-		if ($background_color == -1)
632
-			$background_color = $this->header->m_nBgColor;
655
+		if ($background_color == -1) {
656
+					$background_color = $this->header->m_nBgColor;
657
+		}
633 658
 
634 659
 		$data = &$this->image->m_data;
635 660
 		$header = &$this->image->m_gih;
@@ -645,11 +670,13 @@  discard block
 block discarded – undo
645 670
 			for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++)
646 671
 			{
647 672
 				// Is this in the proper range?  If so, get the specific pixel data...
648
-				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight))
649
-					$bmp .= $data{$i};
673
+				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) {
674
+									$bmp .= $data{$i};
675
+				}
650 676
 				// Otherwise, this is background...
651
-				else
652
-					$bmp .= chr($background_color);
677
+				else {
678
+									$bmp .= chr($background_color);
679
+				}
653 680
 			}
654 681
 		}
655 682
 
@@ -678,8 +705,9 @@  discard block
 block discarded – undo
678 705
 			$tmp = 'tRNS';
679 706
 
680 707
 			// Stick each color on - full transparency or none.
681
-			for ($i = 0; $i < $colors; $i++)
682
-				$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
708
+			for ($i = 0; $i < $colors; $i++) {
709
+							$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
710
+			}
683 711
 
684 712
 			$out .= $tmp . pack('N', smf_crc32($tmp));
685 713
 		}
Please login to merge, or discard this patch.
Sources/Class-Package.php 3 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.
Braces   +266 added lines, -199 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
  * Class xmlArray
@@ -65,8 +66,9 @@  discard block
 block discarded – undo
65 66
 		}
66 67
 
67 68
 		// Is the input an array? (ie. passed from file()?)
68
-		if (is_array($data))
69
-			$data = implode('', $data);
69
+		if (is_array($data)) {
70
+					$data = implode('', $data);
71
+		}
70 72
 
71 73
 		// Remove any xml declaration or doctype, and parse out comments and CDATA.
72 74
 		$data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data)));
@@ -101,8 +103,9 @@  discard block
 block discarded – undo
101 103
 		// Get the element, in array form.
102 104
 		$array = $this->path($path);
103 105
 
104
-		if ($array === false)
105
-			return false;
106
+		if ($array === false) {
107
+					return false;
108
+		}
106 109
 
107 110
 		// Getting elements into this is a bit complicated...
108 111
 		if ($get_elements && !is_string($array))
@@ -113,8 +116,9 @@  discard block
 block discarded – undo
113 116
 			foreach ($array->array as $val)
114 117
 			{
115 118
 				// Skip the name and any attributes.
116
-				if (is_array($val))
117
-					$temp .= $this->_xml($val, null);
119
+				if (is_array($val)) {
120
+									$temp .= $this->_xml($val, null);
121
+				}
118 122
 			}
119 123
 
120 124
 			// Just get the XML data and then take out the CDATAs.
@@ -156,32 +160,35 @@  discard block
 block discarded – undo
156 160
 			elseif (substr($el, 0, 1) == '@')
157 161
 			{
158 162
 				// It simplifies things if the attribute is already there ;).
159
-				if (isset($array[$el]))
160
-					return $array[$el];
161
-				else
163
+				if (isset($array[$el])) {
164
+									return $array[$el];
165
+				} else
162 166
 				{
163 167
 					$trace = debug_backtrace();
164 168
 					$i = 0;
165
-					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
166
-						$i++;
169
+					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
170
+											$i++;
171
+					}
167 172
 					$debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')';
168 173
 
169 174
 					// Cause an error.
170
-					if ($this->debug_level & E_NOTICE)
171
-						trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
175
+					if ($this->debug_level & E_NOTICE) {
176
+											trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
177
+					}
172 178
 					return false;
173 179
 				}
180
+			} else {
181
+							$lvl = null;
174 182
 			}
175
-			else
176
-				$lvl = null;
177 183
 
178 184
 			// Find this element.
179 185
 			$array = $this->_path($array, $el, $lvl);
180 186
 		}
181 187
 
182 188
 		// Clean up after $lvl, for $return_full.
183
-		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']'))
184
-			$array = array('name' => $el . '[]', $array);
189
+		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) {
190
+					$array = array('name' => $el . '[]', $array);
191
+		}
185 192
 
186 193
 		// Create the right type of class...
187 194
 		$newClass = get_class($this);
@@ -216,10 +223,11 @@  discard block
 block discarded – undo
216 223
 				$el = substr($el, 0, strpos($el, '['));
217 224
 			}
218 225
 			// Find an attribute.
219
-			elseif (substr($el, 0, 1) == '@')
220
-				return isset($array[$el]);
221
-			else
222
-				$lvl = null;
226
+			elseif (substr($el, 0, 1) == '@') {
227
+							return isset($array[$el]);
228
+			} else {
229
+							$lvl = null;
230
+			}
223 231
 
224 232
 			// Find this element.
225 233
 			$array = $this->_path($array, $el, $lvl, true);
@@ -244,8 +252,9 @@  discard block
 block discarded – undo
244 252
 		$i = 0;
245 253
 		foreach ($temp->array as $item)
246 254
 		{
247
-			if (is_array($item))
248
-				$i++;
255
+			if (is_array($item)) {
256
+							$i++;
257
+			}
249 258
 		}
250 259
 
251 260
 		return $i;
@@ -269,8 +278,9 @@  discard block
 block discarded – undo
269 278
 		foreach ($xml->array as $val)
270 279
 		{
271 280
 			// Skip these, they aren't elements.
272
-			if (!is_array($val) || $val['name'] == '!')
273
-				continue;
281
+			if (!is_array($val) || $val['name'] == '!') {
282
+							continue;
283
+			}
274 284
 
275 285
 			// Create the right type of class...
276 286
 			$newClass = get_class($this);
@@ -297,14 +307,16 @@  discard block
 block discarded – undo
297 307
 			$path = $this->path($path);
298 308
 
299 309
 			// The path was not found
300
-			if ($path === false)
301
-				return false;
310
+			if ($path === false) {
311
+							return false;
312
+			}
302 313
 
303 314
 			$path = $path->array;
304 315
 		}
305 316
 		// Just use the current array.
306
-		else
307
-			$path = $this->array;
317
+		else {
318
+					$path = $this->array;
319
+		}
308 320
 
309 321
 		// Add the xml declaration to the front.
310 322
 		return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0);
@@ -326,14 +338,16 @@  discard block
 block discarded – undo
326 338
 			$path = $this->path($path);
327 339
 
328 340
 			// The path was not found
329
-			if ($path === false)
330
-				return false;
341
+			if ($path === false) {
342
+							return false;
343
+			}
331 344
 
332 345
 			$path = $path->array;
333 346
 		}
334 347
 		// No, so just use the current array.
335
-		else
336
-			$path = $this->array;
348
+		else {
349
+					$path = $this->array;
350
+		}
337 351
 
338 352
 		return $this->_array($path);
339 353
 	}
@@ -355,8 +369,9 @@  discard block
 block discarded – undo
355 369
 		{
356 370
 			// Find and remove the next tag.
357 371
 			preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match);
358
-			if (isset($match[0]))
359
-				$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
372
+			if (isset($match[0])) {
373
+							$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
374
+			}
360 375
 
361 376
 			// Didn't find a tag?  Keep looping....
362 377
 			if (!isset($match[1]) || $match[1] == '')
@@ -367,11 +382,12 @@  discard block
 block discarded – undo
367 382
 					$text_value = $this->_from_cdata($data);
368 383
 					$data = '';
369 384
 
370
-					if ($text_value != '')
371
-						$current[] = array(
385
+					if ($text_value != '') {
386
+											$current[] = array(
372 387
 							'name' => '!',
373 388
 							'value' => $text_value
374 389
 						);
390
+					}
375 391
 				}
376 392
 				// If the < isn't immediately next to the current position... more data.
377 393
 				elseif (strpos($data, '<') > 0)
@@ -379,11 +395,12 @@  discard block
 block discarded – undo
379 395
 					$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<')));
380 396
 					$data = substr($data, strpos($data, '<'));
381 397
 
382
-					if ($text_value != '')
383
-						$current[] = array(
398
+					if ($text_value != '') {
399
+											$current[] = array(
384 400
 							'name' => '!',
385 401
 							'value' => $text_value
386 402
 						);
403
+					}
387 404
 				}
388 405
 				// If we're looking at a </something> with no start, kill it.
389 406
 				elseif (strpos($data, '<') !== false && strpos($data, '<') == 0)
@@ -393,22 +410,23 @@  discard block
 block discarded – undo
393 410
 						$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1)));
394 411
 						$data = substr($data, strpos($data, '<', 1));
395 412
 
396
-						if ($text_value != '')
397
-							$current[] = array(
413
+						if ($text_value != '') {
414
+													$current[] = array(
398 415
 								'name' => '!',
399 416
 								'value' => $text_value
400 417
 							);
401
-					}
402
-					else
418
+						}
419
+					} else
403 420
 					{
404 421
 						$text_value = $this->_from_cdata($data);
405 422
 						$data = '';
406 423
 
407
-						if ($text_value != '')
408
-							$current[] = array(
424
+						if ($text_value != '') {
425
+													$current[] = array(
409 426
 								'name' => '!',
410 427
 								'value' => $text_value
411 428
 							);
429
+						}
412 430
 					}
413 431
 				}
414 432
 
@@ -425,8 +443,9 @@  discard block
 block discarded – undo
425 443
 			{
426 444
 				// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
427 445
 				$last_tag_end = strpos($data, '</' . $match[1]. '>');
428
-				if ($last_tag_end === false)
429
-					continue;
446
+				if ($last_tag_end === false) {
447
+									continue;
448
+				}
430 449
 
431 450
 				$offset = 0;
432 451
 				while (1 == 1)
@@ -434,16 +453,17 @@  discard block
 block discarded – undo
434 453
 					// Where is the next start tag?
435 454
 					$next_tag_start = strpos($data, '<' . $match[1], $offset);
436 455
 					// If the next start tag is after the last end tag then we've found the right close.
437
-					if ($next_tag_start === false || $next_tag_start > $last_tag_end)
438
-						break;
456
+					if ($next_tag_start === false || $next_tag_start > $last_tag_end) {
457
+											break;
458
+					}
439 459
 
440 460
 					// If not then find the next ending tag.
441 461
 					$next_tag_end = strpos($data, '</' . $match[1]. '>', $offset);
442 462
 
443 463
 					// Didn't find one? Then just use the last and sod it.
444
-					if ($next_tag_end === false)
445
-						break;
446
-					else
464
+					if ($next_tag_end === false) {
465
+											break;
466
+					} else
447 467
 					{
448 468
 						$last_tag_end = $next_tag_end;
449 469
 						$offset = $next_tag_start + 1;
@@ -457,16 +477,17 @@  discard block
 block discarded – undo
457 477
 				if (!empty($inner_match))
458 478
 				{
459 479
 					// Parse the inner data.
460
-					if (strpos($inner_match, '<') !== false)
461
-						$el += $this->_parse($inner_match);
462
-					elseif (trim($inner_match) != '')
480
+					if (strpos($inner_match, '<') !== false) {
481
+											$el += $this->_parse($inner_match);
482
+					} elseif (trim($inner_match) != '')
463 483
 					{
464 484
 						$text_value = $this->_from_cdata($inner_match);
465
-						if ($text_value != '')
466
-							$el[] = array(
485
+						if ($text_value != '') {
486
+													$el[] = array(
467 487
 								'name' => '!',
468 488
 								'value' => $text_value
469 489
 							);
490
+						}
470 491
 					}
471 492
 				}
472 493
 			}
@@ -478,8 +499,9 @@  discard block
 block discarded – undo
478 499
 				preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER);
479 500
 
480 501
 				// Set them as @attribute-name.
481
-				foreach ($attr as $match_attr)
482
-					$el['@' . $match_attr[1]] = $match_attr[2];
502
+				foreach ($attr as $match_attr) {
503
+									$el['@' . $match_attr[1]] = $match_attr[2];
504
+				}
483 505
 			}
484 506
 		}
485 507
 
@@ -503,16 +525,18 @@  discard block
 block discarded – undo
503 525
 		if (is_array($array) && !isset($array['name']))
504 526
 		{
505 527
 			$temp = '';
506
-			foreach ($array as $val)
507
-				$temp .= $this->_xml($val, $indent);
528
+			foreach ($array as $val) {
529
+							$temp .= $this->_xml($val, $indent);
530
+			}
508 531
 			return $temp;
509 532
 		}
510 533
 
511 534
 		// This is just text!
512
-		if ($array['name'] == '!')
513
-			return $indentation . '<![CDATA[' . $array['value'] . ']]>';
514
-		elseif (substr($array['name'], -2) == '[]')
515
-			$array['name'] = substr($array['name'], 0, -2);
535
+		if ($array['name'] == '!') {
536
+					return $indentation . '<![CDATA[' . $array['value'] . ']]>';
537
+		} elseif (substr($array['name'], -2) == '[]') {
538
+					$array['name'] = substr($array['name'], 0, -2);
539
+		}
516 540
 
517 541
 		// Start the element.
518 542
 		$output = $indentation . '<' . $array['name'];
@@ -523,9 +547,9 @@  discard block
 block discarded – undo
523 547
 		// Run through and recursively output all the elements or attrbutes inside this.
524 548
 		foreach ($array as $k => $v)
525 549
 		{
526
-			if (substr($k, 0, 1) == '@')
527
-				$output .= ' ' . substr($k, 1) . '="' . $v . '"';
528
-			elseif (is_array($v))
550
+			if (substr($k, 0, 1) == '@') {
551
+							$output .= ' ' . substr($k, 1) . '="' . $v . '"';
552
+			} elseif (is_array($v))
529 553
 			{
530 554
 				$output_el .= $this->_xml($v, $indent === null ? null : $indent + 1);
531 555
 				$inside_elements = true;
@@ -533,10 +557,11 @@  discard block
 block discarded – undo
533 557
 		}
534 558
 
535 559
 		// Indent, if necessary.... then close the tag.
536
-		if ($inside_elements)
537
-			$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
538
-		else
539
-			$output .= ' />';
560
+		if ($inside_elements) {
561
+					$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
562
+		} else {
563
+					$output .= ' />';
564
+		}
540 565
 
541 566
 		return $output;
542 567
 	}
@@ -553,19 +578,22 @@  discard block
 block discarded – undo
553 578
 		$text = '';
554 579
 		foreach ($array as $value)
555 580
 		{
556
-			if (!is_array($value) || !isset($value['name']))
557
-				continue;
581
+			if (!is_array($value) || !isset($value['name'])) {
582
+							continue;
583
+			}
558 584
 
559
-			if ($value['name'] == '!')
560
-				$text .= $value['value'];
561
-			else
562
-				$return[$value['name']] = $this->_array($value);
585
+			if ($value['name'] == '!') {
586
+							$text .= $value['value'];
587
+			} else {
588
+							$return[$value['name']] = $this->_array($value);
589
+			}
563 590
 		}
564 591
 
565
-		if (empty($return))
566
-			return $text;
567
-		else
568
-			return $return;
592
+		if (empty($return)) {
593
+					return $text;
594
+		} else {
595
+					return $return;
596
+		}
569 597
 	}
570 598
 
571 599
 	/**
@@ -583,24 +611,28 @@  discard block
 block discarded – undo
583 611
 		foreach ($parts as $part)
584 612
 		{
585 613
 			// Handle XML comments.
586
-			if (!$inCdata && $part === '<!--')
587
-				$inComment = true;
588
-			if ($inComment && $part === '-->')
589
-				$inComment = false;
590
-			elseif ($inComment)
591
-				continue;
614
+			if (!$inCdata && $part === '<!--') {
615
+							$inComment = true;
616
+			}
617
+			if ($inComment && $part === '-->') {
618
+							$inComment = false;
619
+			} elseif ($inComment) {
620
+							continue;
621
+			}
592 622
 
593 623
 			// Handle Cdata blocks.
594
-			elseif (!$inComment && $part === '<![CDATA[')
595
-				$inCdata = true;
596
-			elseif ($inCdata && $part === ']]>')
597
-				$inCdata = false;
598
-			elseif ($inCdata)
599
-				$output .= htmlentities($part, ENT_QUOTES);
624
+			elseif (!$inComment && $part === '<![CDATA[') {
625
+							$inCdata = true;
626
+			} elseif ($inCdata && $part === ']]>') {
627
+							$inCdata = false;
628
+			} elseif ($inCdata) {
629
+							$output .= htmlentities($part, ENT_QUOTES);
630
+			}
600 631
 
601 632
 			// Everything else is kept as is.
602
-			else
603
-				$output .= $part;
633
+			else {
634
+							$output .= $part;
635
+			}
604 636
 		}
605 637
 
606 638
 		return $output;
@@ -635,22 +667,26 @@  discard block
 block discarded – undo
635 667
 	protected function _fetch($array)
636 668
 	{
637 669
 		// Don't return anything if this is just a string.
638
-		if (is_string($array))
639
-			return '';
670
+		if (is_string($array)) {
671
+					return '';
672
+		}
640 673
 
641 674
 		$temp = '';
642 675
 		foreach ($array as $text)
643 676
 		{
644 677
 			// This means it's most likely an attribute or the name itself.
645
-			if (!isset($text['name']))
646
-				continue;
678
+			if (!isset($text['name'])) {
679
+							continue;
680
+			}
647 681
 
648 682
 			// This is text!
649
-			if ($text['name'] == '!')
650
-				$temp .= $text['value'];
683
+			if ($text['name'] == '!') {
684
+							$temp .= $text['value'];
685
+			}
651 686
 			// Another element - dive in ;).
652
-			else
653
-				$temp .= $this->_fetch($text);
687
+			else {
688
+							$temp .= $this->_fetch($text);
689
+			}
654 690
 		}
655 691
 
656 692
 		// Return all the bits and pieces we've put together.
@@ -669,12 +705,14 @@  discard block
 block discarded – undo
669 705
 	protected function _path($array, $path, $level, $no_error = false)
670 706
 	{
671 707
 		// Is $array even an array?  It might be false!
672
-		if (!is_array($array))
673
-			return false;
708
+		if (!is_array($array)) {
709
+					return false;
710
+		}
674 711
 
675 712
 		// Asking for *no* path?
676
-		if ($path == '' || $path == '.')
677
-			return $array;
713
+		if ($path == '' || $path == '.') {
714
+					return $array;
715
+		}
678 716
 		$paths = explode('|', $path);
679 717
 
680 718
 		// A * means all elements of any name.
@@ -685,16 +723,18 @@  discard block
 block discarded – undo
685 723
 		// Check each element.
686 724
 		foreach ($array as $value)
687 725
 		{
688
-			if (!is_array($value) || $value['name'] === '!')
689
-				continue;
726
+			if (!is_array($value) || $value['name'] === '!') {
727
+							continue;
728
+			}
690 729
 
691 730
 			if ($show_all || in_array($value['name'], $paths))
692 731
 			{
693 732
 				// Skip elements before "the one".
694
-				if ($level !== null && $level > 0)
695
-					$level--;
696
-				else
697
-					$results[] = $value;
733
+				if ($level !== null && $level > 0) {
734
+									$level--;
735
+				} else {
736
+									$results[] = $value;
737
+				}
698 738
 			}
699 739
 		}
700 740
 
@@ -703,21 +743,25 @@  discard block
 block discarded – undo
703 743
 		{
704 744
 			$trace = debug_backtrace();
705 745
 			$i = 0;
706
-			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
707
-				$i++;
746
+			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
747
+							$i++;
748
+			}
708 749
 			$debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'];
709 750
 
710 751
 			// Cause an error.
711
-			if ($this->debug_level & E_NOTICE && !$no_error)
712
-				trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
752
+			if ($this->debug_level & E_NOTICE && !$no_error) {
753
+							trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
754
+			}
713 755
 			return false;
714 756
 		}
715 757
 		// Only one result.
716
-		elseif (count($results) == 1 || $level !== null)
717
-			return $results[0];
758
+		elseif (count($results) == 1 || $level !== null) {
759
+					return $results[0];
760
+		}
718 761
 		// Return the result set.
719
-		else
720
-			return $results + array('name' => $path . '[]');
762
+		else {
763
+					return $results + array('name' => $path . '[]');
764
+		}
721 765
 	}
722 766
 }
723 767
 
@@ -764,8 +808,9 @@  discard block
 block discarded – undo
764 808
 		$this->error = false;
765 809
 		$this->pasv = array();
766 810
 
767
-		if ($ftp_server !== null)
768
-			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
811
+		if ($ftp_server !== null) {
812
+					$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
813
+		}
769 814
 	}
770 815
 
771 816
 	/**
@@ -778,14 +823,16 @@  discard block
 block discarded – undo
778 823
 	 */
779 824
 	public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
780 825
 	{
781
-		if (strpos($ftp_server, 'ftp://') === 0)
782
-			$ftp_server = substr($ftp_server, 6);
783
-		elseif (strpos($ftp_server, 'ftps://') === 0)
784
-			$ftp_server = 'ssl://' . substr($ftp_server, 7);
785
-		if (strpos($ftp_server, 'http://') === 0)
786
-			$ftp_server = substr($ftp_server, 7);
787
-		elseif (strpos($ftp_server, 'https://') === 0)
788
-			$ftp_server = substr($ftp_server, 8);
826
+		if (strpos($ftp_server, 'ftp://') === 0) {
827
+					$ftp_server = substr($ftp_server, 6);
828
+		} elseif (strpos($ftp_server, 'ftps://') === 0) {
829
+					$ftp_server = 'ssl://' . substr($ftp_server, 7);
830
+		}
831
+		if (strpos($ftp_server, 'http://') === 0) {
832
+					$ftp_server = substr($ftp_server, 7);
833
+		} elseif (strpos($ftp_server, 'https://') === 0) {
834
+					$ftp_server = substr($ftp_server, 8);
835
+		}
789 836
 		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
790 837
 
791 838
 		// Connect to the FTP server.
@@ -834,12 +881,14 @@  discard block
 block discarded – undo
834 881
 	 */
835 882
 	public function chdir($ftp_path)
836 883
 	{
837
-		if (!is_resource($this->connection))
838
-			return false;
884
+		if (!is_resource($this->connection)) {
885
+					return false;
886
+		}
839 887
 
840 888
 		// No slash on the end, please...
841
-		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/')
842
-			$ftp_path = substr($ftp_path, 0, -1);
889
+		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') {
890
+					$ftp_path = substr($ftp_path, 0, -1);
891
+		}
843 892
 
844 893
 		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
845 894
 		if (!$this->check_response(250))
@@ -860,11 +909,13 @@  discard block
 block discarded – undo
860 909
 	 */
861 910
 	public function chmod($ftp_file, $chmod)
862 911
 	{
863
-		if (!is_resource($this->connection))
864
-			return false;
912
+		if (!is_resource($this->connection)) {
913
+					return false;
914
+		}
865 915
 
866
-		if ($ftp_file == '')
867
-			$ftp_file = '.';
916
+		if ($ftp_file == '') {
917
+					$ftp_file = '.';
918
+		}
868 919
 
869 920
 		// Do we have a file or a dir?
870 921
 		$is_dir = is_dir($ftp_file);
@@ -880,9 +931,7 @@  discard block
 block discarded – undo
880 931
 			{
881 932
 				$is_writable = true;
882 933
 				break;
883
-			}
884
-
885
-			else
934
+			} else
886 935
 			{
887 936
 				// Convert the chmod value from octal (0777) to text ("777").
888 937
 				fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n");
@@ -905,8 +954,9 @@  discard block
 block discarded – undo
905 954
 	public function unlink($ftp_file)
906 955
 	{
907 956
 		// We are actually connected, right?
908
-		if (!is_resource($this->connection))
909
-			return false;
957
+		if (!is_resource($this->connection)) {
958
+					return false;
959
+		}
910 960
 
911 961
 		// Delete file X.
912 962
 		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -935,9 +985,9 @@  discard block
 block discarded – undo
935 985
 	{
936 986
 		// Wait for a response that isn't continued with -, but don't wait too long.
937 987
 		$time = time();
938
-		do
939
-			$this->last_message = fgets($this->connection, 1024);
940
-		while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
988
+		do {
989
+					$this->last_message = fgets($this->connection, 1024);
990
+		} while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
941 991
 
942 992
 		// Was the desired response returned?
943 993
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -951,15 +1001,16 @@  discard block
 block discarded – undo
951 1001
 	public function passive()
952 1002
 	{
953 1003
 		// We can't create a passive data connection without a primary one first being there.
954
-		if (!is_resource($this->connection))
955
-			return false;
1004
+		if (!is_resource($this->connection)) {
1005
+					return false;
1006
+		}
956 1007
 
957 1008
 		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
958 1009
 		@fwrite($this->connection, 'PASV' . "\r\n");
959 1010
 		$time = time();
960
-		do
961
-			$response = fgets($this->connection, 1024);
962
-		while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
1011
+		do {
1012
+					$response = fgets($this->connection, 1024);
1013
+		} while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
963 1014
 
964 1015
 		// If it's not 227, we weren't given an IP and port, which means it failed.
965 1016
 		if (strpos($response, '227 ') !== 0)
@@ -990,12 +1041,14 @@  discard block
 block discarded – undo
990 1041
 	public function create_file($ftp_file)
991 1042
 	{
992 1043
 		// First, we have to be connected... very important.
993
-		if (!is_resource($this->connection))
994
-			return false;
1044
+		if (!is_resource($this->connection)) {
1045
+					return false;
1046
+		}
995 1047
 
996 1048
 		// I'd like one passive mode, please!
997
-		if (!$this->passive())
998
-			return false;
1049
+		if (!$this->passive()) {
1050
+					return false;
1051
+		}
999 1052
 
1000 1053
 		// Seems logical enough, so far...
1001 1054
 		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -1030,12 +1083,14 @@  discard block
 block discarded – undo
1030 1083
 	public function list_dir($ftp_path = '', $search = false)
1031 1084
 	{
1032 1085
 		// Are we even connected...?
1033
-		if (!is_resource($this->connection))
1034
-			return false;
1086
+		if (!is_resource($this->connection)) {
1087
+					return false;
1088
+		}
1035 1089
 
1036 1090
 		// Passive... non-agressive...
1037
-		if (!$this->passive())
1038
-			return false;
1091
+		if (!$this->passive()) {
1092
+					return false;
1093
+		}
1039 1094
 
1040 1095
 		// Get the listing!
1041 1096
 		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -1051,8 +1106,9 @@  discard block
 block discarded – undo
1051 1106
 
1052 1107
 		// Read in the file listing.
1053 1108
 		$data = '';
1054
-		while (!feof($fp))
1055
-			$data .= fread($fp, 4096);
1109
+		while (!feof($fp)) {
1110
+					$data .= fread($fp, 4096);
1111
+		}
1056 1112
 		fclose($fp);
1057 1113
 
1058 1114
 		// Everything go okay?
@@ -1074,21 +1130,23 @@  discard block
 block discarded – undo
1074 1130
 	 */
1075 1131
 	public function locate($file, $listing = null)
1076 1132
 	{
1077
-		if ($listing === null)
1078
-			$listing = $this->list_dir('', true);
1133
+		if ($listing === null) {
1134
+					$listing = $this->list_dir('', true);
1135
+		}
1079 1136
 		$listing = explode("\n", $listing);
1080 1137
 
1081 1138
 		@fwrite($this->connection, 'PWD' . "\r\n");
1082 1139
 		$time = time();
1083
-		do
1084
-			$response = fgets($this->connection, 1024);
1085
-		while ($response[3] != ' ' && time() - $time < 5);
1140
+		do {
1141
+					$response = fgets($this->connection, 1024);
1142
+		} while ($response[3] != ' ' && time() - $time < 5);
1086 1143
 
1087 1144
 		// Check for 257!
1088
-		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1089
-			$current_dir = strtr($match[1], array('""' => '"'));
1090
-		else
1091
-			$current_dir = '';
1145
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
1146
+					$current_dir = strtr($match[1], array('""' => '"'));
1147
+		} else {
1148
+					$current_dir = '';
1149
+		}
1092 1150
 
1093 1151
 		for ($i = 0, $n = count($listing); $i < $n; $i++)
1094 1152
 		{
@@ -1101,12 +1159,15 @@  discard block
 block discarded – undo
1101 1159
 			// Okay, this file's name is:
1102 1160
 			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1103 1161
 
1104
-			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1105
-				return $listing[$i];
1106
-			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1107
-				return $listing[$i];
1108
-			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1109
-				return $listing[$i];
1162
+			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
1163
+							return $listing[$i];
1164
+			}
1165
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
1166
+							return $listing[$i];
1167
+			}
1168
+			if (basename($listing[$i]) == $file || $listing[$i] == $file) {
1169
+							return $listing[$i];
1170
+			}
1110 1171
 		}
1111 1172
 
1112 1173
 		return false;
@@ -1121,8 +1182,9 @@  discard block
 block discarded – undo
1121 1182
 	public function create_dir($ftp_dir)
1122 1183
 	{
1123 1184
 		// We must be connected to the server to do something.
1124
-		if (!is_resource($this->connection))
1125
-			return false;
1185
+		if (!is_resource($this->connection)) {
1186
+					return false;
1187
+		}
1126 1188
 
1127 1189
 		// Make this new beautiful directory!
1128 1190
 		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -1154,35 +1216,40 @@  discard block
 block discarded – undo
1154 1216
 
1155 1217
 				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
1156 1218
 
1157
-				if (substr($path, -1) == '/')
1158
-					$path = substr($path, 0, -1);
1219
+				if (substr($path, -1) == '/') {
1220
+									$path = substr($path, 0, -1);
1221
+				}
1159 1222
 
1160
-				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
1161
-					$path .= dirname($_SERVER['PHP_SELF']);
1223
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
1224
+									$path .= dirname($_SERVER['PHP_SELF']);
1225
+				}
1226
+			} elseif (strpos($filesystem_path, '/var/www/') === 0) {
1227
+							$path = substr($filesystem_path, 8);
1228
+			} else {
1229
+							$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1162 1230
 			}
1163
-			elseif (strpos($filesystem_path, '/var/www/') === 0)
1164
-				$path = substr($filesystem_path, 8);
1165
-			else
1166
-				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1231
+		} else {
1232
+					$path = '';
1167 1233
 		}
1168
-		else
1169
-			$path = '';
1170 1234
 
1171 1235
 		if (is_resource($this->connection) && $this->list_dir($path) == '')
1172 1236
 		{
1173 1237
 			$data = $this->list_dir('', true);
1174 1238
 
1175
-			if ($lookup_file === null)
1176
-				$lookup_file = $_SERVER['PHP_SELF'];
1239
+			if ($lookup_file === null) {
1240
+							$lookup_file = $_SERVER['PHP_SELF'];
1241
+			}
1177 1242
 
1178 1243
 			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
1179
-			if ($found_path == false)
1180
-				$found_path = dirname($this->locate(basename($lookup_file)));
1181
-			if ($found_path != false)
1182
-				$path = $found_path;
1244
+			if ($found_path == false) {
1245
+							$found_path = dirname($this->locate(basename($lookup_file)));
1246
+			}
1247
+			if ($found_path != false) {
1248
+							$path = $found_path;
1249
+			}
1250
+		} elseif (is_resource($this->connection)) {
1251
+					$found_path = true;
1183 1252
 		}
1184
-		elseif (is_resource($this->connection))
1185
-			$found_path = true;
1186 1253
 
1187 1254
 		return array($username, $path, isset($found_path));
1188 1255
 	}
Please login to merge, or discard this patch.
Sources/Class-SearchAPI.php 1 patch
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,6 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param array $wordsSearch Search words
57 57
 	 * @param array $wordsExclude Words to exclude
58 58
 	 * @param bool $isExcluded Whether the specfied word should be excluded
59
+	 * @return void
59 60
 	 */
60 61
 	public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded);
61 62
 
@@ -130,7 +131,7 @@  discard block
 block discarded – undo
130 131
 	 * @param array $excludedIndexWords Indexed words that should be excluded
131 132
 	 * @param array $participants
132 133
 	 * @param array $searchArray
133
-	 * @return mixed
134
+	 * @return integer
134 135
 	 */
135 136
 	public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array &$participants, array &$searchArray);
136 137
 }
Please login to merge, or discard this patch.
Sources/Class-TOTP.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Generate the timestamp for the calculation
281 281
 	 *
282
-	 * @return integer Timestamp
282
+	 * @return double Timestamp
283 283
 	 */
284 284
 	public function generateTimestamp()
285 285
 	{
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * Truncate the given hash down to just what we need
291 291
 	 *
292 292
 	 * @param string $hash Hash to truncate
293
-	 * @return string Truncated hash value
293
+	 * @return integer Truncated hash value
294 294
 	 */
295 295
 	public function truncateHash($hash)
296 296
 	{
Please login to merge, or discard this patch.
Sources/DbPackages-postgresql.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -518,7 +518,7 @@
 block discarded – undo
518 518
  * @param array $parameters Not used?
519 519
  * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated.
520 520
  * @param string $error
521
- * @return boolean Whether or not the operation was successful
521
+ * @return false|null Whether or not the operation was successful
522 522
  */
523 523
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
524 524
 {
Please login to merge, or discard this patch.
Braces   +110 added lines, -86 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
  * Add the file functions to the $smcFunc array.
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
 		'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages',
53 54
 		'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys',
54 55
 		'themes', 'topics');
55
-	foreach ($reservedTables as $k => $table_name)
56
-		$reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+	foreach ($reservedTables as $k => $table_name) {
57
+			$reservedTables[$k] = strtolower($db_prefix . $table_name);
58
+	}
57 59
 
58 60
 	// We in turn may need the extra stuff.
59 61
 	db_extend('extra');
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
103 105
 
104 106
 	// First - no way do we touch SMF tables.
105
-	if (in_array(strtolower($table_name), $reservedTables))
106
-		return false;
107
+	if (in_array(strtolower($table_name), $reservedTables)) {
108
+			return false;
109
+	}
107 110
 
108 111
 	// Log that we'll want to remove this on uninstall.
109 112
 	$db_package_log[] = array('remove_table', $table_name);
@@ -113,10 +116,11 @@  discard block
 block discarded – undo
113 116
 	if (in_array($full_table_name, $tables))
114 117
 	{
115 118
 		// This is a sad day... drop the table? If not, return false (error) by default.
116
-		if ($if_exists == 'overwrite')
117
-			$smcFunc['db_drop_table']($table_name);
118
-		else
119
-			return $if_exists == 'ignore';
119
+		if ($if_exists == 'overwrite') {
120
+					$smcFunc['db_drop_table']($table_name);
121
+		} else {
122
+					return $if_exists == 'ignore';
123
+		}
120 124
 	}
121 125
 
122 126
 	// If we've got this far - good news - no table exists. We can build our own!
@@ -134,17 +138,18 @@  discard block
 block discarded – undo
134 138
 				)
135 139
 			);
136 140
 			$default = 'default nextval(\'' . $table_name . '_seq\')';
141
+		} elseif (isset($column['default']) && $column['default'] !== null) {
142
+					$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
143
+		} else {
144
+					$default = '';
137 145
 		}
138
-		elseif (isset($column['default']) && $column['default'] !== null)
139
-			$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
140
-		else
141
-			$default = '';
142 146
 
143 147
 		// Sort out the size...
144 148
 		$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
145 149
 		list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']);
146
-		if ($size !== null)
147
-			$type = $type . '(' . $size . ')';
150
+		if ($size !== null) {
151
+					$type = $type . '(' . $size . ')';
152
+		}
148 153
 
149 154
 		// Now just put it together!
150 155
 		$table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
@@ -157,19 +162,21 @@  discard block
 block discarded – undo
157 162
 		$columns = implode(',', $index['columns']);
158 163
 
159 164
 		// Primary goes in the table...
160
-		if (isset($index['type']) && $index['type'] == 'primary')
161
-			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
162
-		else
165
+		if (isset($index['type']) && $index['type'] == 'primary') {
166
+					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
167
+		} else
163 168
 		{
164
-			if (empty($index['name']))
165
-				$index['name'] = implode('_', $index['columns']);
169
+			if (empty($index['name'])) {
170
+							$index['name'] = implode('_', $index['columns']);
171
+			}
166 172
 			$index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')';
167 173
 		}
168 174
 	}
169 175
 
170 176
 	// No trailing commas!
171
-	if (substr($table_query, -1) == ',')
172
-		$table_query = substr($table_query, 0, -1);
177
+	if (substr($table_query, -1) == ',') {
178
+			$table_query = substr($table_query, 0, -1);
179
+	}
173 180
 
174 181
 	$table_query .= ')';
175 182
 
@@ -180,12 +187,13 @@  discard block
 block discarded – undo
180 187
 		)
181 188
 	);
182 189
 	// And the indexes...
183
-	foreach ($index_queries as $query)
184
-		$smcFunc['db_query']('', $query,
190
+	foreach ($index_queries as $query) {
191
+			$smcFunc['db_query']('', $query,
185 192
 		array(
186 193
 			'security_override' => true,
187 194
 		)
188 195
 	);
196
+	}
189 197
 
190 198
 	// Go, go power rangers!
191 199
 	$smcFunc['db_transaction']('commit');
@@ -213,8 +221,9 @@  discard block
 block discarded – undo
213 221
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
214 222
 
215 223
 	// God no - dropping one of these = bad.
216
-	if (in_array(strtolower($table_name), $reservedTables))
217
-		return false;
224
+	if (in_array(strtolower($table_name), $reservedTables)) {
225
+			return false;
226
+	}
218 227
 
219 228
 	// Does it exist?
220 229
 	if (in_array($full_table_name, $smcFunc['db_list_tables']()))
@@ -272,21 +281,24 @@  discard block
 block discarded – undo
272 281
 
273 282
 	// Does it exist - if so don't add it again!
274 283
 	$columns = $smcFunc['db_list_columns']($table_name, false);
275
-	foreach ($columns as $column)
276
-		if ($column == $column_info['name'])
284
+	foreach ($columns as $column) {
285
+			if ($column == $column_info['name'])
277 286
 		{
278 287
 			// If we're going to overwrite then use change column.
279 288
 			if ($if_exists == 'update')
280 289
 				return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
281
-			else
282
-				return false;
290
+	}
291
+			else {
292
+							return false;
293
+			}
283 294
 		}
284 295
 
285 296
 	// Get the specifics...
286 297
 	$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
287 298
 	list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
288
-	if ($size !== null)
289
-		$type = $type . '(' . $size . ')';
299
+	if ($size !== null) {
300
+			$type = $type . '(' . $size . ')';
301
+	}
290 302
 
291 303
 	// Now add the thing!
292 304
 	$query = '
@@ -301,11 +313,12 @@  discard block
 block discarded – undo
301 313
 	// If there's more attributes they need to be done via a change on PostgreSQL.
302 314
 	unset($column_info['type'], $column_info['size']);
303 315
 
304
-	if (count($column_info) != 1)
305
-		return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
306
-	else
307
-		return true;
308
-}
316
+	if (count($column_info) != 1) {
317
+			return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
318
+	} else {
319
+			return true;
320
+	}
321
+	}
309 322
 
310 323
 /**
311 324
  * Removes a column.
@@ -324,8 +337,8 @@  discard block
 block discarded – undo
324 337
 
325 338
 	// Does it exist?
326 339
 	$columns = $smcFunc['db_list_columns']($table_name, true);
327
-	foreach ($columns as $column)
328
-		if ($column['name'] == $column_name)
340
+	foreach ($columns as $column) {
341
+			if ($column['name'] == $column_name)
329 342
 		{
330 343
 			// If there is an auto we need remove it!
331 344
 			if ($column['auto'])
@@ -335,6 +348,7 @@  discard block
 block discarded – undo
335 348
 						'security_override' => true,
336 349
 					)
337 350
 				);
351
+	}
338 352
 
339 353
 			$smcFunc['db_query']('', '
340 354
 				ALTER TABLE ' . $table_name . '
@@ -369,13 +383,15 @@  discard block
 block discarded – undo
369 383
 	// Check it does exist!
370 384
 	$columns = $smcFunc['db_list_columns']($table_name, true);
371 385
 	$old_info = null;
372
-	foreach ($columns as $column)
373
-		if ($column['name'] == $old_column)
386
+	foreach ($columns as $column) {
387
+			if ($column['name'] == $old_column)
374 388
 			$old_info = $column;
389
+	}
375 390
 
376 391
 	// Nothing?
377
-	if ($old_info == null)
378
-		return false;
392
+	if ($old_info == null) {
393
+			return false;
394
+	}
379 395
 
380 396
 	// Now we check each bit individually and ALTER as required.
381 397
 	if (isset($column_info['name']) && $column_info['name'] != $old_column)
@@ -432,8 +448,9 @@  discard block
 block discarded – undo
432 448
 	{
433 449
 		$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
434 450
 		list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
435
-		if ($size !== null)
436
-			$type = $type . '(' . $size . ')';
451
+		if ($size !== null) {
452
+					$type = $type . '(' . $size . ')';
453
+		}
437 454
 
438 455
 		// The alter is a pain.
439 456
 		$smcFunc['db_transaction']('begin');
@@ -527,21 +544,23 @@  discard block
 block discarded – undo
527 544
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
528 545
 
529 546
 	// No columns = no index.
530
-	if (empty($index_info['columns']))
531
-		return false;
547
+	if (empty($index_info['columns'])) {
548
+			return false;
549
+	}
532 550
 	$columns = implode(',', $index_info['columns']);
533 551
 
534 552
 	// No name - make it up!
535 553
 	if (empty($index_info['name']))
536 554
 	{
537 555
 		// No need for primary.
538
-		if (isset($index_info['type']) && $index_info['type'] == 'primary')
539
-			$index_info['name'] = '';
540
-		else
541
-			$index_info['name'] = $table_name . implode('_', $index_info['columns']);
556
+		if (isset($index_info['type']) && $index_info['type'] == 'primary') {
557
+					$index_info['name'] = '';
558
+		} else {
559
+					$index_info['name'] = $table_name . implode('_', $index_info['columns']);
560
+		}
561
+	} else {
562
+			$index_info['name'] = $table_name . $index_info['name'];
542 563
 	}
543
-	else
544
-		$index_info['name'] = $table_name . $index_info['name'];
545 564
 
546 565
 	// Log that we are going to want to remove this!
547 566
 	$db_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -554,10 +573,11 @@  discard block
 block discarded – undo
554 573
 		if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary'))
555 574
 		{
556 575
 			// If we want to overwrite simply remove the current one then continue.
557
-			if ($if_exists != 'update' || $index['type'] == 'primary')
558
-				return false;
559
-			else
560
-				$smcFunc['db_remove_index']($table_name, $index_info['name']);
576
+			if ($if_exists != 'update' || $index['type'] == 'primary') {
577
+							return false;
578
+			} else {
579
+							$smcFunc['db_remove_index']($table_name, $index_info['name']);
580
+			}
561 581
 		}
562 582
 	}
563 583
 
@@ -571,8 +591,7 @@  discard block
 block discarded – undo
571 591
 				'security_override' => true,
572 592
 			)
573 593
 		);
574
-	}
575
-	else
594
+	} else
576 595
 	{
577 596
 		$smcFunc['db_query']('', '
578 597
 			CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')',
@@ -600,8 +619,9 @@  discard block
 block discarded – undo
600 619
 
601 620
 	// Better exist!
602 621
 	$indexes = $smcFunc['db_list_indexes']($table_name, true);
603
-	if ($index_name != 'primary')
604
-		$index_name = $table_name . '_' . $index_name;
622
+	if ($index_name != 'primary') {
623
+			$index_name = $table_name . '_' . $index_name;
624
+	}
605 625
 
606 626
 	foreach ($indexes as $index)
607 627
 	{
@@ -665,8 +685,7 @@  discard block
 block discarded – undo
665 685
 			'datetime' => 'timestamp without time zone',
666 686
 			'timestamp' => 'timestamp without time zone',
667 687
 		);
668
-	}
669
-	else
688
+	} else
670 689
 	{
671 690
 		$types = array(
672 691
 			'character varying' => 'varchar',
@@ -682,14 +701,16 @@  discard block
 block discarded – undo
682 701
 	// Got it? Change it!
683 702
 	if (isset($types[$type_name]))
684 703
 	{
685
-		if ($type_name == 'tinytext')
686
-			$type_size = 255;
704
+		if ($type_name == 'tinytext') {
705
+					$type_size = 255;
706
+		}
687 707
 		$type_name = $types[$type_name];
688 708
 	}
689 709
 
690 710
 	// Only char fields got size
691
-	if (strpos($type_name, 'char') === false)
692
-			$type_size = null;
711
+	if (strpos($type_name, 'char') === false) {
712
+				$type_size = null;
713
+	}
693 714
 
694 715
 
695 716
 	return array($type_name, $type_size);
@@ -744,8 +765,7 @@  discard block
 block discarded – undo
744 765
 		if (!$detail)
745 766
 		{
746 767
 			$columns[] = $row['column_name'];
747
-		}
748
-		else
768
+		} else
749 769
 		{
750 770
 			$auto = false;
751 771
 			// What is the default?
@@ -753,11 +773,11 @@  discard block
 block discarded – undo
753 773
 			{
754 774
 				$default = null;
755 775
 				$auto = true;
776
+			} elseif (trim($row['column_default']) != '') {
777
+							$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
778
+			} else {
779
+							$default = null;
756 780
 			}
757
-			elseif (trim($row['column_default']) != '')
758
-				$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
759
-			else
760
-				$default = null;
761 781
 
762 782
 			// Make the type generic.
763 783
 			list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true);
@@ -808,26 +828,30 @@  discard block
 block discarded – undo
808 828
 	while ($row = $smcFunc['db_fetch_assoc']($result))
809 829
 	{
810 830
 		// Try get the columns that make it up.
811
-		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
812
-			continue;
831
+		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
832
+					continue;
833
+		}
813 834
 
814 835
 		$columns = explode(',', $matches[1]);
815 836
 
816
-		if (empty($columns))
817
-			continue;
837
+		if (empty($columns)) {
838
+					continue;
839
+		}
818 840
 
819
-		foreach ($columns as $k => $v)
820
-			$columns[$k] = trim($v);
841
+		foreach ($columns as $k => $v) {
842
+					$columns[$k] = trim($v);
843
+		}
821 844
 
822 845
 		// Fix up the name to be consistent cross databases
823
-		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1)
824
-			$row['name'] = 'PRIMARY';
825
-		else
826
-			$row['name'] = str_replace($table_name . '_', '', $row['name']);
846
+		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) {
847
+					$row['name'] = 'PRIMARY';
848
+		} else {
849
+					$row['name'] = str_replace($table_name . '_', '', $row['name']);
850
+		}
827 851
 
828
-		if (!$detail)
829
-			$indexes[] = $row['name'];
830
-		else
852
+		if (!$detail) {
853
+					$indexes[] = $row['name'];
854
+		} else
831 855
 		{
832 856
 			$indexes[$row['name']] = array(
833 857
 				'name' => $row['name'],
Please login to merge, or discard this patch.
Sources/Drafts.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @param string $post_errors A string of info about errors encountered trying to save this draft
177 177
  * @param array $recipientList An array of data about who this PM is being sent to
178
- * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
178
+ * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
179 179
  */
180 180
 function SavePMDraft(&$post_errors, $recipientList)
181 181
 {
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
  *
394 394
  * @param int $id_draft The ID of the draft to delete
395 395
  * @param boolean $check Whether or not to check that the draft belongs to the current user
396
- * @return boolean False if it couldn't be deleted (doesn't return anything otherwise)
396
+ * @return false|null False if it couldn't be deleted (doesn't return anything otherwise)
397 397
  */
398 398
 function DeleteDraft($id_draft, $check = true)
399 399
 {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
  * @param int $member_id ID of the member to show drafts for
428 428
  * @param boolean|integer If $type is 1, this can be set to only load drafts for posts in the specific topic
429 429
  * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts
430
- * @return boolean False if the drafts couldn't be loaded, nothing otherwise
430
+ * @return false|null False if the drafts couldn't be loaded, nothing otherwise
431 431
  */
432 432
 function ShowDrafts($member_id, $topic = false, $draft_type = 0)
433 433
 {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
  * Allows for the deleting and loading/editing of drafts
512 512
  *
513 513
  * @param type $memID
514
- * @param type $draft_type
514
+ * @param integer $draft_type
515 515
  */
516 516
 function showProfileDrafts($memID, $draft_type = 0)
517 517
 {
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
  * Uses the showpmdraft template
665 665
  * Allows for the deleting and loading/editing of drafts
666 666
  *
667
- * @param type $memID
667
+ * @param integer $memID
668 668
  */
669 669
 function showPMDrafts($memID = -1)
670 670
 {
Please login to merge, or discard this patch.
Braces   +81 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 loadLanguage('Drafts');
21 22
 
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 	global $context, $user_info, $smcFunc, $modSettings, $board;
34 35
 
35 36
 	// can you be, should you be ... here?
36
-	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
37
-		return false;
37
+	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) {
38
+			return false;
39
+	}
38 40
 
39 41
 	// read in what they sent us, if anything
40 42
 	$id_draft = (int) $_POST['id_draft'];
@@ -46,14 +48,16 @@  discard block
 block discarded – undo
46 48
 		$context['draft_saved_on'] = $draft_info['poster_time'];
47 49
 
48 50
 		// since we were called from the autosave function, send something back
49
-		if (!empty($id_draft))
50
-			XmlDraft($id_draft);
51
+		if (!empty($id_draft)) {
52
+					XmlDraft($id_draft);
53
+		}
51 54
 
52 55
 		return true;
53 56
 	}
54 57
 
55
-	if (!isset($_POST['message']))
56
-		$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
58
+	if (!isset($_POST['message'])) {
59
+			$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
60
+	}
57 61
 
58 62
 	// prepare any data from the form
59 63
 	$topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
@@ -66,8 +70,9 @@  discard block
 block discarded – undo
66 70
 
67 71
 	// message and subject still need a bit more work
68 72
 	preparsecode($draft['body']);
69
-	if ($smcFunc['strlen']($draft['subject']) > 100)
70
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
73
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
74
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
75
+	}
71 76
 
72 77
 	// Modifying an existing draft, like hitting the save draft button or autosave enabled?
73 78
 	if (!empty($id_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ -150,9 +155,9 @@  discard block
 block discarded – undo
150 155
 		{
151 156
 			$context['draft_saved'] = true;
152 157
 			$context['id_draft'] = $id_draft;
158
+		} else {
159
+					$post_errors[] = 'draft_not_saved';
153 160
 		}
154
-		else
155
-			$post_errors[] = 'draft_not_saved';
156 161
 
157 162
 		// cleanup
158 163
 		unset($_POST['save_draft']);
@@ -182,8 +187,9 @@  discard block
 block discarded – undo
182 187
 	global $context, $user_info, $smcFunc, $modSettings;
183 188
 
184 189
 	// PM survey says ... can you stay or must you go
185
-	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
186
-		return false;
190
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) {
191
+			return false;
192
+	}
187 193
 
188 194
 	// read in what you sent us
189 195
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
@@ -195,8 +201,9 @@  discard block
 block discarded – undo
195 201
 		$context['draft_saved_on'] = $draft_info['poster_time'];
196 202
 
197 203
 		// Send something back to the javascript caller
198
-		if (!empty($id_draft))
199
-			XmlDraft($id_draft);
204
+		if (!empty($id_draft)) {
205
+					XmlDraft($id_draft);
206
+		}
200 207
 
201 208
 		return true;
202 209
 	}
@@ -206,9 +213,9 @@  discard block
 block discarded – undo
206 213
 	{
207 214
 		$recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array();
208 215
 		$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
216
+	} elseif (!empty($draft_info['to_list']) && empty($recipientList)) {
217
+			$recipientList = smf_json_decode($draft_info['to_list'], true);
209 218
 	}
210
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
211
-		$recipientList = smf_json_decode($draft_info['to_list'], true);
212 219
 
213 220
 	// prepare the data we got from the form
214 221
 	$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -217,8 +224,9 @@  discard block
 block discarded – undo
217 224
 
218 225
 	// message and subject always need a bit more work
219 226
 	preparsecode($draft['body']);
220
-	if ($smcFunc['strlen']($draft['subject']) > 100)
221
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
227
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
228
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
229
+	}
222 230
 
223 231
 	// Modifying an existing PM draft?
224 232
 	if (!empty($id_pm_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ -284,9 +292,9 @@  discard block
 block discarded – undo
284 292
 		{
285 293
 			$context['draft_saved'] = true;
286 294
 			$context['id_pm_draft'] = $id_pm_draft;
295
+		} else {
296
+					$post_errors[] = 'draft_not_saved';
287 297
 		}
288
-		else
289
-			$post_errors[] = 'draft_not_saved';
290 298
 	}
291 299
 
292 300
 	// if we were called from the autosave function, send something back
@@ -319,8 +327,9 @@  discard block
 block discarded – undo
319 327
 	$type = (int) $type;
320 328
 
321 329
 	// nothing to read, nothing to do
322
-	if (empty($id_draft))
323
-		return false;
330
+	if (empty($id_draft)) {
331
+			return false;
332
+	}
324 333
 
325 334
 	// load in this draft from the DB
326 335
 	$request = $smcFunc['db_query']('', '
@@ -341,8 +350,9 @@  discard block
 block discarded – undo
341 350
 	);
342 351
 
343 352
 	// no results?
344
-	if (!$smcFunc['db_num_rows']($request))
345
-		return false;
353
+	if (!$smcFunc['db_num_rows']($request)) {
354
+			return false;
355
+	}
346 356
 
347 357
 	// load up the data
348 358
 	$draft_info = $smcFunc['db_fetch_assoc']($request);
@@ -363,8 +373,7 @@  discard block
 block discarded – undo
363 373
 			$context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
364 374
 			$context['board'] = !empty($draft_info['board_id']) ? $draft_info['id_board'] : '';
365 375
 			$context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
366
-		}
367
-		elseif ($type === 1)
376
+		} elseif ($type === 1)
368 377
 		{
369 378
 			// one of those pm drafts? then set it up like we have an error
370 379
 			$_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
@@ -400,12 +409,14 @@  discard block
 block discarded – undo
400 409
 	global $user_info, $smcFunc;
401 410
 
402 411
 	// Only a single draft.
403
-	if (is_numeric($id_draft))
404
-		$id_draft = array($id_draft);
412
+	if (is_numeric($id_draft)) {
413
+			$id_draft = array($id_draft);
414
+	}
405 415
 
406 416
 	// can't delete nothing
407
-	if (empty($id_draft) || ($check && empty($user_info['id'])))
408
-		return false;
417
+	if (empty($id_draft) || ($check && empty($user_info['id']))) {
418
+			return false;
419
+	}
409 420
 
410 421
 	$smcFunc['db_query']('', '
411 422
 		DELETE FROM {db_prefix}user_drafts
@@ -434,14 +445,16 @@  discard block
 block discarded – undo
434 445
 	global $smcFunc, $scripturl, $context, $txt, $modSettings;
435 446
 
436 447
 	// Permissions
437
-	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id))
438
-		return false;
448
+	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) {
449
+			return false;
450
+	}
439 451
 
440 452
 	$context['drafts'] = array();
441 453
 
442 454
 	// has a specific draft has been selected?  Load it up if there is not a message already in the editor
443
-	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message']))
444
-		ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
455
+	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
456
+			ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
457
+	}
445 458
 
446 459
 	// load the drafts this user has available
447 460
 	$request = $smcFunc['db_query']('', '
@@ -464,23 +477,26 @@  discard block
 block discarded – undo
464 477
 	// add them to the draft array for display
465 478
 	while ($row = $smcFunc['db_fetch_assoc']($request))
466 479
 	{
467
-		if (empty($row['subject']))
468
-			$row['subject'] = $txt['no_subject'];
480
+		if (empty($row['subject'])) {
481
+					$row['subject'] = $txt['no_subject'];
482
+		}
469 483
 
470 484
 		// Post drafts
471
-		if ($draft_type === 0)
472
-			$context['drafts'][] = array(
485
+		if ($draft_type === 0) {
486
+					$context['drafts'][] = array(
473 487
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
474 488
 				'poster_time' => timeformat($row['poster_time']),
475 489
 				'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic='. $row['id_topic'] .'.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>',
476 490
 			);
491
+		}
477 492
 		// PM drafts
478
-		elseif ($draft_type === 1)
479
-			$context['drafts'][] = array(
493
+		elseif ($draft_type === 1) {
494
+					$context['drafts'][] = array(
480 495
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
481 496
 				'poster_time' => timeformat($row['poster_time']),
482 497
 				'link' => '<a href="' . $scripturl . '?action=pm;sa=send;id_draft=' . $row['id_draft'] . '">' . (!empty($row['subject']) ? $row['subject'] : $txt['drafts_none']) . '</a>',
483 498
 			);
499
+		}
484 500
 	}
485 501
 	$smcFunc['db_free_result']($request);
486 502
 }
@@ -544,8 +560,9 @@  discard block
 block discarded – undo
544 560
 	}
545 561
 
546 562
 	// Default to 10.
547
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
548
-		$_REQUEST['viewscount'] = 10;
563
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
564
+			$_REQUEST['viewscount'] = 10;
565
+	}
549 566
 
550 567
 	// Get the count of applicable drafts on the boards they can (still) see ...
551 568
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -610,12 +627,14 @@  discard block
 block discarded – undo
610 627
 	while ($row = $smcFunc['db_fetch_assoc']($request))
611 628
 	{
612 629
 		// Censor....
613
-		if (empty($row['body']))
614
-			$row['body'] = '';
630
+		if (empty($row['body'])) {
631
+					$row['body'] = '';
632
+		}
615 633
 
616 634
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
617
-		if (empty($row['subject']))
618
-			$row['subject'] = $txt['no_subject'];
635
+		if (empty($row['subject'])) {
636
+					$row['subject'] = $txt['no_subject'];
637
+		}
619 638
 
620 639
 		censorText($row['body']);
621 640
 		censorText($row['subject']);
@@ -647,8 +666,9 @@  discard block
 block discarded – undo
647 666
 	$smcFunc['db_free_result']($request);
648 667
 
649 668
 	// If the drafts were retrieved in reverse order, get them right again.
650
-	if ($reverse)
651
-		$context['drafts'] = array_reverse($context['drafts'], true);
669
+	if ($reverse) {
670
+			$context['drafts'] = array_reverse($context['drafts'], true);
671
+	}
652 672
 
653 673
 	// Menu tab
654 674
 	$context[$context['profile_menu_name']]['tab_data'] = array(
@@ -706,8 +726,9 @@  discard block
 block discarded – undo
706 726
 	}
707 727
 
708 728
 	// Default to 10.
709
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
710
-		$_REQUEST['viewscount'] = 10;
729
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
730
+			$_REQUEST['viewscount'] = 10;
731
+	}
711 732
 
712 733
 	// Get the count of applicable drafts
713 734
 	$request = $smcFunc['db_query']('', '
@@ -766,12 +787,14 @@  discard block
 block discarded – undo
766 787
 	while ($row = $smcFunc['db_fetch_assoc']($request))
767 788
 	{
768 789
 		// Censor....
769
-		if (empty($row['body']))
770
-			$row['body'] = '';
790
+		if (empty($row['body'])) {
791
+					$row['body'] = '';
792
+		}
771 793
 
772 794
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
773
-		if (empty($row['subject']))
774
-			$row['subject'] = $txt['no_subject'];
795
+		if (empty($row['subject'])) {
796
+					$row['subject'] = $txt['no_subject'];
797
+		}
775 798
 
776 799
 		censorText($row['body']);
777 800
 		censorText($row['subject']);
@@ -826,8 +849,9 @@  discard block
 block discarded – undo
826 849
 	$smcFunc['db_free_result']($request);
827 850
 
828 851
 	// if the drafts were retrieved in reverse order, then put them in the right order again.
829
-	if ($reverse)
830
-		$context['drafts'] = array_reverse($context['drafts'], true);
852
+	if ($reverse) {
853
+			$context['drafts'] = array_reverse($context['drafts'], true);
854
+	}
831 855
 
832 856
 	// off to the template we go
833 857
 	$context['page_title'] = $txt['drafts'];
Please login to merge, or discard this patch.