Completed
Pull Request — release-2.1 (#4873)
by Fran
07:58
created
other/upgrade.php 2 patches
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -821,13 +821,13 @@  discard block
 block discarded – undo
821 821
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
822 822
 	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
823 823
 		$upcontext['warning'] = '
824
-			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br>
824
+			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) . '<br>
825 825
 			<ul>
826
-				<li>'. $txt['upgrade_boarddir'] .'  ' . $boarddir . '</li>
827
-				<li>'. $txt['upgrade_sourcedir'] .'  ' . $boarddir . '</li>
828
-				<li>'. $txt['upgrade_cachedir'] .'  ' . $cachedir_temp . '</li>
826
+				<li>'. $txt['upgrade_boarddir'] . '  ' . $boarddir . '</li>
827
+				<li>'. $txt['upgrade_sourcedir'] . '  ' . $boarddir . '</li>
828
+				<li>'. $txt['upgrade_cachedir'] . '  ' . $cachedir_temp . '</li>
829 829
 			</ul>
830
-			'. $txt['upgrade_incorrect_settings'] .'';
830
+			'. $txt['upgrade_incorrect_settings'] . '';
831 831
 
832 832
 	// Confirm mbstring is loaded...
833 833
 	if (!extension_loaded('mbstring'))
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
 
1762 1762
 	// Our custom error handler - does nothing but does stop public errors from XML!
1763 1763
 	set_error_handler(
1764
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1764
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1765 1765
 		{
1766 1766
 			if ($support_js)
1767 1767
 				return true;
@@ -2089,13 +2089,13 @@  discard block
 block discarded – undo
2089 2089
 
2090 2090
 	// Otherwise we have to display this somewhere appropriate if possible.
2091 2091
 	$upcontext['forced_error_message'] = '
2092
-			<strong>'. $txt['upgrade_unsuccessful'] .'</strong><br>
2092
+			<strong>'. $txt['upgrade_unsuccessful'] . '</strong><br>
2093 2093
 
2094 2094
 			<div style="margin: 2ex;">
2095
-				'. $txt['upgrade_thisquery'] .'
2095
+				'. $txt['upgrade_thisquery'] . '
2096 2096
 				<blockquote><pre>' . nl2br(htmlspecialchars(trim($string))) . ';</pre></blockquote>
2097 2097
 
2098
-				'. $txt['upgrade_causerror'] .'
2098
+				'. $txt['upgrade_causerror'] . '
2099 2099
 				<blockquote>' . nl2br(htmlspecialchars($db_error_message)) . '</blockquote>
2100 2100
 			</div>
2101 2101
 
@@ -2760,94 +2760,94 @@  discard block
 block discarded – undo
2760 2760
 		// Translation table for the character sets not native for MySQL.
2761 2761
 		$translation_tables = array(
2762 2762
 			'windows-1255' => array(
2763
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2764
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2765
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2766
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2767
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2768
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2769
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2770
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2771
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2772
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2773
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2774
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2775
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2776
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2777
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2778
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2779
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2780
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2781
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2782
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2783
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2784
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2785
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2786
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2787
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2788
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2789
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2790
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2791
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2792
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2793
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2794
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2795
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2796
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2797
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2798
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2799
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2800
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2801
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2802
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2803
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2804
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2763
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2764
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2765
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2766
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2767
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2768
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2769
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2770
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2771
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2772
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2773
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2774
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2775
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2776
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2777
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2778
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2779
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2780
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2781
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2782
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2783
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2784
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2785
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2786
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2787
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2788
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2789
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2790
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2791
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2792
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2793
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2794
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2795
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2796
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2797
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2798
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2799
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2800
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2801
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2802
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2803
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2804
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2805 2805
 				'0xFA' => '0xD7AA',
2806 2806
 			),
2807 2807
 			'windows-1253' => array(
2808
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2809
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2810
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2811
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2812
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2813
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2814
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2815
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2816
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2817
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2818
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2819
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2820
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2821
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2822
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2823
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2824
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2825
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2826
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2827
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2828
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2829
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2830
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2831
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2832
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2833
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2834
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2835
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2836
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2837
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2838
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2839
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2840
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2841
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2842
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2843
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2844
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2845
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2846
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2847
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2848
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2849
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2850
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2808
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2809
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2810
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2811
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2812
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2813
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2814
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2815
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2816
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2817
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2818
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2819
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2820
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2821
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2822
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2823
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2824
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2825
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2826
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2827
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2828
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2829
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2830
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2831
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2832
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2833
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2834
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2835
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2836
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2837
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2838
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2839
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2840
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2841
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2842
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2843
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2844
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2845
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2846
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2847
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2848
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2849
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2850
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2851 2851
 			),
2852 2852
 		);
2853 2853
 
@@ -3061,7 +3061,7 @@  discard block
 block discarded – undo
3061 3061
 
3062 3062
 		if ($upcontext['dropping_index'] && $command_line)
3063 3063
 		{
3064
-			echo "\n" . '', $txt['upgrade_fulltext_error'] ,'';
3064
+			echo "\n" . '', $txt['upgrade_fulltext_error'], '';
3065 3065
 			flush();
3066 3066
 		}
3067 3067
 	}
@@ -3405,7 +3405,7 @@  discard block
 block discarded – undo
3405 3405
 	{
3406 3406
 		echo '
3407 3407
 		<div class="error">
3408
-			<p>', $txt['upgrade_writable_files'] ,'</p>
3408
+			<p>', $txt['upgrade_writable_files'], '</p>
3409 3409
 			<ul class="error_content">
3410 3410
 				<li>' . implode('</li>
3411 3411
 				<li>', $upcontext['chmod']['files']) . '</li>
@@ -3777,7 +3777,7 @@  discard block
 block discarded – undo
3777 3777
 						<p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>';
3778 3778
 		if ($active < 600)
3779 3779
 			echo '
3780
-						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>';
3780
+						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '</p>';
3781 3781
 
3782 3782
 		if ($active > $upcontext['inactive_timeout'])
3783 3783
 			echo '
@@ -3886,7 +3886,7 @@  discard block
 block discarded – undo
3886 3886
 	if (!empty($upcontext['upgrade_options_warning']))
3887 3887
 		echo '
3888 3888
 				<div class="errorbox">
3889
-					<h3>', $txt['upgrade_warning'] ,'</h3>
3889
+					<h3>', $txt['upgrade_warning'], '</h3>
3890 3890
 					', $upcontext['upgrade_options_warning'], '
3891 3891
 				</div>';
3892 3892
 
@@ -3950,7 +3950,7 @@  discard block
 block discarded – undo
3950 3950
 	echo '
3951 3951
 				<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3952 3952
 					<input type="hidden" name="backup_done" id="backup_done" value="0">
3953
-					<strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']) ,'</strong>
3953
+					<strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']), '</strong>
3954 3954
 					<div id="debug_section">
3955 3955
 						<span id="debuginfo"></span>
3956 3956
 					</div>';
@@ -4400,7 +4400,7 @@  discard block
 block discarded – undo
4400 4400
 							if (!attemptAgain)
4401 4401
 							{
4402 4402
 								document.getElementById("error_block").style.display = "";
4403
-								setInnerHTML(document.getElementById("error_message"), "', sprintf($txt['upgrade_repondtime'], ($timeLimitThreshold * 10)), '"<a href="#" onclick="retTimeout(true); return false;">"', $txt['upgrade_respondtime_clickhere'], '"</a>';');
4403
+								setInnerHTML(document.getElementById("error_message"), "', sprintf($txt['upgrade_repondtime'], ($timeLimitThreshold * 10)), '"<a href="#" onclick="retTimeout(true); return false;">"', $txt['upgrade_respondtime_clickhere'], '"</a>'; ');
4404 4404
 							}
4405 4405
 							else
4406 4406
 							{
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
 	}
@@ -464,10 +490,11 @@  discard block
 block discarded – undo
464 490
 	}
465 491
 
466 492
 	// Override the language file?
467
-	if (isset($_GET['lang_file']))
468
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
469
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
470
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
493
+	if (isset($_GET['lang_file'])) {
494
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
495
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
496
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
497
+	}
471 498
 
472 499
 	// Make sure it exists, if it doesn't reset it.
473 500
 	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']))
@@ -476,12 +503,14 @@  discard block
 block discarded – undo
476 503
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
477 504
 
478 505
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
479
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
480
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
506
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
507
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
508
+		}
481 509
 
482 510
 		// For backup we load the english at first -> second language overwrite the english one
483
-		if (count($incontext['detected_languages']) > 1)
484
-			require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
511
+		if (count($incontext['detected_languages']) > 1) {
512
+					require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
513
+		}
485 514
 	}
486 515
 
487 516
 	// And now include the actual language file itself.
@@ -489,11 +518,12 @@  discard block
 block discarded – undo
489 518
 
490 519
 	// Which language did we load? Assume that he likes his language.
491 520
 	preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches);
492
-	if (empty($matches[1]))
493
-		$matches = [
521
+	if (empty($matches[1])) {
522
+			$matches = [
494 523
 			0 => 'nothing',
495 524
 			1 => 'english',
496 525
 		];
526
+	}
497 527
 	$user_info['language'] = $matches[1];
498 528
 }
499 529
 
@@ -503,8 +533,9 @@  discard block
 block discarded – undo
503 533
 	global $upgradeurl, $upcontext, $command_line;
504 534
 
505 535
 	// Command line users can't be redirected.
506
-	if ($command_line)
507
-		upgradeExit(true);
536
+	if ($command_line) {
537
+			upgradeExit(true);
538
+	}
508 539
 
509 540
 	// Are we providing the core info?
510 541
 	if ($addForm)
@@ -530,12 +561,14 @@  discard block
 block discarded – undo
530 561
 	define('SMF', 1);
531 562
 
532 563
 	// Start the session.
533
-	if (@ini_get('session.save_handler') == 'user')
534
-		@ini_set('session.save_handler', 'files');
564
+	if (@ini_get('session.save_handler') == 'user') {
565
+			@ini_set('session.save_handler', 'files');
566
+	}
535 567
 	@session_start();
536 568
 
537
-	if (empty($smcFunc))
538
-		$smcFunc = array();
569
+	if (empty($smcFunc)) {
570
+			$smcFunc = array();
571
+	}
539 572
 
540 573
 	// We need this for authentication and some upgrade code
541 574
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -562,24 +595,27 @@  discard block
 block discarded – undo
562 595
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
563 596
 
564 597
 		// Make the connection...
565
-		if (empty($db_connection))
566
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
567
-		else
568
-			// If we've returned here, ping/reconnect to be safe
598
+		if (empty($db_connection)) {
599
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
600
+		} else {
601
+					// If we've returned here, ping/reconnect to be safe
569 602
 			$smcFunc['db_ping']($db_connection);
603
+		}
570 604
 
571 605
 		// Oh dear god!!
572
-		if ($db_connection === null)
573
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
606
+		if ($db_connection === null) {
607
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
608
+		}
574 609
 
575
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
576
-			$smcFunc['db_query']('', '
610
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
611
+					$smcFunc['db_query']('', '
577 612
 			SET NAMES {string:db_character_set}',
578 613
 			array(
579 614
 				'db_error_skip' => true,
580 615
 				'db_character_set' => $db_character_set,
581 616
 			)
582 617
 		);
618
+		}
583 619
 
584 620
 		// Load the modSettings data...
585 621
 		$request = $smcFunc['db_query']('', '
@@ -590,11 +626,11 @@  discard block
 block discarded – undo
590 626
 			)
591 627
 		);
592 628
 		$modSettings = array();
593
-		while ($row = $smcFunc['db_fetch_assoc']($request))
594
-			$modSettings[$row['variable']] = $row['value'];
629
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
630
+					$modSettings[$row['variable']] = $row['value'];
631
+		}
595 632
 		$smcFunc['db_free_result']($request);
596
-	}
597
-	else
633
+	} else
598 634
 	{
599 635
 		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.');
600 636
 	}
@@ -608,9 +644,10 @@  discard block
 block discarded – undo
608 644
 		cleanRequest();
609 645
 	}
610 646
 
611
-	if (!isset($_GET['substep']))
612
-		$_GET['substep'] = 0;
613
-}
647
+	if (!isset($_GET['substep'])) {
648
+			$_GET['substep'] = 0;
649
+	}
650
+	}
614 651
 
615 652
 function initialize_inputs()
616 653
 {
@@ -640,8 +677,9 @@  discard block
 block discarded – undo
640 677
 		$dh = opendir(dirname(__FILE__));
641 678
 		while ($file = readdir($dh))
642 679
 		{
643
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
644
-				@unlink(dirname(__FILE__) . '/' . $file);
680
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
681
+							@unlink(dirname(__FILE__) . '/' . $file);
682
+			}
645 683
 		}
646 684
 		closedir($dh);
647 685
 
@@ -670,8 +708,9 @@  discard block
 block discarded – undo
670 708
 	$temp = 'upgrade_php?step';
671 709
 	while (strlen($temp) > 4)
672 710
 	{
673
-		if (isset($_GET[$temp]))
674
-			unset($_GET[$temp]);
711
+		if (isset($_GET[$temp])) {
712
+					unset($_GET[$temp]);
713
+		}
675 714
 		$temp = substr($temp, 1);
676 715
 	}
677 716
 
@@ -698,32 +737,39 @@  discard block
 block discarded – undo
698 737
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
699 738
 
700 739
 	// Need legacy scripts?
701
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
702
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
703
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
704
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
705
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
706
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
740
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
741
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
742
+	}
743
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
744
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
745
+	}
746
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
747
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
748
+	}
707 749
 
708 750
 	// We don't need "-utf8" files anymore...
709 751
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
710 752
 
711 753
 	// This needs to exist!
712
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
713
-		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>]');
714
-	else
715
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
754
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
755
+			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>]');
756
+	} else {
757
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
758
+	}
716 759
 
717
-	if (!$check)
718
-		// 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.
760
+	if (!$check) {
761
+			// 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.
719 762
 		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.');
763
+	}
720 764
 
