Completed
Pull Request — release-2.1 (#4470)
by Fran
10:39
created
other/upgrade.php 3 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -489,6 +489,9 @@  discard block
 block discarded – undo
489 489
 	}
490 490
 
491 491
 // Used to direct the user to another location.
492
+/**
493
+ * @param string $location
494
+ */
492 495
 function redirectLocation($location, $addForm = true)
493 496
 {
494 497
 	global $upgradeurl, $upcontext, $command_line;
@@ -1711,6 +1714,9 @@  discard block
 block discarded – undo
1711 1714
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1712 1715
 }
1713 1716
 
1717
+/**
1718
+ * @param string $filename
1719
+ */
1714 1720
 function parse_sql($filename)
1715 1721
 {
1716 1722
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1745,6 +1751,10 @@  discard block
 block discarded – undo
1745 1751
 
1746 1752
 	// Our custom error handler - does nothing but does stop public errors from XML!
1747 1753
 	set_error_handler(
1754
+
1755
+		/**
1756
+		 * @param string $errno
1757
+		 */
1748 1758
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1749 1759
 		{
1750 1760
 			if ($support_js)
@@ -1959,6 +1969,9 @@  discard block
 block discarded – undo
1959 1969
 	return true;
1960 1970
 }
1961 1971
 
1972
+/**
1973
+ * @param string $string
1974
+ */
1962 1975
 function upgrade_query($string, $unbuffered = false)
1963 1976
 {
1964 1977
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4712,7 +4725,7 @@  discard block
 block discarded – undo
4712 4725
  * @param int $setSize The amount of entries after which to update the database.
4713 4726
  *
4714 4727
  * newCol needs to be a varbinary(16) null able field
4715
- * @return bool
4728
+ * @return boolean|null
4716 4729
  */
4717 4730
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4718 4731
 {
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 
1746 1746
 	// Our custom error handler - does nothing but does stop public errors from XML!
1747 1747
 	set_error_handler(
1748
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1748
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1749 1749
 		{
1750 1750
 			if ($support_js)
1751 1751
 				return true;
@@ -2735,94 +2735,94 @@  discard block
 block discarded – undo
2735 2735
 		// Translation table for the character sets not native for MySQL.
2736 2736
 		$translation_tables = array(
2737 2737
 			'windows-1255' => array(
2738
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2739
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2740
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2741
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2742
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2743
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2744
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2745
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2746
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2747
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2748
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2749
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2750
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2751
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2752
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2753
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2754
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2755
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2756
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2757
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2758
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2759
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2760
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2761
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2762
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2763
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2764
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2765
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2766
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2767
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2768
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2769
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2770
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2771
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2772
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2773
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2774
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2775
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2776
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2777
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2778
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2779
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2738
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2739
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2740
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2741
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2742
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2743
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2744
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2745
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2746
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2747
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2748
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2749
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2750
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2751
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2752
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2753
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2754
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2755
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2756
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2757
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2758
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2759
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2760
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2761
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2762
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2763
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2764
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2765
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2766
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2767
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2768
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2769
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2770
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2771
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2772
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2773
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2774
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2775
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2776
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2777
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2778
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2779
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2780 2780
 				'0xFA' => '0xD7AA',
2781 2781
 			),
2782 2782
 			'windows-1253' => array(
2783
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2784
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2785
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2786
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2787
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2788
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2789
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2790
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2791
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2792
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2793
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2794
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2795
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2796
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2797
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2798
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2799
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2800
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2801
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2802
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2803
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2804
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2805
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2806
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2807
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2808
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2809
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2810
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2811
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2812
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2813
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2814
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2815
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2816
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2817
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2818
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2819
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2820
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2821
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2822
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2823
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2824
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2825
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2783
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2784
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2785
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2786
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2787
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2788
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2789
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2790
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2791
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2792
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2793
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2794
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2795
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2796
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2797
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2798
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2799
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2800
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2801
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2802
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2803
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2804
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2805
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2806
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2807
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2808
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2809
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2810
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2811
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2812
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2813
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2814
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2815
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2816
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2817
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2818
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2819
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2820
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2821
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2822
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2823
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2824
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2825
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2826 2826
 			),
2827 2827
 		);
2828 2828
 
@@ -3683,8 +3683,8 @@  discard block
 block discarded – undo
3683 3683
 {
3684 3684
 	global $upcontext, $disable_security, $settings, $txt;
3685 3685
 
3686
-	$smf_url='https://www.simplemachines.org';
3687
-	$formatted_url='<a href=" '. $smf_url .' ">Simple Machines Website</a>';
3686
+	$smf_url = 'https://www.simplemachines.org';
3687
+	$formatted_url = '<a href=" ' . $smf_url . ' ">Simple Machines Website</a>';
3688 3688
 
3689 3689
 	echo '
3690 3690
 		<script src="https://www.simplemachines.org/smf/current-version.js?version=' . SMF_VERSION . '"></script>
@@ -3762,7 +3762,7 @@  discard block
 block discarded – undo
3762 3762
 
3763 3763
 		if ($active < 600)
3764 3764
 			echo '
3765
-				', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '';
3765
+				', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '';
3766 3766
 
3767 3767
 		if ($active > $upcontext['inactive_timeout'])
3768 3768
 			echo '
@@ -3866,8 +3866,8 @@  discard block
 block discarded – undo
3866 3866
 {
3867 3867
 	global $upcontext, $modSettings, $db_prefix, $mmessage, $mtitle, $txt;
3868 3868
 
3869
-	$smf_url='https://www.simplemachines.org/about/stats.php';
3870
-	$formatted_url='<a href=" '. $smf_url .' " target="_blank" rel="noopener">info page</a>';
3869
+	$smf_url = 'https://www.simplemachines.org/about/stats.php';
3870
+	$formatted_url = '<a href=" ' . $smf_url . ' " target="_blank" rel="noopener">info page</a>';
3871 3871
 	echo '
3872 3872
 			<h3>', $txt['upgrade_areyouready'], '</h3>
3873 3873
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
@@ -3966,7 +3966,7 @@  discard block
 block discarded – undo
3966 3966
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3967 3967
 			<input type="hidden" name="backup_done" id="backup_done" value="0">
3968 3968
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3969
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
3969
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
3970 3970
 			<span id="debuginfo"></span>
3971 3971
 			</div>';
3972 3972
 
@@ -4467,7 +4467,7 @@  discard block
 block discarded – undo
4467 4467
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4468 4468
 			<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4469 4469
 			<strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong>
4470
-			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;">
4470
+			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;">
4471 4471
 			<span id="debuginfo"></span>
4472 4472
 			</div>';
4473 4473
 
@@ -4568,7 +4568,7 @@  discard block
 block discarded – undo
4568 4568
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4569 4569
 			<input type="hidden" name="json_done" id="json_done" value="0">
4570 4570
 			<strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong>
4571
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4571
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4572 4572
 			<span id="debuginfo"></span>
4573 4573
 			</div>';
4574 4574
 
@@ -4656,7 +4656,7 @@  discard block
 block discarded – undo
4656 4656
 	global $upcontext, $upgradeurl, $settings, $boardurl, $is_debug, $txt;
4657 4657
 
4658 4658
 	$smf_url = 'https://www.simplemachines.org';
4659
-	$formatted_url = '<a href=" '. $smf_url .' ">look to us for assistance</a>.';
4659
+	$formatted_url = '<a href=" ' . $smf_url . ' ">look to us for assistance</a>.';
4660 4660
 
4661 4661
 	echo '
4662 4662
 	<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
Please login to merge, or discard this patch.
Braces   +898 added lines, -659 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,10 +223,12 @@  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
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
224 234
 // Default title...
@@ -236,13 +246,15 @@  discard block
 block discarded – undo
236 246
 	$support_js = $upcontext['upgrade_status']['js'];
237 247
 
238 248
 	// Only set this if the upgrader status says so.
239
-	if (empty($is_debug))
240
-		$is_debug = $upcontext['upgrade_status']['debug'];
249
+	if (empty($is_debug)) {
250
+			$is_debug = $upcontext['upgrade_status']['debug'];
251
+	}
241 252
 
242 253
 	// Load the language.
243
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
244
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
245
-}
254
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
255
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
256
+	}
257
+	}
246 258
 // Set the defaults.
247 259
 else
248 260
 {
@@ -260,15 +272,18 @@  discard block
 block discarded – undo
260 272
 }
261 273
 
262 274
 // If this isn't the first stage see whether they are logging in and resuming.
263
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
275
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
264 276
 	checkLogin();
277
+}
265 278
 
266
-if ($command_line)
279
+if ($command_line) {
267 280
 	cmdStep0();
281
+}
268 282
 
269 283
 // Don't error if we're using xml.
270
-if (isset($_GET['xml']))
284
+if (isset($_GET['xml'])) {
271 285
 	$upcontext['return_error'] = true;
286
+}
272 287
 
273 288
 // Loop through all the steps doing each one as required.
274 289
 $upcontext['overall_percent'] = 0;
@@ -289,9 +304,9 @@  discard block
 block discarded – undo
289 304
 		}
290 305
 
291 306
 		// Call the step and if it returns false that means pause!
292
-		if (function_exists($step[2]) && $step[2]() === false)
293
-			break;
294
-		elseif (function_exists($step[2])) {
307
+		if (function_exists($step[2]) && $step[2]() === false) {
308
+					break;
309
+		} elseif (function_exists($step[2])) {
295 310
 			//Start each new step with this unset, so the 'normal' template is called first
296 311
 			unset($_GET['xml']);
297 312
 			//Clear out warnings at the start of each step
@@ -337,17 +352,18 @@  discard block
 block discarded – undo
337 352
 		// This should not happen my dear... HELP ME DEVELOPERS!!
338 353
 		if (!empty($command_line))
339 354
 		{
340
-			if (function_exists('debug_print_backtrace'))
341
-				debug_print_backtrace();
355
+			if (function_exists('debug_print_backtrace')) {
356
+							debug_print_backtrace();
357
+			}
342 358
 
343 359
 			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.';
344 360
 			flush();
345 361
 			die();
346 362
 		}
347 363
 
348
-		if (!isset($_GET['xml']))
349
-			template_upgrade_above();
350
-		else
364
+		if (!isset($_GET['xml'])) {
365
+					template_upgrade_above();
366
+		} else
351 367
 		{
352 368
 			header('content-type: text/xml; charset=UTF-8');
353 369
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -369,25 +385,29 @@  discard block
 block discarded – undo
369 385
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
370 386
 
371 387
 			// Custom stuff to pass back?
372
-			if (!empty($upcontext['query_string']))
373
-				$upcontext['form_url'] .= $upcontext['query_string'];
388
+			if (!empty($upcontext['query_string'])) {
389
+							$upcontext['form_url'] .= $upcontext['query_string'];
390
+			}
374 391
 
375 392
 			// Call the appropriate subtemplate
376
-			if (is_callable('template_' . $upcontext['sub_template']))
377
-				call_user_func('template_' . $upcontext['sub_template']);
378
-			else
379
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
393
+			if (is_callable('template_' . $upcontext['sub_template'])) {
394
+							call_user_func('template_' . $upcontext['sub_template']);
395
+			} else {
396
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
397
+			}
380 398
 		}
381 399
 
382 400
 		// Was there an error?
383
-		if (!empty($upcontext['forced_error_message']))
384
-			echo $upcontext['forced_error_message'];
401
+		if (!empty($upcontext['forced_error_message'])) {
402
+					echo $upcontext['forced_error_message'];
403
+		}
385 404
 
386 405
 		// Show the footer.
387
-		if (!isset($_GET['xml']))
388
-			template_upgrade_below();
389
-		else
390
-			template_xml_below();
406
+		if (!isset($_GET['xml'])) {
407
+					template_upgrade_below();
408
+		} else {
409
+					template_xml_below();
410
+		}
391 411
 	}
392 412
 
393 413
 
@@ -399,15 +419,19 @@  discard block
 block discarded – undo
399 419
 		$seconds = intval($active % 60);
400 420
 
401 421
 		$totalTime = '';
402
-		if ($hours > 0)
403
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
404
-		if ($minutes > 0)
405
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
406
-		if ($seconds > 0)
407
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
422
+		if ($hours > 0) {
423
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
424
+		}
425
+		if ($minutes > 0) {
426
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
427
+		}
428
+		if ($seconds > 0) {
429
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
430
+		}
408 431
 
409
-		if (!empty($totalTime))
410
-			echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
432
+		if (!empty($totalTime)) {
433
+					echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
434
+		}
411 435
 	}
412 436
 
413 437
 	// Bang - gone!
@@ -428,8 +452,9 @@  discard block
 block discarded – undo
428 452
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
429 453
 		while ($entry = $dir->read())
430 454
 		{
431
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
432
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
455
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
456
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
457
+			}
433 458
 		}
434 459
 		$dir->close();
435 460
 	}
@@ -464,10 +489,11 @@  discard block
 block discarded – undo
464 489
 	}
465 490
 
466 491
 		// 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'];
492
+		if (isset($_GET['lang_file'])) {
493
+					$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
494
+		} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
495
+					$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
496
+		}
471 497
 
472 498
 		// Make sure it exists, if it doesn't reset it.
473 499
 		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,8 +502,9 @@  discard block
 block discarded – undo
476 502
 			list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
477 503
 
478 504
 			// 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']);
505
+			if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
506
+							list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
507
+			}
481 508
 		}
482 509
 
483 510
 		// And now include the actual language file itself.
@@ -494,8 +521,9 @@  discard block
 block discarded – undo
494 521
 	global $upgradeurl, $upcontext, $command_line;
495 522
 
496 523
 	// Command line users can't be redirected.
497
-	if ($command_line)
498
-		upgradeExit(true);
524
+	if ($command_line) {
525
+			upgradeExit(true);
526
+	}
499 527
 
500 528
 	// Are we providing the core info?
501 529
 	if ($addForm)
@@ -521,12 +549,14 @@  discard block
 block discarded – undo
521 549
 	define('SMF', 1);
522 550
 
523 551
 	// Start the session.
524
-	if (@ini_get('session.save_handler') == 'user')
525
-		@ini_set('session.save_handler', 'files');
552
+	if (@ini_get('session.save_handler') == 'user') {
553
+			@ini_set('session.save_handler', 'files');
554
+	}
526 555
 	@session_start();
