Completed
Pull Request — release-2.1 (#4873)
by Fran
10:04
created
other/upgrade.php 2 patches
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		echo '<!DOCTYPE html>
450 450
 <html>
451 451
 	<head>
452
-		<title>', $txt['upgrader_error'] ,' </title>
452
+		<title>', $txt['upgrader_error'], ' </title>
453 453
 		<style>
454 454
 			body {
455 455
 				font-family: sans-serif;
@@ -465,12 +465,12 @@  discard block
 block discarded – undo
465 465
 		</style>
466 466
 	</head>
467 467
 	<body>
468
-		<h1>', $txt['upgrade_criterr'] ,'</h1>
469
-		<p>', $txt['upgrade_nofiles'] ,'</p>
468
+		<h1>', $txt['upgrade_criterr'], '</h1>
469
+		<p>', $txt['upgrade_nofiles'], '</p>
470 470
 		<div class="directory">', dirname($_SERVER['PHP_SELF']) != '/' ? dirname($_SERVER['PHP_SELF']) : '', '/Themes/default/languages</div>
471
-		<p>', $txt['upgrade_check_files'] ,'</p>
472
-		<p>', $txt['upgrade_check_files2'] ,'</p>
473
-		<p>', $txt['upgrade_support'] ,'</p>
471
+		<p>', $txt['upgrade_check_files'], '</p>
472
+		<p>', $txt['upgrade_check_files2'], '</p>
473
+		<p>', $txt['upgrade_support'], '</p>
474 474
 	</body>
475 475
 </html>';
476 476
 		die;
@@ -834,13 +834,13 @@  discard block
 block discarded – undo
834 834
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
835 835
 	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
836 836
 		$upcontext['warning'] = '
837
-			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br>
837
+			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) . '<br>
838 838
 			<ul>
839
-				<li>'. $txt['upgrade_boarddir'] .'  ' . $boarddir . '</li>
840
-				<li>'. $txt['upgrade_sourcedir'] .'  ' . $boarddir . '</li>
841
-				<li>'. $txt['upgrade_cachedir'] .'  ' . $cachedir_temp . '</li>
839
+				<li>'. $txt['upgrade_boarddir'] . '  ' . $boarddir . '</li>
840
+				<li>'. $txt['upgrade_sourcedir'] . '  ' . $boarddir . '</li>
841
+				<li>'. $txt['upgrade_cachedir'] . '  ' . $cachedir_temp . '</li>
842 842
 			</ul>
843
-			'. $txt['upgrade_incorrect_settings'] .'';
843
+			'. $txt['upgrade_incorrect_settings'] . '';
844 844
 
845 845
 	// Confirm mbstring is loaded...
846 846
 	if (!extension_loaded('mbstring'))
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 
1775 1775
 	// Our custom error handler - does nothing but does stop public errors from XML!
1776 1776
 	set_error_handler(
1777
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1777
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1778 1778
 		{
1779 1779
 			if ($support_js)
1780 1780
 				return true;
@@ -2773,94 +2773,94 @@  discard block
 block discarded – undo
2773 2773
 		// Translation table for the character sets not native for MySQL.
2774 2774
 		$translation_tables = array(
2775 2775
 			'windows-1255' => array(
2776
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2777
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2778
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2779
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2780
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2781
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2782
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2783
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2784
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2785
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2786
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2787
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2788
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2789
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2790
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2791
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2792
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2793
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2794
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2795
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2796
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2797
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2798
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2799
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2800
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2801
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2802
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2803
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2804
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2805
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2806
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2807
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2808
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2809
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2810
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2811
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2812
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2813
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2814
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2815
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2816
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2817
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2776
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2777
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2778
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2779
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2780
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2781
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2782
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2783
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2784
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2785
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2786
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2787
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2788
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2789
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2790
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2791
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2792
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2793
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2794
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2795
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2796
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2797
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2798
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2799
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2800
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2801
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2802
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2803
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2804
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2805
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2806
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2807
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2808
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2809
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2810
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2811
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2812
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2813
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2814
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2815
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2816
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2817
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2818 2818
 				'0xFA' => '0xD7AA',
2819 2819
 			),
2820 2820
 			'windows-1253' => array(
2821
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2822
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2823
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2824
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2825
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2826
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2827
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2828
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2829
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2830
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2831
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2832
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2833
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2834
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2835
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2836
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2837
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2838
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2839
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2840
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2841
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2842
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2843
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2844
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2845
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2846
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2847
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2848
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2849
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2850
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2851
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2852
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2853
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2854
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2855
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2856
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2857
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2858
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2859
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2860
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2861
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2862
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2863
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2821
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2822
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2823
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2824
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2825
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2826
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2827
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2828
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2829
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2830
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2831
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2832
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2833
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2834
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2835
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2836
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2837
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2838
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2839
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2840
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2841
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2842
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2843
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2844
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2845
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2846
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2847
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2848
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2849
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2850
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2851
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2852
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2853
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2854
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2855
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2856
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2857
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2858
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2859
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2860
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2861
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2862
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2863
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2864 2864
 			),
2865 2865
 		);
2866 2866
 
@@ -3074,7 +3074,7 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
 		if ($upcontext['dropping_index'] && $command_line)
3076 3076
 		{
3077
-			echo "\n" . '', $txt['upgrade_fulltext_error'] ,'';
3077
+			echo "\n" . '', $txt['upgrade_fulltext_error'], '';
3078 3078
 			flush();
3079 3079
 		}
3080 3080
 	}
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
 	{
3419 3419
 		echo '
3420 3420
 		<div class="error">
3421
-			<p>', $txt['upgrade_writable_files'] ,'</p>
3421
+			<p>', $txt['upgrade_writable_files'], '</p>
3422 3422
 			<ul class="error_content">
3423 3423
 				<li>' . implode('</li>
3424 3424
 				<li>', $upcontext['chmod']['files']) . '</li>
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 						<p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>';
3791 3791
 		if ($active < 600)
3792 3792
 			echo '
3793
-						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>';
3793
+						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '</p>';
3794 3794
 
3795 3795
 		if ($active > $upcontext['inactive_timeout'])
3796 3796
 			echo '
Please login to merge, or discard this patch.
Braces   +907 added lines, -664 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 $upcontext['inactive_timeout'] = 10;
76 76
 
77 77
 // The helper is crucial. Include it first thing.
78
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
78
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
79 79
 	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
80
+}
80 81
 
81 82
 require_once($upgrade_path . '/upgrade-helper.php');
82 83
 
@@ -107,11 +108,14 @@  discard block
 block discarded – undo
107 108
 	ini_set('default_socket_timeout', 900);
108 109
 }
109 110
 // Clean the upgrade path if this is from the client.
110
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
111
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
111
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
112
+	for ($i = 1;
113
+}
114
+$i < $_SERVER['argc']; $i++)
112 115
 	{
113
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
114
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
116
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
117
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
118
+		}
115 119
 	}
116 120
 
117 121
 // Are we from the client?
@@ -119,16 +123,17 @@  discard block
 block discarded – undo
119 123
 {
120 124
 	$command_line = true;
121 125
 	$disable_security = true;
122
-}
123
-else
126
+} else {
124 127
 	$command_line = false;
128
+}
125 129
 
126 130
 // Load this now just because we can.
127 131
 require_once($upgrade_path . '/Settings.php');
128 132
 
129 133
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
130
-if (isset($language))
134
+if (isset($language)) {
131 135
 	$language = str_ireplace('-utf8', '', $language);
136
+}
132 137
 
133 138
 // Are we logged in?
134 139
 if (isset($upgradeData))
@@ -136,10 +141,12 @@  discard block
 block discarded – undo
136 141
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
137 142
 
138 143
 	// Check for sensible values.
139
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
140
-		$upcontext['user']['started'] = time();
141
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
142
-		$upcontext['user']['updated'] = 0;
144
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
145
+			$upcontext['user']['started'] = time();
146
+	}
147
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
148
+			$upcontext['user']['updated'] = 0;
149
+	}
143 150
 
144 151
 	$upcontext['started'] = $upcontext['user']['started'];
145 152
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -204,8 +211,9 @@  discard block
 block discarded – undo
204 211
 			'db_error_skip' => true,
205 212
 		)
206 213
 	);
207
-	while ($row = $smcFunc['db_fetch_assoc']($request))
208
-		$modSettings[$row['variable']] = $row['value'];
214
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
215
+			$modSettings[$row['variable']] = $row['value'];
216
+	}
209 217
 	$smcFunc['db_free_result']($request);
210 218
 }
211 219
 
@@ -215,14 +223,17 @@  discard block
 block discarded – undo
215 223
 	$modSettings['theme_url'] = 'Themes/default';
216 224
 	$modSettings['images_url'] = 'Themes/default/images';
217 225
 }
218
-if (!isset($settings['default_theme_url']))
226
+if (!isset($settings['default_theme_url'])) {
219 227
 	$settings['default_theme_url'] = $modSettings['theme_url'];
220
-if (!isset($settings['default_theme_dir']))
228
+}
229
+if (!isset($settings['default_theme_dir'])) {
221 230
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
231
+}
222 232
 
223 233
 // This is needed in case someone invokes the upgrader using https when upgrading an http forum
224
-if (httpsOn())
234
+if (httpsOn()) {
225 235
 	$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
236
+}
226 237
 
227 238
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
228 239
 // Default title...
@@ -240,13 +251,15 @@  discard block
 block discarded – undo
240 251
 	$support_js = $upcontext['upgrade_status']['js'];
241 252
 
242 253
 	// Only set this if the upgrader status says so.
243
-	if (empty($is_debug))
244
-		$is_debug = $upcontext['upgrade_status']['debug'];
254
+	if (empty($is_debug)) {
255
+			$is_debug = $upcontext['upgrade_status']['debug'];
256
+	}
245 257
 
246 258
 	// Load the language.
247
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
248
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
249
-}
259
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
260
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
261
+	}
262
+	}
250 263
 // Set the defaults.
251 264
 else
252 265
 {
@@ -264,15 +277,18 @@  discard block
 block discarded – undo
264 277
 }
265 278
 
266 279
 // If this isn't the first stage see whether they are logging in and resuming.
267
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
280
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
268 281
 	checkLogin();
282
+}
269 283
 
270
-if ($command_line)
284
+if ($command_line) {
271 285
 	cmdStep0();
286
+}
272 287
 
273 288
 // Don't error if we're using xml.
274
-if (isset($_GET['xml']))
289
+if (isset($_GET['xml'])) {
275 290
 	$upcontext['return_error'] = true;
291
+}
276 292
 
277 293
 // Loop through all the steps doing each one as required.
278 294
 $upcontext['overall_percent'] = 0;
@@ -293,9 +309,9 @@  discard block
 block discarded – undo
293 309
 		}
294 310
 
295 311
 		// Call the step and if it returns false that means pause!
296
-		if (function_exists($step[2]) && $step[2]() === false)
297
-			break;
298
-		elseif (function_exists($step[2])) {
312
+		if (function_exists($step[2]) && $step[2]() === false) {
313
+					break;
314
+		} elseif (function_exists($step[2])) {
299 315
 			//Start each new step with this unset, so the 'normal' template is called first
300 316
 			unset($_GET['xml']);
301 317
 			//Clear out warnings at the start of each step
@@ -341,17 +357,18 @@  discard block
 block discarded – undo
341 357
 		// This should not happen my dear... HELP ME DEVELOPERS!!
342 358
 		if (!empty($command_line))
343 359
 		{
344
-			if (function_exists('debug_print_backtrace'))
345
-				debug_print_backtrace();
360
+			if (function_exists('debug_print_backtrace')) {
361
+							debug_print_backtrace();
362
+			}
346 363
 
347 364
 			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.';
348 365
 			flush();
349 366
 			die();
350 367
 		}
351 368
 
352
-		if (!isset($_GET['xml']))
353
-			template_upgrade_above();
354
-		else
369
+		if (!isset($_GET['xml'])) {
370
+					template_upgrade_above();
371
+		} else
355 372
 		{
356 373
 			header('content-type: text/xml; charset=UTF-8');
357 374
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -373,25 +390,29 @@  discard block
 block discarded – undo
373 390
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
374 391
 
375 392
 			// Custom stuff to pass back?
376
-			if (!empty($upcontext['query_string']))
377
-				$upcontext['form_url'] .= $upcontext['query_string'];
393
+			if (!empty($upcontext['query_string'])) {
394
+							$upcontext['form_url'] .= $upcontext['query_string'];
395
+			}
378 396
 
379 397
 			// Call the appropriate subtemplate
380
-			if (is_callable('template_' . $upcontext['sub_template']))
381
-				call_user_func('template_' . $upcontext['sub_template']);
382
-			else
383
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
398
+			if (is_callable('template_' . $upcontext['sub_template'])) {
399
+							call_user_func('template_' . $upcontext['sub_template']);
400
+			} else {
401
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
402
+			}
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" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
437
+		if (!empty($totalTime)) {
438
+					echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
439
+		}
415 440
 	}
416 441
 
417 442
 	// Bang - gone!
@@ -432,8 +457,9 @@  discard block
 block discarded – undo
432 457
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
433 458
 		while ($entry = $dir->read())
434 459
 		{
435
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
436
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
460
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
461
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
462
+			}
437 463
 		}
438 464
 		$dir->close();
439 465
 	}
@@ -477,10 +503,11 @@  discard block
 block discarded – undo
477 503
 	}
478 504
 
479 505
 	// Override the language file?
480
-	if (isset($_GET['lang_file']))
481
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
482
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
483
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
506
+	if (isset($_GET['lang_file'])) {
507
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
508
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
509
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
510
+	}
484 511
 
485 512
 	// Make sure it exists, if it doesn't reset it.
486 513
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -489,12 +516,14 @@  discard block
 block discarded – undo
489 516
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
490 517
 
491 518
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
492
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
493
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
519
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
520
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
521
+		}
494 522
 
495 523
 		// For backup we load the english at first -> second language overwrite the english one
496
-		if (count($incontext['detected_languages']) > 1)
497
-			require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
524
+		if (count($incontext['detected_languages']) > 1) {
525
+					require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
526
+		}
498 527
 	}
499 528
 
500 529
 	// And now include the actual language file itself.
@@ -502,11 +531,12 @@  discard block
 block discarded – undo
502 531
 
503 532
 	// Which language did we load? Assume that he likes his language.
504 533
 	preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches);
505
-	if (empty($matches[1]))
506
-		$matches = [
534
+	if (empty($matches[1])) {
535
+			$matches = [
507 536
 			0 => 'nothing',
508 537
 			1 => 'english',
509 538
 		];
539
+	}
510 540
 	$user_info['language'] = $matches[1];
511 541
 }