721 765
 	// Do they meet the install requirements?
722
-	if (!php_version_check())
723
-		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.');
766
+	if (!php_version_check()) {
767
+			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.');
768
+	}
724 769
 
725
-	if (!db_version_check())
726
-		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.');
770
+	if (!db_version_check()) {
771
+			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.');
772
+	}
727 773
 
728 774
 	// Do some checks to make sure they have proper privileges
729 775
 	db_extend('packages');
@@ -738,14 +784,16 @@  discard block
 block discarded – undo
738 784
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
739 785
 
740 786
 	// Sorry... we need CREATE, ALTER and DROP
741
-	if (!$create || !$alter || !$drop)
742
-		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.');
787
+	if (!$create || !$alter || !$drop) {
788
+			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.');
789
+	}
743 790
 
744 791
 	// Do a quick version spot check.
745 792
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
746 793
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
747
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
748
-		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.');
794
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
795
+			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.');
796
+	}
749 797
 
750 798
 	// What absolutely needs to be writable?
751 799
 	$writable_files = array(
@@ -754,12 +802,13 @@  discard block
 block discarded – undo
754 802
 	);
755 803
 
756 804
 	// Only check for minified writable files if we have it enabled or not set.
757
-	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files']))
758
-		$writable_files += array(
805
+	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) {
806
+			$writable_files += array(
759 807
 			$modSettings['theme_dir'] . '/css/minified.css',
760 808
 			$modSettings['theme_dir'] . '/scripts/minified.js',
761 809
 			$modSettings['theme_dir'] . '/scripts/minified_deferred.js',
762 810
 		);
811
+	}
763 812
 
764 813
 	// Do we need to add this setting?
765 814
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
@@ -771,12 +820,13 @@  discard block
 block discarded – undo
771 820
 	quickFileWritable($custom_av_dir);
772 821
 
773 822
 	// Are we good now?
774
-	if (!is_writable($custom_av_dir))
775
-		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));
776
-	elseif ($need_settings_update)
823
+	if (!is_writable($custom_av_dir)) {
824
+			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));
825
+	} elseif ($need_settings_update)
777 826
 	{
778
-		if (!function_exists('cache_put_data'))
779
-			require_once($sourcedir . '/Load.php');
827
+		if (!function_exists('cache_put_data')) {
828
+					require_once($sourcedir . '/Load.php');
829
+		}
780 830
 
781 831
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
782 832
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
@@ -786,29 +836,34 @@  discard block
 block discarded – undo
786 836
 
787 837
 	// Check the cache directory.
788 838
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
789
-	if (!file_exists($cachedir_temp))
790
-		@mkdir($cachedir_temp);
839
+	if (!file_exists($cachedir_temp)) {
840
+			@mkdir($cachedir_temp);
841
+	}
791 842
 
792
-	if (!file_exists($cachedir_temp))
793
-		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.');
843
+	if (!file_exists($cachedir_temp)) {
844
+			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.');
845
+	}
794 846
 
795
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
796
-		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>.');
797
-	elseif (!isset($_GET['skiplang']))
847
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
848
+			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>.');
849
+	} elseif (!isset($_GET['skiplang']))
798 850
 	{
799 851
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
800 852
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
801 853
 
802
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
803
-			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>]');
854
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
855
+					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>]');
856
+		}
804 857
 	}
805 858
 
806
-	if (!makeFilesWritable($writable_files))
807
-		return false;
859
+	if (!makeFilesWritable($writable_files)) {
860
+			return false;
861
+	}
808 862
 
809 863
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
810
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
811
-		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.');
864
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
865
+			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.');
866
+	}
812 867
 
813 868
 	// Upgrade the agreement.
814 869
 	elseif (isset($modSettings['agreement']))
@@ -819,8 +874,8 @@  discard block
 block discarded – undo
819 874
 	}
820 875
 
821 876
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
822
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
823
-		$upcontext['warning'] = '
877
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
878
+			$upcontext['warning'] = '
824 879
 			'. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br>
825 880
 			<ul>
826 881
 				<li>'. $txt['upgrade_boarddir'] .'  ' . $boarddir . '</li>
@@ -828,19 +883,23 @@  discard block
 block discarded – undo
828 883
 				<li>'. $txt['upgrade_cachedir'] .'  ' . $cachedir_temp . '</li>
829 884
 			</ul>
830 885
 			'. $txt['upgrade_incorrect_settings'] .'';
886
+	}
831 887
 
832 888
 	// Confirm mbstring is loaded...
833
-	if (!extension_loaded('mbstring'))
834
-		return throw_error($txt['install_no_mbstring']);
889
+	if (!extension_loaded('mbstring')) {
890
+			return throw_error($txt['install_no_mbstring']);
891
+	}
835 892
 
836 893
 	// Check for https stream support.
837 894
 	$supported_streams = stream_get_wrappers();
838
-	if (!in_array('https', $supported_streams))
839
-		$upcontext['custom_warning'] = $txt['install_no_https'];
895
+	if (!in_array('https', $supported_streams)) {
896
+			$upcontext['custom_warning'] = $txt['install_no_https'];
897
+	}
840 898
 
841 899
 	// Either we're logged in or we're going to present the login.
842
-	if (checkLogin())
843
-		return true;
900
+	if (checkLogin()) {
901
+			return true;
902
+	}
844 903
 
845 904
 	$upcontext += createToken('login');
846 905
 
@@ -854,15 +913,17 @@  discard block
 block discarded – undo
854 913
 	global $smcFunc, $db_type, $support_js;
855 914
 
856 915
 	// Don't bother if the security is disabled.
857
-	if ($disable_security)
858
-		return true;
916
+	if ($disable_security) {
917
+			return true;
918
+	}
859 919
 
860 920
 	// Are we trying to login?
861 921
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
862 922
 	{
863 923
 		// If we've disabled security pick a suitable name!
864
-		if (empty($_POST['user']))
865
-			$_POST['user'] = 'Administrator';
924
+		if (empty($_POST['user'])) {
925
+					$_POST['user'] = 'Administrator';
926
+		}
866 927
 
867 928
 		// Before 2.0 these column names were different!
868 929
 		$oldDB = false;
@@ -877,16 +938,17 @@  discard block
 block discarded – undo
877 938
 					'db_error_skip' => true,
878 939
 				)
879 940
 			);
880
-			if ($smcFunc['db_num_rows']($request) != 0)
881
-				$oldDB = true;
941
+			if ($smcFunc['db_num_rows']($request) != 0) {
942
+							$oldDB = true;
943
+			}
882 944
 			$smcFunc['db_free_result']($request);
883 945
 		}
884 946
 
885 947
 		// Get what we believe to be their details.
886 948
 		if (!$disable_security)
887 949
 		{
888
-			if ($oldDB)
889
-				$request = $smcFunc['db_query']('', '
950
+			if ($oldDB) {
951
+							$request = $smcFunc['db_query']('', '
890 952
 					SELECT id_member, memberName AS member_name, passwd, id_group,
891 953
 					additionalGroups AS additional_groups, lngfile
892 954
 					FROM {db_prefix}members
@@ -896,8 +958,8 @@  discard block
 block discarded – undo
896 958
 						'db_error_skip' => true,
897 959
 					)
898 960
 				);
899
-			else
900
-				$request = $smcFunc['db_query']('', '
961
+			} else {
962
+							$request = $smcFunc['db_query']('', '
901 963
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
902 964
 					FROM {db_prefix}members
903 965
 					WHERE member_name = {string:member_name}',
@@ -906,6 +968,7 @@  discard block
 block discarded – undo
906 968
 						'db_error_skip' => true,
907 969
 					)
908 970
 				);
971
+			}
909 972
 			if ($smcFunc['db_num_rows']($request) != 0)
910 973
 			{
911 974
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -913,16 +976,17 @@  discard block
 block discarded – undo
913 976
 				$groups = explode(',', $addGroups);
914 977
 				$groups[] = $id_group;
915 978
 
916
-				foreach ($groups as $k => $v)
917
-					$groups[$k] = (int) $v;
979
+				foreach ($groups as $k => $v) {
980
+									$groups[$k] = (int) $v;
981
+				}
918 982
 
919 983
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
920 984
 
921 985
 				// We don't use "-utf8" anymore...
922 986
 				$user_language = str_ireplace('-utf8', '', $user_language);
987
+			} else {
988
+							$upcontext['username_incorrect'] = true;
923 989
 			}
924
-			else
925
-				$upcontext['username_incorrect'] = true;
926 990
 
927 991
 			$smcFunc['db_free_result']($request);
928 992
 		}
@@ -933,13 +997,14 @@  discard block
 block discarded – undo
933 997
 		{
934 998
 			$upcontext['upgrade_status']['js'] = 1;
935 999
 			$support_js = 1;
1000
+		} else {
1001
+					$support_js = 0;
936 1002
 		}
937
-		else
938
-			$support_js = 0;
939 1003
 
940 1004
 		// Note down the version we are coming from.
941
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
942
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
1005
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
1006
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
1007
+		}
943 1008
 
944 1009
 		// Didn't get anywhere?
945 1010
 		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']))
@@ -973,15 +1038,15 @@  discard block
 block discarded – undo
973 1038
 							'db_error_skip' => true,
974 1039
 						)
975 1040
 					);
976
-					if ($smcFunc['db_num_rows']($request) == 0)
977
-						return throw_error('You need to be an admin to perform an upgrade!');
1041
+					if ($smcFunc['db_num_rows']($request) == 0) {
1042
+											return throw_error('You need to be an admin to perform an upgrade!');
1043
+					}
978 1044
 					$smcFunc['db_free_result']($request);
979 1045
 				}
980 1046
 
981 1047
 				$upcontext['user']['id'] = $id_member;
982 1048
 				$upcontext['user']['name'] = $name;
983
-			}
984
-			else
1049
+			} else
985 1050
 			{
986 1051
 				$upcontext['user']['id'] = 1;
987 1052
 				$upcontext['user']['name'] = 'Administrator';
@@ -997,11 +1062,11 @@  discard block
 block discarded – undo
997 1062
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
998 1063
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
999 1064
 
1000
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1001
-					$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'] . '.';
1002
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
1003
-					$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'] . '.';
1004
-				else
1065
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1066
+									$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'] . '.';
1067
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1068
+									$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'] . '.';
1069
+				} else
1005 1070
 				{
1006 1071
 					// Set this as the new language.
1007 1072
 					$upcontext['language'] = $user_language;
@@ -1045,8 +1110,9 @@  discard block
 block discarded – undo
1045 1110
 	unset($member_columns);
1046 1111
 
1047 1112
 	// If we've not submitted then we're done.
1048
-	if (empty($_POST['upcont']))
1049
-		return false;
1113
+	if (empty($_POST['upcont'])) {
1114
+			return false;
1115
+	}
1050 1116
 
1051 1117
 	// Firstly, if they're enabling SM stat collection just do it.
1052 1118
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -1066,16 +1132,17 @@  discard block
 block discarded – undo
1066 1132
 				fwrite($fp, $out);
1067 1133
 
1068 1134
 				$return_data = '';
1069
-				while (!feof($fp))
1070
-					$return_data .= fgets($fp, 128);
1135
+				while (!feof($fp)) {
1136
+									$return_data .= fgets($fp, 128);
1137
+				}
1071 1138
 
1072 1139
 				fclose($fp);
1073 1140
 
1074 1141
 				// Get the unique site ID.
1075 1142
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1076 1143
 
1077
-				if (!empty($ID[1]))
1078
-					$smcFunc['db_insert']('replace',
1144
+				if (!empty($ID[1])) {
1145
+									$smcFunc['db_insert']('replace',
1079 1146
 						$db_prefix . 'settings',
1080 1147
 						array('variable' => 'string', 'value' => 'string'),
1081 1148
 						array(
@@ -1084,9 +1151,9 @@  discard block
 block discarded – undo
1084 1151
 						),
1085 1152
 						array('variable')
1086 1153
 					);
1154
+				}
1087 1155
 			}
1088
-		}
1089
-		else
1156
+		} else
1090 1157
 		{
1091 1158
 			$smcFunc['db_insert']('replace',
1092 1159
 				$db_prefix . 'settings',
@@ -1097,8 +1164,8 @@  discard block
 block discarded – undo
1097 1164
 		}
1098 1165
 	}
1099 1166
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1100
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1101
-		$smcFunc['db_query']('', '
1167
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1168
+			$smcFunc['db_query']('', '
1102 1169
 			DELETE FROM {db_prefix}settings
1103 1170
 			WHERE variable = {string:enable_sm_stats}',
1104 1171
 			array(
@@ -1106,6 +1173,7 @@  discard block
 block discarded – undo
1106 1173
 				'db_error_skip' => true,
1107 1174
 			)
1108 1175
 		);
1176
+	}
1109 1177
 
1110 1178
 	// Deleting old karma stuff?
1111 1179
 	if (!empty($_POST['delete_karma']))
@@ -1120,20 +1188,22 @@  discard block
 block discarded – undo
1120 1188
 		);
1121 1189
 
1122 1190
 		// Cleaning up old karma member settings.