527 556
 
528
-	if (empty($smcFunc))
529
-		$smcFunc = array();
557
+	if (empty($smcFunc)) {
558
+			$smcFunc = array();
559
+	}
530 560
 
531 561
 	// We need this for authentication and some upgrade code
532 562
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -553,24 +583,27 @@  discard block
 block discarded – undo
553 583
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
554 584
 
555 585
 		// Make the connection...
556
-		if (empty($db_connection))
557
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
558
-		else
559
-			// If we've returned here, ping/reconnect to be safe
586
+		if (empty($db_connection)) {
587
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
588
+		} else {
589
+					// If we've returned here, ping/reconnect to be safe
560 590
 			$smcFunc['db_ping']($db_connection);
591
+		}
561 592
 
562 593
 		// Oh dear god!!
563
-		if ($db_connection === null)
564
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
594
+		if ($db_connection === null) {
595
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
596
+		}
565 597
 
566
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
567
-			$smcFunc['db_query']('', '
598
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
599
+					$smcFunc['db_query']('', '
568 600
 			SET NAMES {string:db_character_set}',
569 601
 			array(
570 602
 				'db_error_skip' => true,
571 603
 				'db_character_set' => $db_character_set,
572 604
 			)
573 605
 		);
606
+		}
574 607
 
575 608
 		// Load the modSettings data...
576 609
 		$request = $smcFunc['db_query']('', '
@@ -581,11 +614,11 @@  discard block
 block discarded – undo
581 614
 			)
582 615
 		);
583 616
 		$modSettings = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$modSettings[$row['variable']] = $row['value'];
617
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
618
+					$modSettings[$row['variable']] = $row['value'];
619
+		}
586 620
 		$smcFunc['db_free_result']($request);
587
-	}
588
-	else
621
+	} else
589 622
 	{
590 623
 		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.');
591 624
 	}
@@ -599,9 +632,10 @@  discard block
 block discarded – undo
599 632
 		cleanRequest();
600 633
 	}
601 634
 
602
-	if (!isset($_GET['substep']))
603
-		$_GET['substep'] = 0;
604
-}
635
+	if (!isset($_GET['substep'])) {
636
+			$_GET['substep'] = 0;
637
+	}
638
+	}
605 639
 
606 640
 function initialize_inputs()
607 641
 {
@@ -631,8 +665,9 @@  discard block
 block discarded – undo
631 665
 		$dh = opendir(dirname(__FILE__));
632 666
 		while ($file = readdir($dh))
633 667
 		{
634
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
635
-				@unlink(dirname(__FILE__) . '/' . $file);
668
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
669
+							@unlink(dirname(__FILE__) . '/' . $file);
670
+			}
636 671
 		}
637 672
 		closedir($dh);
638 673
 
@@ -661,8 +696,9 @@  discard block
 block discarded – undo
661 696
 	$temp = 'upgrade_php?step';
662 697
 	while (strlen($temp) > 4)
663 698
 	{
664
-		if (isset($_GET[$temp]))
665
-			unset($_GET[$temp]);
699
+		if (isset($_GET[$temp])) {
700
+					unset($_GET[$temp]);
701
+		}
666 702
 		$temp = substr($temp, 1);
667 703
 	}
668 704
 
@@ -689,32 +725,39 @@  discard block
 block discarded – undo
689 725
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
690 726
 
691 727
 	// Need legacy scripts?
692
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
693
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
694
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
695
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
696
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
697
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
728
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
729
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
730
+	}
731
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
732
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
733
+	}
734
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
735
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
736
+	}
698 737
 
699 738
 	// We don't need "-utf8" files anymore...
700 739
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
701 740
 
702 741
 	// This needs to exist!
703
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
704
-		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>]');
705
-	else
706
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
742
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
743
+			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>]');
744
+	} else {
745
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
746
+	}
707 747
 
708
-	if (!$check)
709
-		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
748
+	if (!$check) {
749
+			// 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.
710 750
 		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.');
751
+	}
711 752
 
712 753
 	// Do they meet the install requirements?
713
-	if (!php_version_check())
714
-		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.');
754
+	if (!php_version_check()) {
755
+			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.');
756
+	}
715 757
 
716
-	if (!db_version_check())
717
-		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.');
758
+	if (!db_version_check()) {
759
+			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.');
760
+	}
718 761
 
719 762
 	// Do some checks to make sure they have proper privileges
720 763
 	db_extend('packages');
@@ -729,14 +772,16 @@  discard block
 block discarded – undo
729 772
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
730 773
 
731 774
 	// Sorry... we need CREATE, ALTER and DROP
732
-	if (!$create || !$alter || !$drop)
733
-		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.');
775
+	if (!$create || !$alter || !$drop) {
776
+			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.');
777
+	}
734 778
 
735 779
 	// Do a quick version spot check.
736 780
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
737 781
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
738
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
739
-		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.');
782
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
783
+			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.');
784
+	}
740 785
 
741 786
 	// What absolutely needs to be writable?
742 787
 	$writable_files = array(
@@ -745,12 +790,13 @@  discard block
 block discarded – undo
745 790
 	);
746 791
 
747 792
 	// Only check for minified writable files if we have it enabled or not set.
748
-	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files']))
749
-		$writable_files += array(
793
+	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) {
794
+			$writable_files += array(
750 795
 			$modSettings['theme_dir'] . '/css/minified.css',
751 796
 			$modSettings['theme_dir'] . '/scripts/minified.js',
752 797
 			$modSettings['theme_dir'] . '/scripts/minified_deferred.js',
753 798
 		);
799
+	}
754 800
 
755 801
 	// Do we need to add this setting?
756 802
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
@@ -762,12 +808,13 @@  discard block
 block discarded – undo
762 808
 	quickFileWritable($custom_av_dir);
763 809
 
764 810
 	// Are we good now?
765
-	if (!is_writable($custom_av_dir))
766
-		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));
767
-	elseif ($need_settings_update)
811
+	if (!is_writable($custom_av_dir)) {
812
+			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));
813
+	} elseif ($need_settings_update)
768 814
 	{
769
-		if (!function_exists('cache_put_data'))
770
-			require_once($sourcedir . '/Load.php');
815
+		if (!function_exists('cache_put_data')) {
816
+					require_once($sourcedir . '/Load.php');
817
+		}
771 818
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
772 819
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
773 820
 	}
@@ -776,28 +823,33 @@  discard block
 block discarded – undo
776 823
 
777 824
 	// Check the cache directory.
778 825
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
779
-	if (!file_exists($cachedir_temp))
780
-		@mkdir($cachedir_temp);
781
-	if (!file_exists($cachedir_temp))
782
-		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.');
783
-
784
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
785
-		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>.');
786
-	elseif (!isset($_GET['skiplang']))
826
+	if (!file_exists($cachedir_temp)) {
827
+			@mkdir($cachedir_temp);
828
+	}
829
+	if (!file_exists($cachedir_temp)) {
830
+			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.');
831
+	}
832
+
833
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
834
+			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>.');
835
+	} elseif (!isset($_GET['skiplang']))
787 836
 	{
788 837
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
789 838
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
790 839
 
791
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
792
-			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>]');
840
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
841
+					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>]');
842
+		}
793 843
 	}
794 844
 
795
-	if (!makeFilesWritable($writable_files))
796
-		return false;
845
+	if (!makeFilesWritable($writable_files)) {
846
+			return false;
847
+	}
797 848
 
798 849
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
799
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
800
-		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.');
850
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
851
+			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.');
852
+	}
801 853
 
802 854
 	// Upgrade the agreement.
803 855
 	elseif (isset($modSettings['agreement']))
@@ -808,8 +860,8 @@  discard block
 block discarded – undo
808 860
 	}
809 861
 
810 862
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
811
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
812
-		$upcontext['warning'] = '
863
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
864
+			$upcontext['warning'] = '
813 865
 			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br>
814 866
 			<ul>
815 867
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -817,19 +869,23 @@  discard block
 block discarded – undo
817 869
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
818 870
 			</ul>
819 871
 			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
872
+	}
820 873
 
821 874
 	// Confirm mbstring is loaded...
822
-	if (!extension_loaded('mbstring'))
823
-		return throw_error($txt['install_no_mbstring']);
875
+	if (!extension_loaded('mbstring')) {
876
+			return throw_error($txt['install_no_mbstring']);
877
+	}
824 878
 
825 879
 	// Check for https stream support.
826 880
 	$supported_streams = stream_get_wrappers();
827
-	if (!in_array('https', $supported_streams))
828
-		$upcontext['custom_warning'] = $txt['install_no_https'];
881
+	if (!in_array('https', $supported_streams)) {
882
+			$upcontext['custom_warning'] = $txt['install_no_https'];
883
+	}
829 884
 
830 885
 	// Either we're logged in or we're going to present the login.
831
-	if (checkLogin())
832
-		return true;
886
+	if (checkLogin()) {
887
+			return true;
888
+	}
833 889
 
834 890
 	$upcontext += createToken('login');
835 891
 
@@ -843,15 +899,17 @@  discard block
 block discarded – undo
843 899
 	global $smcFunc, $db_type, $support_js;
844 900
 
845 901
 	// Don't bother if the security is disabled.
846
-	if ($disable_security)
847
-		return true;
902
+	if ($disable_security) {
903
+			return true;
904
+	}
848 905
 
849 906
 	// Are we trying to login?
850 907
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
851 908
 	{
852 909
 		// If we've disabled security pick a suitable name!
853
-		if (empty($_POST['user']))
854
-			$_POST['user'] = 'Administrator';
910
+		if (empty($_POST['user'])) {
911
+					$_POST['user'] = 'Administrator';
912
+		}
855 913
 
856 914
 		// Before 2.0 these column names were different!
857 915
 		$oldDB = false;
@@ -866,16 +924,17 @@  discard block
 block discarded – undo
866 924
 					'db_error_skip' => true,
867 925
 				)
868 926
 			);
869
-			if ($smcFunc['db_num_rows']($request) != 0)
870
-				$oldDB = true;
927
+			if ($smcFunc['db_num_rows']($request) != 0) {
928
+							$oldDB = true;
929
+			}
871 930
 			$smcFunc['db_free_result']($request);
872 931
 		}
873 932
 
874 933
 		// Get what we believe to be their details.
875 934
 		if (!$disable_security)
876 935
 		{
877
-			if ($oldDB)
878
-				$request = $smcFunc['db_query']('', '
936
+			if ($oldDB) {
937
+							$request = $smcFunc['db_query']('', '
879 938
 					SELECT id_member, memberName AS member_name, passwd, id_group,
880 939
 					additionalGroups AS additional_groups, lngfile
881 940
 					FROM {db_prefix}members
@@ -885,8 +944,8 @@  discard block
 block discarded – undo
885 944
 						'db_error_skip' => true,
886 945
 					)
887 946
 				);
888
-			else
889
-				$request = $smcFunc['db_query']('', '
947
+			} else {
948
+							$request = $smcFunc['db_query']('', '
890 949
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
891 950
 					FROM {db_prefix}members
892 951
 					WHERE member_name = {string:member_name}',
@@ -895,6 +954,7 @@  discard block
 block discarded – undo
895 954
 						'db_error_skip' => true,
896 955
 					)
897 956
 				);
957
+			}
898 958
 			if ($smcFunc['db_num_rows']($request) != 0)
899 959
 			{
900 960
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -902,16 +962,17 @@  discard block
 block discarded – undo
902 962
 				$groups = explode(',', $addGroups);
903 963
 				$groups[] = $id_group;
904 964
 
905
-				foreach ($groups as $k => $v)
906
-					$groups[$k] = (int) $v;
965
+				foreach ($groups as $k => $v) {
966
+									$groups[$k] = (int) $v;
967
+				}
907 968
 
908 969
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
909 970
 
910 971
 				// We don't use "-utf8" anymore...
911 972
 				$user_language = str_ireplace('-utf8', '', $user_language);
973
+			} else {
974
+							$upcontext['username_incorrect'] = true;
912 975
 			}
913
-			else
914
-				$upcontext['username_incorrect'] = true;
915 976
 			$smcFunc['db_free_result']($request);
916 977
 		}
917 978
 		$upcontext['username'] = $_POST['user'];
@@ -921,13 +982,14 @@  discard block
 block discarded – undo
921 982
 		{
922 983
 			$upcontext['upgrade_status']['js'] = 1;
923 984
 			$support_js = 1;
985
+		} else {
986
+					$support_js = 0;
924 987
 		}
925
-		else
926
-			$support_js = 0;
927 988
 
928 989
 		// Note down the version we are coming from.
929
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
930
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
990
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
991
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
992
+		}
931 993
 
932 994
 		// Didn't get anywhere?
933 995
 		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']))
@@ -961,15 +1023,15 @@  discard block
 block discarded – undo
961 1023
 							'db_error_skip' => true,
962 1024
 						)
963 1025
 					);
964
-					if ($smcFunc['db_num_rows']($request) == 0)
965
-						return throw_error('You need to be an admin to perform an upgrade!');
1026
+					if ($smcFunc['db_num_rows']($request) == 0) {
1027
+											return throw_error('You need to be an admin to perform an upgrade!');
1028
+					}
966 1029
 					$smcFunc['db_free_result']($request);
967 1030
 				}
968 1031
 
969 1032
 				$upcontext['user']['id'] = $id_member;
970 1033
 				$upcontext['user']['name'] = $name;