512 542
 
@@ -516,8 +546,9 @@  discard block
 block discarded – undo
516 546
 	global $upgradeurl, $upcontext, $command_line;
517 547
 
518 548
 	// Command line users can't be redirected.
519
-	if ($command_line)
520
-		upgradeExit(true);
549
+	if ($command_line) {
550
+			upgradeExit(true);
551
+	}
521 552
 
522 553
 	// Are we providing the core info?
523 554
 	if ($addForm)
@@ -543,12 +574,14 @@  discard block
 block discarded – undo
543 574
 	define('SMF', 1);
544 575
 
545 576
 	// Start the session.
546
-	if (@ini_get('session.save_handler') == 'user')
547
-		@ini_set('session.save_handler', 'files');
577
+	if (@ini_get('session.save_handler') == 'user') {
578
+			@ini_set('session.save_handler', 'files');
579
+	}
548 580
 	@session_start();
549 581
 
550
-	if (empty($smcFunc))
551
-		$smcFunc = array();
582
+	if (empty($smcFunc)) {
583
+			$smcFunc = array();
584
+	}
552 585
 
553 586
 	// We need this for authentication and some upgrade code
554 587
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -575,24 +608,27 @@  discard block
 block discarded – undo
575 608
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
576 609
 
577 610
 		// Make the connection...
578
-		if (empty($db_connection))
579
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
580
-		else
581
-			// If we've returned here, ping/reconnect to be safe
611
+		if (empty($db_connection)) {
612
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
613
+		} else {
614
+					// If we've returned here, ping/reconnect to be safe
582 615
 			$smcFunc['db_ping']($db_connection);
616
+		}
583 617
 
584 618
 		// Oh dear god!!
585
-		if ($db_connection === null)
586
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
619
+		if ($db_connection === null) {
620
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
621
+		}
587 622
 
588
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
589
-			$smcFunc['db_query']('', '
623
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
624
+					$smcFunc['db_query']('', '
590 625
 			SET NAMES {string:db_character_set}',
591 626
 			array(
592 627
 				'db_error_skip' => true,
593 628
 				'db_character_set' => $db_character_set,
594 629
 			)
595 630
 		);
631
+		}
596 632
 
597 633
 		// Load the modSettings data...
598 634
 		$request = $smcFunc['db_query']('', '
@@ -603,11 +639,11 @@  discard block
 block discarded – undo
603 639
 			)
604 640
 		);
605 641
 		$modSettings = array();
606
-		while ($row = $smcFunc['db_fetch_assoc']($request))
607
-			$modSettings[$row['variable']] = $row['value'];
642
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
643
+					$modSettings[$row['variable']] = $row['value'];
644
+		}
608 645
 		$smcFunc['db_free_result']($request);
609
-	}
610
-	else
646
+	} else
611 647
 	{
612 648
 		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.');
613 649
 	}
@@ -621,9 +657,10 @@  discard block
 block discarded – undo
621 657
 		cleanRequest();
622 658
 	}
623 659
 
624
-	if (!isset($_GET['substep']))
625
-		$_GET['substep'] = 0;
626
-}
660
+	if (!isset($_GET['substep'])) {
661
+			$_GET['substep'] = 0;
662
+	}
663
+	}
627 664
 
628 665
 function initialize_inputs()
629 666
 {
@@ -653,8 +690,9 @@  discard block
 block discarded – undo
653 690
 		$dh = opendir(dirname(__FILE__));
654 691
 		while ($file = readdir($dh))
655 692
 		{
656
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
657
-				@unlink(dirname(__FILE__) . '/' . $file);
693
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
694
+							@unlink(dirname(__FILE__) . '/' . $file);
695
+			}
658 696
 		}
659 697
 		closedir($dh);
660 698
 
@@ -683,8 +721,9 @@  discard block
 block discarded – undo
683 721
 	$temp = 'upgrade_php?step';
684 722
 	while (strlen($temp) > 4)
685 723
 	{
686
-		if (isset($_GET[$temp]))
687
-			unset($_GET[$temp]);
724
+		if (isset($_GET[$temp])) {
725
+					unset($_GET[$temp]);
726
+		}
688 727
 		$temp = substr($temp, 1);
689 728
 	}
690 729
 
@@ -711,32 +750,39 @@  discard block
 block discarded – undo
711 750
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
712 751
 
713 752
 	// Need legacy scripts?
714
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
715
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
716
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
717
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
718
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
719
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
753
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
754
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
755
+	}
756
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
757
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
758
+	}
759
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
760
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
761
+	}
720 762
 
721 763
 	// We don't need "-utf8" files anymore...
722 764
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
723 765
 
724 766
 	// This needs to exist!
725
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
726
-		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>]');
727
-	else
728
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
767
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
768
+			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>]');
769
+	} else {
770
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
771
+	}
729 772
 
730
-	if (!$check)
731
-		// 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.
773
+	if (!$check) {
774
+			// 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.
732 775
 		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.');
776
+	}
733 777
 
734 778
 	// Do they meet the install requirements?
735
-	if (!php_version_check())
736
-		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.');
779
+	if (!php_version_check()) {
780
+			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.');
781
+	}
737 782
 
738
-	if (!db_version_check())
739
-		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.');
783
+	if (!db_version_check()) {
784
+			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.');
785
+	}
740 786
 
741 787
 	// Do some checks to make sure they have proper privileges
742 788
 	db_extend('packages');
@@ -751,14 +797,16 @@  discard block
 block discarded – undo
751 797
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
752 798
 
753 799
 	// Sorry... we need CREATE, ALTER and DROP
754
-	if (!$create || !$alter || !$drop)
755
-		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.');
800
+	if (!$create || !$alter || !$drop) {
801
+			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.');
802
+	}
756 803
 
757 804
 	// Do a quick version spot check.
758 805
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
759 806
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
760
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
761
-		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.');
807
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
808
+			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.');
809
+	}
762 810
 
763 811
 	// What absolutely needs to be writable?
764 812
 	$writable_files = array(
@@ -767,12 +815,13 @@  discard block
 block discarded – undo
767 815
 	);
768 816
 
769 817
 	// Only check for minified writable files if we have it enabled or not set.
770
-	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files']))
771
-		$writable_files += array(
818
+	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) {
819
+			$writable_files += array(
772 820
 			$modSettings['theme_dir'] . '/css/minified.css',
773 821
 			$modSettings['theme_dir'] . '/scripts/minified.js',
774 822
 			$modSettings['theme_dir'] . '/scripts/minified_deferred.js',
775 823
 		);
824
+	}
776 825
 
777 826
 	// Do we need to add this setting?
778 827
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
@@ -784,12 +833,13 @@  discard block
 block discarded – undo
784 833
 	quickFileWritable($custom_av_dir);
785 834
 
786 835
 	// Are we good now?
787
-	if (!is_writable($custom_av_dir))
788
-		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));
789
-	elseif ($need_settings_update)
836
+	if (!is_writable($custom_av_dir)) {
837
+			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));
838
+	} elseif ($need_settings_update)
790 839
 	{
791
-		if (!function_exists('cache_put_data'))
792
-			require_once($sourcedir . '/Load.php');
840
+		if (!function_exists('cache_put_data')) {
841
+					require_once($sourcedir . '/Load.php');
842
+		}
793 843
 
794 844
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
795 845
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
@@ -799,29 +849,34 @@  discard block
 block discarded – undo
799 849
 
800 850
 	// Check the cache directory.
801 851
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
802
-	if (!file_exists($cachedir_temp))
803
-		@mkdir($cachedir_temp);
852
+	if (!file_exists($cachedir_temp)) {
853
+			@mkdir($cachedir_temp);
854
+	}
804 855
 
805
-	if (!file_exists($cachedir_temp))
806
-		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.');
856
+	if (!file_exists($cachedir_temp)) {
857
+			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.');
858
+	}
807 859
 
808
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
809
-		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>.');
810
-	elseif (!isset($_GET['skiplang']))
860
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
861
+			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>.');
862
+	} elseif (!isset($_GET['skiplang']))
811 863
 	{
812 864
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
813 865
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
814 866
 
815
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
816
-			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>]');
867
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
868
+					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>]');
869
+		}
817 870
 	}
818 871
 
819
-	if (!makeFilesWritable($writable_files))
820
-		return false;
872
+	if (!makeFilesWritable($writable_files)) {
873
+			return false;
874
+	}
821 875
 
822 876
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
823
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
824
-		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.');
877
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
878
+			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.');
879
+	}
825 880
 
826 881
 	// Upgrade the agreement.
827 882
 	elseif (isset($modSettings['agreement']))
@@ -832,8 +887,8 @@  discard block
 block discarded – undo
832 887
 	}
833 888
 
834 889
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
835
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
836
-		$upcontext['warning'] = '
890
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
891
+			$upcontext['warning'] = '
837 892
 			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br>
838 893
 			<ul>
839 894
 				<li>'. $txt['upgrade_boarddir'] .'  ' . $boarddir . '</li>
@@ -841,19 +896,23 @@  discard block
 block discarded – undo
841 896
 				<li>'. $txt['upgrade_cachedir'] .'  ' . $cachedir_temp . '</li>
842 897
 			</ul>
843 898
 			'. $txt['upgrade_incorrect_settings'] .'';
899
+	}
844 900
 
845 901
 	// Confirm mbstring is loaded...
846
-	if (!extension_loaded('mbstring'))
847
-		return throw_error($txt['install_no_mbstring']);
902
+	if (!extension_loaded('mbstring')) {
903
+			return throw_error($txt['install_no_mbstring']);
904
+	}
848 905
 
849 906
 	// Check for https stream support.
850 907
 	$supported_streams = stream_get_wrappers();
851
-	if (!in_array('https', $supported_streams))
852
-		$upcontext['custom_warning'] = $txt['install_no_https'];
908
+	if (!in_array('https', $supported_streams)) {
909
+			$upcontext['custom_warning'] = $txt['install_no_https'];
910
+	}
853 911
 
854 912
 	// Either we're logged in or we're going to present the login.
855
-	if (checkLogin())
856
-		return true;
913
+	if (checkLogin()) {
914
+			return true;
915
+	}
857 916
 
858 917
 	$upcontext += createToken('login');
859 918
 
@@ -867,15 +926,17 @@  discard block
 block discarded – undo
867 926
 	global $smcFunc, $db_type, $support_js;
868 927
 
869 928
 	// Don't bother if the security is disabled.
870
-	if ($disable_security)
871
-		return true;
929
+	if ($disable_security) {
930
+			return true;
931
+	}
872 932
 
873 933
 	// Are we trying to login?
874 934
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
875 935
 	{
876 936
 		// If we've disabled security pick a suitable name!
877
-		if (empty($_POST['user']))
878
-			$_POST['user'] = 'Administrator';
937
+		if (empty($_POST['user'])) {
938
+					$_POST['user'] = 'Administrator';
939
+		}
879 940
 
880 941
 		// Before 2.0 these column names were different!
881 942
 		$oldDB = false;
@@ -890,16 +951,17 @@  discard block
 block discarded – undo
890 951
 					'db_error_skip' => true,
891 952
 				)
892 953
 			);
893
-			if ($smcFunc['db_num_rows']($request) != 0)
894
-				$oldDB = true;
954
+			if ($smcFunc['db_num_rows']($request) != 0) {
955
+							$oldDB = true;
956
+			}
895 957
 			$smcFunc['db_free_result']($request);
896 958
 		}
897 959
 
898 960
 		// Get what we believe to be their details.
899 961
 		if (!$disable_security)
900 962
 		{
901
-			if ($oldDB)
902
-				$request = $smcFunc['db_query']('', '
963
+			if ($oldDB) {
964
+							$request = $smcFunc['db_query']('', '
903 965
 					SELECT id_member, memberName AS member_name, passwd, id_group,
904 966
 					additionalGroups AS additional_groups, lngfile
905 967
 					FROM {db_prefix}members
@@ -909,8 +971,8 @@  discard block
 block discarded – undo
909 971
 						'db_error_skip' => true,
910 972
 					)
911 973
 				);
912
-			else
913
-				$request = $smcFunc['db_query']('', '
974
+			} else {
975
+							$request = $smcFunc['db_query']('', '
914 976
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
915 977
 					FROM {db_prefix}members
916 978
 					WHERE member_name = {string:member_name}',
@@ -919,6 +981,7 @@  discard block
 block discarded – undo
919 981
 						'db_error_skip' => true,
920 982
 					)
921 983
 				);
984
+			}
922 985
 			if ($smcFunc['db_num_rows']($request) != 0)
923 986
 			{
924 987
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -926,16 +989,17 @@  discard block
 block discarded – undo
926 989
 				$groups = explode(',', $addGroups);
927 990
 				$groups[] = $id_group;
928 991
 
929
-				foreach ($groups as $k => $v)
930
-					$groups[$k] = (int) $v;
992
+				foreach ($groups as $k => $v) {
993
+									$groups[$k] = (int) $v;
994
+				}
931 995
 
932 996
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
933 997
 
934 998
 				// We don't use "-utf8" anymore...
935 999
 				$user_language = str_ireplace('-utf8', '', $user_language);
1000
+			} else {
1001
+							$upcontext['username_incorrect'] = true;
936 1002
 			}
937
-			else
938
-				$upcontext['username_incorrect'] = true;
939 1003
 
940 1004
 			$smcFunc['db_free_result']($request);
941 1005
 		}
@@ -946,13 +1010,14 @@  discard block
 block discarded – undo
946 1010
 		{
947 1011
 			$upcontext['upgrade_status']['js'] = 1;
948 1012
 			$support_js = 1;
1013
+		} else {
1014
+					$support_js = 0;
949 1015
 		}
950
-		else
951
-			$support_js = 0;
952 1016
 
953 1017
 		// Note down the version we are coming from.
954
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
955
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
1018
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
1019
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
1020
+		}
956 1021
 
957 1022
 		// Didn't get anywhere?
958 1023
 		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']))
@@ -986,15 +1051,15 @@  discard block
 block discarded – undo
986 1051
 							'db_error_skip' => true,
987 1052
 						)
988 1053
 					);
989
-					if ($smcFunc['db_num_rows']($request) == 0)
990
-						return throw_error('You need to be an admin to perform an upgrade!');
1054
+					if ($smcFunc['db_num_rows']($request) == 0) {
1055
+											return throw_error('You need to be an admin to perform an upgrade!');
1056
+					}
991 1057
 					$smcFunc['db_free_result']($request);
992 1058
 				}
993 1059
 
994 1060
 				$upcontext['user']['id'] = $id_member;
995 1061
 				$upcontext['user']['name'] = $name;