1123
-		if ($upcontext['karma_installed']['good'])
1124
-			$smcFunc['db_query']('', '
1191
+		if ($upcontext['karma_installed']['good']) {
1192
+					$smcFunc['db_query']('', '
1125 1193
 				ALTER TABLE {db_prefix}members
1126 1194
 				DROP karma_good',
1127 1195
 				array()
1128 1196
 			);
1197
+		}
1129 1198
 
1130 1199
 		// Does karma bad was enable?
1131
-		if ($upcontext['karma_installed']['bad'])
1132
-			$smcFunc['db_query']('', '
1200
+		if ($upcontext['karma_installed']['bad']) {
1201
+					$smcFunc['db_query']('', '
1133 1202
 				ALTER TABLE {db_prefix}members
1134 1203
 				DROP karma_bad',
1135 1204
 				array()
1136 1205
 			);
1206
+		}
1137 1207
 
1138 1208
 		// Cleaning up old karma permissions.
1139 1209
 		$smcFunc['db_query']('', '
@@ -1151,32 +1221,37 @@  discard block
 block discarded – undo
1151 1221
 	}
1152 1222
 
1153 1223
 	// Emptying the error log?
1154
-	if (!empty($_POST['empty_error']))
1155
-		$smcFunc['db_query']('truncate_table', '
1224
+	if (!empty($_POST['empty_error'])) {
1225
+			$smcFunc['db_query']('truncate_table', '
1156 1226
 			TRUNCATE {db_prefix}log_errors',
1157 1227
 			array(
1158 1228
 			)
1159 1229
 		);
1230
+	}
1160 1231
 
1161 1232
 	$changes = array();
1162 1233
 
1163 1234
 	// Add proxy settings.
1164
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1165
-		$changes += array(
1235
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1236
+			$changes += array(
1166 1237
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1167 1238
 			'image_proxy_maxsize' => 5190,
1168 1239
 			'image_proxy_enabled' => 0,
1169 1240
 		);
1241
+	}
1170 1242
 
1171 1243
 	// If $boardurl reflects https, set force_ssl
1172
-	if (!function_exists('cache_put_data'))
1173
-		require_once($sourcedir . '/Load.php');
1174
-	if (stripos($boardurl, 'https://') !== false)
1175
-		updateSettings(array('force_ssl' => '1'));
1244
+	if (!function_exists('cache_put_data')) {
1245
+			require_once($sourcedir . '/Load.php');
1246
+	}
1247
+	if (stripos($boardurl, 'https://') !== false) {
1248
+			updateSettings(array('force_ssl' => '1'));
1249
+	}
1176 1250
 
1177 1251
 	// If we're overriding the language follow it through.
1178
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1179
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1252
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1253
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1254
+	}
1180 1255
 
1181 1256
 	if (!empty($_POST['maint']))
1182 1257
 	{
@@ -1188,26 +1263,29 @@  discard block
 block discarded – undo
1188 1263
 		{
1189 1264
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1190 1265
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1191
-		}
1192
-		else
1266
+		} else
1193 1267
 		{
1194 1268
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1195 1269
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1196 1270
 		}
1197 1271
 	}
1198 1272
 
1199
-	if ($command_line)
1200
-		echo ' * Updating Settings.php...';
1273
+	if ($command_line) {
1274
+			echo ' * Updating Settings.php...';
1275
+	}
1201 1276
 
1202 1277
 	// Fix some old paths.
1203
-	if (substr($boarddir, 0, 1) == '.')
1204
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1278
+	if (substr($boarddir, 0, 1) == '.') {
1279
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1280
+	}
1205 1281
 
1206
-	if (substr($sourcedir, 0, 1) == '.')
1207
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1282
+	if (substr($sourcedir, 0, 1) == '.') {
1283
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1284
+	}
1208 1285
 
1209
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1210
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1286
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1287
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1288
+	}
1211 1289
 
1212 1290
 	// If they have a "host:port" setup for the host, split that into separate values
1213 1291
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1218,32 +1296,36 @@  discard block
 block discarded – undo
1218 1296
 		$changes['db_server'] = '\'' . $db_server . '\'';
1219 1297
 
1220 1298
 		// Only set this if we're not using the default port
1221
-		if ($db_port != ini_get('mysqli.default_port'))
1222
-			$changes['db_port'] = (int) $db_port;
1223
-	}
1224
-	elseif (!empty($db_port))
1299
+		if ($db_port != ini_get('mysqli.default_port')) {
1300
+					$changes['db_port'] = (int) $db_port;
1301
+		}
1302
+	} elseif (!empty($db_port))
1225 1303
 	{
1226 1304
 		// If db_port is set and is the same as the default, set it to ''
1227 1305
 		if ($db_type == 'mysql')
1228 1306
 		{
1229
-			if ($db_port == ini_get('mysqli.default_port'))
1230
-				$changes['db_port'] = '\'\'';
1231
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1232
-				$changes['db_port'] = '\'\'';
1307
+			if ($db_port == ini_get('mysqli.default_port')) {
1308
+							$changes['db_port'] = '\'\'';
1309
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1310
+							$changes['db_port'] = '\'\'';
1311
+			}
1233 1312
 		}
1234 1313
 	}
1235 1314
 
1236 1315
 	// Maybe we haven't had this option yet?
1237
-	if (empty($packagesdir))
1238
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1316
+	if (empty($packagesdir)) {
1317
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1318
+	}
1239 1319
 
1240 1320
 	// Add support for $tasksdir var.
1241
-	if (empty($tasksdir))
1242
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1321
+	if (empty($tasksdir)) {
1322
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1323
+	}
1243 1324
 
1244 1325
 	// Make sure we fix the language as well.
1245
-	if (stristr($language, '-utf8'))
1246
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1326
+	if (stristr($language, '-utf8')) {
1327
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1328
+	}
1247 1329
 
1248 1330
 	// @todo Maybe change the cookie name if going to 1.1, too?
1249 1331
 
@@ -1254,8 +1336,9 @@  discard block
 block discarded – undo
1254 1336
 	// Tell Settings.php to store db_last_error.php in the cache
1255 1337
 	move_db_last_error_to_cachedir();
1256 1338
 
1257
-	if ($command_line)
1258
-		echo ' Successful.' . "\n";
1339
+	if ($command_line) {
1340
+			echo ' Successful.' . "\n";
1341
+	}
1259 1342
 
1260 1343
 	// Are we doing debug?
1261 1344
 	if (isset($_POST['debug']))
@@ -1265,8 +1348,9 @@  discard block
 block discarded – undo
1265 1348
 	}
1266 1349
 
1267 1350
 	// If we're not backing up then jump one.
1268
-	if (empty($_POST['backup']))
1269
-		$upcontext['current_step']++;
1351
+	if (empty($_POST['backup'])) {
1352
+			$upcontext['current_step']++;
1353
+	}
1270 1354
 
1271 1355
 	// If we've got here then let's proceed to the next step!
1272 1356
 	return true;
@@ -1281,8 +1365,9 @@  discard block
 block discarded – undo
1281 1365
 	$upcontext['page_title'] = $txt['backup_database'];
1282 1366
 
1283 1367
 	// Done it already - js wise?
1284
-	if (!empty($_POST['backup_done']))
1285
-		return true;
1368
+	if (!empty($_POST['backup_done'])) {
1369
+			return true;
1370
+	}
1286 1371
 
1287 1372
 	// Some useful stuff here.
1288 1373
 	db_extend();
@@ -1296,9 +1381,10 @@  discard block
 block discarded – undo
1296 1381
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1297 1382
 
1298 1383
 	$table_names = array();
1299
-	foreach ($tables as $table)
1300
-		if (substr($table, 0, 7) !== 'backup_')
1384
+	foreach ($tables as $table) {
1385
+			if (substr($table, 0, 7) !== 'backup_')
1301 1386
 			$table_names[] = $table;
1387
+	}
1302 1388
 
1303 1389
 	$upcontext['table_count'] = count($table_names);
1304 1390
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1308,12 +1394,14 @@  discard block
 block discarded – undo
1308 1394
 	$file_steps = $upcontext['table_count'];
1309 1395
 
1310 1396
 	// What ones have we already done?
1311
-	foreach ($table_names as $id => $table)
1312
-		if ($id < $_GET['substep'])
1397
+	foreach ($table_names as $id => $table) {
1398
+			if ($id < $_GET['substep'])
1313 1399
 			$upcontext['previous_tables'][] = $table;
1400
+	}
1314 1401
 
1315
-	if ($command_line)
1316
-		echo 'Backing Up Tables.';
1402
+	if ($command_line) {
1403
+			echo 'Backing Up Tables.';
1404
+	}
1317 1405
 
1318 1406
 	// If we don't support javascript we backup here.
1319 1407
 	if (!$support_js || isset($_GET['xml']))
@@ -1332,8 +1420,9 @@  discard block
 block discarded – undo
1332 1420
 			backupTable($table_names[$substep]);
1333 1421
 
1334 1422
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1335
-			if (isset($_GET['xml']))
1336
-				return upgradeExit();
1423
+			if (isset($_GET['xml'])) {
1424
+							return upgradeExit();
1425
+			}
1337 1426
 		}
1338 1427
 
1339 1428
 		if ($command_line)
@@ -1366,9 +1455,10 @@  discard block
 block discarded – undo
1366 1455
 
1367 1456
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1368 1457
 
1369
-	if ($command_line)
1370
-		echo ' done.';
1371
-}
1458
+	if ($command_line) {
1459
+			echo ' done.';
1460
+	}
1461
+	}
1372 1462
 
1373 1463
 // Step 2: Everything.
1374 1464
 function DatabaseChanges()
@@ -1377,8 +1467,9 @@  discard block
 block discarded – undo
1377 1467
 	global $upcontext, $support_js, $db_type;
1378 1468
 
1379 1469
 	// Have we just completed this?
1380
-	if (!empty($_POST['database_done']))
1381
-		return true;
1470
+	if (!empty($_POST['database_done'])) {
1471
+			return true;
1472
+	}
1382 1473
 
1383 1474
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1384 1475
 	$upcontext['page_title'] = $txt['database_changes'];
@@ -1393,15 +1484,16 @@  discard block
 block discarded – undo
1393 1484
 	);
1394 1485
 
1395 1486
 	// How many files are there in total?
1396
-	if (isset($_GET['filecount']))
1397
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1398
-	else
1487
+	if (isset($_GET['filecount'])) {
1488
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1489
+	} else
1399 1490
 	{
1400 1491
 		$upcontext['file_count'] = 0;
1401 1492
 		foreach ($files as $file)
1402 1493
 		{
1403
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1404
-				$upcontext['file_count']++;
1494
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1495
+							$upcontext['file_count']++;
1496
+			}
1405 1497
 		}
1406 1498
 	}
1407 1499
 
@@ -1411,9 +1503,9 @@  discard block
 block discarded – undo
1411 1503
 	$upcontext['cur_file_num'] = 0;
1412 1504
 	foreach ($files as $file)
1413 1505
 	{
1414
-		if ($did_not_do)
1415
-			$did_not_do--;
1416
-		else
1506
+		if ($did_not_do) {
1507
+					$did_not_do--;
1508
+		} else
1417 1509
 		{
1418 1510
 			$upcontext['cur_file_num']++;
1419 1511
 			$upcontext['cur_file_name'] = $file[0];
@@ -1440,12 +1532,13 @@  discard block
 block discarded – undo
1440 1532
 					// Flag to move on to the next.
1441 1533
 					$upcontext['completed_step'] = true;
1442 1534
 					// Did we complete the whole file?
1443
-					if ($nextFile)
1444
-						$upcontext['current_debug_item_num'] = -1;
1535
+					if ($nextFile) {
1536
+											$upcontext['current_debug_item_num'] = -1;
1537
+					}
1445 1538
 					return upgradeExit();
1539
+				} elseif ($support_js) {
1540
+									break;
1446 1541
 				}
1447
-				elseif ($support_js)
1448
-					break;
1449 1542
 			}
1450 1543
 			// Set the progress bar to be right as if we had - even if we hadn't...
1451 1544
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1471,8 +1564,9 @@  discard block
 block discarded – undo
1471 1564
 	global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings;
1472 1565
 
1473 1566
 	// Now it's nice to have some of the basic SMF source files.
1474
-	if (!isset($_GET['ssi']) && !$command_line)
1475
-		redirectLocation('&ssi=1');
1567
+	if (!isset($_GET['ssi']) && !$command_line) {
1568
+			redirectLocation('&ssi=1');
1569
+	}
1476 1570
 
1477 1571
 	$upcontext['sub_template'] = 'upgrade_complete';
1478 1572
 	$upcontext['page_title'] = $txt['upgrade_complete'];
@@ -1488,14 +1582,16 @@  discard block
 block discarded – undo
1488 1582
 	// Are we in maintenance mode?
1489 1583
 	if (isset($upcontext['user']['main']))
1490 1584
 	{
1491
-		if ($command_line)
1492
-			echo ' * ';
1585
+		if ($command_line) {
1586
+					echo ' * ';
1587
+		}
1493 1588
 		$upcontext['removed_maintenance'] = true;
1494 1589
 		$changes['maintenance'] = $upcontext['user']['main'];
1495 1590
 	}
1496 1591
 	// Otherwise if somehow we are in 2 let's go to 1.
1497
-	elseif (!empty($maintenance) && $maintenance == 2)
1498
-		$changes['maintenance'] = 1;
1592
+	elseif (!empty($maintenance) && $maintenance == 2) {
1593
+			$changes['maintenance'] = 1;
1594
+	}
1499 1595
 
1500 1596
 	// Wipe this out...
1501 1597
 	$upcontext['user'] = array();
@@ -1510,21 +1606,23 @@  discard block
 block discarded – undo
1510 1606
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1511 1607
 
1512 1608
 	// Now is the perfect time to fetch the SM files.
1513
-	if ($command_line)
1514
-		cli_scheduled_fetchSMfiles();
1515
-	else
1609
+	if ($command_line) {
1610
+			cli_scheduled_fetchSMfiles();
1611
+	} else
1516 1612
 	{
1517 1613
 		require_once($sourcedir . '/ScheduledTasks.php');
1518 1614
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
1519 1615
 		scheduled_fetchSMfiles(); // Now go get those files!
1520 1616
 		// This is needed in case someone invokes the upgrader using https when upgrading an http forum
1521
-		if (httpsOn())
1522
-			$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1617
+		if (httpsOn()) {
1618
+					$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1619
+		}
1523 1620
 	}
1524 1621
 
1525 1622
 	// Log what we've done.
1526
-	if (empty($user_info['id']))
1527
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1623
+	if (empty($user_info['id'])) {
1624
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1625
+	}
1528 1626
 
1529 1627
 	// Log the action manually, so CLI still works.