971
-			}
972
-			else
1034
+			} else
973 1035
 			{
974 1036
 				$upcontext['user']['id'] = 1;
975 1037
 				$upcontext['user']['name'] = 'Administrator';
@@ -985,11 +1047,11 @@  discard block
 block discarded – undo
985 1047
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
986 1048
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
987 1049
 
988
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
989
-					$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'] . '.';
990
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
991
-					$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'] . '.';
992
-				else
1050
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1051
+									$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'] . '.';
1052
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1053
+									$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'] . '.';
1054
+				} else
993 1055
 				{
994 1056
 					// Set this as the new language.
995 1057
 					$upcontext['language'] = $user_language;
@@ -1033,8 +1095,9 @@  discard block
 block discarded – undo
1033 1095
 	unset($member_columns);
1034 1096
 
1035 1097
 	// If we've not submitted then we're done.
1036
-	if (empty($_POST['upcont']))
1037
-		return false;
1098
+	if (empty($_POST['upcont'])) {
1099
+			return false;
1100
+	}
1038 1101
 
1039 1102
 	// Firstly, if they're enabling SM stat collection just do it.
1040 1103
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -1054,16 +1117,17 @@  discard block
 block discarded – undo
1054 1117
 				fwrite($fp, $out);
1055 1118
 
1056 1119
 				$return_data = '';
1057
-				while (!feof($fp))
1058
-					$return_data .= fgets($fp, 128);
1120
+				while (!feof($fp)) {
1121
+									$return_data .= fgets($fp, 128);
1122
+				}
1059 1123
 
1060 1124
 				fclose($fp);
1061 1125
 
1062 1126
 				// Get the unique site ID.
1063 1127
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1064 1128
 
1065
-				if (!empty($ID[1]))
1066
-					$smcFunc['db_insert']('replace',
1129
+				if (!empty($ID[1])) {
1130
+									$smcFunc['db_insert']('replace',
1067 1131
 						$db_prefix . 'settings',
1068 1132
 						array('variable' => 'string', 'value' => 'string'),
1069 1133
 						array(
@@ -1072,9 +1136,9 @@  discard block
 block discarded – undo
1072 1136
 						),
1073 1137
 						array('variable')
1074 1138
 					);
1139
+				}
1075 1140
 			}
1076
-		}
1077
-		else
1141
+		} else
1078 1142
 		{
1079 1143
 			$smcFunc['db_insert']('replace',
1080 1144
 				$db_prefix . 'settings',
@@ -1085,8 +1149,8 @@  discard block
 block discarded – undo
1085 1149
 		}
1086 1150
 	}
1087 1151
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1088
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1089
-		$smcFunc['db_query']('', '
1152
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1153
+			$smcFunc['db_query']('', '
1090 1154
 			DELETE FROM {db_prefix}settings
1091 1155
 			WHERE variable = {string:enable_sm_stats}',
1092 1156
 			array(
@@ -1094,6 +1158,7 @@  discard block
 block discarded – undo
1094 1158
 				'db_error_skip' => true,
1095 1159
 			)
1096 1160
 		);
1161
+	}
1097 1162
 
1098 1163
 	// Deleting old karma stuff?
1099 1164
 	if (!empty($_POST['delete_karma']))
@@ -1108,20 +1173,22 @@  discard block
 block discarded – undo
1108 1173
 		);
1109 1174
 
1110 1175
 		// Cleaning up old karma member settings.
1111
-		if ($upcontext['karma_installed']['good'])
1112
-			$smcFunc['db_query']('', '
1176
+		if ($upcontext['karma_installed']['good']) {
1177
+					$smcFunc['db_query']('', '
1113 1178
 				ALTER TABLE {db_prefix}members
1114 1179
 				DROP karma_good',
1115 1180
 				array()
1116 1181
 			);
1182
+		}
1117 1183
 
1118 1184
 		// Does karma bad was enable?
1119
-		if ($upcontext['karma_installed']['bad'])
1120
-			$smcFunc['db_query']('', '
1185
+		if ($upcontext['karma_installed']['bad']) {
1186
+					$smcFunc['db_query']('', '
1121 1187
 				ALTER TABLE {db_prefix}members
1122 1188
 				DROP karma_bad',
1123 1189
 				array()
1124 1190
 			);
1191
+		}
1125 1192
 
1126 1193
 		// Cleaning up old karma permissions.
1127 1194
 		$smcFunc['db_query']('', '
@@ -1139,32 +1206,37 @@  discard block
 block discarded – undo
1139 1206
 	}
1140 1207
 
1141 1208
 	// Emptying the error log?
1142
-	if (!empty($_POST['empty_error']))
1143
-		$smcFunc['db_query']('truncate_table', '
1209
+	if (!empty($_POST['empty_error'])) {
1210
+			$smcFunc['db_query']('truncate_table', '
1144 1211
 			TRUNCATE {db_prefix}log_errors',
1145 1212
 			array(
1146 1213
 			)
1147 1214
 		);
1215
+	}
1148 1216
 
1149 1217
 	$changes = array();
1150 1218
 
1151 1219
 	// Add proxy settings.
1152
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1153
-		$changes += array(
1220
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1221
+			$changes += array(
1154 1222
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1155 1223
 			'image_proxy_maxsize' => 5190,
1156 1224
 			'image_proxy_enabled' => 0,
1157 1225
 		);
1226
+	}
1158 1227
 
1159 1228
 	// If $boardurl reflects https, set force_ssl
1160
-	if (!function_exists('cache_put_data'))
1161
-		require_once($sourcedir . '/Load.php');
1162
-	if (stripos($boardurl, 'https://') !== false)
1163
-		updateSettings(array('force_ssl' => '1'));
1229
+	if (!function_exists('cache_put_data')) {
1230
+			require_once($sourcedir . '/Load.php');
1231
+	}
1232
+	if (stripos($boardurl, 'https://') !== false) {
1233
+			updateSettings(array('force_ssl' => '1'));
1234
+	}
1164 1235
 
1165 1236
 	// If we're overriding the language follow it through.
1166
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1167
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1237
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1238
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1239
+	}
1168 1240
 
1169 1241
 	if (!empty($_POST['maint']))
1170 1242
 	{
@@ -1176,26 +1248,29 @@  discard block
 block discarded – undo
1176 1248
 		{
1177 1249
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1178 1250
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1179
-		}
1180
-		else
1251
+		} else
1181 1252
 		{
1182 1253
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1183 1254
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1184 1255
 		}
1185 1256
 	}
1186 1257
 
1187
-	if ($command_line)
1188
-		echo ' * Updating Settings.php...';
1258
+	if ($command_line) {
1259
+			echo ' * Updating Settings.php...';
1260
+	}
1189 1261
 
1190 1262
 	// Fix some old paths.
1191
-	if (substr($boarddir, 0, 1) == '.')
1192
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1263
+	if (substr($boarddir, 0, 1) == '.') {
1264
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1265
+	}
1193 1266
 
1194
-	if (substr($sourcedir, 0, 1) == '.')
1195
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1267
+	if (substr($sourcedir, 0, 1) == '.') {
1268
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1269
+	}
1196 1270
 
1197
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1198
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1271
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1272
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1273
+	}
1199 1274
 
1200 1275
 	// If they have a "host:port" setup for the host, split that into separate values
1201 1276
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1206,32 +1281,36 @@  discard block
 block discarded – undo
1206 1281
 		$changes['db_server'] = '\'' . $db_server . '\'';
1207 1282
 
1208 1283
 		// Only set this if we're not using the default port
1209
-		if ($db_port != ini_get('mysqli.default_port'))
1210
-			$changes['db_port'] = (int) $db_port;
1211
-	}
1212
-	elseif (!empty($db_port))
1284
+		if ($db_port != ini_get('mysqli.default_port')) {
1285
+					$changes['db_port'] = (int) $db_port;
1286
+		}
1287
+	} elseif (!empty($db_port))
1213 1288
 	{
1214 1289
 		// If db_port is set and is the same as the default, set it to ''
1215 1290
 		if ($db_type == 'mysql')
1216 1291
 		{
1217
-			if ($db_port == ini_get('mysqli.default_port'))
1218
-				$changes['db_port'] = '\'\'';
1219
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1220
-				$changes['db_port'] = '\'\'';
1292
+			if ($db_port == ini_get('mysqli.default_port')) {
1293
+							$changes['db_port'] = '\'\'';
1294
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1295
+							$changes['db_port'] = '\'\'';
1296
+			}
1221 1297
 		}
1222 1298
 	}
1223 1299
 
1224 1300
 	// Maybe we haven't had this option yet?
1225
-	if (empty($packagesdir))
1226
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1301
+	if (empty($packagesdir)) {
1302
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1303
+	}
1227 1304
 
1228 1305
 	// Add support for $tasksdir var.
1229
-	if (empty($tasksdir))
1230
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1306
+	if (empty($tasksdir)) {
1307
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1308
+	}
1231 1309
 
1232 1310
 	// Make sure we fix the language as well.
1233
-	if (stristr($language, '-utf8'))
1234
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1311
+	if (stristr($language, '-utf8')) {
1312
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1313
+	}
1235 1314
 
1236 1315
 	// @todo Maybe change the cookie name if going to 1.1, too?
1237 1316
 
@@ -1242,8 +1321,9 @@  discard block
 block discarded – undo
1242 1321
 	// Tell Settings.php to store db_last_error.php in the cache
1243 1322
 	move_db_last_error_to_cachedir();
1244 1323
 
1245
-	if ($command_line)
1246
-		echo ' Successful.' . "\n";
1324
+	if ($command_line) {
1325
+			echo ' Successful.' . "\n";
1326
+	}
1247 1327
 
1248 1328
 	// Are we doing debug?
1249 1329
 	if (isset($_POST['debug']))
@@ -1253,8 +1333,9 @@  discard block
 block discarded – undo
1253 1333
 	}
1254 1334
 
1255 1335
 	// If we're not backing up then jump one.
1256
-	if (empty($_POST['backup']))
1257
-		$upcontext['current_step']++;
1336
+	if (empty($_POST['backup'])) {
1337
+			$upcontext['current_step']++;
1338
+	}
1258 1339
 
1259 1340
 	// If we've got here then let's proceed to the next step!
1260 1341
 	return true;
@@ -1269,8 +1350,9 @@  discard block
 block discarded – undo
1269 1350
 	$upcontext['page_title'] = 'Backup Database';
1270 1351
 
1271 1352
 	// Done it already - js wise?
1272
-	if (!empty($_POST['backup_done']))
1273
-		return true;
1353
+	if (!empty($_POST['backup_done'])) {
1354
+			return true;
1355
+	}
1274 1356
 
1275 1357
 	// Some useful stuff here.
1276 1358
 	db_extend();
@@ -1284,9 +1366,10 @@  discard block
 block discarded – undo
1284 1366
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1285 1367
 
1286 1368
 	$table_names = array();
1287
-	foreach ($tables as $table)
1288
-		if (substr($table, 0, 7) !== 'backup_')
1369
+	foreach ($tables as $table) {
1370
+			if (substr($table, 0, 7) !== 'backup_')
1289 1371
 			$table_names[] = $table;
1372
+	}
1290 1373
 
1291 1374
 	$upcontext['table_count'] = count($table_names);
1292 1375
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1296,12 +1379,14 @@  discard block
 block discarded – undo
1296 1379
 	$file_steps = $upcontext['table_count'];
1297 1380
 
1298 1381
 	// What ones have we already done?
1299
-	foreach ($table_names as $id => $table)
1300
-		if ($id < $_GET['substep'])
1382
+	foreach ($table_names as $id => $table) {
1383
+			if ($id < $_GET['substep'])
1301 1384
 			$upcontext['previous_tables'][] = $table;
1385
+	}
1302 1386
 
1303
-	if ($command_line)
1304
-		echo 'Backing Up Tables.';
1387
+	if ($command_line) {
1388
+			echo 'Backing Up Tables.';
1389
+	}
1305 1390
 
1306 1391
 	// If we don't support javascript we backup here.
1307 1392
 	if (!$support_js || isset($_GET['xml']))
@@ -1320,8 +1405,9 @@  discard block
 block discarded – undo
1320 1405
 			backupTable($table_names[$substep]);
1321 1406
 
1322 1407
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1323
-			if (isset($_GET['xml']))
1324
-				return upgradeExit();
1408
+			if (isset($_GET['xml'])) {
1409
+							return upgradeExit();
1410
+			}
1325 1411
 		}
1326 1412
 
1327 1413
 		if ($command_line)
@@ -1354,9 +1440,10 @@  discard block
 block discarded – undo
1354 1440
 
1355 1441
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1356 1442
 
1357
-	if ($command_line)
1358
-		echo ' done.';
1359
-}
1443
+	if ($command_line) {
1444
+			echo ' done.';
1445
+	}
1446
+	}
1360 1447
 
1361 1448
 // Step 2: Everything.
1362 1449
 function DatabaseChanges()
@@ -1365,8 +1452,9 @@  discard block
 block discarded – undo
1365 1452
 	global $upcontext, $support_js, $db_type;
1366 1453
 
1367 1454
 	// Have we just completed this?
1368
-	if (!empty($_POST['database_done']))
1369
-		return true;
1455
+	if (!empty($_POST['database_done'])) {
1456
+			return true;
1457
+	}
1370 1458
 
1371 1459
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1372 1460
 	$upcontext['page_title'] = 'Database Changes';
@@ -1381,15 +1469,16 @@  discard block
 block discarded – undo
1381 1469
 	);
1382 1470
 
1383 1471
 	// How many files are there in total?
1384
-	if (isset($_GET['filecount']))
1385
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1386
-	else
1472
+	if (isset($_GET['filecount'])) {
1473
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1474
+	} else
1387 1475
 	{
1388 1476
 		$upcontext['file_count'] = 0;
1389 1477
 		foreach ($files as $file)
1390 1478
 		{
1391
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1392
-				$upcontext['file_count']++;
1479
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1480
+							$upcontext['file_count']++;
1481
+			}
1393 1482
 		}
1394 1483
 	}
1395 1484
 
@@ -1399,9 +1488,9 @@  discard block
 block discarded – undo
1399 1488
 	$upcontext['cur_file_num'] = 0;
1400 1489
 	foreach ($files as $file)
1401 1490
 	{
1402
-		if ($did_not_do)
1403
-			$did_not_do--;
1404
-		else
1491
+		if ($did_not_do) {
1492
+					$did_not_do--;
1493
+		} else
1405 1494
 		{
1406 1495
 			$upcontext['cur_file_num']++;
1407 1496
 			$upcontext['cur_file_name'] = $file[0];
@@ -1428,12 +1517,13 @@  discard block
 block discarded – undo
1428 1517
 					// Flag to move on to the next.
1429 1518
 					$upcontext['completed_step'] = true;
1430 1519
 					// Did we complete the whole file?
1431
-					if ($nextFile)
1432
-						$upcontext['current_debug_item_num'] = -1;
1520
+					if ($nextFile) {
1521
+											$upcontext['current_debug_item_num'] = -1;
1522
+					}
1433 1523
 					return upgradeExit();
1524
+				} elseif ($support_js) {
1525
+									break;
1434 1526
 				}
1435
-				elseif ($support_js)
1436
-					break;
1437 1527
 			}