996
-			}
997
-			else
1062
+			} else
998 1063
 			{
999 1064
 				$upcontext['user']['id'] = 1;
1000 1065
 				$upcontext['user']['name'] = 'Administrator';
@@ -1010,11 +1075,11 @@  discard block
 block discarded – undo
1010 1075
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
1011 1076
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
1012 1077
 
1013
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1014
-					$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'] . '.';
1015
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
1016
-					$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'] . '.';
1017
-				else
1078
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1079
+									$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'] . '.';
1080
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1081
+									$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'] . '.';
1082
+				} else
1018 1083
 				{
1019 1084
 					// Set this as the new language.
1020 1085
 					$upcontext['language'] = $user_language;
@@ -1058,8 +1123,9 @@  discard block
 block discarded – undo
1058 1123
 	unset($member_columns);
1059 1124
 
1060 1125
 	// If we've not submitted then we're done.
1061
-	if (empty($_POST['upcont']))
1062
-		return false;
1126
+	if (empty($_POST['upcont'])) {
1127
+			return false;
1128
+	}
1063 1129
 
1064 1130
 	// Firstly, if they're enabling SM stat collection just do it.
1065 1131
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -1079,16 +1145,17 @@  discard block
 block discarded – undo
1079 1145
 				fwrite($fp, $out);
1080 1146
 
1081 1147
 				$return_data = '';
1082
-				while (!feof($fp))
1083
-					$return_data .= fgets($fp, 128);
1148
+				while (!feof($fp)) {
1149
+									$return_data .= fgets($fp, 128);
1150
+				}
1084 1151
 
1085 1152
 				fclose($fp);
1086 1153
 
1087 1154
 				// Get the unique site ID.
1088 1155
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1089 1156
 
1090
-				if (!empty($ID[1]))
1091
-					$smcFunc['db_insert']('replace',
1157
+				if (!empty($ID[1])) {
1158
+									$smcFunc['db_insert']('replace',
1092 1159
 						$db_prefix . 'settings',
1093 1160
 						array('variable' => 'string', 'value' => 'string'),
1094 1161
 						array(
@@ -1097,9 +1164,9 @@  discard block
 block discarded – undo
1097 1164
 						),
1098 1165
 						array('variable')
1099 1166
 					);
1167
+				}
1100 1168
 			}
1101
-		}
1102
-		else
1169
+		} else
1103 1170
 		{
1104 1171
 			$smcFunc['db_insert']('replace',
1105 1172
 				$db_prefix . 'settings',
@@ -1110,8 +1177,8 @@  discard block
 block discarded – undo
1110 1177
 		}
1111 1178
 	}
1112 1179
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1113
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1114
-		$smcFunc['db_query']('', '
1180
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1181
+			$smcFunc['db_query']('', '
1115 1182
 			DELETE FROM {db_prefix}settings
1116 1183
 			WHERE variable = {string:enable_sm_stats}',
1117 1184
 			array(
@@ -1119,6 +1186,7 @@  discard block
 block discarded – undo
1119 1186
 				'db_error_skip' => true,
1120 1187
 			)
1121 1188
 		);
1189
+	}
1122 1190
 
1123 1191
 	// Deleting old karma stuff?
1124 1192
 	if (!empty($_POST['delete_karma']))
@@ -1133,20 +1201,22 @@  discard block
 block discarded – undo
1133 1201
 		);
1134 1202
 
1135 1203
 		// Cleaning up old karma member settings.
1136
-		if ($upcontext['karma_installed']['good'])
1137
-			$smcFunc['db_query']('', '
1204
+		if ($upcontext['karma_installed']['good']) {
1205
+					$smcFunc['db_query']('', '
1138 1206
 				ALTER TABLE {db_prefix}members
1139 1207
 				DROP karma_good',
1140 1208
 				array()
1141 1209
 			);
1210
+		}
1142 1211
 
1143 1212
 		// Does karma bad was enable?
1144
-		if ($upcontext['karma_installed']['bad'])
1145
-			$smcFunc['db_query']('', '
1213
+		if ($upcontext['karma_installed']['bad']) {
1214
+					$smcFunc['db_query']('', '
1146 1215
 				ALTER TABLE {db_prefix}members
1147 1216
 				DROP karma_bad',
1148 1217
 				array()
1149 1218
 			);
1219
+		}
1150 1220
 
1151 1221
 		// Cleaning up old karma permissions.
1152 1222
 		$smcFunc['db_query']('', '
@@ -1164,32 +1234,37 @@  discard block
 block discarded – undo
1164 1234
 	}
1165 1235
 
1166 1236
 	// Emptying the error log?
1167
-	if (!empty($_POST['empty_error']))
1168
-		$smcFunc['db_query']('truncate_table', '
1237
+	if (!empty($_POST['empty_error'])) {
1238
+			$smcFunc['db_query']('truncate_table', '
1169 1239
 			TRUNCATE {db_prefix}log_errors',
1170 1240
 			array(
1171 1241
 			)
1172 1242
 		);
1243
+	}
1173 1244
 
1174 1245
 	$changes = array();
1175 1246
 
1176 1247
 	// Add proxy settings.
1177
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1178
-		$changes += array(
1248
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1249
+			$changes += array(
1179 1250
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1180 1251
 			'image_proxy_maxsize' => 5190,
1181 1252
 			'image_proxy_enabled' => 0,
1182 1253
 		);
1254
+	}
1183 1255
 
1184 1256
 	// If $boardurl reflects https, set force_ssl
1185
-	if (!function_exists('cache_put_data'))
1186
-		require_once($sourcedir . '/Load.php');
1187
-	if (stripos($boardurl, 'https://') !== false)
1188
-		updateSettings(array('force_ssl' => '1'));
1257
+	if (!function_exists('cache_put_data')) {
1258
+			require_once($sourcedir . '/Load.php');
1259
+	}
1260
+	if (stripos($boardurl, 'https://') !== false) {
1261
+			updateSettings(array('force_ssl' => '1'));
1262
+	}
1189 1263
 
1190 1264
 	// If we're overriding the language follow it through.
1191
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1192
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1265
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1266
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1267
+	}
1193 1268
 
1194 1269
 	if (!empty($_POST['maint']))
1195 1270
 	{
@@ -1201,26 +1276,29 @@  discard block
 block discarded – undo
1201 1276
 		{
1202 1277
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1203 1278
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1204
-		}
1205
-		else
1279
+		} else
1206 1280
 		{
1207 1281
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1208 1282
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1209 1283
 		}
1210 1284
 	}
1211 1285
 
1212
-	if ($command_line)
1213
-		echo ' * Updating Settings.php...';
1286
+	if ($command_line) {
1287
+			echo ' * Updating Settings.php...';
1288
+	}
1214 1289
 
1215 1290
 	// Fix some old paths.
1216
-	if (substr($boarddir, 0, 1) == '.')
1217
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1291
+	if (substr($boarddir, 0, 1) == '.') {
1292
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1293
+	}
1218 1294
 
1219
-	if (substr($sourcedir, 0, 1) == '.')
1220
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1295
+	if (substr($sourcedir, 0, 1) == '.') {
1296
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1297
+	}
1221 1298
 
1222
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1223
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1299
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1300
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1301
+	}
1224 1302
 
1225 1303
 	// If they have a "host:port" setup for the host, split that into separate values
1226 1304
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1231,32 +1309,36 @@  discard block
 block discarded – undo
1231 1309
 		$changes['db_server'] = '\'' . $db_server . '\'';
1232 1310
 
1233 1311
 		// Only set this if we're not using the default port
1234
-		if ($db_port != ini_get('mysqli.default_port'))
1235
-			$changes['db_port'] = (int) $db_port;
1236
-	}
1237
-	elseif (!empty($db_port))
1312
+		if ($db_port != ini_get('mysqli.default_port')) {
1313
+					$changes['db_port'] = (int) $db_port;
1314
+		}
1315
+	} elseif (!empty($db_port))
1238 1316
 	{
1239 1317
 		// If db_port is set and is the same as the default, set it to ''
1240 1318
 		if ($db_type == 'mysql')
1241 1319
 		{
1242
-			if ($db_port == ini_get('mysqli.default_port'))
1243
-				$changes['db_port'] = '\'\'';
1244
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1245
-				$changes['db_port'] = '\'\'';
1320
+			if ($db_port == ini_get('mysqli.default_port')) {
1321
+							$changes['db_port'] = '\'\'';
1322
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1323
+							$changes['db_port'] = '\'\'';
1324
+			}
1246 1325
 		}
1247 1326
 	}
1248 1327
 
1249 1328
 	// Maybe we haven't had this option yet?
1250
-	if (empty($packagesdir))
1251
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1329
+	if (empty($packagesdir)) {
1330
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1331
+	}
1252 1332
 
1253 1333
 	// Add support for $tasksdir var.
1254
-	if (empty($tasksdir))
1255
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1334
+	if (empty($tasksdir)) {
1335
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1336
+	}
1256 1337
 
1257 1338
 	// Make sure we fix the language as well.
1258
-	if (stristr($language, '-utf8'))
1259
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1339
+	if (stristr($language, '-utf8')) {
1340
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1341
+	}
1260 1342
 
1261 1343
 	// @todo Maybe change the cookie name if going to 1.1, too?
1262 1344
 
@@ -1267,8 +1349,9 @@  discard block
 block discarded – undo
1267 1349
 	// Tell Settings.php to store db_last_error.php in the cache
1268 1350
 	move_db_last_error_to_cachedir();
1269 1351
 
1270
-	if ($command_line)
1271
-		echo ' Successful.' . "\n";
1352
+	if ($command_line) {
1353
+			echo ' Successful.' . "\n";
1354
+	}
1272 1355
 
1273 1356
 	// Are we doing debug?
1274 1357
 	if (isset($_POST['debug']))
@@ -1278,8 +1361,9 @@  discard block
 block discarded – undo
1278 1361
 	}
1279 1362
 
1280 1363
 	// If we're not backing up then jump one.
1281
-	if (empty($_POST['backup']))
1282
-		$upcontext['current_step']++;
1364
+	if (empty($_POST['backup'])) {
1365
+			$upcontext['current_step']++;
1366
+	}
1283 1367
 
1284 1368
 	// If we've got here then let's proceed to the next step!
1285 1369
 	return true;
@@ -1294,8 +1378,9 @@  discard block
 block discarded – undo
1294 1378
 	$upcontext['page_title'] = $txt['backup_database'];
1295 1379
 
1296 1380
 	// Done it already - js wise?
1297
-	if (!empty($_POST['backup_done']))
1298
-		return true;
1381
+	if (!empty($_POST['backup_done'])) {
1382
+			return true;
1383
+	}
1299 1384
 
1300 1385
 	// Some useful stuff here.
1301 1386
 	db_extend();
@@ -1309,9 +1394,10 @@  discard block
 block discarded – undo
1309 1394
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1310 1395
 
1311 1396
 	$table_names = array();
1312
-	foreach ($tables as $table)
1313
-		if (substr($table, 0, 7) !== 'backup_')
1397
+	foreach ($tables as $table) {
1398
+			if (substr($table, 0, 7) !== 'backup_')
1314 1399
 			$table_names[] = $table;
1400
+	}
1315 1401
 
1316 1402
 	$upcontext['table_count'] = count($table_names);
1317 1403
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1321,12 +1407,14 @@  discard block
 block discarded – undo
1321 1407
 	$file_steps = $upcontext['table_count'];
1322 1408
 
1323 1409
 	// What ones have we already done?
1324
-	foreach ($table_names as $id => $table)
1325
-		if ($id < $_GET['substep'])
1410
+	foreach ($table_names as $id => $table) {
1411
+			if ($id < $_GET['substep'])
1326 1412
 			$upcontext['previous_tables'][] = $table;
1413
+	}
1327 1414
 
1328
-	if ($command_line)
1329
-		echo 'Backing Up Tables.';
1415
+	if ($command_line) {
1416
+			echo 'Backing Up Tables.';
1417
+	}
1330 1418
 
1331 1419
 	// If we don't support javascript we backup here.
1332 1420
 	if (!$support_js || isset($_GET['xml']))
@@ -1345,8 +1433,9 @@  discard block
 block discarded – undo
1345 1433
 			backupTable($table_names[$substep]);
1346 1434
 
1347 1435
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1348
-			if (isset($_GET['xml']))
1349
-				return upgradeExit();
1436
+			if (isset($_GET['xml'])) {
1437
+							return upgradeExit();
1438
+			}
1350 1439
 		}
1351 1440
 
1352 1441
 		if ($command_line)
@@ -1379,9 +1468,10 @@  discard block
 block discarded – undo
1379 1468
 
1380 1469
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1381 1470
 
1382
-	if ($command_line)
1383
-		echo ' done.';
1384
-}
1471
+	if ($command_line) {
1472
+			echo ' done.';
1473
+	}
1474
+	}
1385 1475
 
1386 1476
 // Step 2: Everything.
1387 1477
 function DatabaseChanges()
@@ -1390,8 +1480,9 @@  discard block
 block discarded – undo
1390 1480
 	global $upcontext, $support_js, $db_type;
1391 1481
 
1392 1482
 	// Have we just completed this?
1393
-	if (!empty($_POST['database_done']))
1394
-		return true;
1483
+	if (!empty($_POST['database_done'])) {
1484
+			return true;
1485
+	}
1395 1486
 
1396 1487
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1397 1488
 	$upcontext['page_title'] = $txt['database_changes'];
@@ -1406,15 +1497,16 @@  discard block
 block discarded – undo
1406 1497
 	);
1407 1498
 
1408 1499
 	// How many files are there in total?
1409
-	if (isset($_GET['filecount']))
1410
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1411
-	else
1500
+	if (isset($_GET['filecount'])) {
1501
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1502
+	} else
1412 1503
 	{
1413 1504
 		$upcontext['file_count'] = 0;
1414 1505
 		foreach ($files as $file)
1415 1506
 		{
1416
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1417
-				$upcontext['file_count']++;
1507
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1508
+							$upcontext['file_count']++;
1509
+			}
1418 1510
 		}
1419 1511
 	}
1420 1512
 
@@ -1424,9 +1516,9 @@  discard block
 block discarded – undo
1424 1516
 	$upcontext['cur_file_num'] = 0;
1425 1517
 	foreach ($files as $file)