1530 1628
 	$smcFunc['db_insert']('',
@@ -1543,8 +1641,9 @@  discard block
 block discarded – undo
1543 1641
 
1544 1642
 	// Save the current database version.
1545 1643
 	$server_version = $smcFunc['db_server_info']();
1546
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1547
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1644
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1645
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1646
+	}
1548 1647
 
1549 1648
 	if ($command_line)
1550 1649
 	{
@@ -1556,8 +1655,9 @@  discard block
 block discarded – undo
1556 1655
 
1557 1656
 	// Make sure it says we're done.
1558 1657
 	$upcontext['overall_percent'] = 100;
1559
-	if (isset($upcontext['step_progress']))
1560
-		unset($upcontext['step_progress']);
1658
+	if (isset($upcontext['step_progress'])) {
1659
+			unset($upcontext['step_progress']);
1660
+	}
1561 1661
 
1562 1662
 	$_GET['substep'] = 0;
1563 1663
 	return false;
@@ -1568,8 +1668,9 @@  discard block
 block discarded – undo
1568 1668
 {
1569 1669
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1570 1670
 
1571
-	if (empty($modSettings['time_format']))
1572
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1671
+	if (empty($modSettings['time_format'])) {
1672
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1673
+	}
1573 1674
 
1574 1675
 	// What files do we want to get
1575 1676
 	$request = $smcFunc['db_query']('', '
@@ -1603,8 +1704,9 @@  discard block
 block discarded – undo
1603 1704
 		$file_data = fetch_web_data($url);
1604 1705
 
1605 1706
 		// If we got an error - give up - the site might be down.
1606
-		if ($file_data === false)
1607
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1707
+		if ($file_data === false) {
1708
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1709
+		}
1608 1710
 
1609 1711
 		// Save the file to the database.
1610 1712
 		$smcFunc['db_query']('substring', '
@@ -1646,8 +1748,9 @@  discard block
 block discarded – undo
1646 1748
 	$themeData = array();
1647 1749
 	foreach ($values as $variable => $value)
1648 1750
 	{
1649
-		if (!isset($value) || $value === null)
1650
-			$value = 0;
1751
+		if (!isset($value) || $value === null) {
1752
+					$value = 0;
1753
+		}
1651 1754
 
1652 1755
 		$themeData[] = array(0, 1, $variable, $value);
1653 1756
 	}
@@ -1676,8 +1779,9 @@  discard block
 block discarded – undo
1676 1779
 
1677 1780
 	foreach ($values as $variable => $value)
1678 1781
 	{
1679
-		if (empty($modSettings[$value[0]]))
1680
-			continue;
1782
+		if (empty($modSettings[$value[0]])) {
1783
+					continue;
1784
+		}
1681 1785
 
1682 1786
 		$smcFunc['db_query']('', '
1683 1787
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1763,19 +1867,21 @@  discard block
 block discarded – undo
1763 1867
 	set_error_handler(
1764 1868
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1765 1869
 		{
1766
-			if ($support_js)
1767
-				return true;
1768
-			else
1769
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1870
+			if ($support_js) {
1871
+							return true;
1872
+			} else {
1873
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1874
+			}
1770 1875
 		}
1771 1876
 	);
1772 1877
 
1773 1878
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1774 1879
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1775
-	if ($db_type == 'mysql')
1776
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1777
-	else
1778
-		$db_collation = '';
1880
+	if ($db_type == 'mysql') {
1881
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1882
+	} else {
1883
+			$db_collation = '';
1884
+	}
1779 1885
 
1780 1886
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1781 1887
 
@@ -1787,8 +1893,9 @@  discard block
 block discarded – undo
1787 1893
 	$last_step = '';
1788 1894
 
1789 1895
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1790
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1791
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1896
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1897
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1898
+	}
1792 1899
 
1793 1900
 	// Count the total number of steps within this file - for progress.
1794 1901
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1808,15 +1915,18 @@  discard block
 block discarded – undo
1808 1915
 		$do_current = $substep >= $_GET['substep'];
1809 1916
 
1810 1917
 		// Get rid of any comments in the beginning of the line...
1811
-		if (substr(trim($line), 0, 2) === '/*')
1812
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1918
+		if (substr(trim($line), 0, 2) === '/*') {
1919
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1920
+		}
1813 1921
 
1814 1922
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1815
-		if ($is_debug && !$support_js && $command_line)
1816
-			flush();
1923
+		if ($is_debug && !$support_js && $command_line) {
1924
+					flush();
1925
+		}
1817 1926
 
1818
-		if (trim($line) === '')
1819
-			continue;
1927
+		if (trim($line) === '') {
1928
+					continue;
1929
+		}
1820 1930
 
1821 1931
 		if (trim(substr($line, 0, 3)) === '---')
1822 1932
 		{
@@ -1826,8 +1936,9 @@  discard block
 block discarded – undo
1826 1936
 			if (trim($current_data) != '' && $type !== '}')
1827 1937
 			{
1828 1938
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1829
-				if ($command_line)
1830
-					echo $upcontext['error_message'];
1939
+				if ($command_line) {
1940
+									echo $upcontext['error_message'];
1941
+				}
1831 1942
 			}
1832 1943
 
1833 1944
 			if ($type == ' ')
@@ -1845,17 +1956,18 @@  discard block
 block discarded – undo
1845 1956
 				if ($do_current)
1846 1957
 				{
1847 1958
 					$upcontext['actioned_items'][] = $last_step;
1848
-					if ($command_line)
1849
-						echo ' * ';
1959
+					if ($command_line) {
1960
+											echo ' * ';
1961
+					}
1850 1962
 				}
1851
-			}
1852
-			elseif ($type == '#')
1963
+			} elseif ($type == '#')
1853 1964
 			{
1854 1965
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1855 1966
 
1856 1967
 				$upcontext['current_debug_item_num']++;
1857
-				if (trim($line) != '---#')
1858
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1968
+				if (trim($line) != '---#') {
1969
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1970
+				}
1859 1971
 
1860 1972
 				// Have we already done something?
1861 1973
 				if (isset($_GET['xml']) && $done_something)
@@ -1866,34 +1978,36 @@  discard block
 block discarded – undo
1866 1978
 
1867 1979
 				if ($do_current)
1868 1980
 				{
1869
-					if (trim($line) == '---#' && $command_line)
1870
-						echo ' done.', $endl;
1871
-					elseif ($command_line)
1872
-						echo ' +++ ', rtrim(substr($line, 4));
1873
-					elseif (trim($line) != '---#')
1981
+					if (trim($line) == '---#' && $command_line) {
1982
+											echo ' done.', $endl;
1983
+					} elseif ($command_line) {
1984
+											echo ' +++ ', rtrim(substr($line, 4));
1985
+					} elseif (trim($line) != '---#')
1874 1986
 					{
1875
-						if ($is_debug)
1876
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1987
+						if ($is_debug) {
1988
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1989
+						}
1877 1990
 					}
1878 1991
 				}
1879 1992
 
1880 1993
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1881 1994
 				{
1882
-					if ($command_line)
1883
-						echo ' * ';
1884
-					else
1885
-						$upcontext['actioned_items'][] = $last_step;
1995
+					if ($command_line) {
1996
+											echo ' * ';
1997
+					} else {
1998
+											$upcontext['actioned_items'][] = $last_step;
1999
+					}
1886 2000
 				}
1887 2001
 
1888 2002
 				// Small step - only if we're actually doing stuff.
1889
-				if ($do_current)
1890
-					nextSubstep(++$substep);
1891
-				else
1892
-					$substep++;
1893
-			}
1894
-			elseif ($type == '{')
1895
-				$current_type = 'code';
1896
-			elseif ($type == '}')
2003
+				if ($do_current) {
2004
+									nextSubstep(++$substep);
2005
+				} else {
2006
+									$substep++;
2007
+				}
2008
+			} elseif ($type == '{') {
2009
+							$current_type = 'code';
2010
+			} elseif ($type == '}')
1897 2011
 			{
1898 2012
 				$current_type = 'sql';
1899 2013
 
@@ -1906,8 +2020,9 @@  discard block
 block discarded – undo
1906 2020
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1907 2021
 				{
1908 2022
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1909
-					if ($command_line)
1910
-						echo $upcontext['error_message'];
2023
+					if ($command_line) {
2024
+											echo $upcontext['error_message'];
2025
+					}
1911 2026
 				}
1912 2027
 
1913 2028
 				// Done with code!
@@ -1995,8 +2110,9 @@  discard block
 block discarded – undo
1995 2110
 	$db_unbuffered = false;
1996 2111
 
1997 2112
 	// Failure?!
1998
-	if ($result !== false)
1999
-		return $result;
2113
+	if ($result !== false) {
2114
+			return $result;
2115
+	}
2000 2116
 
2001 2117
 	$db_error_message = $smcFunc['db_error']($db_connection);
2002 2118
 	// If MySQL we do something more clever.
@@ -2024,54 +2140,61 @@  discard block
 block discarded – undo
2024 2140
 			{
2025 2141
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2026 2142
 				$result = mysqli_query($db_connection, $string);
2027
-				if ($result !== false)
2028
-					return $result;
2143
+				if ($result !== false) {
2144
+									return $result;
2145
+				}
2029 2146
 			}
2030
-		}
2031
-		elseif ($mysqli_errno == 2013)
2147
+		} elseif ($mysqli_errno == 2013)
2032 2148
 		{
2033 2149
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2034 2150
 			mysqli_select_db($db_connection, $db_name);
2035 2151
 			if ($db_connection)
2036 2152
 			{
2037 2153
 				$result = mysqli_query($db_connection, $string);
2038
-				if ($result !== false)
2039
-					return $result;
2154
+				if ($result !== false) {
2155
+									return $result;
2156
+				}
2040 2157
 			}
2041 2158
 		}
2042 2159
 		// Duplicate column name... should be okay ;).
2043
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2044
-			return false;
2160
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2161
+					return false;
2162
+		}
2045 2163
 		// Duplicate insert... make sure it's the proper type of query ;).
2046
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2047
-			return false;
2164
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2165
+					return false;
2166
+		}
2048 2167
 		// Creating an index on a non-existent column.
2049
-		elseif ($mysqli_errno == 1072)
2050
-			return false;
2051
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2052
-			return false;
2168
+		elseif ($mysqli_errno == 1072) {
2169
+					return false;
2170
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2171
+					return false;
2172
+		}
2053 2173
 	}
2054 2174
 	// If a table already exists don't go potty.
2055 2175
 	else
2056 2176
 	{
2057 2177
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2058 2178
 		{
2059
-			if (strpos($db_error_message, 'exist') !== false)
2060
-				return true;
2061
-		}
2062
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2179
+			if (strpos($db_error_message, 'exist') !== false) {
2180
+							return true;
2181
+			}
2182
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2063 2183
 		{
2064
-			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error)
2065
-				return true;
2184
+			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) {
2185
+							return true;
2186
+			}
2066 2187
 		}
2067 2188
 	}
2068 2189
 
2069 2190
 	// Get the query string so we pass everything.
2070 2191
 	$query_string = '';
2071
-	foreach ($_GET as $k => $v)
2072
-		$query_string .= ';' . $k . '=' . $v;
2073
-	if (strlen($query_string) != 0)
2074
-		$query_string = '?' . substr($query_string, 1);
2192
+	foreach ($_GET as $k => $v) {
2193
+			$query_string .= ';' . $k . '=' . $v;
2194
+	}
2195
+	if (strlen($query_string) != 0) {
2196
+			$query_string = '?' . substr($query_string, 1);
2197
+	}
2075 2198
 
2076 2199
 	if ($command_line)
2077 2200
 	{
@@ -2126,16 +2249,18 @@  discard block
 block discarded – undo
2126 2249
 			{
2127 2250
 				$found |= 1;
2128 2251
 				// Do some checks on the data if we have it set.
2129
-				if (isset($change['col_type']))
2130
-					$found &= $change['col_type'] === $column['type'];
2131
-				if (isset($change['null_allowed']))
2132
-					$found &= $column['null'] == $change['null_allowed'];
2133
-				if (isset($change['default']))
2134
-					$found &= $change['default'] === $column['default'];
2252
+				if (isset($change['col_type'])) {
2253
+									$found &= $change['col_type'] === $column['type'];
2254
+				}
2255
+				if (isset($change['null_allowed'])) {
2256
+									$found &= $column['null'] == $change['null_allowed'];
2257
+				}
2258
+				if (isset($change['default'])) {
2259
+									$found &= $change['default'] === $column['default'];
2260
+				}
2135 2261
 			}
2136 2262
 		}
2137
-	}
2138
-	elseif ($change['type'] === 'index')
2263
+	} elseif ($change['type'] === 'index')
2139 2264
 	{
2140 2265
 		$request = upgrade_query('
2141 2266
 			SHOW INDEX
@@ -2144,9 +2269,10 @@  discard block
 block discarded – undo
2144 2269
 		{
2145 2270
 			$cur_index = array();
2146 2271
 
2147
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2148
-				if ($row['Key_name'] === $change['name'])
2272
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2273
+							if ($row['Key_name'] === $change['name'])
2149 2274
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2275
+			}
2150 2276
 
2151 2277
 			ksort($cur_index, SORT_NUMERIC);
2152 2278
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2156,14 +2282,17 @@  discard block
 block discarded – undo
2156 2282
 	}
2157 2283
 
2158 2284
 	// If we're trying to add and it's added, we're done.
2159
-	if ($found && in_array($change['method'], array('add', 'change')))
2160
-		return true;
2285
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2286
+			return true;
2287
+	}
2161 2288
 	// Otherwise if we're removing and it wasn't found we're also done.
2162
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2163
-		return true;
2289
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2290
+			return true;
2291
+	}
2164 2292
 	// Otherwise is it just a test?
2165
-	elseif ($is_test)
2166
-		return false;
2293
+	elseif ($is_test) {
2294
+			return false;
2295
+	}
2167 2296
 
2168 2297
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2169 2298
 	$running = false;
@@ -2174,8 +2303,9 @@  discard block
 block discarded – undo
2174 2303
 			SHOW FULL PROCESSLIST');