1438 1528
 			// Set the progress bar to be right as if we had - even if we hadn't...
1439 1529
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1458,8 +1548,9 @@  discard block
 block discarded – undo
1458 1548
 	global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1459 1549
 
1460 1550
 	// Now it's nice to have some of the basic SMF source files.
1461
-	if (!isset($_GET['ssi']) && !$command_line)
1462
-		redirectLocation('&ssi=1');
1551
+	if (!isset($_GET['ssi']) && !$command_line) {
1552
+			redirectLocation('&ssi=1');
1553
+	}
1463 1554
 
1464 1555
 	$upcontext['sub_template'] = 'upgrade_complete';
1465 1556
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1475,14 +1566,16 @@  discard block
 block discarded – undo
1475 1566
 	// Are we in maintenance mode?
1476 1567
 	if (isset($upcontext['user']['main']))
1477 1568
 	{
1478
-		if ($command_line)
1479
-			echo ' * ';
1569
+		if ($command_line) {
1570
+					echo ' * ';
1571
+		}
1480 1572
 		$upcontext['removed_maintenance'] = true;
1481 1573
 		$changes['maintenance'] = $upcontext['user']['main'];
1482 1574
 	}
1483 1575
 	// Otherwise if somehow we are in 2 let's go to 1.
1484
-	elseif (!empty($maintenance) && $maintenance == 2)
1485
-		$changes['maintenance'] = 1;
1576
+	elseif (!empty($maintenance) && $maintenance == 2) {
1577
+			$changes['maintenance'] = 1;
1578
+	}
1486 1579
 
1487 1580
 	// Wipe this out...
1488 1581
 	$upcontext['user'] = array();
@@ -1497,9 +1590,9 @@  discard block
 block discarded – undo
1497 1590
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1498 1591
 
1499 1592
 	// Now is the perfect time to fetch the SM files.
1500
-	if ($command_line)
1501
-		cli_scheduled_fetchSMfiles();
1502
-	else
1593
+	if ($command_line) {
1594
+			cli_scheduled_fetchSMfiles();
1595
+	} else
1503 1596
 	{
1504 1597
 		require_once($sourcedir . '/ScheduledTasks.php');
1505 1598
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1507,8 +1600,9 @@  discard block
 block discarded – undo
1507 1600
 	}
1508 1601
 
1509 1602
 	// Log what we've done.
1510
-	if (empty($user_info['id']))
1511
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1603
+	if (empty($user_info['id'])) {
1604
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1605
+	}
1512 1606
 
1513 1607
 	// Log the action manually, so CLI still works.
1514 1608
 	$smcFunc['db_insert']('',
@@ -1527,8 +1621,9 @@  discard block
 block discarded – undo
1527 1621
 
1528 1622
 	// Save the current database version.
1529 1623
 	$server_version = $smcFunc['db_server_info']();
1530
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1531
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1624
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1625
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1626
+	}
1532 1627
 
1533 1628
 	if ($command_line)
1534 1629
 	{
@@ -1540,8 +1635,9 @@  discard block
 block discarded – undo
1540 1635
 
1541 1636
 	// Make sure it says we're done.
1542 1637
 	$upcontext['overall_percent'] = 100;
1543
-	if (isset($upcontext['step_progress']))
1544
-		unset($upcontext['step_progress']);
1638
+	if (isset($upcontext['step_progress'])) {
1639
+			unset($upcontext['step_progress']);
1640
+	}
1545 1641
 
1546 1642
 	$_GET['substep'] = 0;
1547 1643
 	return false;
@@ -1552,8 +1648,9 @@  discard block
 block discarded – undo
1552 1648
 {
1553 1649
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1554 1650
 
1555
-	if (empty($modSettings['time_format']))
1556
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1651
+	if (empty($modSettings['time_format'])) {
1652
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1653
+	}
1557 1654
 
1558 1655
 	// What files do we want to get
1559 1656
 	$request = $smcFunc['db_query']('', '
@@ -1587,8 +1684,9 @@  discard block
 block discarded – undo
1587 1684
 		$file_data = fetch_web_data($url);
1588 1685
 
1589 1686
 		// If we got an error - give up - the site might be down.
1590
-		if ($file_data === false)
1591
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1687
+		if ($file_data === false) {
1688
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1689
+		}
1592 1690
 
1593 1691
 		// Save the file to the database.
1594 1692
 		$smcFunc['db_query']('substring', '
@@ -1630,8 +1728,9 @@  discard block
 block discarded – undo
1630 1728
 	$themeData = array();
1631 1729
 	foreach ($values as $variable => $value)
1632 1730
 	{
1633
-		if (!isset($value) || $value === null)
1634
-			$value = 0;
1731
+		if (!isset($value) || $value === null) {
1732
+					$value = 0;
1733
+		}
1635 1734
 
1636 1735
 		$themeData[] = array(0, 1, $variable, $value);
1637 1736
 	}
@@ -1660,8 +1759,9 @@  discard block
 block discarded – undo
1660 1759
 
1661 1760
 	foreach ($values as $variable => $value)
1662 1761
 	{
1663
-		if (empty($modSettings[$value[0]]))
1664
-			continue;
1762
+		if (empty($modSettings[$value[0]])) {
1763
+					continue;
1764
+		}
1665 1765
 
1666 1766
 		$smcFunc['db_query']('', '
1667 1767
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1747,19 +1847,21 @@  discard block
 block discarded – undo
1747 1847
 	set_error_handler(
1748 1848
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1749 1849
 		{
1750
-			if ($support_js)
1751
-				return true;
1752
-			else
1753
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1850
+			if ($support_js) {
1851
+							return true;
1852
+			} else {
1853
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1854
+			}
1754 1855
 		}
1755 1856
 	);
1756 1857
 
1757 1858
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1758 1859
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1759
-	if ($db_type == 'mysql')
1760
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1761
-	else
1762
-		$db_collation = '';
1860
+	if ($db_type == 'mysql') {
1861
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1862
+	} else {
1863
+			$db_collation = '';
1864
+	}
1763 1865
 
1764 1866
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1765 1867
 
@@ -1771,8 +1873,9 @@  discard block
 block discarded – undo
1771 1873
 	$last_step = '';
1772 1874
 
1773 1875
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1774
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1775
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1876
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1877
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1878
+	}
1776 1879
 
1777 1880
 	// Count the total number of steps within this file - for progress.
1778 1881
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1792,15 +1895,18 @@  discard block
 block discarded – undo
1792 1895
 		$do_current = $substep >= $_GET['substep'];
1793 1896
 
1794 1897
 		// Get rid of any comments in the beginning of the line...
1795
-		if (substr(trim($line), 0, 2) === '/*')
1796
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1898
+		if (substr(trim($line), 0, 2) === '/*') {
1899
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1900
+		}
1797 1901
 
1798 1902
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1799
-		if ($is_debug && !$support_js && $command_line)
1800
-			flush();
1903
+		if ($is_debug && !$support_js && $command_line) {
1904
+					flush();
1905
+		}
1801 1906
 
1802
-		if (trim($line) === '')
1803
-			continue;
1907
+		if (trim($line) === '') {
1908
+					continue;
1909
+		}
1804 1910
 
1805 1911
 		if (trim(substr($line, 0, 3)) === '---')
1806 1912
 		{
@@ -1810,8 +1916,9 @@  discard block
 block discarded – undo
1810 1916
 			if (trim($current_data) != '' && $type !== '}')
1811 1917
 			{
1812 1918
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1813
-				if ($command_line)
1814
-					echo $upcontext['error_message'];
1919
+				if ($command_line) {
1920
+									echo $upcontext['error_message'];
1921
+				}
1815 1922
 			}
1816 1923
 
1817 1924
 			if ($type == ' ')
@@ -1829,17 +1936,18 @@  discard block
 block discarded – undo
1829 1936
 				if ($do_current)
1830 1937
 				{
1831 1938
 					$upcontext['actioned_items'][] = $last_step;
1832
-					if ($command_line)
1833
-						echo ' * ';
1939
+					if ($command_line) {
1940
+											echo ' * ';
1941
+					}
1834 1942
 				}
1835
-			}
1836
-			elseif ($type == '#')
1943
+			} elseif ($type == '#')
1837 1944
 			{
1838 1945
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1839 1946
 
1840 1947
 				$upcontext['current_debug_item_num']++;
1841
-				if (trim($line) != '---#')
1842
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1948
+				if (trim($line) != '---#') {
1949
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1950
+				}
1843 1951
 
1844 1952
 				// Have we already done something?
1845 1953
 				if (isset($_GET['xml']) && $done_something)
@@ -1850,34 +1958,36 @@  discard block
 block discarded – undo
1850 1958
 
1851 1959
 				if ($do_current)
1852 1960
 				{
1853
-					if (trim($line) == '---#' && $command_line)
1854
-						echo ' done.', $endl;
1855
-					elseif ($command_line)
1856
-						echo ' +++ ', rtrim(substr($line, 4));
1857
-					elseif (trim($line) != '---#')
1961
+					if (trim($line) == '---#' && $command_line) {
1962
+											echo ' done.', $endl;
1963
+					} elseif ($command_line) {
1964
+											echo ' +++ ', rtrim(substr($line, 4));
1965
+					} elseif (trim($line) != '---#')
1858 1966
 					{
1859
-						if ($is_debug)
1860
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1967
+						if ($is_debug) {
1968
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1969
+						}
1861 1970
 					}
1862 1971
 				}
1863 1972
 
1864 1973
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1865 1974
 				{
1866
-					if ($command_line)
1867
-						echo ' * ';
1868
-					else
1869
-						$upcontext['actioned_items'][] = $last_step;
1975
+					if ($command_line) {
1976
+											echo ' * ';
1977
+					} else {
1978
+											$upcontext['actioned_items'][] = $last_step;
1979
+					}
1870 1980
 				}
1871 1981
 
1872 1982
 				// Small step - only if we're actually doing stuff.
1873
-				if ($do_current)
1874
-					nextSubstep(++$substep);
1875
-				else
1876
-					$substep++;
1877
-			}
1878
-			elseif ($type == '{')
1879
-				$current_type = 'code';
1880
-			elseif ($type == '}')
1983
+				if ($do_current) {
1984
+									nextSubstep(++$substep);
1985
+				} else {
1986
+									$substep++;
1987
+				}
1988
+			} elseif ($type == '{') {
1989
+							$current_type = 'code';
1990
+			} elseif ($type == '}')
1881 1991
 			{
1882 1992
 				$current_type = 'sql';
1883 1993
 
@@ -1890,8 +2000,9 @@  discard block
 block discarded – undo
1890 2000
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1891 2001
 				{
1892 2002
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1893
-					if ($command_line)
1894
-						echo $upcontext['error_message'];
2003
+					if ($command_line) {
2004
+											echo $upcontext['error_message'];
2005
+					}
1895 2006
 				}
1896 2007
 
1897 2008
 				// Done with code!
@@ -1971,8 +2082,9 @@  discard block
 block discarded – undo
1971 2082
 	$db_unbuffered = false;
1972 2083
 
1973 2084
 	// Failure?!
1974
-	if ($result !== false)
1975
-		return $result;
2085
+	if ($result !== false) {
2086
+			return $result;
2087
+	}
1976 2088
 
1977 2089
 	$db_error_message = $smcFunc['db_error']($db_connection);
1978 2090
 	// If MySQL we do something more clever.
@@ -2000,54 +2112,61 @@  discard block
 block discarded – undo
2000 2112
 			{
2001 2113
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2002 2114
 				$result = mysqli_query($db_connection, $string);
2003
-				if ($result !== false)
2004
-					return $result;
2115
+				if ($result !== false) {
2116
+									return $result;
2117
+				}
2005 2118
 			}
2006
-		}
2007
-		elseif ($mysqli_errno == 2013)
2119
+		} elseif ($mysqli_errno == 2013)
2008 2120
 		{
2009 2121
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2010 2122
 			mysqli_select_db($db_connection, $db_name);
2011 2123
 			if ($db_connection)
2012 2124
 			{
2013 2125
 				$result = mysqli_query($db_connection, $string);
2014
-				if ($result !== false)
2015
-					return $result;
2126
+				if ($result !== false) {
2127
+									return $result;
2128
+				}
2016 2129
 			}
2017 2130
 		}
2018 2131
 		// Duplicate column name... should be okay ;).
2019
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2020
-			return false;
2132
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2133
+					return false;
2134
+		}
2021 2135
 		// Duplicate insert... make sure it's the proper type of query ;).
2022
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2023
-			return false;
2136
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2137
+					return false;
2138
+		}
2024 2139
 		// Creating an index on a non-existent column.
2025
-		elseif ($mysqli_errno == 1072)
2026
-			return false;
2027
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2028
-			return false;
2140
+		elseif ($mysqli_errno == 1072) {
2141
+					return false;
2142
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2143
+					return false;
2144
+		}
2029 2145
 	}
2030 2146
 	// If a table already exists don't go potty.
2031 2147
 	else
2032 2148
 	{
2033 2149
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2034 2150
 		{
2035
-			if (strpos($db_error_message, 'exist') !== false)
2036
-				return true;
2037
-		}
2038
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2151
+			if (strpos($db_error_message, 'exist') !== false) {
2152
+							return true;
2153
+			}
2154
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2039 2155
 		{
2040
-			if (strpos($db_error_message, 'duplicate') !== false)
2041
-				return true;
2156
+			if (strpos($db_error_message, 'duplicate') !== false) {
2157
+							return true;
2158
+			}
2042 2159
 		}
2043 2160
 	}
2044 2161
 
2045 2162
 	// Get the query string so we pass everything.
2046 2163
 	$query_string = '';
2047
-	foreach ($_GET as $k => $v)
2048
-		$query_string .= ';' . $k . '=' . $v;
2049
-	if (strlen($query_string) != 0)
2050
-		$query_string = '?' . substr($query_string, 1);
2164
+	foreach ($_GET as $k => $v) {
2165
+			$query_string .= ';' . $k . '=' . $v;
2166
+	}
2167
+	if (strlen($query_string) != 0) {
2168
+			$query_string = '?' . substr($query_string, 1);
2169
+	}
2051 2170
 
2052 2171
 	if ($command_line)