1426 1518
 	{
1427
-		if ($did_not_do)
1428
-			$did_not_do--;
1429
-		else
1519
+		if ($did_not_do) {
1520
+					$did_not_do--;
1521
+		} else
1430 1522
 		{
1431 1523
 			$upcontext['cur_file_num']++;
1432 1524
 			$upcontext['cur_file_name'] = $file[0];
@@ -1453,12 +1545,13 @@  discard block
 block discarded – undo
1453 1545
 					// Flag to move on to the next.
1454 1546
 					$upcontext['completed_step'] = true;
1455 1547
 					// Did we complete the whole file?
1456
-					if ($nextFile)
1457
-						$upcontext['current_debug_item_num'] = -1;
1548
+					if ($nextFile) {
1549
+											$upcontext['current_debug_item_num'] = -1;
1550
+					}
1458 1551
 					return upgradeExit();
1552
+				} elseif ($support_js) {
1553
+									break;
1459 1554
 				}
1460
-				elseif ($support_js)
1461
-					break;
1462 1555
 			}
1463 1556
 			// Set the progress bar to be right as if we had - even if we hadn't...
1464 1557
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1484,8 +1577,9 @@  discard block
 block discarded – undo
1484 1577
 	global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings;
1485 1578
 
1486 1579
 	// Now it's nice to have some of the basic SMF source files.
1487
-	if (!isset($_GET['ssi']) && !$command_line)
1488
-		redirectLocation('&ssi=1');
1580
+	if (!isset($_GET['ssi']) && !$command_line) {
1581
+			redirectLocation('&ssi=1');
1582
+	}
1489 1583
 
1490 1584
 	$upcontext['sub_template'] = 'upgrade_complete';
1491 1585
 	$upcontext['page_title'] = $txt['upgrade_complete'];
@@ -1501,14 +1595,16 @@  discard block
 block discarded – undo
1501 1595
 	// Are we in maintenance mode?
1502 1596
 	if (isset($upcontext['user']['main']))
1503 1597
 	{
1504
-		if ($command_line)
1505
-			echo ' * ';
1598
+		if ($command_line) {
1599
+					echo ' * ';
1600
+		}
1506 1601
 		$upcontext['removed_maintenance'] = true;
1507 1602
 		$changes['maintenance'] = $upcontext['user']['main'];
1508 1603
 	}
1509 1604
 	// Otherwise if somehow we are in 2 let's go to 1.
1510
-	elseif (!empty($maintenance) && $maintenance == 2)
1511
-		$changes['maintenance'] = 1;
1605
+	elseif (!empty($maintenance) && $maintenance == 2) {
1606
+			$changes['maintenance'] = 1;
1607
+	}
1512 1608
 
1513 1609
 	// Wipe this out...
1514 1610
 	$upcontext['user'] = array();
@@ -1523,21 +1619,23 @@  discard block
 block discarded – undo
1523 1619
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1524 1620
 
1525 1621
 	// Now is the perfect time to fetch the SM files.
1526
-	if ($command_line)
1527
-		cli_scheduled_fetchSMfiles();
1528
-	else
1622
+	if ($command_line) {
1623
+			cli_scheduled_fetchSMfiles();
1624
+	} else
1529 1625
 	{
1530 1626
 		require_once($sourcedir . '/ScheduledTasks.php');
1531 1627
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
1532 1628
 		scheduled_fetchSMfiles(); // Now go get those files!
1533 1629
 		// This is needed in case someone invokes the upgrader using https when upgrading an http forum
1534
-		if (httpsOn())
1535
-			$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1630
+		if (httpsOn()) {
1631
+					$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1632
+		}
1536 1633
 	}
1537 1634
 
1538 1635
 	// Log what we've done.
1539
-	if (empty($user_info['id']))
1540
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1636
+	if (empty($user_info['id'])) {
1637
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1638
+	}
1541 1639
 
1542 1640
 	// Log the action manually, so CLI still works.
1543 1641
 	$smcFunc['db_insert']('',
@@ -1556,8 +1654,9 @@  discard block
 block discarded – undo
1556 1654
 
1557 1655
 	// Save the current database version.
1558 1656
 	$server_version = $smcFunc['db_server_info']();
1559
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1560
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1657
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1658
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1659
+	}
1561 1660
 
1562 1661
 	if ($command_line)
1563 1662
 	{
@@ -1569,8 +1668,9 @@  discard block
 block discarded – undo
1569 1668
 
1570 1669
 	// Make sure it says we're done.
1571 1670
 	$upcontext['overall_percent'] = 100;
1572
-	if (isset($upcontext['step_progress']))
1573
-		unset($upcontext['step_progress']);
1671
+	if (isset($upcontext['step_progress'])) {
1672
+			unset($upcontext['step_progress']);
1673
+	}
1574 1674
 
1575 1675
 	$_GET['substep'] = 0;
1576 1676
 	return false;
@@ -1581,8 +1681,9 @@  discard block
 block discarded – undo
1581 1681
 {
1582 1682
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1583 1683
 
1584
-	if (empty($modSettings['time_format']))
1585
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1684
+	if (empty($modSettings['time_format'])) {
1685
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1686
+	}
1586 1687
 
1587 1688
 	// What files do we want to get
1588 1689
 	$request = $smcFunc['db_query']('', '
@@ -1616,8 +1717,9 @@  discard block
 block discarded – undo
1616 1717
 		$file_data = fetch_web_data($url);
1617 1718
 
1618 1719
 		// If we got an error - give up - the site might be down.
1619
-		if ($file_data === false)
1620
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1720
+		if ($file_data === false) {
1721
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1722
+		}
1621 1723
 
1622 1724
 		// Save the file to the database.
1623 1725
 		$smcFunc['db_query']('substring', '
@@ -1659,8 +1761,9 @@  discard block
 block discarded – undo
1659 1761
 	$themeData = array();
1660 1762
 	foreach ($values as $variable => $value)
1661 1763
 	{
1662
-		if (!isset($value) || $value === null)
1663
-			$value = 0;
1764
+		if (!isset($value) || $value === null) {
1765
+					$value = 0;
1766
+		}
1664 1767
 
1665 1768
 		$themeData[] = array(0, 1, $variable, $value);
1666 1769
 	}
@@ -1689,8 +1792,9 @@  discard block
 block discarded – undo
1689 1792
 
1690 1793
 	foreach ($values as $variable => $value)
1691 1794
 	{
1692
-		if (empty($modSettings[$value[0]]))
1693
-			continue;
1795
+		if (empty($modSettings[$value[0]])) {
1796
+					continue;
1797
+		}
1694 1798
 
1695 1799
 		$smcFunc['db_query']('', '
1696 1800
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1776,19 +1880,21 @@  discard block
 block discarded – undo
1776 1880
 	set_error_handler(
1777 1881
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1778 1882
 		{
1779
-			if ($support_js)
1780
-				return true;
1781
-			else
1782
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1883
+			if ($support_js) {
1884
+							return true;
1885
+			} else {
1886
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1887
+			}
1783 1888
 		}
1784 1889
 	);
1785 1890
 
1786 1891
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1787 1892
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1788
-	if ($db_type == 'mysql')
1789
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1790
-	else
1791
-		$db_collation = '';
1893
+	if ($db_type == 'mysql') {
1894
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1895
+	} else {
1896
+			$db_collation = '';
1897
+	}
1792 1898
 
1793 1899
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1794 1900
 
@@ -1800,8 +1906,9 @@  discard block
 block discarded – undo
1800 1906
 	$last_step = '';
1801 1907
 
1802 1908
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1803
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1804
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1909
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1910
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1911
+	}
1805 1912
 
1806 1913
 	// Count the total number of steps within this file - for progress.
1807 1914
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1821,15 +1928,18 @@  discard block
 block discarded – undo
1821 1928
 		$do_current = $substep >= $_GET['substep'];
1822 1929
 
1823 1930
 		// Get rid of any comments in the beginning of the line...
1824
-		if (substr(trim($line), 0, 2) === '/*')
1825
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1931
+		if (substr(trim($line), 0, 2) === '/*') {
1932
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1933
+		}
1826 1934
 
1827 1935
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1828
-		if ($is_debug && !$support_js && $command_line)
1829
-			flush();
1936
+		if ($is_debug && !$support_js && $command_line) {
1937
+					flush();
1938
+		}
1830 1939
 
1831
-		if (trim($line) === '')
1832
-			continue;
1940
+		if (trim($line) === '') {
1941
+					continue;
1942
+		}
1833 1943
 
1834 1944
 		if (trim(substr($line, 0, 3)) === '---')
1835 1945
 		{
@@ -1839,8 +1949,9 @@  discard block
 block discarded – undo
1839 1949
 			if (trim($current_data) != '' && $type !== '}')
1840 1950
 			{
1841 1951
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1842
-				if ($command_line)
1843
-					echo $upcontext['error_message'];
1952
+				if ($command_line) {
1953
+									echo $upcontext['error_message'];
1954
+				}
1844 1955
 			}
1845 1956
 
1846 1957
 			if ($type == ' ')
@@ -1858,17 +1969,18 @@  discard block
 block discarded – undo
1858 1969
 				if ($do_current)
1859 1970
 				{
1860 1971
 					$upcontext['actioned_items'][] = $last_step;
1861
-					if ($command_line)
1862
-						echo ' * ';
1972
+					if ($command_line) {
1973
+											echo ' * ';
1974
+					}
1863 1975
 				}
1864
-			}
1865
-			elseif ($type == '#')
1976
+			} elseif ($type == '#')
1866 1977
 			{
1867 1978
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1868 1979
 
1869 1980
 				$upcontext['current_debug_item_num']++;
1870
-				if (trim($line) != '---#')
1871
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1981
+				if (trim($line) != '---#') {
1982
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1983
+				}
1872 1984
 
1873 1985
 				// Have we already done something?
1874 1986
 				if (isset($_GET['xml']) && $done_something)
@@ -1879,34 +1991,36 @@  discard block
 block discarded – undo
1879 1991
 
1880 1992
 				if ($do_current)
1881 1993
 				{
1882
-					if (trim($line) == '---#' && $command_line)
1883
-						echo ' done.', $endl;
1884
-					elseif ($command_line)
1885
-						echo ' +++ ', rtrim(substr($line, 4));
1886
-					elseif (trim($line) != '---#')
1994
+					if (trim($line) == '---#' && $command_line) {
1995
+											echo ' done.', $endl;
1996
+					} elseif ($command_line) {
1997
+											echo ' +++ ', rtrim(substr($line, 4));
1998
+					} elseif (trim($line) != '---#')
1887 1999
 					{
1888
-						if ($is_debug)
1889
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2000
+						if ($is_debug) {
2001
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2002
+						}
1890 2003
 					}
1891 2004
 				}
1892 2005
 
1893 2006
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1894 2007
 				{
1895
-					if ($command_line)
1896
-						echo ' * ';
1897
-					else
1898
-						$upcontext['actioned_items'][] = $last_step;
2008
+					if ($command_line) {
2009
+											echo ' * ';
2010
+					} else {
2011
+											$upcontext['actioned_items'][] = $last_step;
2012
+					}
1899 2013
 				}
1900 2014
 
1901 2015
 				// Small step - only if we're actually doing stuff.
1902
-				if ($do_current)
1903
-					nextSubstep(++$substep);
1904
-				else
1905
-					$substep++;
1906
-			}
1907
-			elseif ($type == '{')
1908
-				$current_type = 'code';
1909
-			elseif ($type == '}')
2016
+				if ($do_current) {
2017
+									nextSubstep(++$substep);
2018
+				} else {
2019
+									$substep++;
2020
+				}
2021
+			} elseif ($type == '{') {
2022
+							$current_type = 'code';
2023
+			} elseif ($type == '}')
1910 2024
 			{
1911 2025
 				$current_type = 'sql';
1912 2026
 
@@ -1919,8 +2033,9 @@  discard block
 block discarded – undo
1919 2033
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1920 2034
 				{
1921 2035
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1922
-					if ($command_line)
1923
-						echo $upcontext['error_message'];
2036
+					if ($command_line) {
2037
+											echo $upcontext['error_message'];
2038
+					}
1924 2039
 				}
1925 2040
 
1926 2041
 				// Done with code!
@@ -2008,8 +2123,9 @@  discard block
 block discarded – undo
2008 2123
 	$db_unbuffered = false;
2009 2124
 
2010 2125
 	// Failure?!
2011
-	if ($result !== false)
2012
-		return $result;
2126
+	if ($result !== false) {
2127
+			return $result;
2128
+	}
2013 2129
 
2014 2130
 	$db_error_message = $smcFunc['db_error']($db_connection);
2015 2131
 	// If MySQL we do something more clever.
@@ -2037,54 +2153,61 @@  discard block
 block discarded – undo
2037 2153
 			{
2038 2154
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2039 2155
 				$result = mysqli_query($db_connection, $string);
2040
-				if ($result !== false)
2041
-					return $result;
2156
+				if ($result !== false) {
2157
+									return $result;
2158
+				}
2042 2159
 			}
2043
-		}
2044
-		elseif ($mysqli_errno == 2013)
2160
+		} elseif ($mysqli_errno == 2013)
2045 2161
 		{
2046 2162
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2047 2163
 			mysqli_select_db($db_connection, $db_name);
2048 2164
 			if ($db_connection)
2049 2165
 			{
2050 2166
 				$result = mysqli_query($db_connection, $string);
2051
-				if ($result !== false)
2052
-					return $result;
2167
+				if ($result !== false) {
2168
+									return $result;
2169
+				}
2053 2170
 			}
2054 2171
 		}
2055 2172
 		// Duplicate column name... should be okay ;).
2056
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2057
-			return false;
2173
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2174
+					return false;
2175
+		}
2058 2176
 		// Duplicate insert... make sure it's the proper type of query ;).
2059
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2060
-			return false;
2177
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2178
+					return false;
2179
+		}
2061 2180
 		// Creating an index on a non-existent column.
2062
-		elseif ($mysqli_errno == 1072)
2063
-			return false;
2064
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2065
-			return false;
2181
+		elseif ($mysqli_errno == 1072) {
2182
+					return false;
2183
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2184
+					return false;
2185
+		}
2066 2186
 	}
2067 2187
 	// If a table already exists don't go potty.
2068 2188
 	else
2069 2189
 	{
2070 2190
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2071 2191
 		{
2072
-			if (strpos($db_error_message, 'exist') !== false)
2073
-				return true;
2074
-		}
2075
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2192
+			if (strpos($db_error_message, 'exist') !== false) {
2193
+							return true;
2194
+			}
2195
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2076 2196
 		{
2077
-			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error)
2078
-				return true;
2197
+			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) {
2198
+							return true;
2199
+			}
2079 2200
 		}
2080 2201
 	}
2081 2202
 
2082 2203
 	// Get the query string so we pass everything.
2083 2204
 	$query_string = '';