2175 2304
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2176 2305
 		{
2177
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2178
-				$found = true;
2306
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2307
+							$found = true;
2308
+			}
2179 2309
 		}
2180 2310
 
2181 2311
 		// Can't find it? Then we need to run it fools!
@@ -2187,8 +2317,9 @@  discard block
 block discarded – undo
2187 2317
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2188 2318
 				' . $change['text'], true) !== false;
2189 2319
 
2190
-			if (!$success)
2191
-				return false;
2320
+			if (!$success) {
2321
+							return false;
2322
+			}
2192 2323
 
2193 2324
 			// Return
2194 2325
 			$running = true;
@@ -2230,8 +2361,9 @@  discard block
 block discarded – undo
2230 2361
 			'db_error_skip' => true,
2231 2362
 		)
2232 2363
 	);
2233
-	if ($smcFunc['db_num_rows']($request) === 0)
2234
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2364
+	if ($smcFunc['db_num_rows']($request) === 0) {
2365
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2366
+	}
2235 2367
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2236 2368
 	$smcFunc['db_free_result']($request);
2237 2369
 
@@ -2253,18 +2385,19 @@  discard block
 block discarded – undo
2253 2385
 			)
2254 2386
 		);
2255 2387
 		// No results? Just forget it all together.
2256
-		if ($smcFunc['db_num_rows']($request) === 0)
2257
-			unset($table_row['Collation']);
2258
-		else
2259
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2388
+		if ($smcFunc['db_num_rows']($request) === 0) {
2389
+					unset($table_row['Collation']);
2390
+		} else {
2391
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2392
+		}
2260 2393
 		$smcFunc['db_free_result']($request);
2261 2394
 	}
2262 2395
 
2263 2396
 	if ($column_fix)
2264 2397
 	{
2265 2398
 		// Make sure there are no NULL's left.
2266
-		if ($null_fix)
2267
-			$smcFunc['db_query']('', '
2399
+		if ($null_fix) {
2400
+					$smcFunc['db_query']('', '
2268 2401
 				UPDATE {db_prefix}' . $change['table'] . '
2269 2402
 				SET ' . $change['column'] . ' = {string:default}
2270 2403
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2273,6 +2406,7 @@  discard block
 block discarded – undo
2273 2406
 					'db_error_skip' => true,
2274 2407
 				)
2275 2408
 			);
2409
+		}
2276 2410
 
2277 2411
 		// Do the actual alteration.
2278 2412
 		$smcFunc['db_query']('', '
@@ -2301,8 +2435,9 @@  discard block
 block discarded – undo
2301 2435
 	}
2302 2436
 
2303 2437
 	// Not a column we need to check on?
2304
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2305
-		return;
2438
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2439
+			return;
2440
+	}
2306 2441
 
2307 2442
 	// Break it up you (six|seven).
2308 2443
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2321,13 +2456,13 @@  discard block
 block discarded – undo
2321 2456
 				'new_name' => $temp[2],
2322 2457
 		));
2323 2458
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2324
-		if ($smcFunc['db_num_rows'] != 1)
2325
-			return;
2459
+		if ($smcFunc['db_num_rows'] != 1) {
2460
+					return;
2461
+		}
2326 2462
 
2327 2463
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2328 2464
 		$smcFunc['db_free_result']($request);
2329
-	}
2330
-	else
2465
+	} else
2331 2466
 	{
2332 2467
 		// Do this the old fashion, sure method way.
2333 2468
 		$request = $smcFunc['db_query']('', '
@@ -2338,21 +2473,24 @@  discard block
 block discarded – undo
2338 2473
 		));
2339 2474
 		// Mayday!
2340 2475
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2341
-		if ($smcFunc['db_num_rows'] == 0)
2342
-			return;
2476
+		if ($smcFunc['db_num_rows'] == 0) {
2477
+					return;
2478
+		}
2343 2479
 
2344 2480
 		// Oh where, oh where has my little field gone. Oh where can it be...
2345
-		while ($row = $smcFunc['db_query']($request))
2346
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2481
+		while ($row = $smcFunc['db_query']($request)) {
2482
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2347 2483
 			{
2348 2484
 				$current_type = $row['Type'];
2485
+		}
2349 2486
 				break;
2350 2487
 			}
2351 2488
 	}
2352 2489
 
2353 2490
 	// If this doesn't match, the column may of been altered for a reason.
2354
-	if (trim($current_type) != trim($temp[3]))
2355
-		$temp[3] = $current_type;
2491
+	if (trim($current_type) != trim($temp[3])) {
2492
+			$temp[3] = $current_type;
2493
+	}
2356 2494
 
2357 2495
 	// Piece this back together.
2358 2496
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2364,8 +2502,9 @@  discard block
 block discarded – undo
2364 2502
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2365 2503
 	global $step_progress, $is_debug, $upcontext;
2366 2504
 
2367
-	if ($_GET['substep'] < $substep)
2368
-		$_GET['substep'] = $substep;
2505
+	if ($_GET['substep'] < $substep) {
2506
+			$_GET['substep'] = $substep;
2507
+	}
2369 2508
 
2370 2509
 	if ($command_line)
2371 2510
 	{
@@ -2378,29 +2517,33 @@  discard block
 block discarded – undo
2378 2517
 	}
2379 2518
 
2380 2519
 	@set_time_limit(300);
2381
-	if (function_exists('apache_reset_timeout'))
2382
-		@apache_reset_timeout();
2520
+	if (function_exists('apache_reset_timeout')) {
2521
+			@apache_reset_timeout();
2522
+	}
2383 2523
 
2384
-	if (time() - $start_time <= $timeLimitThreshold)
2385
-		return;
2524
+	if (time() - $start_time <= $timeLimitThreshold) {
2525
+			return;
2526
+	}
2386 2527
 
2387 2528
 	// Do we have some custom step progress stuff?
2388 2529
 	if (!empty($step_progress))
2389 2530
 	{
2390 2531
 		$upcontext['substep_progress'] = 0;
2391 2532
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2392
-		if ($step_progress['current'] > $step_progress['total'])
2393
-			$upcontext['substep_progress'] = 99.9;
2394
-		else
2395
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2533
+		if ($step_progress['current'] > $step_progress['total']) {
2534
+					$upcontext['substep_progress'] = 99.9;
2535
+		} else {
2536
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2537
+		}
2396 2538
 
2397 2539
 		// Make it nicely rounded.
2398 2540
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2399 2541
 	}
2400 2542
 
2401 2543
 	// If this is XML we just exit right away!
2402
-	if (isset($_GET['xml']))
2403
-		return upgradeExit();
2544
+	if (isset($_GET['xml'])) {
2545
+			return upgradeExit();
2546
+	}
2404 2547
 
2405 2548
 	// We're going to pause after this!
2406 2549
 	$upcontext['pause'] = true;
@@ -2408,13 +2551,15 @@  discard block
 block discarded – undo
2408 2551
 	$upcontext['query_string'] = '';
2409 2552
 	foreach ($_GET as $k => $v)
2410 2553
 	{
2411
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2412
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2554
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2555
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2556
+		}
2413 2557
 	}
2414 2558
 
2415 2559
 	// Custom warning?
2416
-	if (!empty($custom_warning))
2417
-		$upcontext['custom_warning'] = $custom_warning;
2560
+	if (!empty($custom_warning)) {
2561
+			$upcontext['custom_warning'] = $custom_warning;
2562
+	}
2418 2563
 
2419 2564
 	upgradeExit();
2420 2565
 }
@@ -2429,25 +2574,26 @@  discard block
 block discarded – undo
2429 2574
 	ob_implicit_flush(true);
2430 2575
 	@set_time_limit(600);
2431 2576
 
2432
-	if (!isset($_SERVER['argv']))
2433
-		$_SERVER['argv'] = array();
2577
+	if (!isset($_SERVER['argv'])) {
2578
+			$_SERVER['argv'] = array();
2579
+	}
2434 2580
 	$_GET['maint'] = 1;
2435 2581
 
2436 2582
 	foreach ($_SERVER['argv'] as $i => $arg)
2437 2583
 	{
2438
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2439
-			$_GET['lang'] = $match[1];
2440
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2441
-			continue;
2442
-		elseif ($arg == '--no-maintenance')
2443
-			$_GET['maint'] = 0;
2444
-		elseif ($arg == '--debug')
2445
-			$is_debug = true;
2446
-		elseif ($arg == '--backup')
2447
-			$_POST['backup'] = 1;
2448
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2449
-			$_GET['conv'] = 1;
2450
-		elseif ($i != 0)
2584
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2585
+					$_GET['lang'] = $match[1];
2586
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2587
+					continue;
2588
+		} elseif ($arg == '--no-maintenance') {
2589
+					$_GET['maint'] = 0;
2590
+		} elseif ($arg == '--debug') {
2591
+					$is_debug = true;
2592
+		} elseif ($arg == '--backup') {
2593
+					$_POST['backup'] = 1;
2594
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2595
+					$_GET['conv'] = 1;
2596
+		} elseif ($i != 0)
2451 2597
 		{
2452 2598
 			echo 'SMF Command-line Upgrader
2453 2599
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2461,10 +2607,12 @@  discard block
 block discarded – undo
2461 2607
 		}
2462 2608
 	}
2463 2609
 
2464
-	if (!php_version_check())
2465
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2466
-	if (!db_version_check())
2467
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2610
+	if (!php_version_check()) {
2611
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2612
+	}
2613
+	if (!db_version_check()) {
2614
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2615
+	}
2468 2616
 
2469 2617
 	// Do some checks to make sure they have proper privileges
2470 2618
 	db_extend('packages');
@@ -2479,34 +2627,39 @@  discard block
 block discarded – undo
2479 2627
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2480 2628
 
2481 2629
 	// Sorry... we need CREATE, ALTER and DROP
2482
-	if (!$create || !$alter || !$drop)
2483
-		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);
2630
+	if (!$create || !$alter || !$drop) {
2631
+			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);
2632
+	}
2484 2633
 
2485 2634
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2486 2635
 		&& @file_exists($sourcedir . '/QueryString.php')
2487 2636
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2488
-	if (!$check && !isset($modSettings['smfVersion']))
2489
-		print_error('Error: Some files are missing or out-of-date.', true);
2637
+	if (!$check && !isset($modSettings['smfVersion'])) {
2638
+			print_error('Error: Some files are missing or out-of-date.', true);
2639
+	}
2490 2640
 
2491 2641
 	// Do a quick version spot check.
2492 2642
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2493 2643
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2494
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2495
-		print_error('Error: Some files have not yet been updated properly.');
2644
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2645
+			print_error('Error: Some files have not yet been updated properly.');
2646
+	}
2496 2647
 
2497 2648
 	// Make sure Settings.php is writable.
2498 2649
 	quickFileWritable($boarddir . '/Settings.php');
2499
-	if (!is_writable($boarddir . '/Settings.php'))
2500
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2650
+	if (!is_writable($boarddir . '/Settings.php')) {
2651
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2652
+	}
2501 2653
 
2502 2654
 	// Make sure Settings_bak.php is writable.
2503 2655
 	quickFileWritable($boarddir . '/Settings_bak.php');
2504
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2505
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2656
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2657
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2658
+	}
2506 2659
 
2507
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2508
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2509
-	elseif (isset($modSettings['agreement']))
2660
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2661
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2662
+	} elseif (isset($modSettings['agreement']))
2510 2663
 	{
2511 2664
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2512 2665
 		fwrite($fp, $modSettings['agreement']);
@@ -2516,36 +2669,42 @@  discard block
 block discarded – undo
2516 2669
 	// Make sure Themes is writable.
2517 2670
 	quickFileWritable($modSettings['theme_dir']);
2518 2671
 
2519
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2520
-		print_error('Error: Unable to obtain write access to "Themes".');
2672
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2673
+			print_error('Error: Unable to obtain write access to "Themes".');
2674
+	}
2521 2675
 
2522 2676
 	// Make sure cache directory exists and is writable!
2523 2677
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2524
-	if (!file_exists($cachedir_temp))
2525
-		@mkdir($cachedir_temp);
2678
+	if (!file_exists($cachedir_temp)) {
2679
+			@mkdir($cachedir_temp);
2680
+	}
2526 2681
 
2527 2682
 	// Make sure the cache temp dir is writable.
2528 2683
 	quickFileWritable($cachedir_temp);
2529 2684
 
2530
-	if (!is_writable($cachedir_temp))
2531
-		print_error('Error: Unable to obtain write access to "cache".', true);
2685
+	if (!is_writable($cachedir_temp)) {
2686
+			print_error('Error: Unable to obtain write access to "cache".', true);
2687
+	}
2532 2688
 
2533 2689
 	// Make sure db_last_error.php is writable.
2534 2690
 	quickFileWritable($cachedir_temp . '/db_last_error.php');
2535
-	if (!is_writable($cachedir_temp . '/db_last_error.php'))
2536
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2691
+	if (!is_writable($cachedir_temp . '/db_last_error.php')) {
2692
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2693
+	}
2537 2694
 
2538
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2539
-		print_error('Error: Unable to find language files!', true);
2540
-	else
2695
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2696
+			print_error('Error: Unable to find language files!', true);
2697
+	} else
2541 2698
 	{
2542 2699
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2543 2700
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2544 2701
 
2545
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2546
-			print_error('Error: Language files out of date.', true);
2547
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2548
-			print_error('Error: Install language is missing for selected language.', true);
2702
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2703
+					print_error('Error: Language files out of date.', true);
2704
+		}
2705
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2706
+					print_error('Error: Install language is missing for selected language.', true);
2707
+		}
2549 2708
 
2550 2709
 		// Otherwise include it!
2551 2710
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2565,8 +2724,9 @@  discard block
 block discarded – undo
2565 2724
 	global $db_prefix, $db_type, $command_line, $support_js, $txt;
2566 2725
 
2567 2726
 	// Done it already?
2568
-	if (!empty($_POST['utf8_done']))
2569
-		return true;
2727
+	if (!empty($_POST['utf8_done'])) {
2728
+			return true;
2729
+	}
2570 2730
 