2053 2172
 	{
@@ -2102,16 +2221,18 @@  discard block
 block discarded – undo
2102 2221
 			{
2103 2222
 				$found |= 1;
2104 2223
 				// Do some checks on the data if we have it set.
2105
-				if (isset($change['col_type']))
2106
-					$found &= $change['col_type'] === $column['type'];
2107
-				if (isset($change['null_allowed']))
2108
-					$found &= $column['null'] == $change['null_allowed'];
2109
-				if (isset($change['default']))
2110
-					$found &= $change['default'] === $column['default'];
2224
+				if (isset($change['col_type'])) {
2225
+									$found &= $change['col_type'] === $column['type'];
2226
+				}
2227
+				if (isset($change['null_allowed'])) {
2228
+									$found &= $column['null'] == $change['null_allowed'];
2229
+				}
2230
+				if (isset($change['default'])) {
2231
+									$found &= $change['default'] === $column['default'];
2232
+				}
2111 2233
 			}
2112 2234
 		}
2113
-	}
2114
-	elseif ($change['type'] === 'index')
2235
+	} elseif ($change['type'] === 'index')
2115 2236
 	{
2116 2237
 		$request = upgrade_query('
2117 2238
 			SHOW INDEX
@@ -2120,9 +2241,10 @@  discard block
 block discarded – undo
2120 2241
 		{
2121 2242
 			$cur_index = array();
2122 2243
 
2123
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2124
-				if ($row['Key_name'] === $change['name'])
2244
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2245
+							if ($row['Key_name'] === $change['name'])
2125 2246
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2247
+			}
2126 2248
 
2127 2249
 			ksort($cur_index, SORT_NUMERIC);
2128 2250
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2132,14 +2254,17 @@  discard block
 block discarded – undo
2132 2254
 	}
2133 2255
 
2134 2256
 	// If we're trying to add and it's added, we're done.
2135
-	if ($found && in_array($change['method'], array('add', 'change')))
2136
-		return true;
2257
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2258
+			return true;
2259
+	}
2137 2260
 	// Otherwise if we're removing and it wasn't found we're also done.
2138
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2139
-		return true;
2261
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2262
+			return true;
2263
+	}
2140 2264
 	// Otherwise is it just a test?
2141
-	elseif ($is_test)
2142
-		return false;
2265
+	elseif ($is_test) {
2266
+			return false;
2267
+	}
2143 2268
 
2144 2269
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2145 2270
 	$running = false;
@@ -2150,8 +2275,9 @@  discard block
 block discarded – undo
2150 2275
 			SHOW FULL PROCESSLIST');
2151 2276
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2152 2277
 		{
2153
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2154
-				$found = true;
2278
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2279
+							$found = true;
2280
+			}
2155 2281
 		}
2156 2282
 
2157 2283
 		// Can't find it? Then we need to run it fools!
@@ -2163,8 +2289,9 @@  discard block
 block discarded – undo
2163 2289
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2164 2290
 				' . $change['text'], true) !== false;
2165 2291
 
2166
-			if (!$success)
2167
-				return false;
2292
+			if (!$success) {
2293
+							return false;
2294
+			}
2168 2295
 
2169 2296
 			// Return
2170 2297
 			$running = true;
@@ -2206,8 +2333,9 @@  discard block
 block discarded – undo
2206 2333
 			'db_error_skip' => true,
2207 2334
 		)
2208 2335
 	);
2209
-	if ($smcFunc['db_num_rows']($request) === 0)
2210
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2336
+	if ($smcFunc['db_num_rows']($request) === 0) {
2337
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2338
+	}
2211 2339
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2212 2340
 	$smcFunc['db_free_result']($request);
2213 2341
 
@@ -2229,18 +2357,19 @@  discard block
 block discarded – undo
2229 2357
 			)
2230 2358
 		);
2231 2359
 		// No results? Just forget it all together.
2232
-		if ($smcFunc['db_num_rows']($request) === 0)
2233
-			unset($table_row['Collation']);
2234
-		else
2235
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2360
+		if ($smcFunc['db_num_rows']($request) === 0) {
2361
+					unset($table_row['Collation']);
2362
+		} else {
2363
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2364
+		}
2236 2365
 		$smcFunc['db_free_result']($request);
2237 2366
 	}
2238 2367
 
2239 2368
 	if ($column_fix)
2240 2369
 	{
2241 2370
 		// Make sure there are no NULL's left.
2242
-		if ($null_fix)
2243
-			$smcFunc['db_query']('', '
2371
+		if ($null_fix) {
2372
+					$smcFunc['db_query']('', '
2244 2373
 				UPDATE {db_prefix}' . $change['table'] . '
2245 2374
 				SET ' . $change['column'] . ' = {string:default}
2246 2375
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2249,6 +2378,7 @@  discard block
 block discarded – undo
2249 2378
 					'db_error_skip' => true,
2250 2379
 				)
2251 2380
 			);
2381
+		}
2252 2382
 
2253 2383
 		// Do the actual alteration.
2254 2384
 		$smcFunc['db_query']('', '
@@ -2277,8 +2407,9 @@  discard block
 block discarded – undo
2277 2407
 	}
2278 2408
 
2279 2409
 	// Not a column we need to check on?
2280
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2281
-		return;
2410
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2411
+			return;
2412
+	}
2282 2413
 
2283 2414
 	// Break it up you (six|seven).
2284 2415
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2297,13 +2428,13 @@  discard block
 block discarded – undo
2297 2428
 				'new_name' => $temp[2],
2298 2429
 		));
2299 2430
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2300
-		if ($smcFunc['db_num_rows'] != 1)
2301
-			return;
2431
+		if ($smcFunc['db_num_rows'] != 1) {
2432
+					return;
2433
+		}
2302 2434
 
2303 2435
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2304 2436
 		$smcFunc['db_free_result']($request);
2305
-	}
2306
-	else
2437
+	} else
2307 2438
 	{
2308 2439
 		// Do this the old fashion, sure method way.
2309 2440
 		$request = $smcFunc['db_query']('', '
@@ -2314,21 +2445,24 @@  discard block
 block discarded – undo
2314 2445
 		));
2315 2446
 		// Mayday!
2316 2447
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2317
-		if ($smcFunc['db_num_rows'] == 0)
2318
-			return;
2448
+		if ($smcFunc['db_num_rows'] == 0) {
2449
+					return;
2450
+		}
2319 2451
 
2320 2452
 		// Oh where, oh where has my little field gone. Oh where can it be...
2321
-		while ($row = $smcFunc['db_query']($request))
2322
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2453
+		while ($row = $smcFunc['db_query']($request)) {
2454
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2323 2455
 			{
2324 2456
 				$current_type = $row['Type'];
2457
+		}
2325 2458
 				break;
2326 2459
 			}
2327 2460
 	}
2328 2461
 
2329 2462
 	// If this doesn't match, the column may of been altered for a reason.
2330
-	if (trim($current_type) != trim($temp[3]))
2331
-		$temp[3] = $current_type;
2463
+	if (trim($current_type) != trim($temp[3])) {
2464
+			$temp[3] = $current_type;
2465
+	}
2332 2466
 
2333 2467
 	// Piece this back together.
2334 2468
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2340,8 +2474,9 @@  discard block
 block discarded – undo
2340 2474
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2341 2475
 	global $step_progress, $is_debug, $upcontext;
2342 2476
 
2343
-	if ($_GET['substep'] < $substep)
2344
-		$_GET['substep'] = $substep;
2477
+	if ($_GET['substep'] < $substep) {
2478
+			$_GET['substep'] = $substep;
2479
+	}
2345 2480
 
2346 2481
 	if ($command_line)
2347 2482
 	{
@@ -2354,29 +2489,33 @@  discard block
 block discarded – undo
2354 2489
 	}
2355 2490
 
2356 2491
 	@set_time_limit(300);
2357
-	if (function_exists('apache_reset_timeout'))
2358
-		@apache_reset_timeout();
2492
+	if (function_exists('apache_reset_timeout')) {
2493
+			@apache_reset_timeout();
2494
+	}
2359 2495
 
2360
-	if (time() - $start_time <= $timeLimitThreshold)
2361
-		return;
2496
+	if (time() - $start_time <= $timeLimitThreshold) {
2497
+			return;
2498
+	}
2362 2499
 
2363 2500
 	// Do we have some custom step progress stuff?
2364 2501
 	if (!empty($step_progress))
2365 2502
 	{
2366 2503
 		$upcontext['substep_progress'] = 0;
2367 2504
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2368
-		if ($step_progress['current'] > $step_progress['total'])
2369
-			$upcontext['substep_progress'] = 99.9;
2370
-		else
2371
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2505
+		if ($step_progress['current'] > $step_progress['total']) {
2506
+					$upcontext['substep_progress'] = 99.9;
2507
+		} else {
2508
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2509
+		}
2372 2510
 
2373 2511
 		// Make it nicely rounded.
2374 2512
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2375 2513
 	}
2376 2514
 
2377 2515
 	// If this is XML we just exit right away!
2378
-	if (isset($_GET['xml']))
2379
-		return upgradeExit();
2516
+	if (isset($_GET['xml'])) {
2517
+			return upgradeExit();
2518
+	}
2380 2519
 
2381 2520
 	// We're going to pause after this!
2382 2521
 	$upcontext['pause'] = true;
@@ -2384,13 +2523,15 @@  discard block
 block discarded – undo
2384 2523
 	$upcontext['query_string'] = '';
2385 2524
 	foreach ($_GET as $k => $v)
2386 2525
 	{
2387
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2388
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2526
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2527
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2528
+		}
2389 2529
 	}
2390 2530
 
2391 2531
 	// Custom warning?
2392
-	if (!empty($custom_warning))
2393
-		$upcontext['custom_warning'] = $custom_warning;
2532
+	if (!empty($custom_warning)) {
2533
+			$upcontext['custom_warning'] = $custom_warning;
2534
+	}
2394 2535
 
2395 2536
 	upgradeExit();
2396 2537
 }
@@ -2405,25 +2546,26 @@  discard block
 block discarded – undo
2405 2546
 	ob_implicit_flush(true);
2406 2547
 	@set_time_limit(600);
2407 2548
 
2408
-	if (!isset($_SERVER['argv']))
2409
-		$_SERVER['argv'] = array();
2549
+	if (!isset($_SERVER['argv'])) {
2550
+			$_SERVER['argv'] = array();
2551
+	}
2410 2552
 	$_GET['maint'] = 1;
2411 2553
 
2412 2554
 	foreach ($_SERVER['argv'] as $i => $arg)
2413 2555
 	{
2414
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2415
-			$_GET['lang'] = $match[1];
2416
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2417
-			continue;
2418
-		elseif ($arg == '--no-maintenance')
2419
-			$_GET['maint'] = 0;
2420
-		elseif ($arg == '--debug')
2421
-			$is_debug = true;
2422
-		elseif ($arg == '--backup')
2423
-			$_POST['backup'] = 1;
2424
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2425
-			$_GET['conv'] = 1;
2426
-		elseif ($i != 0)
2556
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2557
+					$_GET['lang'] = $match[1];
2558
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2559
+					continue;
2560
+		} elseif ($arg == '--no-maintenance') {
2561
+					$_GET['maint'] = 0;
2562
+		} elseif ($arg == '--debug') {
2563
+					$is_debug = true;
2564
+		} elseif ($arg == '--backup') {
2565
+					$_POST['backup'] = 1;
2566
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2567
+					$_GET['conv'] = 1;
2568
+		} elseif ($i != 0)
2427 2569
 		{
2428 2570
 			echo 'SMF Command-line Upgrader
2429 2571
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2437,10 +2579,12 @@  discard block
 block discarded – undo
2437 2579
 		}
2438 2580
 	}
2439 2581
 
2440
-	if (!php_version_check())
2441
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2442
-	if (!db_version_check())
2443
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2582
+	if (!php_version_check()) {
2583
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2584
+	}
2585
+	if (!db_version_check()) {
2586
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2587
+	}
2444 2588
 
2445 2589
 	// Do some checks to make sure they have proper privileges
2446 2590
 	db_extend('packages');
@@ -2455,34 +2599,39 @@  discard block
 block discarded – undo
2455 2599
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2456 2600
 
2457 2601
 	// Sorry... we need CREATE, ALTER and DROP
2458
-	if (!$create || !$alter || !$drop)
2459
-		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);
2602
+	if (!$create || !$alter || !$drop) {
2603
+			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);
2604
+	}
2460 2605
 
2461 2606
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2462 2607
 		&& @file_exists($sourcedir . '/QueryString.php')
2463 2608
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2464
-	if (!$check && !isset($modSettings['smfVersion']))
2465
-		print_error('Error: Some files are missing or out-of-date.', true);
2609
+	if (!$check && !isset($modSettings['smfVersion'])) {
2610
+			print_error('Error: Some files are missing or out-of-date.', true);
2611
+	}
2466 2612
 
2467 2613
 	// Do a quick version spot check.
2468 2614
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2469 2615
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2470
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2471
-		print_error('Error: Some files have not yet been updated properly.');
2616
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2617
+			print_error('Error: Some files have not yet been updated properly.');
2618
+	}
2472 2619
 
2473 2620
 	// Make sure Settings.php is writable.
2474 2621
 	quickFileWritable($boarddir . '/Settings.php');
2475
-	if (!is_writable($boarddir . '/Settings.php'))
2476
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2622
+	if (!is_writable($boarddir . '/Settings.php')) {
2623
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2624
+	}
2477 2625
 
2478 2626
 	// Make sure Settings_bak.php is writable.
2479 2627
 	quickFileWritable($boarddir . '/Settings_bak.php');
2480
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2481
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2628
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2629
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2630
+	}
2482 2631
 
2483
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2484
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2485
-	elseif (isset($modSettings['agreement']))
2632
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2633
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2634
+	} elseif (isset($modSettings['agreement']))
2486 2635
 	{
2487 2636
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2488 2637
 		fwrite($fp, $modSettings['agreement']);
@@ -2492,36 +2641,42 @@  discard block
 block discarded – undo
2492 2641
 	// Make sure Themes is writable.
2493 2642
 	quickFileWritable($modSettings['theme_dir']);
2494 2643
 
2495
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2496
-		print_error('Error: Unable to obtain write access to "Themes".');
2644
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2645
+			print_error('Error: Unable to obtain write access to "Themes".');
2646
+	}
2497 2647
 
2498 2648
 	// Make sure cache directory exists and is writable!