2084
-	foreach ($_GET as $k => $v)
2085
-		$query_string .= ';' . $k . '=' . $v;
2086
-	if (strlen($query_string) != 0)
2087
-		$query_string = '?' . substr($query_string, 1);
2205
+	foreach ($_GET as $k => $v) {
2206
+			$query_string .= ';' . $k . '=' . $v;
2207
+	}
2208
+	if (strlen($query_string) != 0) {
2209
+			$query_string = '?' . substr($query_string, 1);
2210
+	}
2088 2211
 
2089 2212
 	if ($command_line)
2090 2213
 	{
@@ -2139,16 +2262,18 @@  discard block
 block discarded – undo
2139 2262
 			{
2140 2263
 				$found |= 1;
2141 2264
 				// Do some checks on the data if we have it set.
2142
-				if (isset($change['col_type']))
2143
-					$found &= $change['col_type'] === $column['type'];
2144
-				if (isset($change['null_allowed']))
2145
-					$found &= $column['null'] == $change['null_allowed'];
2146
-				if (isset($change['default']))
2147
-					$found &= $change['default'] === $column['default'];
2265
+				if (isset($change['col_type'])) {
2266
+									$found &= $change['col_type'] === $column['type'];
2267
+				}
2268
+				if (isset($change['null_allowed'])) {
2269
+									$found &= $column['null'] == $change['null_allowed'];
2270
+				}
2271
+				if (isset($change['default'])) {
2272
+									$found &= $change['default'] === $column['default'];
2273
+				}
2148 2274
 			}
2149 2275
 		}
2150
-	}
2151
-	elseif ($change['type'] === 'index')
2276
+	} elseif ($change['type'] === 'index')
2152 2277
 	{
2153 2278
 		$request = upgrade_query('
2154 2279
 			SHOW INDEX
@@ -2157,9 +2282,10 @@  discard block
 block discarded – undo
2157 2282
 		{
2158 2283
 			$cur_index = array();
2159 2284
 
2160
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2161
-				if ($row['Key_name'] === $change['name'])
2285
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2286
+							if ($row['Key_name'] === $change['name'])
2162 2287
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2288
+			}
2163 2289
 
2164 2290
 			ksort($cur_index, SORT_NUMERIC);
2165 2291
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2169,14 +2295,17 @@  discard block
 block discarded – undo
2169 2295
 	}
2170 2296
 
2171 2297
 	// If we're trying to add and it's added, we're done.
2172
-	if ($found && in_array($change['method'], array('add', 'change')))
2173
-		return true;
2298
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2299
+			return true;
2300
+	}
2174 2301
 	// Otherwise if we're removing and it wasn't found we're also done.
2175
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2176
-		return true;
2302
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2303
+			return true;
2304
+	}
2177 2305
 	// Otherwise is it just a test?
2178
-	elseif ($is_test)
2179
-		return false;
2306
+	elseif ($is_test) {
2307
+			return false;
2308
+	}
2180 2309
 
2181 2310
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2182 2311
 	$running = false;
@@ -2187,8 +2316,9 @@  discard block
 block discarded – undo
2187 2316
 			SHOW FULL PROCESSLIST');
2188 2317
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2189 2318
 		{
2190
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2191
-				$found = true;
2319
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2320
+							$found = true;
2321
+			}
2192 2322
 		}
2193 2323
 
2194 2324
 		// Can't find it? Then we need to run it fools!
@@ -2200,8 +2330,9 @@  discard block
 block discarded – undo
2200 2330
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2201 2331
 				' . $change['text'], true) !== false;
2202 2332
 
2203
-			if (!$success)
2204
-				return false;
2333
+			if (!$success) {
2334
+							return false;
2335
+			}
2205 2336
 
2206 2337
 			// Return
2207 2338
 			$running = true;
@@ -2243,8 +2374,9 @@  discard block
 block discarded – undo
2243 2374
 			'db_error_skip' => true,
2244 2375
 		)
2245 2376
 	);
2246
-	if ($smcFunc['db_num_rows']($request) === 0)
2247
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2377
+	if ($smcFunc['db_num_rows']($request) === 0) {
2378
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2379
+	}
2248 2380
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2249 2381
 	$smcFunc['db_free_result']($request);
2250 2382
 
@@ -2266,18 +2398,19 @@  discard block
 block discarded – undo
2266 2398
 			)
2267 2399
 		);
2268 2400
 		// No results? Just forget it all together.
2269
-		if ($smcFunc['db_num_rows']($request) === 0)
2270
-			unset($table_row['Collation']);
2271
-		else
2272
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2401
+		if ($smcFunc['db_num_rows']($request) === 0) {
2402
+					unset($table_row['Collation']);
2403
+		} else {
2404
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2405
+		}
2273 2406
 		$smcFunc['db_free_result']($request);
2274 2407
 	}
2275 2408
 
2276 2409
 	if ($column_fix)
2277 2410
 	{
2278 2411
 		// Make sure there are no NULL's left.
2279
-		if ($null_fix)
2280
-			$smcFunc['db_query']('', '
2412
+		if ($null_fix) {
2413
+					$smcFunc['db_query']('', '
2281 2414
 				UPDATE {db_prefix}' . $change['table'] . '
2282 2415
 				SET ' . $change['column'] . ' = {string:default}
2283 2416
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2286,6 +2419,7 @@  discard block
 block discarded – undo
2286 2419
 					'db_error_skip' => true,
2287 2420
 				)
2288 2421
 			);
2422
+		}
2289 2423
 
2290 2424
 		// Do the actual alteration.
2291 2425
 		$smcFunc['db_query']('', '
@@ -2314,8 +2448,9 @@  discard block
 block discarded – undo
2314 2448
 	}
2315 2449
 
2316 2450
 	// Not a column we need to check on?
2317
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2318
-		return;
2451
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2452
+			return;
2453
+	}
2319 2454
 
2320 2455
 	// Break it up you (six|seven).
2321 2456
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2334,13 +2469,13 @@  discard block
 block discarded – undo
2334 2469
 				'new_name' => $temp[2],
2335 2470
 		));
2336 2471
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2337
-		if ($smcFunc['db_num_rows'] != 1)
2338
-			return;
2472
+		if ($smcFunc['db_num_rows'] != 1) {
2473
+					return;
2474
+		}
2339 2475
 
2340 2476
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2341 2477
 		$smcFunc['db_free_result']($request);
2342
-	}
2343
-	else
2478
+	} else
2344 2479
 	{
2345 2480
 		// Do this the old fashion, sure method way.
2346 2481
 		$request = $smcFunc['db_query']('', '
@@ -2351,21 +2486,24 @@  discard block
 block discarded – undo
2351 2486
 		));
2352 2487
 		// Mayday!
2353 2488
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2354
-		if ($smcFunc['db_num_rows'] == 0)
2355
-			return;
2489
+		if ($smcFunc['db_num_rows'] == 0) {
2490
+					return;
2491
+		}
2356 2492
 
2357 2493
 		// Oh where, oh where has my little field gone. Oh where can it be...
2358
-		while ($row = $smcFunc['db_query']($request))
2359
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2494
+		while ($row = $smcFunc['db_query']($request)) {
2495
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2360 2496
 			{
2361 2497
 				$current_type = $row['Type'];
2498
+		}
2362 2499
 				break;
2363 2500
 			}
2364 2501
 	}
2365 2502
 
2366 2503
 	// If this doesn't match, the column may of been altered for a reason.
2367
-	if (trim($current_type) != trim($temp[3]))
2368
-		$temp[3] = $current_type;
2504
+	if (trim($current_type) != trim($temp[3])) {
2505
+			$temp[3] = $current_type;
2506
+	}
2369 2507
 
2370 2508
 	// Piece this back together.
2371 2509
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2377,8 +2515,9 @@  discard block
 block discarded – undo
2377 2515
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2378 2516
 	global $step_progress, $is_debug, $upcontext;
2379 2517
 
2380
-	if ($_GET['substep'] < $substep)
2381
-		$_GET['substep'] = $substep;
2518
+	if ($_GET['substep'] < $substep) {
2519
+			$_GET['substep'] = $substep;
2520
+	}
2382 2521
 
2383 2522
 	if ($command_line)
2384 2523
 	{
@@ -2391,29 +2530,33 @@  discard block
 block discarded – undo
2391 2530
 	}
2392 2531
 
2393 2532
 	@set_time_limit(300);
2394
-	if (function_exists('apache_reset_timeout'))
2395
-		@apache_reset_timeout();
2533
+	if (function_exists('apache_reset_timeout')) {
2534
+			@apache_reset_timeout();
2535
+	}
2396 2536
 
2397
-	if (time() - $start_time <= $timeLimitThreshold)
2398
-		return;
2537
+	if (time() - $start_time <= $timeLimitThreshold) {
2538
+			return;
2539
+	}
2399 2540
 
2400 2541
 	// Do we have some custom step progress stuff?
2401 2542
 	if (!empty($step_progress))
2402 2543
 	{
2403 2544
 		$upcontext['substep_progress'] = 0;
2404 2545
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2405
-		if ($step_progress['current'] > $step_progress['total'])
2406
-			$upcontext['substep_progress'] = 99.9;
2407
-		else
2408
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2546
+		if ($step_progress['current'] > $step_progress['total']) {
2547
+					$upcontext['substep_progress'] = 99.9;
2548
+		} else {
2549
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2550
+		}
2409 2551
 
2410 2552
 		// Make it nicely rounded.
2411 2553
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2412 2554
 	}
2413 2555
 
2414 2556
 	// If this is XML we just exit right away!
2415
-	if (isset($_GET['xml']))
2416
-		return upgradeExit();
2557
+	if (isset($_GET['xml'])) {
2558
+			return upgradeExit();
2559
+	}
2417 2560
 
2418 2561
 	// We're going to pause after this!
2419 2562
 	$upcontext['pause'] = true;
@@ -2421,13 +2564,15 @@  discard block
 block discarded – undo
2421 2564
 	$upcontext['query_string'] = '';
2422 2565
 	foreach ($_GET as $k => $v)
2423 2566
 	{
2424
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2425
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2567
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2568
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2569
+		}
2426 2570
 	}
2427 2571
 
2428 2572
 	// Custom warning?
2429
-	if (!empty($custom_warning))
2430
-		$upcontext['custom_warning'] = $custom_warning;
2573
+	if (!empty($custom_warning)) {
2574
+			$upcontext['custom_warning'] = $custom_warning;
2575
+	}
2431 2576
 
2432 2577
 	upgradeExit();
2433 2578
 }
@@ -2442,25 +2587,26 @@  discard block
 block discarded – undo
2442 2587
 	ob_implicit_flush(true);
2443 2588
 	@set_time_limit(600);
2444 2589
 
2445
-	if (!isset($_SERVER['argv']))
2446
-		$_SERVER['argv'] = array();
2590
+	if (!isset($_SERVER['argv'])) {
2591
+			$_SERVER['argv'] = array();
2592
+	}
2447 2593
 	$_GET['maint'] = 1;
2448 2594
 
2449 2595
 	foreach ($_SERVER['argv'] as $i => $arg)
2450 2596
 	{
2451
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2452
-			$_GET['lang'] = $match[1];
2453
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2454
-			continue;
2455
-		elseif ($arg == '--no-maintenance')
2456
-			$_GET['maint'] = 0;
2457
-		elseif ($arg == '--debug')
2458
-			$is_debug = true;
2459
-		elseif ($arg == '--backup')
2460
-			$_POST['backup'] = 1;
2461
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2462
-			$_GET['conv'] = 1;
2463
-		elseif ($i != 0)
2597
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2598
+					$_GET['lang'] = $match[1];
2599
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2600
+					continue;
2601
+		} elseif ($arg == '--no-maintenance') {
2602
+					$_GET['maint'] = 0;
2603
+		} elseif ($arg == '--debug') {
2604
+					$is_debug = true;
2605
+		} elseif ($arg == '--backup') {
2606
+					$_POST['backup'] = 1;
2607
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2608
+					$_GET['conv'] = 1;
2609
+		} elseif ($i != 0)
2464 2610
 		{
2465 2611
 			echo 'SMF Command-line Upgrader
2466 2612
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2474,10 +2620,12 @@  discard block
 block discarded – undo
2474 2620
 		}
2475 2621
 	}
2476 2622
 
2477
-	if (!php_version_check())
2478
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2479
-	if (!db_version_check())
2480
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2623
+	if (!php_version_check()) {
2624
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2625
+	}
2626
+	if (!db_version_check()) {
2627
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2628
+	}
2481 2629
 
2482 2630
 	// Do some checks to make sure they have proper privileges
2483 2631
 	db_extend('packages');
@@ -2492,34 +2640,39 @@  discard block
 block discarded – undo
2492 2640
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2493 2641
 
2494 2642
 	// Sorry... we need CREATE, ALTER and DROP
2495
-	if (!$create || !$alter || !$drop)
2496
-		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);
2643
+	if (!$create || !$alter || !$drop) {
2644
+			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);
2645
+	}
2497 2646
 
2498 2647
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2499 2648
 		&& @file_exists($sourcedir . '/QueryString.php')
2500 2649
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2501
-	if (!$check && !isset($modSettings['smfVersion']))
2502
-		print_error('Error: Some files are missing or out-of-date.', true);
2650
+	if (!$check && !isset($modSettings['smfVersion'])) {
2651
+			print_error('Error: Some files are missing or out-of-date.', true);
2652
+	}
2503 2653
 
2504 2654
 	// Do a quick version spot check.
2505 2655
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2506 2656
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2507
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2508
-		print_error('Error: Some files have not yet been updated properly.');
2657
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2658
+			print_error('Error: Some files have not yet been updated properly.');
2659
+	}
2509 2660
 
2510 2661
 	// Make sure Settings.php is writable.
2511 2662
 	quickFileWritable($boarddir . '/Settings.php');
2512
-	if (!is_writable($boarddir . '/Settings.php'))
2513
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2663
+	if (!is_writable($boarddir . '/Settings.php')) {
2664
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2665
+	}
2514 2666
 
2515 2667
 	// Make sure Settings_bak.php is writable.
2516 2668
 	quickFileWritable($boarddir . '/Settings_bak.php');
2517
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2518
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2669
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2670
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2671
+	}
2519 2672
 
2520
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2521
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2522
-	elseif (isset($modSettings['agreement']))
2673
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2674
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2675
+	} elseif (isset($modSettings['agreement']))
2523 2676
 	{
2524 2677
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2525 2678
 		fwrite($fp, $modSettings['agreement']);
@@ -2529,36 +2682,42 @@  discard block
 block discarded – undo
2529 2682
 	// Make sure Themes is writable.
2530 2683
 	quickFileWritable($modSettings['theme_dir']);
2531 2684
 
2532
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2533
-		print_error('Error: Unable to obtain write access to "Themes".');
2685
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2686
+			print_error('Error: Unable to obtain write access to "Themes".');
2687
+	}
2534 2688
 