2571 2731
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2572 2732
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2579,8 +2739,7 @@  discard block
 block discarded – undo
2579 2739
 		);
2580 2740
 
2581 2741
 		return true;
2582
-	}
2583
-	else
2742
+	} else
2584 2743
 	{
2585 2744
 		$upcontext['page_title'] = $txt['converting_utf8'];
2586 2745
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2624,8 +2783,9 @@  discard block
 block discarded – undo
2624 2783
 			)
2625 2784
 		);
2626 2785
 		$db_charsets = array();
2627
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2628
-			$db_charsets[] = $row['Charset'];
2786
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2787
+					$db_charsets[] = $row['Charset'];
2788
+		}
2629 2789
 
2630 2790
 		$smcFunc['db_free_result']($request);
2631 2791
 
@@ -2661,13 +2821,15 @@  discard block
 block discarded – undo
2661 2821
 		// If there's a fulltext index, we need to drop it first...
2662 2822
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2663 2823
 		{
2664
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2665
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2824
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2825
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2666 2826
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2827
+			}
2667 2828
 			$smcFunc['db_free_result']($request);
2668 2829
 
2669
-			if (isset($upcontext['fulltext_index']))
2670
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2830
+			if (isset($upcontext['fulltext_index'])) {
2831
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2832
+			}
2671 2833
 		}
2672 2834
 
2673 2835
 		// Drop it and make a note...
@@ -2857,8 +3019,9 @@  discard block
 block discarded – undo
2857 3019
 			$replace = '%field%';
2858 3020
 
2859 3021
 			// Build a huge REPLACE statement...
2860
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2861
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3022
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3023
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3024
+			}
2862 3025
 		}
2863 3026
 
2864 3027
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2868,9 +3031,10 @@  discard block
 block discarded – undo
2868 3031
 		$upcontext['table_count'] = count($queryTables);
2869 3032
 
2870 3033
 		// What ones have we already done?
2871
-		foreach ($queryTables as $id => $table)
2872
-			if ($id < $_GET['substep'])
3034
+		foreach ($queryTables as $id => $table) {
3035
+					if ($id < $_GET['substep'])
2873 3036
 				$upcontext['previous_tables'][] = $table;
3037
+		}
2874 3038
 
2875 3039
 		$upcontext['cur_table_num'] = $_GET['substep'];
2876 3040
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2907,8 +3071,9 @@  discard block
 block discarded – undo
2907 3071
 			nextSubstep($substep);
2908 3072
 
2909 3073
 			// Just to make sure it doesn't time out.
2910
-			if (function_exists('apache_reset_timeout'))
2911
-				@apache_reset_timeout();
3074
+			if (function_exists('apache_reset_timeout')) {
3075
+							@apache_reset_timeout();
3076
+			}
2912 3077
 
2913 3078
 			$table_charsets = array();
2914 3079
 
@@ -2931,8 +3096,9 @@  discard block
 block discarded – undo
2931 3096
 
2932 3097
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2933 3098
 						if ($charset != 'utf8') {
2934
-							if (!isset($table_charsets[$charset]))
2935
-								$table_charsets[$charset] = array();
3099
+							if (!isset($table_charsets[$charset])) {
3100
+															$table_charsets[$charset] = array();
3101
+							}
2936 3102
 
2937 3103
 							$table_charsets[$charset][] = $column_info;
2938 3104
 						}
@@ -2973,10 +3139,11 @@  discard block
 block discarded – undo
2973 3139
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2974 3140
 				{
2975 3141
 					$update = '';
2976
-					foreach ($table_charsets as $charset => $columns)
2977
-						foreach ($columns as $column)
3142
+					foreach ($table_charsets as $charset => $columns) {
3143
+											foreach ($columns as $column)
2978 3144
 							$update .= '
2979 3145
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3146
+					}
2980 3147
 
2981 3148
 					$smcFunc['db_query']('', '
2982 3149
 						UPDATE {raw:table_name}
@@ -3001,8 +3168,9 @@  discard block
 block discarded – undo
3001 3168
 			// Now do the actual conversion (if still needed).
3002 3169
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3003 3170
 			{
3004
-				if ($command_line)
3005
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3171
+				if ($command_line) {
3172
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3173
+				}
3006 3174
 
3007 3175
 				$smcFunc['db_query']('', '
3008 3176
 					ALTER TABLE {raw:table_name}
@@ -3012,12 +3180,14 @@  discard block
 block discarded – undo
3012 3180
 					)
3013 3181
 				);
3014 3182
 
3015
-				if ($command_line)
3016
-					echo " done.\n";
3183
+				if ($command_line) {
3184
+									echo " done.\n";
3185
+				}
3017 3186
 			}
3018 3187
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3019
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
3020
-				return upgradeExit();
3188
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3189
+							return upgradeExit();
3190
+			}
3021 3191
 		}
3022 3192
 
3023 3193
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -3046,8 +3216,8 @@  discard block
 block discarded – undo
3046 3216
 		);
3047 3217
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3048 3218
 		{
3049
-			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)
3050
-				$smcFunc['db_query']('', '
3219
+			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) {
3220
+							$smcFunc['db_query']('', '
3051 3221
 					UPDATE {db_prefix}log_actions
3052 3222
 					SET extra = {string:extra}
3053 3223
 					WHERE id_action = {int:current_action}',
@@ -3056,6 +3226,7 @@  discard block
 block discarded – undo
3056 3226
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3057 3227
 					)
3058 3228
 				);
3229
+			}
3059 3230
 		}
3060 3231
 		$smcFunc['db_free_result']($request);
3061 3232
 
@@ -3077,15 +3248,17 @@  discard block
 block discarded – undo
3077 3248
 	// First thing's first - did we already do this?
3078 3249
 	if (!empty($modSettings['json_done']))
3079 3250
 	{
3080
-		if ($command_line)
3081
-			return DeleteUpgrade();
3082
-		else
3083
-			return true;
3251
+		if ($command_line) {
3252
+					return DeleteUpgrade();
3253
+		} else {
3254
+					return true;
3255
+		}
3084 3256
 	}
3085 3257
 
3086 3258
 	// Done it already - js wise?
3087
-	if (!empty($_POST['json_done']))
3088
-		return true;
3259
+	if (!empty($_POST['json_done'])) {
3260
+			return true;
3261
+	}
3089 3262
 
3090 3263
 	// List of tables affected by this function
3091 3264
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3117,12 +3290,14 @@  discard block
 block discarded – undo
3117 3290
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3118 3291
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3119 3292
 
3120
-	foreach ($keys as $id => $table)
3121
-		if ($id < $_GET['substep'])
3293
+	foreach ($keys as $id => $table) {
3294
+			if ($id < $_GET['substep'])
3122 3295
 			$upcontext['previous_tables'][] = $table;
3296
+	}
3123 3297
 
3124
-	if ($command_line)
3125
-		echo 'Converting data from serialize() to json_encode().';
3298
+	if ($command_line) {
3299
+			echo 'Converting data from serialize() to json_encode().';
3300
+	}
3126 3301
 
3127 3302
 	if (!$support_js || isset($_GET['xml']))
3128 3303
 	{
@@ -3162,8 +3337,9 @@  discard block
 block discarded – undo
3162 3337
 
3163 3338
 				// Loop through and fix these...
3164 3339
 				$new_settings = array();
3165
-				if ($command_line)
3166
-					echo "\n" . 'Fixing some settings...';
3340
+				if ($command_line) {
3341
+									echo "\n" . 'Fixing some settings...';
3342
+				}
3167 3343
 
3168 3344
 				foreach ($serialized_settings as $var)
3169 3345
 				{
@@ -3171,22 +3347,24 @@  discard block
 block discarded – undo
3171 3347
 					{
3172 3348
 						// Attempt to unserialize the setting
3173 3349
 						$temp = @safe_unserialize($modSettings[$var]);
3174
-						if (!$temp && $command_line)
3175
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3176
-						elseif ($temp !== false)
3177
-							$new_settings[$var] = json_encode($temp);
3350
+						if (!$temp && $command_line) {
3351
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3352
+						} elseif ($temp !== false) {
3353
+													$new_settings[$var] = json_encode($temp);
3354
+						}
3178 3355
 					}
3179 3356
 				}
3180 3357
 
3181 3358
 				// Update everything at once
3182
-				if (!function_exists('cache_put_data'))
3183
-					require_once($sourcedir . '/Load.php');
3359
+				if (!function_exists('cache_put_data')) {
3360
+									require_once($sourcedir . '/Load.php');
3361
+				}
3184 3362
 				updateSettings($new_settings, true);
3185 3363
 
3186
-				if ($command_line)
3187
-					echo ' done.';
3188
-			}
3189
-			elseif ($table == 'themes')
3364
+				if ($command_line) {
3365
+									echo ' done.';
3366
+				}
3367
+			} elseif ($table == 'themes')
3190 3368
 			{
3191 3369
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3192 3370
 				$query = $smcFunc['db_query']('', '
@@ -3205,10 +3383,11 @@  discard block
 block discarded – undo
3205 3383
 
3206 3384
 						if ($command_line)
3207 3385
 						{
3208
-							if ($temp === false)
3209
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3210
-							else
3211
-								echo "\n" . 'Fixing admin preferences...';
3386
+							if ($temp === false) {
3387
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3388
+							} else {
3389
+															echo "\n" . 'Fixing admin preferences...';
3390
+							}
3212 3391
 						}
3213 3392
 
3214 3393
 						if ($temp !== false)
@@ -3230,15 +3409,15 @@  discard block
 block discarded – undo
3230 3409
 								)
3231 3410
 							);
3232 3411
 
3233
-							if ($command_line)
3234
-								echo ' done.';
3412
+							if ($command_line) {
3413
+															echo ' done.';
3414
+							}
3235 3415
 						}
3236 3416
 					}
3237 3417
 
3238 3418
 					$smcFunc['db_free_result']($query);
3239 3419
 				}
3240
-			}
3241
-			else
3420
+			} else
3242 3421
 			{
3243 3422
 				// First item is always the key...
3244 3423
 				$key = $info[0];
@@ -3249,8 +3428,7 @@  discard block
 block discarded – undo
3249 3428
 				{
3250 3429
 					$col_select = $info[1];
3251 3430
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3252
-				}
3253
-				else
3431
+				} else
3254 3432
 				{
3255 3433
 					$col_select = implode(', ', $info);
3256 3434
 				}
@@ -3283,8 +3461,7 @@  discard block
 block discarded – undo
3283 3461
 								if ($temp === false && $command_line)
3284 3462
 								{
3285 3463
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3286
-								}
3287
-								else
3464
+								} else
3288 3465
 								{
3289 3466
 									$row[$col] = json_encode($temp);
3290 3467
 
@@ -3309,16 +3486,18 @@  discard block
 block discarded – undo
3309 3486
 						}
3310 3487
 					}
3311 3488
 
3312
-					if ($command_line)
3313
-						echo ' done.';
3489
+					if ($command_line) {
3490
+											echo ' done.';
3491
+					}
3314 3492
 
3315 3493
 					// Free up some memory...
3316 3494
 					$smcFunc['db_free_result']($query);
3317 3495
 				}
3318 3496
 			}
3319 3497
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3320
-			if (isset($_GET['xml']))
3321
-				return upgradeExit();
3498
+			if (isset($_GET['xml'])) {
3499
+							return upgradeExit();
3500
+			}
3322 3501
 		}
3323 3502
 
3324 3503
 		if ($command_line)
@@ -3333,8 +3512,9 @@  discard block
 block discarded – undo
3333 3512
 
3334 3513
 		$_GET['substep'] = 0;
3335 3514
 		// Make sure we move on!
3336
-		if ($command_line)
3337
-			return DeleteUpgrade();
3515
+		if ($command_line) {
3516
+					return DeleteUpgrade();
3517
+		}
3338 3518
 
3339 3519
 		return true;
3340 3520
 	}
@@ -3391,14 +3571,16 @@  discard block
 block discarded – undo
3391 3571
 	global $upcontext, $txt, $settings;
3392 3572
 
3393 3573
 	// Don't call me twice!
3394
-	if (!empty($upcontext['chmod_called']))
3395
-		return;
3574
+	if (!empty($upcontext['chmod_called'])) {
3575
+			return;
3576
+	}
3396 3577
 
3397 3578
 	$upcontext['chmod_called'] = true;
3398 3579
 
3399 3580
 	// Nothing?
3400
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3401
-		return;
3581
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3582
+			return;
3583
+	}
3402 3584
 
3403 3585
 	// Was it a problem with Windows?
3404 3586
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3430,11 +3612,12 @@  discard block
 block discarded – undo
3430 3612
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\');
3431 3613
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3432 3614
 
3433
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3434
-		echo '
3615
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3616
+			echo '
3435 3617
 					content.write(\'<hr>\n\t\t\t\');
3436 3618
 					content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\');
3437 3619
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3620
+	}
3438 3621
 
3439 3622
 	echo '
3440 3623
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3442,16 +3625,18 @@  discard block
 block discarded – undo
3442 3625
 				}
3443 3626
 			</script>';
3444 3627
 
3445
-	if (!empty($upcontext['chmod']['ftp_error']))
3446
-		echo '
3628
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3629
+			echo '
3447 3630
 			<div class="error_message red">
3448 3631
 				<p>', $txt['upgrade_ftp_error'], '<p>
3449 3632
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3450 3633
 			</div>';
3634
+	}
3451 3635
 
3452
-	if (empty($upcontext['chmod_in_form']))
3453
-		echo '
3636
+	if (empty($upcontext['chmod_in_form'])) {
3637
+			echo '
3454 3638
 			<form action="', $upcontext['form_url'], '" method="post">';
3639
+	}
3455 3640
 
3456 3641
 	echo '
3457 3642
 				<dl class="settings">
@@ -3493,9 +3678,10 @@  discard block
 block discarded – undo
3493 3678
 					<input type="submit" value="', $txt['ftp_connect'], '" class="button">
3494 3679
 				</div>';