2499 2649
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2500
-	if (!file_exists($cachedir_temp))
2501
-		@mkdir($cachedir_temp);
2650
+	if (!file_exists($cachedir_temp)) {
2651
+			@mkdir($cachedir_temp);
2652
+	}
2502 2653
 
2503 2654
 	// Make sure the cache temp dir is writable.
2504 2655
 	quickFileWritable($cachedir_temp);
2505 2656
 
2506
-	if (!is_writable($cachedir_temp))
2507
-		print_error('Error: Unable to obtain write access to "cache".', true);
2657
+	if (!is_writable($cachedir_temp)) {
2658
+			print_error('Error: Unable to obtain write access to "cache".', true);
2659
+	}
2508 2660
 
2509 2661
 	// Make sure db_last_error.php is writable.
2510 2662
 	quickFileWritable($cachedir_temp . '/db_last_error.php');
2511
-	if (!is_writable($cachedir_temp . '/db_last_error.php'))
2512
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2663
+	if (!is_writable($cachedir_temp . '/db_last_error.php')) {
2664
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2665
+	}
2513 2666
 
2514
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2515
-		print_error('Error: Unable to find language files!', true);
2516
-	else
2667
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2668
+			print_error('Error: Unable to find language files!', true);
2669
+	} else
2517 2670
 	{
2518 2671
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2519 2672
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2520 2673
 
2521
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2522
-			print_error('Error: Language files out of date.', true);
2523
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2524
-			print_error('Error: Install language is missing for selected language.', true);
2674
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2675
+					print_error('Error: Language files out of date.', true);
2676
+		}
2677
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2678
+					print_error('Error: Install language is missing for selected language.', true);
2679
+		}
2525 2680
 
2526 2681
 		// Otherwise include it!
2527 2682
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2540,8 +2695,9 @@  discard block
 block discarded – undo
2540 2695
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2541 2696
 
2542 2697
 	// Done it already?
2543
-	if (!empty($_POST['utf8_done']))
2544
-		return true;
2698
+	if (!empty($_POST['utf8_done'])) {
2699
+			return true;
2700
+	}
2545 2701
 
2546 2702
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2547 2703
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2554,8 +2710,7 @@  discard block
 block discarded – undo
2554 2710
 		);
2555 2711
 
2556 2712
 		return true;
2557
-	}
2558
-	else
2713
+	} else
2559 2714
 	{
2560 2715
 		$upcontext['page_title'] = 'Converting to UTF8';
2561 2716
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2599,8 +2754,9 @@  discard block
 block discarded – undo
2599 2754
 			)
2600 2755
 		);
2601 2756
 		$db_charsets = array();
2602
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2603
-			$db_charsets[] = $row['Charset'];
2757
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2758
+					$db_charsets[] = $row['Charset'];
2759
+		}
2604 2760
 
2605 2761
 		$smcFunc['db_free_result']($request);
2606 2762
 
@@ -2636,13 +2792,15 @@  discard block
 block discarded – undo
2636 2792
 		// If there's a fulltext index, we need to drop it first...
2637 2793
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2638 2794
 		{
2639
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2640
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2795
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2796
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2641 2797
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2798
+			}
2642 2799
 			$smcFunc['db_free_result']($request);
2643 2800
 
2644
-			if (isset($upcontext['fulltext_index']))
2645
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2801
+			if (isset($upcontext['fulltext_index'])) {
2802
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2803
+			}
2646 2804
 		}
2647 2805
 
2648 2806
 		// Drop it and make a note...
@@ -2832,8 +2990,9 @@  discard block
 block discarded – undo
2832 2990
 			$replace = '%field%';
2833 2991
 
2834 2992
 			// Build a huge REPLACE statement...
2835
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2836
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2993
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2994
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2995
+			}
2837 2996
 		}
2838 2997
 
2839 2998
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2843,9 +3002,10 @@  discard block
 block discarded – undo
2843 3002
 		$upcontext['table_count'] = count($queryTables);
2844 3003
 
2845 3004
 		// What ones have we already done?
2846
-		foreach ($queryTables as $id => $table)
2847
-			if ($id < $_GET['substep'])
3005
+		foreach ($queryTables as $id => $table) {
3006
+					if ($id < $_GET['substep'])
2848 3007
 				$upcontext['previous_tables'][] = $table;
3008
+		}
2849 3009
 
2850 3010
 		$upcontext['cur_table_num'] = $_GET['substep'];
2851 3011
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2882,8 +3042,9 @@  discard block
 block discarded – undo
2882 3042
 			nextSubstep($substep);
2883 3043
 
2884 3044
 			// Just to make sure it doesn't time out.
2885
-			if (function_exists('apache_reset_timeout'))
2886
-				@apache_reset_timeout();
3045
+			if (function_exists('apache_reset_timeout')) {
3046
+							@apache_reset_timeout();
3047
+			}
2887 3048
 
2888 3049
 			$table_charsets = array();
2889 3050
 
@@ -2906,8 +3067,9 @@  discard block
 block discarded – undo
2906 3067
 
2907 3068
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2908 3069
 						if ($charset != 'utf8') {
2909
-							if (!isset($table_charsets[$charset]))
2910
-								$table_charsets[$charset] = array();
3070
+							if (!isset($table_charsets[$charset])) {
3071
+															$table_charsets[$charset] = array();
3072
+							}
2911 3073
 
2912 3074
 							$table_charsets[$charset][] = $column_info;
2913 3075
 						}
@@ -2948,10 +3110,11 @@  discard block
 block discarded – undo
2948 3110
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2949 3111
 				{
2950 3112
 					$update = '';
2951
-					foreach ($table_charsets as $charset => $columns)
2952
-						foreach ($columns as $column)
3113
+					foreach ($table_charsets as $charset => $columns) {
3114
+											foreach ($columns as $column)
2953 3115
 							$update .= '
2954 3116
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3117
+					}
2955 3118
 
2956 3119
 					$smcFunc['db_query']('', '
2957 3120
 						UPDATE {raw:table_name}
@@ -2976,8 +3139,9 @@  discard block
 block discarded – undo
2976 3139
 			// Now do the actual conversion (if still needed).
2977 3140
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2978 3141
 			{
2979
-				if ($command_line)
2980
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3142
+				if ($command_line) {
3143
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3144
+				}
2981 3145
 
2982 3146
 				$smcFunc['db_query']('', '
2983 3147
 					ALTER TABLE {raw:table_name}
@@ -2987,12 +3151,14 @@  discard block
 block discarded – undo
2987 3151
 					)
2988 3152
 				);
2989 3153
 
2990
-				if ($command_line)
2991
-					echo " done.\n";
3154
+				if ($command_line) {
3155
+									echo " done.\n";
3156
+				}
2992 3157
 			}
2993 3158
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2994
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
2995
-				return upgradeExit();
3159
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3160
+							return upgradeExit();
3161
+			}
2996 3162
 		}
2997 3163
 
2998 3164
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -3021,8 +3187,8 @@  discard block
 block discarded – undo
3021 3187
 		);
3022 3188
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3023 3189
 		{
3024
-			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)
3025
-				$smcFunc['db_query']('', '
3190
+			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) {
3191
+							$smcFunc['db_query']('', '
3026 3192
 					UPDATE {db_prefix}log_actions
3027 3193
 					SET extra = {string:extra}
3028 3194
 					WHERE id_action = {int:current_action}',
@@ -3031,6 +3197,7 @@  discard block
 block discarded – undo
3031 3197
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3032 3198
 					)
3033 3199
 				);
3200
+			}
3034 3201
 		}
3035 3202
 		$smcFunc['db_free_result']($request);
3036 3203
 
@@ -3052,15 +3219,17 @@  discard block
 block discarded – undo
3052 3219
 	// First thing's first - did we already do this?
3053 3220
 	if (!empty($modSettings['json_done']))
3054 3221
 	{
3055
-		if ($command_line)
3056
-			return DeleteUpgrade();
3057
-		else
3058
-			return true;
3222
+		if ($command_line) {
3223
+					return DeleteUpgrade();
3224
+		} else {
3225
+					return true;
3226
+		}
3059 3227
 	}
3060 3228
 
3061 3229
 	// Done it already - js wise?
3062
-	if (!empty($_POST['json_done']))
3063
-		return true;
3230
+	if (!empty($_POST['json_done'])) {
3231
+			return true;
3232
+	}
3064 3233
 
3065 3234
 	// List of tables affected by this function
3066 3235
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3092,12 +3261,14 @@  discard block
 block discarded – undo
3092 3261
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3093 3262
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3094 3263
 
3095
-	foreach ($keys as $id => $table)
3096
-		if ($id < $_GET['substep'])
3264
+	foreach ($keys as $id => $table) {
3265
+			if ($id < $_GET['substep'])
3097 3266
 			$upcontext['previous_tables'][] = $table;
3267
+	}
3098 3268
 
3099
-	if ($command_line)
3100
-		echo 'Converting data from serialize() to json_encode().';
3269
+	if ($command_line) {
3270
+			echo 'Converting data from serialize() to json_encode().';
3271
+	}
3101 3272
 
3102 3273
 	if (!$support_js || isset($_GET['xml']))
3103 3274
 	{
@@ -3137,8 +3308,9 @@  discard block
 block discarded – undo
3137 3308
 
3138 3309
 				// Loop through and fix these...
3139 3310
 				$new_settings = array();
3140
-				if ($command_line)
3141
-					echo "\n" . 'Fixing some settings...';
3311
+				if ($command_line) {
3312
+									echo "\n" . 'Fixing some settings...';
3313
+				}
3142 3314
 
3143 3315
 				foreach ($serialized_settings as $var)
3144 3316
 				{
@@ -3146,22 +3318,24 @@  discard block
 block discarded – undo
3146 3318
 					{
3147 3319
 						// Attempt to unserialize the setting
3148 3320
 						$temp = @safe_unserialize($modSettings[$var]);
3149
-						if (!$temp && $command_line)
3150
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3151
-						elseif ($temp !== false)
3152
-							$new_settings[$var] = json_encode($temp);
3321
+						if (!$temp && $command_line) {
3322
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3323
+						} elseif ($temp !== false) {
3324
+													$new_settings[$var] = json_encode($temp);
3325
+						}
3153 3326
 					}
3154 3327
 				}
3155 3328
 
3156 3329
 				// Update everything at once
3157
-				if (!function_exists('cache_put_data'))
3158
-					require_once($sourcedir . '/Load.php');
3330
+				if (!function_exists('cache_put_data')) {
3331
+									require_once($sourcedir . '/Load.php');
3332
+				}
3159 3333
 				updateSettings($new_settings, true);
3160 3334
 
3161
-				if ($command_line)
3162
-					echo ' done.';
3163
-			}
3164
-			elseif ($table == 'themes')
3335
+				if ($command_line) {
3336
+									echo ' done.';
3337
+				}
3338
+			} elseif ($table == 'themes')
3165 3339
 			{
3166 3340
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3167 3341
 				$query = $smcFunc['db_query']('', '
@@ -3180,10 +3354,11 @@  discard block
 block discarded – undo
3180 3354
 
3181 3355
 						if ($command_line)
3182 3356
 						{
3183
-							if ($temp === false)
3184
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3185
-							else
3186
-								echo "\n" . 'Fixing admin preferences...';
3357
+							if ($temp === false) {
3358
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3359
+							} else {
3360
+															echo "\n" . 'Fixing admin preferences...';
3361
+							}
3187 3362
 						}
3188 3363
 
3189 3364
 						if ($temp !== false)
@@ -3205,15 +3380,15 @@  discard block
 block discarded – undo
3205 3380
 								)
3206 3381
 							);
3207 3382
 
3208
-							if ($command_line)
3209
-								echo ' done.';
3383
+							if ($command_line) {
3384
+															echo ' done.';
3385
+							}
3210 3386
 						}
3211 3387
 					}
3212 3388
 
3213 3389
 					$smcFunc['db_free_result']($query);
3214 3390
 				}
3215
-			}
3216
-			else
3391
+			} else
3217 3392
 			{
3218 3393
 				// First item is always the key...
3219 3394
 				$key = $info[0];
@@ -3224,8 +3399,7 @@  discard block
 block discarded – undo
3224 3399
 				{
3225 3400
 					$col_select = $info[1];
3226 3401
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3227
-				}
3228
-				else
3402
+				} else
3229 3403
 				{
3230 3404
 					$col_select = implode(', ', $info);
3231 3405
 				}
@@ -3258,8 +3432,7 @@  discard block
 block discarded – undo
3258 3432
 								if ($temp === false && $command_line)
3259 3433
 								{
3260 3434
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3261
-								}
3262
-								else
3435
+								} else
3263 3436
 								{
3264 3437
 									$row[$col] = json_encode($temp);
3265 3438
 
@@ -3284,16 +3457,18 @@  discard block
 block discarded – undo
3284 3457
 						}
3285 3458
 					}
3286 3459
 
3287
-					if ($command_line)
3288
-						echo ' done.';
3460
+					if ($command_line) {
3461
+											echo ' done.';
3462
+					}
3289 3463
 
3290 3464
 					// Free up some memory...
3291 3465
 					$smcFunc['db_free_result']($query);
3292 3466
 				}
3293 3467
 			}
3294 3468
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3295
-			if (isset($_GET['xml']))
3296
-				return upgradeExit();
3469
+			if (isset($_GET['xml'])) {
3470
+							return upgradeExit();
3471
+			}
3297 3472
 		}
3298 3473
 
3299 3474
 		if ($command_line)
@@ -3308,8 +3483,9 @@  discard block
 block discarded – undo
3308 3483
 
3309 3484
 		$_GET['substep'] = 0;
3310 3485
 		// Make sure we move on!
3311
-		if ($command_line)
3312
-			return DeleteUpgrade();
3486
+		if ($command_line) {
3487
+					return DeleteUpgrade();
3488
+		}
3313 3489
 
3314 3490
 		return true;
3315 3491
 	}
@@ -3366,14 +3542,16 @@  discard block
 block discarded – undo
3366 3542
 	global $upcontext, $txt, $settings;
3367 3543
 
3368 3544
 	// Don't call me twice!
3369
-	if (!empty($upcontext['chmod_called']))
3370
-		return;
3545
+	if (!empty($upcontext['chmod_called'])) {
3546
+			return;
3547
+	}
3371 3548
 