2535 2689
 	// Make sure cache directory exists and is writable!
2536 2690
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2537
-	if (!file_exists($cachedir_temp))
2538
-		@mkdir($cachedir_temp);
2691
+	if (!file_exists($cachedir_temp)) {
2692
+			@mkdir($cachedir_temp);
2693
+	}
2539 2694
 
2540 2695
 	// Make sure the cache temp dir is writable.
2541 2696
 	quickFileWritable($cachedir_temp);
2542 2697
 
2543
-	if (!is_writable($cachedir_temp))
2544
-		print_error('Error: Unable to obtain write access to "cache".', true);
2698
+	if (!is_writable($cachedir_temp)) {
2699
+			print_error('Error: Unable to obtain write access to "cache".', true);
2700
+	}
2545 2701
 
2546 2702
 	// Make sure db_last_error.php is writable.
2547 2703
 	quickFileWritable($cachedir_temp . '/db_last_error.php');
2548
-	if (!is_writable($cachedir_temp . '/db_last_error.php'))
2549
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2704
+	if (!is_writable($cachedir_temp . '/db_last_error.php')) {
2705
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2706
+	}
2550 2707
 
2551
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2552
-		print_error('Error: Unable to find language files!', true);
2553
-	else
2708
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2709
+			print_error('Error: Unable to find language files!', true);
2710
+	} else
2554 2711
 	{
2555 2712
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2556 2713
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2557 2714
 
2558
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2559
-			print_error('Error: Language files out of date.', true);
2560
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2561
-			print_error('Error: Install language is missing for selected language.', true);
2715
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2716
+					print_error('Error: Language files out of date.', true);
2717
+		}
2718
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2719
+					print_error('Error: Install language is missing for selected language.', true);
2720
+		}
2562 2721
 
2563 2722
 		// Otherwise include it!
2564 2723
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2578,8 +2737,9 @@  discard block
 block discarded – undo
2578 2737
 	global $db_prefix, $db_type, $command_line, $support_js, $txt;
2579 2738
 
2580 2739
 	// Done it already?
2581
-	if (!empty($_POST['utf8_done']))
2582
-		return true;
2740
+	if (!empty($_POST['utf8_done'])) {
2741
+			return true;
2742
+	}
2583 2743
 
2584 2744
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2585 2745
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2592,8 +2752,7 @@  discard block
 block discarded – undo
2592 2752
 		);
2593 2753
 
2594 2754
 		return true;
2595
-	}
2596
-	else
2755
+	} else
2597 2756
 	{
2598 2757
 		$upcontext['page_title'] = $txt['converting_utf8'];
2599 2758
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2637,8 +2796,9 @@  discard block
 block discarded – undo
2637 2796
 			)
2638 2797
 		);
2639 2798
 		$db_charsets = array();
2640
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2641
-			$db_charsets[] = $row['Charset'];
2799
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2800
+					$db_charsets[] = $row['Charset'];
2801
+		}
2642 2802
 
2643 2803
 		$smcFunc['db_free_result']($request);
2644 2804
 
@@ -2674,13 +2834,15 @@  discard block
 block discarded – undo
2674 2834
 		// If there's a fulltext index, we need to drop it first...
2675 2835
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2676 2836
 		{
2677
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2678
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2837
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2838
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2679 2839
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2840
+			}
2680 2841
 			$smcFunc['db_free_result']($request);
2681 2842
 
2682
-			if (isset($upcontext['fulltext_index']))
2683
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2843
+			if (isset($upcontext['fulltext_index'])) {
2844
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2845
+			}
2684 2846
 		}
2685 2847
 
2686 2848
 		// Drop it and make a note...
@@ -2870,8 +3032,9 @@  discard block
 block discarded – undo
2870 3032
 			$replace = '%field%';
2871 3033
 
2872 3034
 			// Build a huge REPLACE statement...
2873
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2874
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3035
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3036
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3037
+			}
2875 3038
 		}
2876 3039
 
2877 3040
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2881,9 +3044,10 @@  discard block
 block discarded – undo
2881 3044
 		$upcontext['table_count'] = count($queryTables);
2882 3045
 
2883 3046
 		// What ones have we already done?
2884
-		foreach ($queryTables as $id => $table)
2885
-			if ($id < $_GET['substep'])
3047
+		foreach ($queryTables as $id => $table) {
3048
+					if ($id < $_GET['substep'])
2886 3049
 				$upcontext['previous_tables'][] = $table;
3050
+		}
2887 3051
 
2888 3052
 		$upcontext['cur_table_num'] = $_GET['substep'];
2889 3053
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2920,8 +3084,9 @@  discard block
 block discarded – undo
2920 3084
 			nextSubstep($substep);
2921 3085
 
2922 3086
 			// Just to make sure it doesn't time out.
2923
-			if (function_exists('apache_reset_timeout'))
2924
-				@apache_reset_timeout();
3087
+			if (function_exists('apache_reset_timeout')) {
3088
+							@apache_reset_timeout();
3089
+			}
2925 3090
 
2926 3091
 			$table_charsets = array();
2927 3092
 
@@ -2944,8 +3109,9 @@  discard block
 block discarded – undo
2944 3109
 
2945 3110
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2946 3111
 						if ($charset != 'utf8') {
2947
-							if (!isset($table_charsets[$charset]))
2948
-								$table_charsets[$charset] = array();
3112
+							if (!isset($table_charsets[$charset])) {
3113
+															$table_charsets[$charset] = array();
3114
+							}
2949 3115
 
2950 3116
 							$table_charsets[$charset][] = $column_info;
2951 3117
 						}
@@ -2986,10 +3152,11 @@  discard block
 block discarded – undo
2986 3152
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2987 3153
 				{
2988 3154
 					$update = '';
2989
-					foreach ($table_charsets as $charset => $columns)
2990
-						foreach ($columns as $column)
3155
+					foreach ($table_charsets as $charset => $columns) {
3156
+											foreach ($columns as $column)
2991 3157
 							$update .= '
2992 3158
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3159
+					}
2993 3160
 
2994 3161
 					$smcFunc['db_query']('', '
2995 3162
 						UPDATE {raw:table_name}
@@ -3014,8 +3181,9 @@  discard block
 block discarded – undo
3014 3181
 			// Now do the actual conversion (if still needed).
3015 3182
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3016 3183
 			{
3017
-				if ($command_line)
3018
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3184
+				if ($command_line) {
3185
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3186
+				}
3019 3187
 
3020 3188
 				$smcFunc['db_query']('', '
3021 3189
 					ALTER TABLE {raw:table_name}
@@ -3025,12 +3193,14 @@  discard block
 block discarded – undo
3025 3193
 					)
3026 3194
 				);
3027 3195
 
3028
-				if ($command_line)
3029
-					echo " done.\n";
3196
+				if ($command_line) {
3197
+									echo " done.\n";
3198
+				}
3030 3199
 			}
3031 3200
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3032
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
3033
-				return upgradeExit();
3201
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3202
+							return upgradeExit();
3203
+			}
3034 3204
 		}
3035 3205
 
3036 3206
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -3059,8 +3229,8 @@  discard block
 block discarded – undo
3059 3229
 		);
3060 3230
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3061 3231
 		{
3062
-			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)
3063
-				$smcFunc['db_query']('', '
3232
+			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) {
3233
+							$smcFunc['db_query']('', '
3064 3234
 					UPDATE {db_prefix}log_actions
3065 3235
 					SET extra = {string:extra}
3066 3236
 					WHERE id_action = {int:current_action}',
@@ -3069,6 +3239,7 @@  discard block
 block discarded – undo
3069 3239
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3070 3240
 					)
3071 3241
 				);
3242
+			}
3072 3243
 		}
3073 3244
 		$smcFunc['db_free_result']($request);
3074 3245
 
@@ -3090,15 +3261,17 @@  discard block
 block discarded – undo
3090 3261
 	// First thing's first - did we already do this?
3091 3262
 	if (!empty($modSettings['json_done']))
3092 3263
 	{
3093
-		if ($command_line)
3094
-			return DeleteUpgrade();
3095
-		else
3096
-			return true;
3264
+		if ($command_line) {
3265
+					return DeleteUpgrade();
3266
+		} else {
3267
+					return true;
3268
+		}
3097 3269
 	}
3098 3270
 
3099 3271
 	// Done it already - js wise?
3100
-	if (!empty($_POST['json_done']))
3101
-		return true;
3272
+	if (!empty($_POST['json_done'])) {
3273
+			return true;
3274
+	}
3102 3275
 
3103 3276
 	// List of tables affected by this function
3104 3277
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3130,12 +3303,14 @@  discard block
 block discarded – undo
3130 3303
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3131 3304
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3132 3305
 
3133
-	foreach ($keys as $id => $table)
3134
-		if ($id < $_GET['substep'])
3306
+	foreach ($keys as $id => $table) {
3307
+			if ($id < $_GET['substep'])
3135 3308
 			$upcontext['previous_tables'][] = $table;
3309
+	}
3136 3310
 
3137
-	if ($command_line)
3138
-		echo 'Converting data from serialize() to json_encode().';
3311
+	if ($command_line) {
3312
+			echo 'Converting data from serialize() to json_encode().';
3313
+	}
3139 3314
 
3140 3315
 	if (!$support_js || isset($_GET['xml']))
3141 3316
 	{
@@ -3175,8 +3350,9 @@  discard block
 block discarded – undo
3175 3350
 
3176 3351
 				// Loop through and fix these...
3177 3352
 				$new_settings = array();
3178
-				if ($command_line)
3179
-					echo "\n" . 'Fixing some settings...';
3353
+				if ($command_line) {
3354
+									echo "\n" . 'Fixing some settings...';
3355
+				}
3180 3356
 
3181 3357
 				foreach ($serialized_settings as $var)
3182 3358
 				{
@@ -3184,22 +3360,24 @@  discard block
 block discarded – undo
3184 3360
 					{
3185 3361
 						// Attempt to unserialize the setting
3186 3362
 						$temp = @safe_unserialize($modSettings[$var]);
3187
-						if (!$temp && $command_line)
3188
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3189
-						elseif ($temp !== false)
3190
-							$new_settings[$var] = json_encode($temp);
3363
+						if (!$temp && $command_line) {
3364
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3365
+						} elseif ($temp !== false) {
3366
+													$new_settings[$var] = json_encode($temp);
3367
+						}
3191 3368
 					}
3192 3369
 				}
3193 3370
 
3194 3371
 				// Update everything at once
3195
-				if (!function_exists('cache_put_data'))
3196
-					require_once($sourcedir . '/Load.php');
3372
+				if (!function_exists('cache_put_data')) {
3373
+									require_once($sourcedir . '/Load.php');
3374
+				}
3197 3375
 				updateSettings($new_settings, true);
3198 3376
 
3199
-				if ($command_line)
3200
-					echo ' done.';
3201
-			}
3202
-			elseif ($table == 'themes')
3377
+				if ($command_line) {
3378
+									echo ' done.';
3379
+				}
3380
+			} elseif ($table == 'themes')
3203 3381
 			{
3204 3382
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3205 3383
 				$query = $smcFunc['db_query']('', '
@@ -3218,10 +3396,11 @@  discard block
 block discarded – undo
3218 3396
 
3219 3397
 						if ($command_line)
3220 3398
 						{
3221
-							if ($temp === false)
3222
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3223
-							else
3224
-								echo "\n" . 'Fixing admin preferences...';
3399
+							if ($temp === false) {
3400
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3401
+							} else {
3402
+															echo "\n" . 'Fixing admin preferences...';
3403
+							}
3225 3404
 						}
3226 3405
 
3227 3406
 						if ($temp !== false)
@@ -3243,15 +3422,15 @@  discard block
 block discarded – undo
3243 3422
 								)
3244 3423
 							);
3245 3424
 
3246
-							if ($command_line)
3247
-								echo ' done.';
3425
+							if ($command_line) {
3426
+															echo ' done.';
3427
+							}
3248 3428
 						}
3249 3429
 					}
3250 3430
 
3251 3431
 					$smcFunc['db_free_result']($query);
3252 3432
 				}
3253
-			}
3254
-			else
3433
+			} else
3255 3434
 			{
3256 3435
 				// First item is always the key...
3257 3436
 				$key = $info[0];
@@ -3262,8 +3441,7 @@  discard block
 block discarded – undo
3262 3441
 				{
3263 3442
 					$col_select = $info[1];
3264 3443
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3265
-				}
3266
-				else
3444
+				} else
3267 3445
 				{
3268 3446
 					$col_select = implode(', ', $info);
3269 3447
 				}
@@ -3296,8 +3474,7 @@  discard block
 block discarded – undo
3296 3474
 								if ($temp === false && $command_line)
3297 3475
 								{
3298 3476
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3299
-								}
3300
-								else
3477
+								} else
3301 3478
 								{
3302 3479
 									$row[$col] = json_encode($temp);
3303 3480
 
@@ -3322,16 +3499,18 @@  discard block
 block discarded – undo
3322 3499
 						}
3323 3500
 					}
3324 3501
 
3325
-					if ($command_line)
3326
-						echo ' done.';
3502
+					if ($command_line) {
3503
+											echo ' done.';
3504
+					}
3327 3505
 
3328 3506
 					// Free up some memory...
3329 3507
 					$smcFunc['db_free_result']($query);
3330 3508
 				}
3331 3509
 			}
3332 3510
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3333
-			if (isset($_GET['xml']))
3334
-				return upgradeExit();
3511
+			if (isset($_GET['xml'])) {
3512
+							return upgradeExit();
3513
+			}
3335 3514
 		}
3336 3515
 
3337 3516
 		if ($command_line)
@@ -3346,8 +3525,9 @@  discard block
 block discarded – undo
3346 3525
 
3347 3526
 		$_GET['substep'] = 0;
3348 3527
 		// Make sure we move on!
3349
-		if ($command_line)
3350
-			return DeleteUpgrade();
3528
+		if ($command_line) {
3529
+					return DeleteUpgrade();
3530
+		}
3351 3531
 
3352 3532
 		return true;
3353 3533
 	}
@@ -3404,14 +3584,16 @@  discard block
 block discarded – undo
3404 3584
 	global $upcontext, $txt, $settings;
3405 3585
 
3406 3586
 	// Don't call me twice!
3407
-	if (!empty($upcontext['chmod_called']))
3408
-		return;
3587
+	if (!empty($upcontext['chmod_called'])) {
3588
+			return;
3589
+	}
3409 3590
 
3410 3591
 	$upcontext['chmod_called'] = true;
3411 3592
 
3412 3593
 	// Nothing?