3495 3680
 
3496
-	if (empty($upcontext['chmod_in_form']))
3497
-		echo '
3681
+	if (empty($upcontext['chmod_in_form'])) {
3682
+			echo '
3498 3683
 			</form>';
3684
+	}
3499 3685
 
3500 3686
 	echo '
3501 3687
 		</div><!-- .panel -->';
@@ -3559,9 +3745,10 @@  discard block
 block discarded – undo
3559 3745
 					<h2>', $txt['upgrade_progress'], '</h2>
3560 3746
 					<ul>';
3561 3747
 
3562
-	foreach ($upcontext['steps'] as $num => $step)
3563
-		echo '
3748
+	foreach ($upcontext['steps'] as $num => $step) {
3749
+			echo '
3564 3750
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3751
+	}
3565 3752
 
3566 3753
 	echo '
3567 3754
 					</ul>
@@ -3574,13 +3761,14 @@  discard block
 block discarded – undo
3574 3761
 						<span id="overall_text">', $upcontext['overall_percent'], '%</span>
3575 3762
 					</div>';
3576 3763
 
3577
-	if (isset($upcontext['step_progress']))
3578
-		echo '
3764
+	if (isset($upcontext['step_progress'])) {
3765
+			echo '
3579 3766
 					<div id="progress_bar_step" class="progress_bar progress_yellow">
3580 3767
 						<h3>', $txt['upgrade_step_progress'], '</h3>
3581 3768
 						<div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div>
3582 3769
 						<span id="step_text">', $upcontext['step_progress'], '%</span>
3583 3770
 					</div>';
3771
+	}
3584 3772
 
3585 3773
 	echo '
3586 3774
 					<h3>', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', '</h3>
@@ -3611,31 +3799,35 @@  discard block
 block discarded – undo
3611 3799
 {
3612 3800
 	global $upcontext, $txt;
3613 3801
 
3614
-	if (!empty($upcontext['pause']))
3615
-		echo '
3802
+	if (!empty($upcontext['pause'])) {
3803
+			echo '
3616 3804
 					<em>', $txt['upgrade_incomplete'], '.</em><br>
3617 3805
 
3618 3806
 					<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3619 3807
 					<h3>
3620 3808
 						', $txt['upgrade_paused_overload'], '
3621 3809
 					</h3>';
3810
+	}
3622 3811
 
3623
-	if (!empty($upcontext['custom_warning']))
3624
-		echo '
3812
+	if (!empty($upcontext['custom_warning'])) {
3813
+			echo '
3625 3814
 					<div class="errorbox">
3626 3815
 						<h3>', $txt['upgrade_note'], '</h3>
3627 3816
 						', $upcontext['custom_warning'], '
3628 3817
 					</div>';
3818
+	}
3629 3819
 
3630 3820
 	echo '
3631 3821
 					<div class="righttext" style="margin: 1ex;">';
3632 3822
 
3633
-	if (!empty($upcontext['continue']))
3634
-		echo '
3823
+	if (!empty($upcontext['continue'])) {
3824
+			echo '
3635 3825
 						<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3636
-	if (!empty($upcontext['skip']))
3637
-		echo '
3826
+	}
3827
+	if (!empty($upcontext['skip'])) {
3828
+			echo '
3638 3829
 						<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3830
+	}
3639 3831
 
3640 3832
 	echo '
3641 3833
 					</div>
@@ -3686,11 +3878,12 @@  discard block
 block discarded – undo
3686 3878
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3687 3879
 	<smf>';
3688 3880
 
3689
-	if (!empty($upcontext['get_data']))
3690
-		foreach ($upcontext['get_data'] as $k => $v)
3881
+	if (!empty($upcontext['get_data'])) {
3882
+			foreach ($upcontext['get_data'] as $k => $v)
3691 3883
 			echo '
3692 3884
 		<get key="', $k, '">', $v, '</get>';
3693
-}
3885
+	}
3886
+	}
3694 3887
 
3695 3888
 function template_xml_below()
3696 3889
 {
@@ -3730,20 +3923,22 @@  discard block
 block discarded – undo
3730 3923
 	template_chmod();
3731 3924
 
3732 3925
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3733
-	if ($upcontext['is_large_forum'])
3734
-		echo '
3926
+	if ($upcontext['is_large_forum']) {
3927
+			echo '
3735 3928
 					<div class="errorbox">
3736 3929
 						<h3>', $txt['upgrade_warning'], '</h3>
3737 3930
 						', $txt['upgrade_warning_lots_data'], '
3738 3931
 					</div>';
3932
+	}
3739 3933
 
3740 3934
 	// A warning message?
3741
-	if (!empty($upcontext['warning']))
3742
-		echo '
3935
+	if (!empty($upcontext['warning'])) {
3936
+			echo '
3743 3937
 					<div class="errorbox">
3744 3938
 						<h3>', $txt['upgrade_warning'], '</h3>
3745 3939
 						', $upcontext['warning'], '
3746 3940
 					</div>';
3941
+	}
3747 3942
 
3748 3943
 	// Paths are incorrect?
3749 3944
 	echo '
@@ -3756,35 +3951,39 @@  discard block
 block discarded – undo
3756 3951
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3757 3952
 	{
3758 3953
 		$ago = time() - $upcontext['started'];
3759
-		if ($ago < 60)
3760
-			$ago = $ago . ' seconds';
3761
-		elseif ($ago < 3600)
3762
-			$ago = (int) ($ago / 60) . ' minutes';
3763
-		else
3764
-			$ago = (int) ($ago / 3600) . ' hours';
3954
+		if ($ago < 60) {
3955
+					$ago = $ago . ' seconds';
3956
+		} elseif ($ago < 3600) {
3957
+					$ago = (int) ($ago / 60) . ' minutes';
3958
+		} else {
3959
+					$ago = (int) ($ago / 3600) . ' hours';
3960
+		}
3765 3961
 
3766 3962
 		$active = time() - $upcontext['updated'];
3767
-		if ($active < 60)
3768
-			$updated = $active . ' seconds';
3769
-		elseif ($active < 3600)
3770
-			$updated = (int) ($active / 60) . ' minutes';
3771
-		else
3772
-			$updated = (int) ($active / 3600) . ' hours';
3963
+		if ($active < 60) {
3964
+					$updated = $active . ' seconds';
3965
+		} elseif ($active < 3600) {
3966
+					$updated = (int) ($active / 60) . ' minutes';
3967
+		} else {
3968
+					$updated = (int) ($active / 3600) . ' hours';
3969
+		}
3773 3970
 
3774 3971
 		echo '
3775 3972
 					<div class="errorbox">
3776 3973
 						<h3>', $txt['upgrade_warning'], '</h3>
3777 3974
 						<p>', sprintf($txt['upgrade_time'], $upcontext['user']['name'], $ago, $updated), '</p>';
3778
-		if ($active < 600)
3779
-			echo '
3975
+		if ($active < 600) {
3976
+					echo '
3780 3977
 						<p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>';
3978
+		}
3781 3979
 
3782
-		if ($active > $upcontext['inactive_timeout'])
3783
-			echo '
3980
+		if ($active > $upcontext['inactive_timeout']) {
3981
+					echo '
3784 3982
 						<p>',$txt['upgrade_run'], '</p>';
3785
-		else
3786
-			echo '
3983
+		} else {
3984
+					echo '
3787 3985
 						<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>';
3986
+		}
3788 3987
 
3789 3988
 		echo '
3790 3989
 					</div>';
@@ -3800,9 +3999,10 @@  discard block
 block discarded – undo
3800 3999
 						<dd>
3801 4000
 							<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3802 4001
 
3803
-	if (!empty($upcontext['username_incorrect']))
3804
-		echo '
4002
+	if (!empty($upcontext['username_incorrect'])) {
4003
+			echo '
3805 4004
 							<div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>';
4005
+	}
3806 4006
 
3807 4007
 	echo '
3808 4008
 						</dd>
@@ -3813,9 +4013,10 @@  discard block
 block discarded – undo
3813 4013
 							<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3814 4014
 							<input type="hidden" name="hash_passwrd" value="">';
3815 4015
 
3816
-	if (!empty($upcontext['password_failed']))
3817
-		echo '
4016
+	if (!empty($upcontext['password_failed'])) {
4017
+			echo '
3818 4018
 							<div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>';
4019
+	}
3819 4020
 
3820 4021
 	echo '
3821 4022
 						</dd>';
@@ -3883,12 +4084,13 @@  discard block
 block discarded – undo
3883 4084
 				<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3884 4085
 
3885 4086
 	// Warning message?
3886
-	if (!empty($upcontext['upgrade_options_warning']))
3887
-		echo '
4087
+	if (!empty($upcontext['upgrade_options_warning'])) {
4088
+			echo '
3888 4089
 				<div class="errorbox">
3889 4090
 					<h3>', $txt['upgrade_warning'] ,'</h3>
3890 4091
 					', $upcontext['upgrade_options_warning'], '
3891 4092
 				</div>';
4093
+	}
3892 4094
 
3893 4095
 	echo '
3894 4096
 				<ul class="upgrade_settings">
@@ -3917,12 +4119,13 @@  discard block
 block discarded – undo
3917 4119
 						<label for="empty_error">', $txt['upgrade_empty_errlog'], '</label>
3918 4120
 					</li>';
3919 4121
 
3920
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3921
-		echo '
4122
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4123
+			echo '
3922 4124
 					<li>
3923 4125
 						<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
3924 4126
 						<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
3925 4127
 					</li>';
4128
+	}
3926 4129
 
3927 4130
 	echo '
3928 4131
 					<li>
@@ -3956,10 +4159,11 @@  discard block
 block discarded – undo
3956 4159
 					</div>';
3957 4160
 
3958 4161
 	// Dont any tables so far?
3959
-	if (!empty($upcontext['previous_tables']))
3960
-		foreach ($upcontext['previous_tables'] as $table)
4162
+	if (!empty($upcontext['previous_tables'])) {
4163
+			foreach ($upcontext['previous_tables'] as $table)
3961 4164
 			echo '
3962 4165
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4166
+	}
3963 4167
 
3964 4168
 	echo '
3965 4169
 					<h3 id="current_tab">
@@ -3998,12 +4202,13 @@  discard block
 block discarded – undo
3998 4202
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3999 4203
 
4000 4204
 		// If debug flood the screen.
4001
-		if ($is_debug)
4002
-			echo '
4205
+		if ($is_debug) {
4206
+					echo '
4003 4207
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4004 4208
 
4005 4209
 							if (document.getElementById(\'debug_section\').scrollHeight)
4006 4210
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4211
+		}
4007 4212
 
4008 4213
 		echo '
4009 4214
 							// Get the next update...
@@ -4036,8 +4241,9 @@  discard block
 block discarded – undo
4036 4241
 {
4037 4242
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt;
4038 4243
 
4039
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4040
-		$is_debug = true;
4244
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4245
+			$is_debug = true;
4246
+	}
4041 4247
 
4042 4248
 	echo '
4043 4249
 				<h3>', $txt['upgrade_db_changes'], '</h3>
@@ -4052,8 +4258,9 @@  discard block
 block discarded – undo
4052 4258
 	{
4053 4259
 		foreach ($upcontext['actioned_items'] as $num => $item)
4054 4260
 		{
4055
-			if ($num != 0)
4056
-				echo ' Successful!';
4261
+			if ($num != 0) {
4262
+							echo ' Successful!';
4263
+			}
4057 4264
 			echo '<br>' . $item;
4058 4265
 		}
4059 4266
 		if (!empty($upcontext['changes_complete']))
@@ -4066,29 +4273,33 @@  discard block
 block discarded – undo
4066 4273
 				$seconds = intval($active % 60);
4067 4274
 
4068 4275
 				$totalTime = '';
4069
-				if ($hours > 0)
4070
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4071
-				if ($minutes > 0)
4072
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4073
-				if ($seconds > 0)
4074
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4276
+				if ($hours > 0) {
4277
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4278
+				}
4279
+				if ($minutes > 0) {
4280
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4281
+				}
4282
+				if ($seconds > 0) {
4283
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4284
+				}
4075 4285
 			}
4076 4286
 
4077
-			if ($is_debug && !empty($totalTime))
4078
-				echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>';
4079
-			else
4080
-				echo '', $txt['upgrade_success'], '<br>';
4287
+			if ($is_debug && !empty($totalTime)) {
4288
+							echo '', sprintf($txt['upgrade_success_time'], $totalTime), '<br>';
4289
+			} else {
4290
+							echo '', $txt['upgrade_success'], '<br>';
4291
+			}
4081 4292
 
4082 4293
 			echo '
4083 4294
 					<p id="commess">', $txt['upgrade_db_complete'], '</p>';
4084 4295
 		}
4085
-	}
4086
-	else
4296
+	} else
4087 4297
 	{
4088 4298
 		// Tell them how many files we have in total.
4089
-		if ($upcontext['file_count'] > 1)
4090
-			echo '
4299
+		if ($upcontext['file_count'] > 1) {
4300
+					echo '
4091 4301
 					<strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4302
+		}
4092 4303
 
4093 4304
 		echo '
4094 4305
 					<h3 id="info2">
@@ -4106,19 +4317,23 @@  discard block
 block discarded – undo
4106 4317
 				$seconds = intval($active % 60);
4107 4318
 
4108 4319
 				$totalTime = '';
4109
-				if ($hours > 0)
4110
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4111
-				if ($minutes > 0)
4112
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4113
-				if ($seconds > 0)
4114
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4320
+				if ($hours > 0) {
4321
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4322
+				}
4323
+				if ($minutes > 0) {
4324
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4325
+				}
4326
+				if ($seconds > 0) {
4327
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4328
+				}
4115 4329
 			}
4116 4330
 
4117 4331
 			echo '
4118 4332
 					<p id="upgradeCompleted">';
4119 4333
 
4120
-			if (!empty($totalTime))
4121
-				echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), '';
4334
+			if (!empty($totalTime)) {
4335
+							echo '', sprintf($txt['upgrade_completed_time2'], $totalTime), '';
4336
+			}
4122 4337
 