3372 3549
 	$upcontext['chmod_called'] = true;
3373 3550
 
3374 3551
 	// Nothing?
3375
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3376
-		return;
3552
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3553
+			return;
3554
+	}
3377 3555
 
3378 3556
 	// Was it a problem with Windows?
3379 3557
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3405,11 +3583,12 @@  discard block
 block discarded – undo
3405 3583
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\');
3406 3584
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3407 3585
 
3408
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3409
-		echo '
3586
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3587
+			echo '
3410 3588
 					content.write(\'<hr>\n\t\t\t\');
3411 3589
 					content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\');
3412 3590
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3591
+	}
3413 3592
 
3414 3593
 	echo '
3415 3594
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3417,17 +3596,19 @@  discard block
 block discarded – undo
3417 3596
 				}
3418 3597
 			</script>';
3419 3598
 
3420
-	if (!empty($upcontext['chmod']['ftp_error']))
3421
-		echo '
3599
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3600
+			echo '
3422 3601
 			<div class="error_message red">
3423 3602
 				', $txt['upgrade_ftp_error'], '<br><br>
3424 3603
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3425 3604
 			</div>
3426 3605
 			<br>';
3606
+	}
3427 3607
 
3428
-	if (empty($upcontext['chmod_in_form']))
3429
-		echo '
3608
+	if (empty($upcontext['chmod_in_form'])) {
3609
+			echo '
3430 3610
 	<form action="', $upcontext['form_url'], '" method="post">';
3611
+	}
3431 3612
 
3432 3613
 	echo '
3433 3614
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3462,10 +3643,11 @@  discard block
 block discarded – undo
3462 3643
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div>
3463 3644
 	</div>';
3464 3645
 
3465
-	if (empty($upcontext['chmod_in_form']))
3466
-		echo '
3646
+	if (empty($upcontext['chmod_in_form'])) {
3647
+			echo '
3467 3648
 	</form>';
3468
-}
3649
+	}
3650
+	}
3469 3651
 
3470 3652
 function template_upgrade_above()
3471 3653
 {
@@ -3525,9 +3707,10 @@  discard block
 block discarded – undo
3525 3707
 				<h2>', $txt['upgrade_progress'], '</h2>
3526 3708
 				<ul>';
3527 3709
 
3528
-	foreach ($upcontext['steps'] as $num => $step)
3529
-		echo '
3710
+	foreach ($upcontext['steps'] as $num => $step) {
3711
+			echo '
3530 3712
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3713
+	}
3531 3714
 
3532 3715
 	echo '
3533 3716
 					</ul>
@@ -3540,8 +3723,8 @@  discard block
 block discarded – undo
3540 3723
 				</div>
3541 3724
 			</div>';
3542 3725
 
3543
-	if (isset($upcontext['step_progress']))
3544
-		echo '
3726
+	if (isset($upcontext['step_progress'])) {
3727
+			echo '
3545 3728
 				<br>
3546 3729
 				<br>
3547 3730
 				<div id="progress_bar_step">
@@ -3550,6 +3733,7 @@  discard block
 block discarded – undo
3550 3733
 						<span>', $txt['upgrade_step_progress'], '</span>
3551 3734
 					</div>
3552 3735
 				</div>';
3736
+	}
3553 3737
 
3554 3738
 	echo '
3555 3739
 				<div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div>
@@ -3580,32 +3764,36 @@  discard block
 block discarded – undo
3580 3764
 {
3581 3765
 	global $upcontext, $txt;
3582 3766
 
3583
-	if (!empty($upcontext['pause']))
3584
-		echo '
3767
+	if (!empty($upcontext['pause'])) {
3768
+			echo '
3585 3769
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3586 3770
 
3587 3771
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3588 3772
 								<h3>
3589 3773
 									', $txt['upgrade_paused_overload'], '
3590 3774
 								</h3>';
3775
+	}
3591 3776
 
3592
-	if (!empty($upcontext['custom_warning']))
3593
-		echo '
3777
+	if (!empty($upcontext['custom_warning'])) {
3778
+			echo '
3594 3779
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3595 3780
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3596 3781
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3597 3782
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3598 3783
 								</div>';
3784
+	}
3599 3785
 
3600 3786
 	echo '
3601 3787
 								<div class="righttext" style="margin: 1ex;">';
3602 3788
 
3603
-	if (!empty($upcontext['continue']))
3604
-		echo '
3789
+	if (!empty($upcontext['continue'])) {
3790
+			echo '
3605 3791
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3606
-	if (!empty($upcontext['skip']))
3607
-		echo '
3792
+	}
3793
+	if (!empty($upcontext['skip'])) {
3794
+			echo '
3608 3795
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3796
+	}
3609 3797
 
3610 3798
 	echo '
3611 3799
 								</div>
@@ -3655,11 +3843,12 @@  discard block
 block discarded – undo
3655 3843
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3656 3844
 	<smf>';
3657 3845
 
3658
-	if (!empty($upcontext['get_data']))
3659
-		foreach ($upcontext['get_data'] as $k => $v)
3846
+	if (!empty($upcontext['get_data'])) {
3847
+			foreach ($upcontext['get_data'] as $k => $v)
3660 3848
 			echo '
3661 3849
 		<get key="', $k, '">', $v, '</get>';
3662
-}
3850
+	}
3851
+	}
3663 3852
 
3664 3853
 function template_xml_below()
3665 3854
 {
@@ -3703,8 +3892,8 @@  discard block
 block discarded – undo
3703 3892
 	template_chmod();
3704 3893
 
3705 3894
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3706
-	if ($upcontext['is_large_forum'])
3707
-		echo '
3895
+	if ($upcontext['is_large_forum']) {
3896
+			echo '
3708 3897
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3709 3898
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3710 3899
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3712,10 +3901,11 @@  discard block
 block discarded – undo
3712 3901
 				', $txt['upgrade_warning_lots_data'], '
3713 3902
 			</div>
3714 3903
 		</div>';
3904
+	}
3715 3905
 
3716 3906
 	// A warning message?
3717
-	if (!empty($upcontext['warning']))
3718
-		echo '
3907
+	if (!empty($upcontext['warning'])) {
3908
+			echo '
3719 3909
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3720 3910
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3721 3911
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3723,6 +3913,7 @@  discard block
 block discarded – undo
3723 3913
 				', $upcontext['warning'], '
3724 3914
 			</div>
3725 3915
 		</div>';
3916
+	}
3726 3917
 
3727 3918
 	// Paths are incorrect?
3728 3919
 	echo '
@@ -3738,20 +3929,22 @@  discard block
 block discarded – undo
3738 3929
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3739 3930
 	{
3740 3931
 		$ago = time() - $upcontext['started'];
3741
-		if ($ago < 60)
3742
-			$ago = $ago . ' seconds';
3743
-		elseif ($ago < 3600)
3744
-			$ago = (int) ($ago / 60) . ' minutes';
3745
-		else
3746
-			$ago = (int) ($ago / 3600) . ' hours';
3932
+		if ($ago < 60) {
3933
+					$ago = $ago . ' seconds';
3934
+		} elseif ($ago < 3600) {
3935
+					$ago = (int) ($ago / 60) . ' minutes';
3936
+		} else {
3937
+					$ago = (int) ($ago / 3600) . ' hours';
3938
+		}
3747 3939
 
3748 3940
 		$active = time() - $upcontext['updated'];
3749
-		if ($active < 60)
3750
-			$updated = $active . ' seconds';
3751
-		elseif ($active < 3600)
3752
-			$updated = (int) ($active / 60) . ' minutes';
3753
-		else
3754
-			$updated = (int) ($active / 3600) . ' hours';
3941
+		if ($active < 60) {
3942
+					$updated = $active . ' seconds';
3943
+		} elseif ($active < 3600) {
3944
+					$updated = (int) ($active / 60) . ' minutes';
3945
+		} else {
3946
+					$updated = (int) ($active / 3600) . ' hours';
3947
+		}
3755 3948
 
3756 3949
 		echo '
3757 3950
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3760,16 +3953,18 @@  discard block
 block discarded – undo
3760 3953
 			<div style="padding-left: 6ex;">
3761 3954
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3762 3955
 
3763
-		if ($active < 600)
3764
-			echo '
3956
+		if ($active < 600) {
3957
+					echo '
3765 3958
 				', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '';
3959
+		}
3766 3960
 
3767
-		if ($active > $upcontext['inactive_timeout'])
3768
-			echo '
3961
+		if ($active > $upcontext['inactive_timeout']) {
3962
+					echo '
3769 3963
 				<br><br>',$txt['upgrade_run'], '';
3770
-		else
3771
-			echo '
3964
+		} else {
3965
+					echo '
3772 3966
 				<br><br>', $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!');
3967
+		}
3773 3968
 
3774 3969
 		echo '
3775 3970
 			</div>
@@ -3785,9 +3980,10 @@  discard block
 block discarded – undo
3785 3980
 					<td>
3786 3981
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3787 3982
 
3788
-	if (!empty($upcontext['username_incorrect']))
3789
-		echo '
3983
+	if (!empty($upcontext['username_incorrect'])) {
3984
+			echo '
3790 3985
 						<div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>';
3986
+	}
3791 3987
 
3792 3988
 	echo '
3793 3989
 					</td>
@@ -3798,9 +3994,10 @@  discard block
 block discarded – undo
3798 3994
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3799 3995
 						<input type="hidden" name="hash_passwrd" value="">';
3800 3996
 
3801
-	if (!empty($upcontext['password_failed']))
3802
-		echo '
3997
+	if (!empty($upcontext['password_failed'])) {
3998
+			echo '
3803 3999
 						<div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>';
4000
+	}
3804 4001
 
3805 4002
 	echo '
3806 4003
 					</td>
@@ -3873,8 +4070,8 @@  discard block
 block discarded – undo
3873 4070
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3874 4071
 
3875 4072
 	// Warning message?
3876
-	if (!empty($upcontext['upgrade_options_warning']))
3877
-		echo '
4073
+	if (!empty($upcontext['upgrade_options_warning'])) {
4074
+			echo '
3878 4075
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3879 4076
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3880 4077
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3882,6 +4079,7 @@  discard block
 block discarded – undo
3882 4079
 				', $upcontext['upgrade_options_warning'], '
3883 4080
 			</div>
3884 4081
 		</div>';
4082
+	}
3885 4083
 
3886 4084
 	echo '
3887 4085
 				<table>
@@ -3924,8 +4122,8 @@  discard block
 block discarded – undo
3924 4122
 						</td>
3925 4123
 					</tr>';
3926 4124
 
3927
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3928
-		echo '
4125
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4126
+			echo '
3929 4127
 					<tr valign="top">
3930 4128
 						<td width="2%">
3931 4129
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
@@ -3934,6 +4132,7 @@  discard block
 block discarded – undo
3934 4132
 							<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
3935 4133
 						</td>
3936 4134
 					</tr>';
4135
+	}
3937 4136
 
3938 4137
 	echo '
3939 4138
 					<tr valign="top">
@@ -3971,10 +4170,11 @@  discard block
 block discarded – undo
3971 4170
 			</div>';
3972 4171
 
3973 4172
 	// Dont any tables so far?
3974
-	if (!empty($upcontext['previous_tables']))
3975
-		foreach ($upcontext['previous_tables'] as $table)
4173
+	if (!empty($upcontext['previous_tables'])) {
4174
+			foreach ($upcontext['previous_tables'] as $table)
3976 4175
 			echo '
3977 4176
 			<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4177
+	}
3978 4178
 
3979 4179
 	echo '
3980 4180
 			<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -4011,12 +4211,13 @@  discard block
 block discarded – undo
4011 4211
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4012 4212
 
4013 4213
 		// If debug flood the screen.
4014
-		if ($is_debug)
4015
-			echo '
4214
+		if ($is_debug) {
4215
+					echo '
4016 4216
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4017 4217
 
4018 4218
 				if (document.getElementById(\'debug_section\').scrollHeight)
4019 4219
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4220
+		}
4020 4221
 
4021 4222
 		echo '
4022 4223
 				// Get the next update...
@@ -4049,8 +4250,9 @@  discard block
 block discarded – undo
4049 4250
 {
4050 4251
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt;
4051 4252
 
4052
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4053
-		$is_debug = true;
4253
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4254
+			$is_debug = true;
4255
+	}
4054 4256
 
4055 4257
 	echo '
4056 4258
 		<h3>', $txt['upgrade_db_changes'], '</h3>
@@ -4065,8 +4267,9 @@  discard block
 block discarded – undo
4065 4267
 	{
4066 4268
 		foreach ($upcontext['actioned_items'] as $num => $item)
4067 4269
 		{
4068
-			if ($num != 0)
4069
-				echo ' Successful!';
4270
+			if ($num != 0) {
4271
+							echo ' Successful!';
4272
+			}
4070 4273
 			echo '<br>' . $item;
4071 4274
 		}
4072 4275
 		if (!empty($upcontext['changes_complete']))
@@ -4079,28 +4282,32 @@  discard block
 block discarded – undo
4079 4282
 				$seconds = intval($active % 60);
4080 4283
 
4081 4284
 				$totalTime = '';
4082
-				if ($hours > 0)
4083
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4084
-				if ($minutes > 0)
4085
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4086
-				if ($seconds > 0)
4087
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4285
+				if ($hours > 0) {
4286
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4287
+				}
4288
+				if ($minutes > 0) {
4289
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4290
+				}
4291
+				if ($seconds > 0) {
4292
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4293
+				}
4088 4294
 			}
4089 4295
 
4090
-			if ($is_debug && !empty($totalTime))
4091
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
4092
-			else
4093
-				echo ' Successful!<br><br>';
4296
+			if ($is_debug && !empty($totalTime)) {
4297
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4298
+			} else {
4299
+							echo ' Successful!<br><br>';
4300
+			}
4094 4301
 
4095 4302
 			echo '<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>';
4096 4303
 		}
4097
-	}
4098
-	else
4304
+	} else
4099 4305
 	{
4100 4306
 		// Tell them how many files we have in total.
4101
-		if ($upcontext['file_count'] > 1)
4102
-			echo '
4307
+		if ($upcontext['file_count'] > 1) {
4308
+					echo '
4103 4309
 		<strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4310
+		}
4104 4311
 
4105 4312
 		echo '
4106 4313
 		<h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -4116,19 +4323,23 @@  discard block
 block discarded – undo
4116 4323
 				$seconds = intval($active % 60);
4117 4324
 
4118 4325
 				$totalTime = '';
4119
-				if ($hours > 0)
4120
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4121
-				if ($minutes > 0)
4122
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4123
-				if ($seconds > 0)
4124
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4326
+				if ($hours > 0) {
4327
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4328
+				}
4329
+				if ($minutes > 0) {
4330
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4331
+				}
4332
+				if ($seconds > 0) {
4333
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4334
+				}
4125 4335
 			}