3413
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3414
-		return;
3594
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3595
+			return;
3596
+	}
3415 3597
 
3416 3598
 	// Was it a problem with Windows?
3417 3599
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3443,11 +3625,12 @@  discard block
 block discarded – undo
3443 3625
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\');
3444 3626
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3445 3627
 
3446
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3447
-		echo '
3628
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3629
+			echo '
3448 3630
 					content.write(\'<hr>\n\t\t\t\');
3449 3631
 					content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\');
3450 3632
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3633
+	}
3451 3634
 
3452 3635
 	echo '
3453 3636
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3455,16 +3638,18 @@  discard block
 block discarded – undo
3455 3638
 				}
3456 3639
 			</script>';
3457 3640
 
3458
-	if (!empty($upcontext['chmod']['ftp_error']))
3459
-		echo '
3641
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3642
+			echo '
3460 3643
 			<div class="error_message red">
3461 3644
 				<p>', $txt['upgrade_ftp_error'], '<p>
3462 3645
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3463 3646
 			</div>';
3647
+	}
3464 3648
 
3465
-	if (empty($upcontext['chmod_in_form']))
3466
-		echo '
3649
+	if (empty($upcontext['chmod_in_form'])) {
3650
+			echo '
3467 3651
 			<form action="', $upcontext['form_url'], '" method="post">';
3652
+	}
3468 3653
 
3469 3654
 	echo '
3470 3655
 				<dl class="settings">
@@ -3506,9 +3691,10 @@  discard block
 block discarded – undo
3506 3691
 					<input type="submit" value="', $txt['ftp_connect'], '" class="button">
3507 3692
 				</div>';
3508 3693
 
3509
-	if (empty($upcontext['chmod_in_form']))
3510
-		echo '
3694
+	if (empty($upcontext['chmod_in_form'])) {
3695
+			echo '
3511 3696
 			</form>';
3697
+	}
3512 3698
 
3513 3699
 	echo '
3514 3700
 		</div><!-- .panel -->';
@@ -3572,9 +3758,10 @@  discard block
 block discarded – undo
3572 3758
 					<h2>', $txt['upgrade_progress'], '</h2>
3573 3759
 					<ul>';
3574 3760
 
3575
-	foreach ($upcontext['steps'] as $num => $step)
3576
-		echo '
3761
+	foreach ($upcontext['steps'] as $num => $step) {
3762
+			echo '
3577 3763
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3764
+	}
3578 3765
 
3579 3766
 	echo '
3580 3767
 					</ul>
@@ -3587,13 +3774,14 @@  discard block
 block discarded – undo
3587 3774
 						<span id="overall_text">', $upcontext['overall_percent'], '%</span>
3588 3775
 					</div>';
3589 3776
 
3590
-	if (isset($upcontext['step_progress']))
3591
-		echo '
3777
+	if (isset($upcontext['step_progress'])) {
3778
+			echo '
3592 3779
 					<div id="progress_bar_step" class="progress_bar progress_yellow">
3593 3780
 						<h3>', $txt['upgrade_step_progress'], '</h3>
3594 3781
 						<div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div>
3595 3782
 						<span id="step_text">', $upcontext['step_progress'], '%</span>
3596 3783
 					</div>';
3784
+	}
3597 3785
 
3598 3786
 	echo '
3599 3787
 					<h3>', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', '</h3>
@@ -3624,31 +3812,35 @@  discard block
 block discarded – undo
3624 3812
 {
3625 3813
 	global $upcontext, $txt;
3626 3814
 
3627
-	if (!empty($upcontext['pause']))
3628
-		echo '
3815
+	if (!empty($upcontext['pause'])) {
3816
+			echo '
3629 3817
 					<em>', $txt['upgrade_incomplete'], '.</em><br>
3630 3818
 
3631 3819
 					<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3632 3820
 					<h3>
3633 3821
 						', $txt['upgrade_paused_overload'], '
3634 3822
 					</h3>';
3823
+	}
3635 3824
 
3636
-	if (!empty($upcontext['custom_warning']))
3637
-		echo '
3825
+	if (!empty($upcontext['custom_warning'])) {
3826
+			echo '
3638 3827
 					<div class="errorbox">
3639 3828
 						<h3>', $txt['upgrade_note'], '</h3>
3640 3829
 						', $upcontext['custom_warning'], '
3641 3830
 					</div>';
3831
+	}
3642 3832
 
3643 3833
 	echo '
3644 3834
 					<div class="righttext" style="margin: 1ex;">';
3645 3835
 
3646
-	if (!empty($upcontext['continue']))
3647
-		echo '
3836
+	if (!empty($upcontext['continue'])) {
3837
+			echo '
3648 3838
 						<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3649
-	if (!empty($upcontext['skip']))
3650
-		echo '
3839
+	}
3840
+	if (!empty($upcontext['skip'])) {
3841
+			echo '
3651 3842
 						<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3843
+	}
3652 3844
 
3653 3845
 	echo '
3654 3846
 					</div>
@@ -3699,11 +3891,12 @@  discard block
 block discarded – undo
3699 3891
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3700 3892
 	<smf>';
3701 3893
 
3702
-	if (!empty($upcontext['get_data']))
3703
-		foreach ($upcontext['get_data'] as $k => $v)
3894
+	if (!empty($upcontext['get_data'])) {
3895
+			foreach ($upcontext['get_data'] as $k => $v)
3704 3896
 			echo '
3705 3897
 		<get key="', $k, '">', $v, '</get>';
3706
-}
3898
+	}
3899
+	}
3707 3900
 
3708 3901
 function template_xml_below()
3709 3902
 {
@@ -3743,20 +3936,22 @@  discard block
 block discarded – undo
3743 3936
 	template_chmod();
3744 3937
 
3745 3938
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3746
-	if ($upcontext['is_large_forum'])
3747
-		echo '
3939
+	if ($upcontext['is_large_forum']) {
3940
+			echo '
3748 3941
 					<div class="errorbox">
3749 3942
 						<h3>', $txt['upgrade_warning'], '</h3>
3750 3943
 						', $txt['upgrade_warning_lots_data'], '
3751 3944
 					</div>';
3945
+	}
3752 3946
 
3753 3947
 	// A warning message?
3754
-	if (!empty($upcontext['warning']))
3755
-		echo '
3948
+	if (!empty($upcontext['warning'])) {
3949
+			echo '
3756 3950
 					<div class="errorbox">
3757 3951
 						<h3>', $txt['upgrade_warning'], '</h3>
3758 3952
 						', $upcontext['warning'], '
3759 3953
 					</div>';
3954
+	}
3760 3955
 
3761 3956
 	// Paths are incorrect?
3762 3957
 	echo '
@@ -3769,35 +3964,39 @@  discard block
 block discarded – undo
3769 3964
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3770 3965
 	{
3771 3966
 		$ago = time() - $upcontext['started'];
3772
-		if ($ago < 60)
3773
-			$ago = $ago . ' seconds';
3774
-		elseif ($ago < 3600)
3775
-			$ago = (int) ($ago / 60) . ' minutes';
3776
-		else
3777
-			$ago = (int) ($ago / 3600) . ' hours';
3967
+		if ($ago < 60) {
3968
+					$ago = $ago . ' seconds';
3969
+		} elseif ($ago < 3600) {
3970
+					$ago = (int) ($ago / 60) . ' minutes';
3971
+		} else {
3972
+					$ago = (int) ($ago / 3600) . ' hours';
3973
+		}
3778 3974
 
3779 3975
 		$active = time() - $upcontext['updated'];
3780
-		if ($active < 60)
3781
-			$updated = $active . ' seconds';
3782
-		elseif ($active < 3600)
3783
-			$updated = (int) ($active / 60) . ' minutes';
3784
-		else
3785
-			$updated = (int) ($active / 3600) . ' hours';
3976
+		if ($active < 60) {
3977
+					$updated = $active . ' seconds';
3978
+		} elseif ($active < 3600) {
3979
+					$updated = (int) ($active / 60) . ' minutes';
3980
+		} else {
3981
+					$updated = (int) ($active / 3600) . ' hours';
3982
+		}
3786 3983
 
3787 3984
 		echo '
3788 3985
 					<div class="errorbox">
3789 3986
 						<h3>', $txt['upgrade_warning'], '</h3>
3790 3987
 						<p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>';
3791
-		if ($active < 600)
3792
-			echo '
3988
+		if ($active < 600) {
3989
+					echo '
3793 3990
 						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>';
3991
+		}
3794 3992
 
3795
-		if ($active > $upcontext['inactive_timeout'])
3796
-			echo '
3993
+		if ($active > $upcontext['inactive_timeout']) {
3994
+					echo '
3797 3995
 						<p>',$txt['upgrade_run'], '</p>';
3798
-		else
3799
-			echo '
3996
+		} else {
3997
+					echo '
3800 3998
 						<p>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'), '</p>';
3999
+		}
3801 4000
 
3802 4001
 		echo '
3803 4002
 					</div>';
@@ -3813,9 +4012,10 @@  discard block
 block discarded – undo
3813 4012
 						<dd>
3814 4013
 							<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3815 4014
 
3816
-	if (!empty($upcontext['username_incorrect']))
3817
-		echo '
4015
+	if (!empty($upcontext['username_incorrect'])) {
4016
+			echo '
3818 4017
 							<div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>';
4018
+	}
3819 4019
 
3820 4020
 	echo '
3821 4021
 						</dd>
@@ -3826,9 +4026,10 @@  discard block
 block discarded – undo
3826 4026
 							<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3827 4027
 							<input type="hidden" name="hash_passwrd" value="">';
3828 4028
 
3829
-	if (!empty($upcontext['password_failed']))
3830
-		echo '
4029
+	if (!empty($upcontext['password_failed'])) {
4030
+			echo '
3831 4031
 							<div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>';
4032
+	}
3832 4033
 
3833 4034
 	echo '
3834 4035
 						</dd>';
@@ -3896,12 +4097,13 @@  discard block
 block discarded – undo
3896 4097
 				<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3897 4098
 
3898 4099
 	// Warning message?
3899
-	if (!empty($upcontext['upgrade_options_warning']))
3900
-		echo '
4100
+	if (!empty($upcontext['upgrade_options_warning'])) {
4101
+			echo '
3901 4102
 				<div class="errorbox">
3902 4103
 					<h3>Warning!</h3>
3903 4104
 					', $upcontext['upgrade_options_warning'], '
3904 4105
 				</div>';
4106
+	}
3905 4107
 
3906 4108
 	echo '
3907 4109
 				<ul class="upgrade_settings">
@@ -3930,12 +4132,13 @@  discard block
 block discarded – undo
3930 4132
 						<label for="empty_error">', $txt['upgrade_empty_errlog'], '</label>
3931 4133
 					</li>';
3932 4134
 
3933
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3934
-		echo '
4135
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4136
+			echo '
3935 4137
 					<li>
3936 4138
 						<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
3937 4139
 						<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
3938 4140
 					</li>';
4141
+	}
3939 4142
 
3940 4143
 	echo '
3941 4144
 					<li>
@@ -3969,10 +4172,11 @@  discard block
 block discarded – undo
3969 4172
 					</div>';
3970 4173
 
3971 4174
 	// Dont any tables so far?
3972
-	if (!empty($upcontext['previous_tables']))
3973
-		foreach ($upcontext['previous_tables'] as $table)
4175
+	if (!empty($upcontext['previous_tables'])) {
4176
+			foreach ($upcontext['previous_tables'] as $table)
3974 4177
 			echo '
3975 4178
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4179
+	}
3976 4180
 
3977 4181
 	echo '
3978 4182
 					<h3 id="current_tab">
@@ -4011,12 +4215,13 @@  discard block
 block discarded – undo
4011 4215
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4012 4216
 
4013 4217
 		// If debug flood the screen.
4014
-		if ($is_debug)
4015
-			echo '
4218
+		if ($is_debug) {
4219
+					echo '
4016 4220
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4017 4221
 
4018 4222
 							if (document.getElementById(\'debug_section\').scrollHeight)
4019 4223
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4224
+		}
4020 4225
 
4021 4226
 		echo '
4022 4227
 							// Get the next update...
@@ -4049,8 +4254,9 @@  discard block
 block discarded – undo
4049 4254
 {
4050 4255
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt;
4051 4256
 
4052
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4053
-		$is_debug = true;
4257
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4258
+			$is_debug = true;
4259
+	}
4054 4260
 
4055 4261
 	echo '
4056 4262
 				<h3>', $txt['upgrade_db_changes'], '</h3>
@@ -4065,8 +4271,9 @@  discard block
 block discarded – undo
4065 4271
 	{
4066 4272
 		foreach ($upcontext['actioned_items'] as $num => $item)
4067 4273
 		{
4068
-			if ($num != 0)
4069
-				echo ' Successful!';
4274
+			if ($num != 0) {
4275
+							echo ' Successful!';
4276
+			}
4070 4277
 			echo '<br>' . $item;
4071 4278
 		}
4072 4279
 		if (!empty($upcontext['changes_complete']))
@@ -4079,29 +4286,33 @@  discard block
 block discarded – undo
4079 4286
 				$seconds = intval($active % 60);
4080 4287
 
4081 4288
 				$totalTime = '';
4082
-				if ($hours > 0)
4083
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4084
-				if ($minutes > 0)
4085
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4086
-				if ($seconds > 0)
4087
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4289
+				if ($hours > 0) {
4290
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4291
+				}
4292
+				if ($minutes > 0) {
4293
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4294
+				}
4295
+				if ($seconds > 0) {
4296
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4297
+				}
4088 4298
 			}
4089 4299
 
4090
-			if ($is_debug && !empty($totalTime))
4091
-				echo ' Successful! Completed in ', $totalTime, '<br>';
4092
-			else
4093
-				echo ' Successful!<br>';
4300
+			if ($is_debug && !empty($totalTime)) {
4301
+							echo ' Successful! Completed in ', $totalTime, '<br>';
4302
+			} else {
4303
+							echo ' Successful!<br>';
4304
+			}
4094 4305
 
4095 4306
 			echo '
4096 4307
 					<p id="commess">', $txt['upgrade_db_complete'], '</p>';
4097 4308
 		}
4098
-	}
4099
-	else
4309
+	} else
4100 4310
 	{
4101 4311
 		// Tell them how many files we have in total.
4102
-		if ($upcontext['file_count'] > 1)
4103
-			echo '
4312
+		if ($upcontext['file_count'] > 1) {
4313
+					echo '
4104 4314
 					<strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4315
+		}
4105 4316
 
4106 4317
 		echo '
4107 4318
 					<h3 id="info2">
@@ -4119,19 +4330,23 @@  discard block
 block discarded – undo
4119 4330
 				$seconds = intval($active % 60);
4120 4331
 
4121 4332
 				$totalTime = '';
4122
-				if ($hours > 0)
4123
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4124
-				if ($minutes > 0)
4125
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4126
-				if ($seconds > 0)
4127
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4333
+				if ($hours > 0) {
4334
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4335
+				}
4336
+				if ($minutes > 0) {
4337
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4338
+				}
4339
+				if ($seconds > 0) {
4340
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4341
+				}
4128 4342
 			}