4123 4338
 			echo '
4124 4339
 					</p>
@@ -4155,9 +4370,10 @@  discard block
 block discarded – undo
4155 4370
 						var getData = "";
4156 4371
 						var debugItems = ', $upcontext['debug_items'], ';';
4157 4372
 
4158
-		if ($is_debug)
4159
-			echo '
4373
+		if ($is_debug) {
4374
+					echo '
4160 4375
 						var upgradeStartTime = ' . $upcontext['started'] . ';';
4376
+		}
4161 4377
 
4162 4378
 		echo '
4163 4379
 						function getNextItem()
@@ -4197,9 +4413,10 @@  discard block
 block discarded – undo
4197 4413
 									document.getElementById("error_block").style.display = "";
4198 4414
 									setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4199 4415
 
4200
-	if ($is_debug)
4201
-		echo '
4416
+	if ($is_debug) {
4417
+			echo '
4202 4418
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4419
+	}
4203 4420
 
4204 4421
 	echo '
4205 4422
 								}
@@ -4220,9 +4437,10 @@  discard block
 block discarded – undo
4220 4437
 									document.getElementById("error_block").style.display = "";
4221 4438
 									setInnerHTML(document.getElementById("error_message"), "', $txt['upgrade_loop'], '" + sDebugName);';
4222 4439
 
4223
-	if ($is_debug)
4224
-		echo '
4440
+	if ($is_debug) {
4441
+			echo '
4225 4442
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4443
+	}
4226 4444
 
4227 4445
 	echo '
4228 4446
 								}
@@ -4279,8 +4497,8 @@  discard block
 block discarded – undo
4279 4497
 							if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4280 4498
 							{';
4281 4499
 
4282
-		if ($is_debug)
4283
-			echo '
4500
+		if ($is_debug) {
4501
+					echo '
4284 4502
 								document.getElementById(\'debug_section\').style.display = "none";
4285 4503
 
4286 4504
 								var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4298,6 +4516,7 @@  discard block
 block discarded – undo
4298 4516
 									totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4299 4517
 
4300 4518
 								setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4519
+		}
4301 4520
 
4302 4521
 		echo '
4303 4522
 
@@ -4305,9 +4524,10 @@  discard block
 block discarded – undo
4305 4524
 								document.getElementById(\'contbutt\').disabled = 0;
4306 4525
 								document.getElementById(\'database_done\').value = 1;';
4307 4526
 
4308
-		if ($upcontext['file_count'] > 1)
4309
-			echo '
4527
+		if ($upcontext['file_count'] > 1) {
4528
+					echo '
4310 4529
 								document.getElementById(\'info1\').style.display = "none";';
4530
+		}
4311 4531
 
4312 4532
 		echo '
4313 4533
 								document.getElementById(\'info2\').style.display = "none";
@@ -4320,9 +4540,10 @@  discard block
 block discarded – undo
4320 4540
 								lastItem = 0;
4321 4541
 								prevFile = curFile;';
4322 4542
 
4323
-		if ($is_debug)
4324
-			echo '
4543
+		if ($is_debug) {
4544
+					echo '
4325 4545
 								setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4546
+		}
4326 4547
 
4327 4548
 		echo '
4328 4549
 								getNextItem();
@@ -4330,8 +4551,8 @@  discard block
 block discarded – undo
4330 4551
 							}';
4331 4552
 
4332 4553
 		// If debug scroll the screen.
4333
-		if ($is_debug)
4334
-			echo '
4554
+		if ($is_debug) {
4555
+					echo '
4335 4556
 							if (iLastSubStepProgress == -1)
4336 4557
 							{
4337 4558
 								// Give it consistent dots.
@@ -4350,6 +4571,7 @@  discard block
 block discarded – undo
4350 4571
 
4351 4572
 							if (document.getElementById(\'debug_section\').scrollHeight)
4352 4573
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4574
+		}
4353 4575
 
4354 4576
 		echo '
4355 4577
 							// Update the page.
@@ -4410,9 +4632,10 @@  discard block
 block discarded – undo
4410 4632
 						}';
4411 4633
 
4412 4634
 		// Start things off assuming we've not errored.
4413
-		if (empty($upcontext['error_message']))
4414
-			echo '
4635
+		if (empty($upcontext['error_message'])) {
4636
+					echo '
4415 4637
 						getNextItem();';
4638
+		}
4416 4639
 
4417 4640
 		echo '
4418 4641
 					//# sourceURL=dynamicScript-dbch.js
@@ -4430,18 +4653,21 @@  discard block
 block discarded – undo
4430 4653
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4431 4654
 	<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>';
4432 4655
 
4433
-	if (!empty($upcontext['error_message']))
4434
-		echo '
4656
+	if (!empty($upcontext['error_message'])) {
4657
+			echo '
4435 4658
 	<error>', $upcontext['error_message'], '</error>';
4659
+	}
4436 4660
 
4437
-	if (!empty($upcontext['error_string']))
4438
-		echo '
4661
+	if (!empty($upcontext['error_string'])) {
4662
+			echo '
4439 4663
 	<sql>', $upcontext['error_string'], '</sql>';
4664
+	}
4440 4665
 
4441
-	if ($is_debug)
4442
-		echo '
4666
+	if ($is_debug) {
4667
+			echo '
4443 4668
 	<curtime>', time(), '</curtime>';
4444
-}
4669
+	}
4670
+	}
4445 4671
 
4446 4672
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4447 4673
 function template_convert_utf8()
@@ -4458,10 +4684,11 @@  discard block
 block discarded – undo
4458 4684
 					</div>';
4459 4685
 
4460 4686
 	// Done any tables so far?
4461
-	if (!empty($upcontext['previous_tables']))
4462
-		foreach ($upcontext['previous_tables'] as $table)
4687
+	if (!empty($upcontext['previous_tables'])) {
4688
+			foreach ($upcontext['previous_tables'] as $table)
4463 4689
 			echo '
4464 4690
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4691
+	}
4465 4692
 
4466 4693
 	echo '
4467 4694
 					<h3 id="current_tab">
@@ -4469,9 +4696,10 @@  discard block
 block discarded – undo
4469 4696
 					</h3>';
4470 4697
 
4471 4698
 	// If we dropped their index, let's let them know
4472
-	if ($upcontext['dropping_index'])
4473
-		echo '
4699
+	if ($upcontext['dropping_index']) {
4700
+			echo '
4474 4701
 					<p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>';
4702
+	}
4475 4703
 
4476 4704
 	// Completion notification
4477 4705
 	echo '
@@ -4508,12 +4736,13 @@  discard block
 block discarded – undo
4508 4736
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4509 4737
 
4510 4738
 		// If debug flood the screen.
4511
-		if ($is_debug)
4512
-			echo '
4739
+		if ($is_debug) {
4740
+					echo '
4513 4741
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4514 4742
 
4515 4743
 						if (document.getElementById(\'debug_section\').scrollHeight)
4516 4744
 							document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4745
+		}
4517 4746
 
4518 4747
 		echo '
4519 4748
 						// Get the next update...
@@ -4559,10 +4788,11 @@  discard block
 block discarded – undo
4559 4788
 					</div>';
4560 4789
 
4561 4790
 	// Dont any tables so far?
4562
-	if (!empty($upcontext['previous_tables']))
4563
-		foreach ($upcontext['previous_tables'] as $table)
4791
+	if (!empty($upcontext['previous_tables'])) {
4792
+			foreach ($upcontext['previous_tables'] as $table)
4564 4793
 			echo '
4565 4794
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4795
+	}
4566 4796
 
4567 4797
 	echo '
4568 4798
 					<h3 id="current_tab">
@@ -4571,9 +4801,10 @@  discard block
 block discarded – undo
4571 4801
 					<p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>';
4572 4802
 
4573 4803
 	// Try to make sure substep was reset.
4574
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4575
-		echo '
4804
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4805
+			echo '
4576 4806
 					<input type="hidden" name="substep" id="substep" value="0">';
4807
+	}
4577 4808
 
4578 4809
 	// Continue please!
4579 4810
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4606,12 +4837,13 @@  discard block
 block discarded – undo
4606 4837
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4607 4838
 
4608 4839
 		// If debug flood the screen.
4609
-		if ($is_debug)
4610
-			echo '
4840
+		if ($is_debug) {
4841
+					echo '
4611 4842
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4612 4843
 
4613 4844
 							if (document.getElementById(\'debug_section\').scrollHeight)
4614 4845
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4846
+		}
4615 4847
 
4616 4848
 		echo '
4617 4849
 							// Get the next update...
@@ -4647,8 +4879,8 @@  discard block
 block discarded – undo
4647 4879
 				<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
4648 4880
 				<form action="', $boardurl, '/index.php">';
4649 4881
 
4650
-	if (!empty($upcontext['can_delete_script']))
4651
-		echo '
4882
+	if (!empty($upcontext['can_delete_script'])) {
4883
+			echo '
4652 4884
 					<label>
4653 4885
 						<input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '
4654 4886
 					</label>
@@ -4662,6 +4894,7 @@  discard block
 block discarded – undo
4662 4894
 						}
4663 4895
 					</script>
4664 4896
 					<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4897
+	}
4665 4898
 
4666 4899
 	$active = time() - $upcontext['started'];
4667 4900
 	$hours = floor($active / 3600);
@@ -4671,17 +4904,21 @@  discard block
 block discarded – undo
4671 4904
 	if ($is_debug)
4672 4905
 	{
4673 4906
 		$totalTime = '';
4674
-		if ($hours > 0)
4675
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4676
-		if ($minutes > 0)
4677
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4678
-		if ($seconds > 0)
4679
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4907
+		if ($hours > 0) {
4908
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4909
+		}
4910
+		if ($minutes > 0) {
4911
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4912
+		}
4913
+		if ($seconds > 0) {
4914
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4915
+		}
4680 4916
 	}
4681 4917
 
4682
-	if ($is_debug && !empty($totalTime))
4683
-		echo '
4918
+	if ($is_debug && !empty($totalTime)) {
4919
+			echo '
4684 4920
 					<p> ', $txt['upgrade_completed_time'], ' ', $totalTime, '</p>';
4921
+	}
4685 4922
 
4686 4923
 	echo '
4687 4924
 					<p>
@@ -4710,8 +4947,9 @@  discard block
 block discarded – undo
4710 4947
 
4711 4948
 	$current_substep = $_GET['substep'];
4712 4949
 
4713
-	if (empty($_GET['a']))
4714
-		$_GET['a'] = 0;
4950
+	if (empty($_GET['a'])) {
4951
+			$_GET['a'] = 0;
4952
+	}
4715 4953
 	$step_progress['name'] = 'Converting ips';
4716 4954
 	$step_progress['current'] = $_GET['a'];
4717 4955
 
@@ -4754,16 +4992,19 @@  discard block
 block discarded – undo
4754 4992
 				'empty' => '',
4755 4993
 				'limit' => $limit,
4756 4994
 		));
4757
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4758
-			$arIp[] = $row[$oldCol];
4995
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4996
+					$arIp[] = $row[$oldCol];
4997
+		}
4759 4998
 		$smcFunc['db_free_result']($request);
4760 4999
 
4761 5000
 		// Special case, null ip could keep us in a loop.
4762
-		if (is_null($arIp[0]))
4763
-			unset($arIp[0]);
5001
+		if (is_null($arIp[0])) {
5002
+					unset($arIp[0]);
5003
+		}
4764 5004
 
4765
-		if (empty($arIp))
4766
-			$is_done = true;
5005
+		if (empty($arIp)) {
5006
+					$is_done = true;
5007
+		}
4767 5008
 
4768 5009
 		$updates = array();
4769 5010
 		$cases = array();
@@ -4772,16 +5013,18 @@  discard block
 block discarded – undo
4772 5013
 		{
4773 5014
 			$arIp[$i] = trim($arIp[$i]);
4774 5015
 
4775
-			if (empty($arIp[$i]))
4776
-				continue;
5016
+			if (empty($arIp[$i])) {
5017
+							continue;
5018
+			}
4777 5019
 
4778 5020
 			$updates['ip' . $i] = $arIp[$i];
4779 5021
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4780 5022
 
4781 5023
 			if ($setSize > 0 && $i % $setSize === 0)
4782 5024
 			{
4783
-				if (count($updates) == 1)
4784
-					continue;
5025
+				if (count($updates) == 1) {
5026
+									continue;
5027
+				}
4785 5028
 
4786 5029
 				$updates['whereSet'] = array_values($updates);
4787 5030
 				$smcFunc['db_query']('', '
@@ -4815,8 +5058,7 @@  discard block
 block discarded – undo
4815 5058
 							'ip' => $ip
4816 5059
 					));
4817 5060
 				}
4818
-			}
4819
-			else
5061
+			} else
4820 5062
 			{
4821 5063
 				$updates['whereSet'] = array_values($updates);
4822 5064
 				$smcFunc['db_query']('', '
@@ -4830,9 +5072,9 @@  discard block
 block discarded – undo
4830 5072
 					$updates
4831 5073
 				);
4832 5074
 			}
5075
+		} else {
5076
+					$is_done = true;
4833 5077
 		}
4834
-		else
4835
-			$is_done = true;
4836 5078
 
4837 5079
 		$_GET['a'] += $limit;
4838 5080
 		$step_progress['current'] = $_GET['a'];
@@ -4858,10 +5100,11 @@  discard block
 block discarded – undo
4858 5100
 
4859 5101
 	$columns = $smcFunc['db_list_columns']($targetTable, true);
4860 5102
 
4861
-	if (isset($columns[$column]))
4862
-		return $columns[$column];
4863
-	else
4864
-		return null;
4865
-}
5103
+	if (isset($columns[$column])) {
5104
+			return $columns[$column];
5105
+	} else {
5106
+			return null;
5107
+	}
5108
+	}
4866 5109
 
4867 5110
 ?>
4868 5111
\ No newline at end of file
Please login to merge, or discard this patch.