4126 4336
 
4127 4337
 			echo '
4128 4338
 			<br><span id="upgradeCompleted">';
4129 4339
 
4130
-			if (!empty($totalTime))
4131
-				echo 'Completed in ', $totalTime, '<br>';
4340
+			if (!empty($totalTime)) {
4341
+							echo 'Completed in ', $totalTime, '<br>';
4342
+			}
4132 4343
 
4133 4344
 			echo '</span>
4134 4345
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -4165,9 +4376,10 @@  discard block
 block discarded – undo
4165 4376
 			var getData = "";
4166 4377
 			var debugItems = ', $upcontext['debug_items'], ';';
4167 4378
 
4168
-		if ($is_debug)
4169
-			echo '
4379
+		if ($is_debug) {
4380
+					echo '
4170 4381
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4382
+		}
4171 4383
 
4172 4384
 		echo '
4173 4385
 			function getNextItem()
@@ -4207,9 +4419,10 @@  discard block
 block discarded – undo
4207 4419
 						document.getElementById("error_block").style.display = "";
4208 4420
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4209 4421
 
4210
-	if ($is_debug)
4211
-		echo '
4422
+	if ($is_debug) {
4423
+			echo '
4212 4424
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4425
+	}
4213 4426
 
4214 4427
 	echo '
4215 4428
 					}
@@ -4230,9 +4443,10 @@  discard block
 block discarded – undo
4230 4443
 						document.getElementById("error_block").style.display = "";
4231 4444
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4232 4445
 
4233
-	if ($is_debug)
4234
-		echo '
4446
+	if ($is_debug) {
4447
+			echo '
4235 4448
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4449
+	}
4236 4450
 
4237 4451
 	echo '
4238 4452
 					}
@@ -4291,8 +4505,8 @@  discard block
 block discarded – undo
4291 4505
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4292 4506
 				{';
4293 4507
 
4294
-		if ($is_debug)
4295
-			echo '
4508
+		if ($is_debug) {
4509
+					echo '
4296 4510
 					document.getElementById(\'debug_section\').style.display = "none";
4297 4511
 
4298 4512
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4310,6 +4524,7 @@  discard block
 block discarded – undo
4310 4524
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4311 4525
 
4312 4526
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4527
+		}
4313 4528
 
4314 4529
 		echo '
4315 4530
 
@@ -4317,9 +4532,10 @@  discard block
 block discarded – undo
4317 4532
 					document.getElementById(\'contbutt\').disabled = 0;
4318 4533
 					document.getElementById(\'database_done\').value = 1;';
4319 4534
 
4320
-		if ($upcontext['file_count'] > 1)
4321
-			echo '
4535
+		if ($upcontext['file_count'] > 1) {
4536
+					echo '
4322 4537
 					document.getElementById(\'info1\').style.display = "none";';
4538
+		}
4323 4539
 
4324 4540
 		echo '
4325 4541
 					document.getElementById(\'info2\').style.display = "none";
@@ -4332,9 +4548,10 @@  discard block
 block discarded – undo
4332 4548
 					lastItem = 0;
4333 4549
 					prevFile = curFile;';
4334 4550
 
4335
-		if ($is_debug)
4336
-			echo '
4551
+		if ($is_debug) {
4552
+					echo '
4337 4553
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4554
+		}
4338 4555
 
4339 4556
 		echo '
4340 4557
 					getNextItem();
@@ -4342,8 +4559,8 @@  discard block
 block discarded – undo
4342 4559
 				}';
4343 4560
 
4344 4561
 		// If debug scroll the screen.
4345
-		if ($is_debug)
4346
-			echo '
4562
+		if ($is_debug) {
4563
+					echo '
4347 4564
 				if (iLastSubStepProgress == -1)
4348 4565
 				{
4349 4566
 					// Give it consistent dots.
@@ -4362,6 +4579,7 @@  discard block
 block discarded – undo
4362 4579
 
4363 4580
 				if (document.getElementById(\'debug_section\').scrollHeight)
4364 4581
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4582
+		}
4365 4583
 
4366 4584
 		echo '
4367 4585
 				// Update the page.
@@ -4422,9 +4640,10 @@  discard block
 block discarded – undo
4422 4640
 			}';
4423 4641
 
4424 4642
 		// Start things off assuming we've not errored.
4425
-		if (empty($upcontext['error_message']))
4426
-			echo '
4643
+		if (empty($upcontext['error_message'])) {
4644
+					echo '
4427 4645
 			getNextItem();';
4646
+		}
4428 4647
 
4429 4648
 		echo '
4430 4649
 		//# sourceURL=dynamicScript-dbch.js
@@ -4442,18 +4661,21 @@  discard block
 block discarded – undo
4442 4661
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4443 4662
 	<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>';
4444 4663
 
4445
-	if (!empty($upcontext['error_message']))
4446
-		echo '
4664
+	if (!empty($upcontext['error_message'])) {
4665
+			echo '
4447 4666
 	<error>', $upcontext['error_message'], '</error>';
4667
+	}
4448 4668
 
4449
-	if (!empty($upcontext['error_string']))
4450
-		echo '
4669
+	if (!empty($upcontext['error_string'])) {
4670
+			echo '
4451 4671
 	<sql>', $upcontext['error_string'], '</sql>';
4672
+	}
4452 4673
 
4453
-	if ($is_debug)
4454
-		echo '
4674
+	if ($is_debug) {
4675
+			echo '
4455 4676
 	<curtime>', time(), '</curtime>';
4456
-}
4677
+	}
4678
+	}
4457 4679
 
4458 4680
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4459 4681
 function template_convert_utf8()
@@ -4472,18 +4694,20 @@  discard block
 block discarded – undo
4472 4694
 			</div>';
4473 4695
 
4474 4696
 	// Done any tables so far?
4475
-	if (!empty($upcontext['previous_tables']))
4476
-		foreach ($upcontext['previous_tables'] as $table)
4697
+	if (!empty($upcontext['previous_tables'])) {
4698
+			foreach ($upcontext['previous_tables'] as $table)
4477 4699
 			echo '
4478 4700
 			<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4701
+	}
4479 4702
 
4480 4703
 	echo '
4481 4704
 			<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4482 4705
 
4483 4706
 	// If we dropped their index, let's let them know
4484
-	if ($upcontext['dropping_index'])
4485
-		echo '
4707
+	if ($upcontext['dropping_index']) {
4708
+			echo '
4486 4709
 				<br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>';
4710
+	}
4487 4711
 
4488 4712
 	// Completion notification
4489 4713
 	echo '
@@ -4520,12 +4744,13 @@  discard block
 block discarded – undo
4520 4744
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4521 4745
 
4522 4746
 		// If debug flood the screen.
4523
-		if ($is_debug)
4524
-			echo '
4747
+		if ($is_debug) {
4748
+					echo '
4525 4749
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4526 4750
 
4527 4751
 				if (document.getElementById(\'debug_section\').scrollHeight)
4528 4752
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4753
+		}
4529 4754
 
4530 4755
 		echo '
4531 4756
 				// Get the next update...
@@ -4573,19 +4798,21 @@  discard block
 block discarded – undo
4573 4798
 			</div>';
4574 4799
 
4575 4800
 	// Dont any tables so far?
4576
-	if (!empty($upcontext['previous_tables']))
4577
-		foreach ($upcontext['previous_tables'] as $table)
4801
+	if (!empty($upcontext['previous_tables'])) {
4802
+			foreach ($upcontext['previous_tables'] as $table)
4578 4803
 			echo '
4579 4804
 			<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4805
+	}
4580 4806
 
4581 4807
 	echo '
4582 4808
 			<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4583 4809
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>';
4584 4810
 
4585 4811
 	// Try to make sure substep was reset.
4586
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4587
-		echo '
4812
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4813
+			echo '
4588 4814
 			<input type="hidden" name="substep" id="substep" value="0">';
4815
+	}
4589 4816
 
4590 4817
 	// Continue please!
4591 4818
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4618,12 +4845,13 @@  discard block
 block discarded – undo
4618 4845
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4619 4846
 
4620 4847
 		// If debug flood the screen.
4621
-		if ($is_debug)
4622
-			echo '
4848
+		if ($is_debug) {
4849
+					echo '
4623 4850
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4624 4851
 
4625 4852
 				if (document.getElementById(\'debug_section\').scrollHeight)
4626 4853
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4854
+		}
4627 4855
 
4628 4856
 		echo '
4629 4857
 				// Get the next update...
@@ -4662,8 +4890,8 @@  discard block
 block discarded – undo
4662 4890
 	<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
4663 4891
 	<form action="', $boardurl, '/index.php">';
4664 4892
 
4665
-	if (!empty($upcontext['can_delete_script']))
4666
-		echo '
4893
+	if (!empty($upcontext['can_delete_script'])) {
4894
+			echo '
4667 4895
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> <em>', $txt['upgrade_delete_server'], '</em>
4668 4896
 			<script>
4669 4897
 				function doTheDelete(theCheck)
@@ -4675,6 +4903,7 @@  discard block
 block discarded – undo
4675 4903
 				}
4676 4904
 			</script>
4677 4905
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4906
+	}
4678 4907
 
4679 4908
 	$active = time() - $upcontext['started'];
4680 4909
 	$hours = floor($active / 3600);
@@ -4684,16 +4913,20 @@  discard block
 block discarded – undo
4684 4913
 	if ($is_debug)
4685 4914
 	{
4686 4915
 		$totalTime = '';
4687
-		if ($hours > 0)
4688
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4689
-		if ($minutes > 0)
4690
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4691
-		if ($seconds > 0)
4692
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4916
+		if ($hours > 0) {
4917
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4918
+		}
4919
+		if ($minutes > 0) {
4920
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4921
+		}
4922
+		if ($seconds > 0) {
4923
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4924
+		}
4693 4925
 	}
4694 4926
 
4695
-	if ($is_debug && !empty($totalTime))
4696
-		echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>';
4927
+	if ($is_debug && !empty($totalTime)) {
4928
+			echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>';
4929
+	}
4697 4930
 
4698 4931
 	echo '<br>
4699 4932
 			', sprintf($txt['upgrade_problems'], $formatted_url), '<br>
@@ -4720,8 +4953,9 @@  discard block
 block discarded – undo
4720 4953
 
4721 4954
 	$current_substep = $_GET['substep'];
4722 4955
 
4723
-	if (empty($_GET['a']))
4724
-		$_GET['a'] = 0;
4956
+	if (empty($_GET['a'])) {
4957
+			$_GET['a'] = 0;
4958
+	}
4725 4959
 	$step_progress['name'] = 'Converting ips';
4726 4960
 	$step_progress['current'] = $_GET['a'];
4727 4961
 
@@ -4764,16 +4998,19 @@  discard block
 block discarded – undo
4764 4998
 				'empty' => '',
4765 4999
 				'limit' => $limit,
4766 5000
 		));
4767
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4768
-			$arIp[] = $row[$oldCol];
5001
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5002
+					$arIp[] = $row[$oldCol];
5003
+		}
4769 5004
 		$smcFunc['db_free_result']($request);
4770 5005
 
4771 5006
 		// Special case, null ip could keep us in a loop.
4772
-		if (is_null($arIp[0]))
4773
-			unset($arIp[0]);
5007
+		if (is_null($arIp[0])) {
5008
+					unset($arIp[0]);
5009
+		}
4774 5010
 
4775
-		if (empty($arIp))
4776
-			$is_done = true;
5011
+		if (empty($arIp)) {
5012
+					$is_done = true;
5013
+		}
4777 5014
 
4778 5015
 		$updates = array();
4779 5016
 		$cases = array();
@@ -4782,16 +5019,18 @@  discard block
 block discarded – undo
4782 5019
 		{
4783 5020
 			$arIp[$i] = trim($arIp[$i]);
4784 5021
 
4785
-			if (empty($arIp[$i]))
4786
-				continue;
5022
+			if (empty($arIp[$i])) {
5023
+							continue;
5024
+			}
4787 5025
 
4788 5026
 			$updates['ip' . $i] = $arIp[$i];
4789 5027
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4790 5028
 
4791 5029
 			if ($setSize > 0 && $i % $setSize === 0)
4792 5030
 			{
4793
-				if (count($updates) == 1)
4794
-					continue;
5031
+				if (count($updates) == 1) {
5032
+									continue;
5033
+				}
4795 5034
 
4796 5035
 				$updates['whereSet'] = array_values($updates);
4797 5036
 				$smcFunc['db_query']('', '
@@ -4825,8 +5064,7 @@  discard block
 block discarded – undo
4825 5064
 							'ip' => $ip
4826 5065
 					));
4827 5066
 				}
4828
-			}
4829
-			else
5067
+			} else
4830 5068
 			{
4831 5069
 				$updates['whereSet'] = array_values($updates);
4832 5070
 				$smcFunc['db_query']('', '
@@ -4840,9 +5078,9 @@  discard block
 block discarded – undo
4840 5078
 					$updates
4841 5079
 				);
4842 5080
 			}
5081
+		} else {
5082
+					$is_done = true;
4843 5083
 		}
4844
-		else
4845
-			$is_done = true;
4846 5084
 
4847 5085
 		$_GET['a'] += $limit;
4848 5086
 		$step_progress['current'] = $_GET['a'];
@@ -4868,10 +5106,11 @@  discard block
 block discarded – undo
4868 5106
 
4869 5107
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4870 5108
 
4871
-	if (isset($columns[$column]))
4872
-		return $columns[$column];
4873
-	else
4874
-		return null;
4875
-}
5109
+	if (isset($columns[$column])) {
5110
+			return $columns[$column];
5111
+	} else {
5112
+			return null;
5113
+	}
5114
+	}
4876 5115
 
4877 5116
 ?>
4878 5117
\ No newline at end of file
Please login to merge, or discard this patch.