4129 4343
 
4130 4344
 			echo '
4131 4345
 					<p id="upgradeCompleted">';
4132 4346
 
4133
-			if (!empty($totalTime))
4134
-				echo 'Completed in ', $totalTime, '';
4347
+			if (!empty($totalTime)) {
4348
+							echo 'Completed in ', $totalTime, '';
4349
+			}
4135 4350
 
4136 4351
 			echo '
4137 4352
 					</p>
@@ -4168,9 +4383,10 @@  discard block
 block discarded – undo
4168 4383
 						var getData = "";
4169 4384
 						var debugItems = ', $upcontext['debug_items'], ';';
4170 4385
 
4171
-		if ($is_debug)
4172
-			echo '
4386
+		if ($is_debug) {
4387
+					echo '
4173 4388
 						var upgradeStartTime = ' . $upcontext['started'] . ';';
4389
+		}
4174 4390
 
4175 4391
 		echo '
4176 4392
 						function getNextItem()
@@ -4210,9 +4426,10 @@  discard block
 block discarded – undo
4210 4426
 									document.getElementById("error_block").style.display = "";
4211 4427
 									setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4212 4428
 
4213
-	if ($is_debug)
4214
-		echo '
4429
+	if ($is_debug) {
4430
+			echo '
4215 4431
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4432
+	}
4216 4433
 
4217 4434
 	echo '
4218 4435
 								}
@@ -4233,9 +4450,10 @@  discard block
 block discarded – undo
4233 4450
 									document.getElementById("error_block").style.display = "";
4234 4451
 									setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4235 4452
 
4236
-	if ($is_debug)
4237
-		echo '
4453
+	if ($is_debug) {
4454
+			echo '
4238 4455
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4456
+	}
4239 4457
 
4240 4458
 	echo '
4241 4459
 								}
@@ -4292,8 +4510,8 @@  discard block
 block discarded – undo
4292 4510
 							if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4293 4511
 							{';
4294 4512
 
4295
-		if ($is_debug)
4296
-			echo '
4513
+		if ($is_debug) {
4514
+					echo '
4297 4515
 								document.getElementById(\'debug_section\').style.display = "none";
4298 4516
 
4299 4517
 								var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4311,6 +4529,7 @@  discard block
 block discarded – undo
4311 4529
 									totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4312 4530
 
4313 4531
 								setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4532
+		}
4314 4533
 
4315 4534
 		echo '
4316 4535
 
@@ -4318,9 +4537,10 @@  discard block
 block discarded – undo
4318 4537
 								document.getElementById(\'contbutt\').disabled = 0;
4319 4538
 								document.getElementById(\'database_done\').value = 1;';
4320 4539
 
4321
-		if ($upcontext['file_count'] > 1)
4322
-			echo '
4540
+		if ($upcontext['file_count'] > 1) {
4541
+					echo '
4323 4542
 								document.getElementById(\'info1\').style.display = "none";';
4543
+		}
4324 4544
 
4325 4545
 		echo '
4326 4546
 								document.getElementById(\'info2\').style.display = "none";
@@ -4333,9 +4553,10 @@  discard block
 block discarded – undo
4333 4553
 								lastItem = 0;
4334 4554
 								prevFile = curFile;';
4335 4555
 
4336
-		if ($is_debug)
4337
-			echo '
4556
+		if ($is_debug) {
4557
+					echo '
4338 4558
 								setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4559
+		}
4339 4560
 
4340 4561
 		echo '
4341 4562
 								getNextItem();
@@ -4343,8 +4564,8 @@  discard block
 block discarded – undo
4343 4564
 							}';
4344 4565
 
4345 4566
 		// If debug scroll the screen.
4346
-		if ($is_debug)
4347
-			echo '
4567
+		if ($is_debug) {
4568
+					echo '
4348 4569
 							if (iLastSubStepProgress == -1)
4349 4570
 							{
4350 4571
 								// Give it consistent dots.
@@ -4363,6 +4584,7 @@  discard block
 block discarded – undo
4363 4584
 
4364 4585
 							if (document.getElementById(\'debug_section\').scrollHeight)
4365 4586
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4587
+		}
4366 4588
 
4367 4589
 		echo '
4368 4590
 							// Update the page.
@@ -4423,9 +4645,10 @@  discard block
 block discarded – undo
4423 4645
 						}';
4424 4646
 
4425 4647
 		// Start things off assuming we've not errored.
4426
-		if (empty($upcontext['error_message']))
4427
-			echo '
4648
+		if (empty($upcontext['error_message'])) {
4649
+					echo '
4428 4650
 						getNextItem();';
4651
+		}
4429 4652
 
4430 4653
 		echo '
4431 4654
 					//# sourceURL=dynamicScript-dbch.js
@@ -4443,18 +4666,21 @@  discard block
 block discarded – undo
4443 4666
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4444 4667
 	<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>';
4445 4668
 
4446
-	if (!empty($upcontext['error_message']))
4447
-		echo '
4669
+	if (!empty($upcontext['error_message'])) {
4670
+			echo '
4448 4671
 	<error>', $upcontext['error_message'], '</error>';
4672
+	}
4449 4673
 
4450
-	if (!empty($upcontext['error_string']))
4451
-		echo '
4674
+	if (!empty($upcontext['error_string'])) {
4675
+			echo '
4452 4676
 	<sql>', $upcontext['error_string'], '</sql>';
4677
+	}
4453 4678
 
4454
-	if ($is_debug)
4455
-		echo '
4679
+	if ($is_debug) {
4680
+			echo '
4456 4681
 	<curtime>', time(), '</curtime>';
4457
-}
4682
+	}
4683
+	}
4458 4684
 
4459 4685
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4460 4686
 function template_convert_utf8()
@@ -4471,10 +4697,11 @@  discard block
 block discarded – undo
4471 4697
 					</div>';
4472 4698
 
4473 4699
 	// Done any tables so far?
4474
-	if (!empty($upcontext['previous_tables']))
4475
-		foreach ($upcontext['previous_tables'] as $table)
4700
+	if (!empty($upcontext['previous_tables'])) {
4701
+			foreach ($upcontext['previous_tables'] as $table)
4476 4702
 			echo '
4477 4703
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4704
+	}
4478 4705
 
4479 4706
 	echo '
4480 4707
 					<h3 id="current_tab">
@@ -4482,9 +4709,10 @@  discard block
 block discarded – undo
4482 4709
 					</h3>';
4483 4710
 
4484 4711
 	// If we dropped their index, let's let them know
4485
-	if ($upcontext['dropping_index'])
4486
-		echo '
4712
+	if ($upcontext['dropping_index']) {
4713
+			echo '
4487 4714
 					<p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>';
4715
+	}
4488 4716
 
4489 4717
 	// Completion notification
4490 4718
 	echo '
@@ -4521,12 +4749,13 @@  discard block
 block discarded – undo
4521 4749
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4522 4750
 
4523 4751
 		// If debug flood the screen.
4524
-		if ($is_debug)
4525
-			echo '
4752
+		if ($is_debug) {
4753
+					echo '
4526 4754
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4527 4755
 
4528 4756
 						if (document.getElementById(\'debug_section\').scrollHeight)
4529 4757
 							document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4758
+		}
4530 4759
 
4531 4760
 		echo '
4532 4761
 						// Get the next update...
@@ -4572,10 +4801,11 @@  discard block
 block discarded – undo
4572 4801
 					</div>';
4573 4802
 
4574 4803
 	// Dont any tables so far?
4575
-	if (!empty($upcontext['previous_tables']))
4576
-		foreach ($upcontext['previous_tables'] as $table)
4804
+	if (!empty($upcontext['previous_tables'])) {
4805
+			foreach ($upcontext['previous_tables'] as $table)
4577 4806
 			echo '
4578 4807
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4808
+	}
4579 4809
 
4580 4810
 	echo '
4581 4811
 					<h3 id="current_tab">
@@ -4584,9 +4814,10 @@  discard block
 block discarded – undo
4584 4814
 					<p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>';
4585 4815
 
4586 4816
 	// Try to make sure substep was reset.
4587
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4588
-		echo '
4817
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4818
+			echo '
4589 4819
 					<input type="hidden" name="substep" id="substep" value="0">';
4820
+	}
4590 4821
 
4591 4822
 	// Continue please!
4592 4823
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4619,12 +4850,13 @@  discard block
 block discarded – undo
4619 4850
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4620 4851
 
4621 4852
 		// If debug flood the screen.
4622
-		if ($is_debug)
4623
-			echo '
4853
+		if ($is_debug) {
4854
+					echo '
4624 4855
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4625 4856
 
4626 4857
 							if (document.getElementById(\'debug_section\').scrollHeight)
4627 4858
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4859
+		}
4628 4860
 
4629 4861
 		echo '
4630 4862
 							// Get the next update...
@@ -4660,8 +4892,8 @@  discard block
 block discarded – undo
4660 4892
 				<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
4661 4893
 				<form action="', $boardurl, '/index.php">';
4662 4894
 
4663
-	if (!empty($upcontext['can_delete_script']))
4664
-		echo '
4895
+	if (!empty($upcontext['can_delete_script'])) {
4896
+			echo '
4665 4897
 					<label>
4666 4898
 						<input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '
4667 4899
 					</label>
@@ -4675,6 +4907,7 @@  discard block
 block discarded – undo
4675 4907
 						}
4676 4908
 					</script>
4677 4909
 					<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4910
+	}
4678 4911
 
4679 4912
 	$active = time() - $upcontext['started'];
4680 4913
 	$hours = floor($active / 3600);
@@ -4684,17 +4917,21 @@  discard block
 block discarded – undo
4684 4917
 	if ($is_debug)
4685 4918
 	{
4686 4919
 		$totalTime = '';
4687
-		if ($hours > 0)
4688
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4689
-		if ($minutes > 0)
4690
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4691
-		if ($seconds > 0)
4692
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4920
+		if ($hours > 0) {
4921
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4922
+		}
4923
+		if ($minutes > 0) {
4924
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4925
+		}
4926
+		if ($seconds > 0) {
4927
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4928
+		}
4693 4929
 	}
4694 4930
 
4695
-	if ($is_debug && !empty($totalTime))
4696
-		echo '
4931
+	if ($is_debug && !empty($totalTime)) {
4932
+			echo '
4697 4933
 					<p> ', $txt['upgrade_completed_time'], ' ', $totalTime, '</p>';
4934
+	}
4698 4935
 
4699 4936
 	echo '
4700 4937
 					<p>
@@ -4723,8 +4960,9 @@  discard block
 block discarded – undo
4723 4960
 
4724 4961
 	$current_substep = $_GET['substep'];
4725 4962
 
4726
-	if (empty($_GET['a']))
4727
-		$_GET['a'] = 0;
4963
+	if (empty($_GET['a'])) {
4964
+			$_GET['a'] = 0;
4965
+	}
4728 4966
 	$step_progress['name'] = 'Converting ips';
4729 4967
 	$step_progress['current'] = $_GET['a'];
4730 4968
 
@@ -4767,16 +5005,19 @@  discard block
 block discarded – undo
4767 5005
 				'empty' => '',
4768 5006
 				'limit' => $limit,
4769 5007
 		));
4770
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4771
-			$arIp[] = $row[$oldCol];
5008
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5009
+					$arIp[] = $row[$oldCol];
5010
+		}
4772 5011
 		$smcFunc['db_free_result']($request);
4773 5012
 
4774 5013
 		// Special case, null ip could keep us in a loop.
4775
-		if (is_null($arIp[0]))
4776
-			unset($arIp[0]);
5014
+		if (is_null($arIp[0])) {
5015
+					unset($arIp[0]);
5016
+		}
4777 5017
 
4778
-		if (empty($arIp))
4779
-			$is_done = true;
5018
+		if (empty($arIp)) {
5019
+					$is_done = true;
5020
+		}
4780 5021
 
4781 5022
 		$updates = array();
4782 5023
 		$cases = array();
@@ -4785,16 +5026,18 @@  discard block
 block discarded – undo
4785 5026
 		{
4786 5027
 			$arIp[$i] = trim($arIp[$i]);
4787 5028
 
4788
-			if (empty($arIp[$i]))
4789
-				continue;
5029
+			if (empty($arIp[$i])) {
5030
+							continue;
5031
+			}
4790 5032
 
4791 5033
 			$updates['ip' . $i] = $arIp[$i];
4792 5034
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4793 5035
 
4794 5036
 			if ($setSize > 0 && $i % $setSize === 0)
4795 5037
 			{
4796
-				if (count($updates) == 1)
4797
-					continue;
5038
+				if (count($updates) == 1) {
5039
+									continue;
5040
+				}
4798 5041
 
4799 5042
 				$updates['whereSet'] = array_values($updates);
4800 5043
 				$smcFunc['db_query']('', '
@@ -4828,8 +5071,7 @@  discard block
 block discarded – undo
4828 5071
 							'ip' => $ip
4829 5072
 					));
4830 5073
 				}
4831
-			}
4832
-			else
5074
+			} else
4833 5075
 			{
4834 5076
 				$updates['whereSet'] = array_values($updates);
4835 5077
 				$smcFunc['db_query']('', '
@@ -4843,9 +5085,9 @@  discard block
 block discarded – undo
4843 5085
 					$updates
4844 5086
 				);
4845 5087
 			}
5088
+		} else {
5089
+					$is_done = true;
4846 5090
 		}
4847
-		else
4848
-			$is_done = true;
4849 5091
 
4850 5092
 		$_GET['a'] += $limit;
4851 5093
 		$step_progress['current'] = $_GET['a'];
@@ -4871,10 +5113,11 @@  discard block
 block discarded – undo
4871 5113
 
4872 5114
 	$columns = $smcFunc['db_list_columns']($targetTable, true);
4873 5115
 
4874
-	if (isset($columns[$column]))
4875
-		return $columns[$column];
4876
-	else
4877
-		return null;
4878
-}
5116
+	if (isset($columns[$column])) {
5117
+			return $columns[$column];
5118
+	} else {
5119
+			return null;
5120
+	}
5121
+	}
4879 5122
 
4880 5123
 ?>
4881 5124
\ No newline at end of file
Please login to merge, or discard this patch.