Completed
Pull Request — release-2.1 (#3835)
by Martyn
09:20
created
Sources/minify/src/Exceptions/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ReCaptcha/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/path-converter/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/path-converter/src/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
other/upgrade.php 3 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -388,6 +388,9 @@  discard block
 block discarded – undo
388 388
 }
389 389
 
390 390
 // Used to direct the user to another location.
391
+/**
392
+ * @param string $location
393
+ */
391 394
 function redirectLocation($location, $addForm = true)
392 395
 {
393 396
 	global $upgradeurl, $upcontext, $command_line;
@@ -1560,6 +1563,9 @@  discard block
 block discarded – undo
1560 1563
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1561 1564
 }
1562 1565
 
1566
+/**
1567
+ * @param string $filename
1568
+ */
1563 1569
 function parse_sql($filename)
1564 1570
 {
1565 1571
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1594,6 +1600,10 @@  discard block
 block discarded – undo
1594 1600
 
1595 1601
 	// Our custom error handler - does nothing but does stop public errors from XML!
1596 1602
 	set_error_handler(
1603
+
1604
+		/**
1605
+		 * @param string $errno
1606
+		 */
1597 1607
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1608
 		{
1599 1609
 			if ($support_js)
@@ -1840,6 +1850,9 @@  discard block
 block discarded – undo
1840 1850
 	return true;
1841 1851
 }
1842 1852
 
1853
+/**
1854
+ * @param string $string
1855
+ */
1843 1856
 function upgrade_query($string, $unbuffered = false)
1844 1857
 {
1845 1858
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4495,7 +4508,7 @@  discard block
 block discarded – undo
4495 4508
  * @param int $setSize The amount of entries after which to update the database.
4496 4509
  *
4497 4510
  * newCol needs to be a varbinary(16) null able field
4498
- * @return bool
4511
+ * @return boolean|null
4499 4512
  */
4500 4513
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4501 4514
 {
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 
1595 1595
 	// Our custom error handler - does nothing but does stop public errors from XML!
1596 1596
 	set_error_handler(
1597
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1597
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1598
 		{
1599 1599
 			if ($support_js)
1600 1600
 				return true;
@@ -2607,94 +2607,94 @@  discard block
 block discarded – undo
2607 2607
 		// Translation table for the character sets not native for MySQL.
2608 2608
 		$translation_tables = array(
2609 2609
 			'windows-1255' => array(
2610
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2611
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2612
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2613
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2614
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2615
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2616
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2617
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2618
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2619
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2620
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2621
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2622
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2623
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2624
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2625
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2626
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2627
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2628
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2629
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2630
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2631
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2632
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2633
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2634
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2635
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2636
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2637
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2638
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2639
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2640
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2641
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2642
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2643
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2644
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2645
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2646
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2647
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2648
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2649
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2650
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2651
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2610
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2611
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2612
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2613
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2614
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2615
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2616
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2617
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2618
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2619
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2620
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2621
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2622
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2623
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2624
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2625
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2626
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2627
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2628
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2629
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2630
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2631
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2632
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2633
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2634
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2635
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2636
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2637
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2638
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2639
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2640
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2641
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2642
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2643
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2644
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2645
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2646
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2647
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2648
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2649
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2650
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2651
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2652 2652
 				'0xFA' => '0xD7AA',
2653 2653
 			),
2654 2654
 			'windows-1253' => array(
2655
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2656
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2657
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2658
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2659
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2660
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2661
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2662
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2663
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2664
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2665
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2666
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2667
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2668
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2669
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2670
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2671
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2672
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2673
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2674
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2675
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2676
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2677
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2678
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2679
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2680
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2681
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2682
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2683
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2684
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2685
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2686
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2687
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2688
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2689
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2690
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2691
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2692
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2693
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2694
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2695
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2696
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2697
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2655
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2656
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2657
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2658
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2659
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2660
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2661
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2662
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2663
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2664
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2665
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2666
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2667
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2668
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2669
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2670
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2671
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2672
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2673
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2674
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2675
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2676
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2677
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2678
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2679
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2680
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2681
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2682
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2683
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2684
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2685
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2686
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2687
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2688
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2689
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2690
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2691
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2692
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2693
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2694
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2695
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2696
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2697
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2698 2698
 			),
2699 2699
 		);
2700 2700
 
Please login to merge, or discard this patch.
Braces   +854 added lines, -626 removed lines patch added patch discarded remove patch
@@ -100,11 +100,14 @@  discard block
 block discarded – undo
100 100
 	ini_set('default_socket_timeout', 900);
101 101
 }
102 102
 // Clean the upgrade path if this is from the client.
103
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
104
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
103
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
104
+	for ($i = 1;
105
+}
106
+$i < $_SERVER['argc']; $i++)
105 107
 	{
106
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
107
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
108
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
109
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
110
+		}
108 111
 	}
109 112
 
110 113
 // Are we from the client?
@@ -112,9 +115,9 @@  discard block
 block discarded – undo
112 115
 {
113 116
 	$command_line = true;
114 117
 	$disable_security = 1;
115
-}
116
-else
118
+} else {
117 119
 	$command_line = false;
120
+}
118 121
 
119 122
 // Load this now just because we can.
120 123
 require_once($upgrade_path . '/Settings.php');
@@ -125,10 +128,12 @@  discard block
 block discarded – undo
125 128
 	$upcontext['user'] = unserialize(base64_decode($upgradeData));
126 129
 
127 130
 	// Check for sensible values.
128
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
129
-		$upcontext['user']['started'] = time();
130
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
131
-		$upcontext['user']['updated'] = 0;
131
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
132
+			$upcontext['user']['started'] = time();
133
+	}
134
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
135
+			$upcontext['user']['updated'] = 0;
136
+	}
132 137
 
133 138
 	$upcontext['started'] = $upcontext['user']['started'];
134 139
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -187,8 +192,9 @@  discard block
 block discarded – undo
187 192
 			'db_error_skip' => true,
188 193
 		)
189 194
 	);
190
-	while ($row = $smcFunc['db_fetch_assoc']($request))
191
-		$modSettings[$row['variable']] = $row['value'];
195
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
196
+			$modSettings[$row['variable']] = $row['value'];
197
+	}
192 198
 	$smcFunc['db_free_result']($request);
193 199
 }
194 200
 
@@ -198,10 +204,12 @@  discard block
 block discarded – undo
198 204
 	$modSettings['theme_url'] = 'Themes/default';
199 205
 	$modSettings['images_url'] = 'Themes/default/images';
200 206
 }
201
-if (!isset($settings['default_theme_url']))
207
+if (!isset($settings['default_theme_url'])) {
202 208
 	$settings['default_theme_url'] = $modSettings['theme_url'];
203
-if (!isset($settings['default_theme_dir']))
209
+}
210
+if (!isset($settings['default_theme_dir'])) {
204 211
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
212
+}
205 213
 
206 214
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
207 215
 // Default title...
@@ -219,13 +227,15 @@  discard block
 block discarded – undo
219 227
 	$support_js = $upcontext['upgrade_status']['js'];
220 228
 
221 229
 	// Only set this if the upgrader status says so.
222
-	if (empty($is_debug))
223
-		$is_debug = $upcontext['upgrade_status']['debug'];
230
+	if (empty($is_debug)) {
231
+			$is_debug = $upcontext['upgrade_status']['debug'];
232
+	}
224 233
 
225 234
 	// Load the language.
226
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
227
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
228
-}
235
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
236
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
237
+	}
238
+	}
229 239
 // Set the defaults.
230 240
 else
231 241
 {
@@ -243,15 +253,18 @@  discard block
 block discarded – undo
243 253
 }
244 254
 
245 255
 // If this isn't the first stage see whether they are logging in and resuming.
246
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
256
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
247 257
 	checkLogin();
258
+}
248 259
 
249
-if ($command_line)
260
+if ($command_line) {
250 261
 	cmdStep0();
262
+}
251 263
 
252 264
 // Don't error if we're using xml.
253
-if (isset($_GET['xml']))
265
+if (isset($_GET['xml'])) {
254 266
 	$upcontext['return_error'] = true;
267
+}
255 268
 
256 269
 // Loop through all the steps doing each one as required.
257 270
 $upcontext['overall_percent'] = 0;
@@ -272,10 +285,11 @@  discard block
 block discarded – undo
272 285
 		}
273 286
 
274 287
 		// Call the step and if it returns false that means pause!
275
-		if (function_exists($step[2]) && $step[2]() === false)
276
-			break;
277
-		elseif (function_exists($step[2]))
278
-			$upcontext['current_step']++;
288
+		if (function_exists($step[2]) && $step[2]() === false) {
289
+					break;
290
+		} elseif (function_exists($step[2])) {
291
+					$upcontext['current_step']++;
292
+		}
279 293
 	}
280 294
 	$upcontext['overall_percent'] += $step[3];
281 295
 }
@@ -314,17 +328,18 @@  discard block
 block discarded – undo
314 328
 		// This should not happen my dear... HELP ME DEVELOPERS!!
315 329
 		if (!empty($command_line))
316 330
 		{
317
-			if (function_exists('debug_print_backtrace'))
318
-				debug_print_backtrace();
331
+			if (function_exists('debug_print_backtrace')) {
332
+							debug_print_backtrace();
333
+			}
319 334
 
320 335
 			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.';
321 336
 			flush();
322 337
 			die();
323 338
 		}
324 339
 
325
-		if (!isset($_GET['xml']))
326
-			template_upgrade_above();
327
-		else
340
+		if (!isset($_GET['xml'])) {
341
+					template_upgrade_above();
342
+		} else
328 343
 		{
329 344
 			header('Content-Type: text/xml; charset=UTF-8');
330 345
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -346,21 +361,24 @@  discard block
 block discarded – undo
346 361
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(safe_serialize($upcontext['upgrade_status']));
347 362
 
348 363
 			// Custom stuff to pass back?
349
-			if (!empty($upcontext['query_string']))
350
-				$upcontext['form_url'] .= $upcontext['query_string'];
364
+			if (!empty($upcontext['query_string'])) {
365
+							$upcontext['form_url'] .= $upcontext['query_string'];
366
+			}
351 367
 
352 368
 			call_user_func('template_' . $upcontext['sub_template']);
353 369
 		}
354 370
 
355 371
 		// Was there an error?
356
-		if (!empty($upcontext['forced_error_message']))
357
-			echo $upcontext['forced_error_message'];
372
+		if (!empty($upcontext['forced_error_message'])) {
373
+					echo $upcontext['forced_error_message'];
374
+		}
358 375
 
359 376
 		// Show the footer.
360
-		if (!isset($_GET['xml']))
361
-			template_upgrade_below();
362
-		else
363
-			template_xml_below();
377
+		if (!isset($_GET['xml'])) {
378
+					template_upgrade_below();
379
+		} else {
380
+					template_xml_below();
381
+		}
364 382
 	}
365 383
 
366 384
 
@@ -372,15 +390,19 @@  discard block
 block discarded – undo
372 390
 		$seconds = intval($active % 60);
373 391
 
374 392
 		$totalTime = '';
375
-		if ($hours > 0)
376
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
377
-		if ($minutes > 0)
378
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
379
-		if ($seconds > 0)
380
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
393
+		if ($hours > 0) {
394
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
395
+		}
396
+		if ($minutes > 0) {
397
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
398
+		}
399
+		if ($seconds > 0) {
400
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
401
+		}
381 402
 
382
-		if (!empty($totalTime))
383
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
403
+		if (!empty($totalTime)) {
404
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
405
+		}
384 406
 	}
385 407
 
386 408
 	// Bang - gone!
@@ -393,8 +415,9 @@  discard block
 block discarded – undo
393 415
 	global $upgradeurl, $upcontext, $command_line;
394 416
 
395 417
 	// Command line users can't be redirected.
396
-	if ($command_line)
397
-		upgradeExit(true);
418
+	if ($command_line) {
419
+			upgradeExit(true);
420
+	}
398 421
 
399 422
 	// Are we providing the core info?
400 423
 	if ($addForm)
@@ -417,19 +440,22 @@  discard block
 block discarded – undo
417 440
 	global $modSettings, $sourcedir, $smcFunc;
418 441
 
419 442
 	// Do the non-SSI stuff...
420
-	if (function_exists('set_magic_quotes_runtime'))
421
-		@set_magic_quotes_runtime(0);
443
+	if (function_exists('set_magic_quotes_runtime')) {
444
+			@set_magic_quotes_runtime(0);
445
+	}
422 446
 
423 447
 	error_reporting(E_ALL);
424 448
 	define('SMF', 1);
425 449
 
426 450
 	// Start the session.
427
-	if (@ini_get('session.save_handler') == 'user')
428
-		@ini_set('session.save_handler', 'files');
451
+	if (@ini_get('session.save_handler') == 'user') {
452
+			@ini_set('session.save_handler', 'files');
453
+	}
429 454
 	@session_start();
430 455
 
431
-	if (empty($smcFunc))
432
-		$smcFunc = array();
456
+	if (empty($smcFunc)) {
457
+			$smcFunc = array();
458
+	}
433 459
 
434 460
 	// We need this for authentication and some upgrade code
435 461
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -441,8 +467,9 @@  discard block
 block discarded – undo
441 467
 	initialize_inputs();
442 468
 
443 469
 	// Get the database going!
444
-	if (empty($db_type))
445
-		$db_type = 'mysql';
470
+	if (empty($db_type)) {
471
+			$db_type = 'mysql';
472
+	}
446 473
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
447 474
 	{
448 475
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -451,17 +478,19 @@  discard block
 block discarded – undo
451 478
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
452 479
 
453 480
 		// Oh dear god!!
454
-		if ($db_connection === null)
455
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
481
+		if ($db_connection === null) {
482
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
483
+		}
456 484
 
457
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
458
-			$smcFunc['db_query']('', '
485
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
486
+					$smcFunc['db_query']('', '
459 487
 			SET NAMES {string:db_character_set}',
460 488
 			array(
461 489
 				'db_error_skip' => true,
462 490
 				'db_character_set' => $db_character_set,
463 491
 			)
464 492
 		);
493
+		}
465 494
 
466 495
 		// Load the modSettings data...
467 496
 		$request = $smcFunc['db_query']('', '
@@ -472,11 +501,11 @@  discard block
 block discarded – undo
472 501
 			)
473 502
 		);
474 503
 		$modSettings = array();
475
-		while ($row = $smcFunc['db_fetch_assoc']($request))
476
-			$modSettings[$row['variable']] = $row['value'];
504
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
505
+					$modSettings[$row['variable']] = $row['value'];
506
+		}
477 507
 		$smcFunc['db_free_result']($request);
478
-	}
479
-	else
508
+	} else
480 509
 	{
481 510
 		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.');
482 511
 	}
@@ -490,9 +519,10 @@  discard block
 block discarded – undo
490 519
 		cleanRequest();
491 520
 	}
492 521
 
493
-	if (!isset($_GET['substep']))
494
-		$_GET['substep'] = 0;
495
-}
522
+	if (!isset($_GET['substep'])) {
523
+			$_GET['substep'] = 0;
524
+	}
525
+	}
496 526
 
497 527
 function initialize_inputs()
498 528
 {
@@ -522,8 +552,9 @@  discard block
 block discarded – undo
522 552
 		$dh = opendir(dirname(__FILE__));
523 553
 		while ($file = readdir($dh))
524 554
 		{
525
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
526
-				@unlink(dirname(__FILE__) . '/' . $file);
555
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
556
+							@unlink(dirname(__FILE__) . '/' . $file);
557
+			}
527 558
 		}
528 559
 		closedir($dh);
529 560
 
@@ -553,8 +584,9 @@  discard block
 block discarded – undo
553 584
 	{
554 585
 		$upcontext['remote_files_available'] = false;
555 586
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
556
-		if ($test)
557
-			$upcontext['remote_files_available'] = true;
587
+		if ($test) {
588
+					$upcontext['remote_files_available'] = true;
589
+		}
558 590
 		@fclose($test);
559 591
 	}
560 592
 
@@ -562,8 +594,9 @@  discard block
 block discarded – undo
562 594
 	$temp = 'upgrade_php?step';
563 595
 	while (strlen($temp) > 4)
564 596
 	{
565
-		if (isset($_GET[$temp]))
566
-			unset($_GET[$temp]);
597
+		if (isset($_GET[$temp])) {
598
+					unset($_GET[$temp]);
599
+		}
567 600
 		$temp = substr($temp, 1);
568 601
 	}
569 602
 
@@ -590,29 +623,36 @@  discard block
 block discarded – undo
590 623
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
591 624
 
592 625
 	// Need legacy scripts?
593
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
594
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
595
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
596
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
597
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
598
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
626
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
627
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
628
+	}
629
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
630
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
631
+	}
632
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
633
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
634
+	}
599 635
 
600 636
 	// This needs to exist!
601
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
602
-		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>]');
603
-	else
604
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
637
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
638
+			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>]');
639
+	} else {
640
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
641
+	}
605 642
 
606
-	if (!$check)
607
-		// 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.
643
+	if (!$check) {
644
+			// 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.
608 645
 		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.');
646
+	}
609 647
 
610 648
 	// Do they meet the install requirements?
611
-	if (!php_version_check())
612
-		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.');
649
+	if (!php_version_check()) {
650
+			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.');
651
+	}
613 652
 
614
-	if (!db_version_check())
615
-		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.');
653
+	if (!db_version_check()) {
654
+			return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
655
+	}
616 656
 
617 657
 	// Do some checks to make sure they have proper privileges
618 658
 	db_extend('packages');
@@ -627,14 +667,16 @@  discard block
 block discarded – undo
627 667
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
628 668
 
629 669
 	// Sorry... we need CREATE, ALTER and DROP
630
-	if (!$create || !$alter || !$drop)
631
-		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.');
670
+	if (!$create || !$alter || !$drop) {
671
+			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.');
672
+	}
632 673
 
633 674
 	// Do a quick version spot check.
634 675
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
635 676
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
636
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
637
-		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.');
677
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
678
+			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.');
679
+	}
638 680
 
639 681
 	// What absolutely needs to be writable?
640 682
 	$writable_files = array(
@@ -656,12 +698,13 @@  discard block
 block discarded – undo
656 698
 	quickFileWritable($custom_av_dir);
657 699
 
658 700
 	// Are we good now?
659
-	if (!is_writable($custom_av_dir))
660
-		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));
661
-	elseif ($need_settings_update)
701
+	if (!is_writable($custom_av_dir)) {
702
+			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));
703
+	} elseif ($need_settings_update)
662 704
 	{
663
-		if (!function_exists('cache_put_data'))
664
-			require_once($sourcedir . '/Load.php');
705
+		if (!function_exists('cache_put_data')) {
706
+					require_once($sourcedir . '/Load.php');
707
+		}
665 708
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
666 709
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
667 710
 	}
@@ -670,28 +713,33 @@  discard block
 block discarded – undo
670 713
 
671 714
 	// Check the cache directory.
672 715
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
673
-	if (!file_exists($cachedir_temp))
674
-		@mkdir($cachedir_temp);
675
-	if (!file_exists($cachedir_temp))
676
-		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.');
677
-
678
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
679
-		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>.');
680
-	elseif (!isset($_GET['skiplang']))
716
+	if (!file_exists($cachedir_temp)) {
717
+			@mkdir($cachedir_temp);
718
+	}
719
+	if (!file_exists($cachedir_temp)) {
720
+			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.');
721
+	}
722
+
723
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
724
+			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>.');
725
+	} elseif (!isset($_GET['skiplang']))
681 726
 	{
682 727
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
683 728
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
684 729
 
685
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
686
-			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>]');
730
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
731
+					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>]');
732
+		}
687 733
 	}
688 734
 
689
-	if (!makeFilesWritable($writable_files))
690
-		return false;
735
+	if (!makeFilesWritable($writable_files)) {
736
+			return false;
737
+	}
691 738
 
692 739
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
693
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
694
-		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.');
740
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
741
+			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.');
742
+	}
695 743
 
696 744
 	// Upgrade the agreement.
697 745
 	elseif (isset($modSettings['agreement']))
@@ -702,8 +750,8 @@  discard block
 block discarded – undo
702 750
 	}
703 751
 
704 752
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
705
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
706
-		$upcontext['warning'] = '
753
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
754
+			$upcontext['warning'] = '
707 755
 			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>
708 756
 			<ul>
709 757
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -711,10 +759,12 @@  discard block
 block discarded – undo
711 759
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
712 760
 			</ul>
713 761
 			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
762
+	}
714 763
 
715 764
 	// Either we're logged in or we're going to present the login.
716
-	if (checkLogin())
717
-		return true;
765
+	if (checkLogin()) {
766
+			return true;
767
+	}
718 768
 
719 769
 	$upcontext += createToken('login');
720 770
 
@@ -728,15 +778,17 @@  discard block
 block discarded – undo
728 778
 	global $smcFunc, $db_type, $support_js;
729 779
 
730 780
 	// Don't bother if the security is disabled.
731
-	if ($disable_security)
732
-		return true;
781
+	if ($disable_security) {
782
+			return true;
783
+	}
733 784
 
734 785
 	// Are we trying to login?
735 786
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
736 787
 	{
737 788
 		// If we've disabled security pick a suitable name!
738
-		if (empty($_POST['user']))
739
-			$_POST['user'] = 'Administrator';
789
+		if (empty($_POST['user'])) {
790
+					$_POST['user'] = 'Administrator';
791
+		}
740 792
 
741 793
 		// Before 2.0 these column names were different!
742 794
 		$oldDB = false;
@@ -751,16 +803,17 @@  discard block
 block discarded – undo
751 803
 					'db_error_skip' => true,
752 804
 				)
753 805
 			);
754
-			if ($smcFunc['db_num_rows']($request) != 0)
755
-				$oldDB = true;
806
+			if ($smcFunc['db_num_rows']($request) != 0) {
807
+							$oldDB = true;
808
+			}
756 809
 			$smcFunc['db_free_result']($request);
757 810
 		}
758 811
 
759 812
 		// Get what we believe to be their details.
760 813
 		if (!$disable_security)
761 814
 		{
762
-			if ($oldDB)
763
-				$request = $smcFunc['db_query']('', '
815
+			if ($oldDB) {
816
+							$request = $smcFunc['db_query']('', '
764 817
 					SELECT id_member, memberName AS member_name, passwd, id_group,
765 818
 					additionalGroups AS additional_groups, lngfile
766 819
 					FROM {db_prefix}members
@@ -770,8 +823,8 @@  discard block
 block discarded – undo
770 823
 						'db_error_skip' => true,
771 824
 					)
772 825
 				);
773
-			else
774
-				$request = $smcFunc['db_query']('', '
826
+			} else {
827
+							$request = $smcFunc['db_query']('', '
775 828
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
776 829
 					FROM {db_prefix}members
777 830
 					WHERE member_name = {string:member_name}',
@@ -780,6 +833,7 @@  discard block
 block discarded – undo
780 833
 						'db_error_skip' => true,
781 834
 					)
782 835
 				);
836
+			}
783 837
 			if ($smcFunc['db_num_rows']($request) != 0)
784 838
 			{
785 839
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -787,13 +841,14 @@  discard block
 block discarded – undo
787 841
 				$groups = explode(',', $addGroups);
788 842
 				$groups[] = $id_group;
789 843
 
790
-				foreach ($groups as $k => $v)
791
-					$groups[$k] = (int) $v;
844
+				foreach ($groups as $k => $v) {
845
+									$groups[$k] = (int) $v;
846
+				}
792 847
 
793 848
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
849
+			} else {
850
+							$upcontext['username_incorrect'] = true;
794 851
 			}
795
-			else
796
-				$upcontext['username_incorrect'] = true;
797 852
 			$smcFunc['db_free_result']($request);
798 853
 		}
799 854
 		$upcontext['username'] = $_POST['user'];
@@ -803,13 +858,14 @@  discard block
 block discarded – undo
803 858
 		{
804 859
 			$upcontext['upgrade_status']['js'] = 1;
805 860
 			$support_js = 1;
861
+		} else {
862
+					$support_js = 0;
806 863
 		}
807
-		else
808
-			$support_js = 0;
809 864
 
810 865
 		// Note down the version we are coming from.
811
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
812
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
866
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
867
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
868
+		}
813 869
 
814 870
 		// Didn't get anywhere?
815 871
 		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']))
@@ -843,15 +899,15 @@  discard block
 block discarded – undo
843 899
 							'db_error_skip' => true,
844 900
 						)
845 901
 					);
846
-					if ($smcFunc['db_num_rows']($request) == 0)
847
-						return throw_error('You need to be an admin to perform an upgrade!');
902
+					if ($smcFunc['db_num_rows']($request) == 0) {
903
+											return throw_error('You need to be an admin to perform an upgrade!');
904
+					}
848 905
 					$smcFunc['db_free_result']($request);
849 906
 				}
850 907
 
851 908
 				$upcontext['user']['id'] = $id_member;
852 909
 				$upcontext['user']['name'] = $name;
853
-			}
854
-			else
910
+			} else
855 911
 			{
856 912
 				$upcontext['user']['id'] = 1;
857 913
 				$upcontext['user']['name'] = 'Administrator';
@@ -867,11 +923,11 @@  discard block
 block discarded – undo
867 923
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
868 924
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
869 925
 
870
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
871
-					$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'] . '.';
872
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
873
-					$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'] . '.';
874
-				else
926
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
927
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
928
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
929
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
930
+				} else
875 931
 				{
876 932
 					// Set this as the new language.
877 933
 					$upcontext['language'] = $user_language;
@@ -915,8 +971,9 @@  discard block
 block discarded – undo
915 971
 	unset($member_columns);
916 972
 
917 973
 	// If we've not submitted then we're done.
918
-	if (empty($_POST['upcont']))
919
-		return false;
974
+	if (empty($_POST['upcont'])) {
975
+			return false;
976
+	}
920 977
 
921 978
 	// Firstly, if they're enabling SM stat collection just do it.
922 979
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']))
@@ -931,25 +988,26 @@  discard block
 block discarded – undo
931 988
 			fwrite($fp, $out);
932 989
 
933 990
 			$return_data = '';
934
-			while (!feof($fp))
935
-				$return_data .= fgets($fp, 128);
991
+			while (!feof($fp)) {
992
+							$return_data .= fgets($fp, 128);
993
+			}
936 994
 
937 995
 			fclose($fp);
938 996
 
939 997
 			// Get the unique site ID.
940 998
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
941 999
 
942
-			if (!empty($ID[1]))
943
-				$smcFunc['db_insert']('replace',
1000
+			if (!empty($ID[1])) {
1001
+							$smcFunc['db_insert']('replace',
944 1002
 					$db_prefix . 'settings',
945 1003
 					array('variable' => 'string', 'value' => 'string'),
946 1004
 					array('allow_sm_stats', $ID[1]),
947 1005
 					array('variable')
948 1006
 				);
1007
+			}
949 1008
 		}
950
-	}
951
-	else
952
-		$smcFunc['db_query']('', '
1009
+	} else {
1010
+			$smcFunc['db_query']('', '
953 1011
 			DELETE FROM {db_prefix}settings
954 1012
 			WHERE variable = {string:allow_sm_stats}',
955 1013
 			array(
@@ -957,6 +1015,7 @@  discard block
 block discarded – undo
957 1015
 				'db_error_skip' => true,
958 1016
 			)
959 1017
 		);
1018
+	}
960 1019
 
961 1020
 	// Deleting old karma stuff?
962 1021
 	if (!empty($_POST['delete_karma']))
@@ -971,20 +1030,22 @@  discard block
 block discarded – undo
971 1030
 		);
972 1031
 
973 1032
 		// Cleaning up old karma member settings.
974
-		if ($upcontext['karma_installed']['good'])
975
-			$smcFunc['db_query']('', '
1033
+		if ($upcontext['karma_installed']['good']) {
1034
+					$smcFunc['db_query']('', '
976 1035
 				ALTER TABLE {db_prefix}members
977 1036
 				DROP karma_good',
978 1037
 				array()
979 1038
 			);
1039
+		}
980 1040
 
981 1041
 		// Does karma bad was enable?
982
-		if ($upcontext['karma_installed']['bad'])
983
-			$smcFunc['db_query']('', '
1042
+		if ($upcontext['karma_installed']['bad']) {
1043
+					$smcFunc['db_query']('', '
984 1044
 				ALTER TABLE {db_prefix}members
985 1045
 				DROP karma_bad',
986 1046
 				array()
987 1047
 			);
1048
+		}
988 1049
 
989 1050
 		// Cleaning up old karma permissions.
990 1051
 		$smcFunc['db_query']('', '
@@ -997,26 +1058,29 @@  discard block
 block discarded – undo
997 1058
 	}
998 1059
 
999 1060
 	// Emptying the error log?
1000
-	if (!empty($_POST['empty_error']))
1001
-		$smcFunc['db_query']('truncate_table', '
1061
+	if (!empty($_POST['empty_error'])) {
1062
+			$smcFunc['db_query']('truncate_table', '
1002 1063
 			TRUNCATE {db_prefix}log_errors',
1003 1064
 			array(
1004 1065
 			)
1005 1066
 		);
1067
+	}
1006 1068
 
1007 1069
 	$changes = array();
1008 1070
 
1009 1071
 	// Add proxy settings.
1010
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1011
-		$changes += array(
1072
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1073
+			$changes += array(
1012 1074
 			'image_proxy_secret' => substr(sha1(mt_rand()), 0, 20),
1013 1075
 			'image_proxy_maxsize' => 5190,
1014 1076
 			'image_proxy_enabled' => 0,
1015 1077
 		);
1078
+	}
1016 1079
 
1017 1080
 	// If we're overriding the language follow it through.
1018
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1019
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1081
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1082
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1083
+	}
1020 1084
 
1021 1085
 	if (!empty($_POST['maint']))
1022 1086
 	{
@@ -1028,30 +1092,34 @@  discard block
 block discarded – undo
1028 1092
 		{
1029 1093
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1030 1094
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1031
-		}
1032
-		else
1095
+		} else
1033 1096
 		{
1034 1097
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1035 1098
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1036 1099
 		}
1037 1100
 	}
1038 1101
 
1039
-	if ($command_line)
1040
-		echo ' * Updating Settings.php...';
1102
+	if ($command_line) {
1103
+			echo ' * Updating Settings.php...';
1104
+	}
1041 1105
 
1042 1106
 	// Fix some old paths.
1043
-	if (substr($boarddir, 0, 1) == '.')
1044
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1107
+	if (substr($boarddir, 0, 1) == '.') {
1108
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1109
+	}
1045 1110
 
1046
-	if (substr($sourcedir, 0, 1) == '.')
1047
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1111
+	if (substr($sourcedir, 0, 1) == '.') {
1112
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1113
+	}
1048 1114
 
1049
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1050
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1115
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1116
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1117
+	}
1051 1118
 
1052 1119
 	// Not had the database type added before?
1053
-	if (empty($db_type))
1054
-		$changes['db_type'] = 'mysql';
1120
+	if (empty($db_type)) {
1121
+			$changes['db_type'] = 'mysql';
1122
+	}
1055 1123
 
1056 1124
 	// If they have a "host:port" setup for the host, split that into separate values
1057 1125
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1062,28 +1130,31 @@  discard block
 block discarded – undo
1062 1130
 		$changes['db_server'] = '\'' . $db_server . '\'';
1063 1131
 
1064 1132
 		// Only set this if we're not using the default port
1065
-		if ($db_port != ini_get('mysqli.default_port'))
1066
-			$changes['db_port'] = (int) $db_port;
1067
-	}
1068
-	elseif (!empty($db_port))
1133
+		if ($db_port != ini_get('mysqli.default_port')) {
1134
+					$changes['db_port'] = (int) $db_port;
1135
+		}
1136
+	} elseif (!empty($db_port))
1069 1137
 	{
1070 1138
 		// If db_port is set and is the same as the default, set it to ''
1071 1139
 		if ($db_type == 'mysql')
1072 1140
 		{
1073
-			if ($db_port == ini_get('mysqli.default_port'))
1074
-				$changes['db_port'] = '\'\'';
1075
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1076
-				$changes['db_port'] = '\'\'';
1141
+			if ($db_port == ini_get('mysqli.default_port')) {
1142
+							$changes['db_port'] = '\'\'';
1143
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1144
+							$changes['db_port'] = '\'\'';
1145
+			}
1077 1146
 		}
1078 1147
 	}
1079 1148
 
1080 1149
 	// Maybe we haven't had this option yet?
1081
-	if (empty($packagesdir))
1082
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1150
+	if (empty($packagesdir)) {
1151
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1152
+	}
1083 1153
 
1084 1154
 	// Add support for $tasksdir var.
1085
-	if (empty($tasksdir))
1086
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1155
+	if (empty($tasksdir)) {
1156
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1157
+	}
1087 1158
 
1088 1159
 	// @todo Maybe change the cookie name if going to 1.1, too?
1089 1160
 
@@ -1091,8 +1162,9 @@  discard block
 block discarded – undo
1091 1162
 	require_once($sourcedir . '/Subs-Admin.php');
1092 1163
 	updateSettingsFile($changes);
1093 1164
 
1094
-	if ($command_line)
1095
-		echo ' Successful.' . "\n";
1165
+	if ($command_line) {
1166
+			echo ' Successful.' . "\n";
1167
+	}
1096 1168
 
1097 1169
 	// Are we doing debug?
1098 1170
 	if (isset($_POST['debug']))
@@ -1102,8 +1174,9 @@  discard block
 block discarded – undo
1102 1174
 	}
1103 1175
 
1104 1176
 	// If we're not backing up then jump one.
1105
-	if (empty($_POST['backup']))
1106
-		$upcontext['current_step']++;
1177
+	if (empty($_POST['backup'])) {
1178
+			$upcontext['current_step']++;
1179
+	}
1107 1180
 
1108 1181
 	// If we've got here then let's proceed to the next step!
1109 1182
 	return true;
@@ -1118,8 +1191,9 @@  discard block
 block discarded – undo
1118 1191
 	$upcontext['page_title'] = 'Backup Database';
1119 1192
 
1120 1193
 	// Done it already - js wise?
1121
-	if (!empty($_POST['backup_done']))
1122
-		return true;
1194
+	if (!empty($_POST['backup_done'])) {
1195
+			return true;
1196
+	}
1123 1197
 
1124 1198
 	// Some useful stuff here.
1125 1199
 	db_extend();
@@ -1133,9 +1207,10 @@  discard block
 block discarded – undo
1133 1207
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1134 1208
 
1135 1209
 	$table_names = array();
1136
-	foreach ($tables as $table)
1137
-		if (substr($table, 0, 7) !== 'backup_')
1210
+	foreach ($tables as $table) {
1211
+			if (substr($table, 0, 7) !== 'backup_')
1138 1212
 			$table_names[] = $table;
1213
+	}
1139 1214
 
1140 1215
 	$upcontext['table_count'] = count($table_names);
1141 1216
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1145,12 +1220,14 @@  discard block
 block discarded – undo
1145 1220
 	$file_steps = $upcontext['table_count'];
1146 1221
 
1147 1222
 	// What ones have we already done?
1148
-	foreach ($table_names as $id => $table)
1149
-		if ($id < $_GET['substep'])
1223
+	foreach ($table_names as $id => $table) {
1224
+			if ($id < $_GET['substep'])
1150 1225
 			$upcontext['previous_tables'][] = $table;
1226
+	}
1151 1227
 
1152
-	if ($command_line)
1153
-		echo 'Backing Up Tables.';
1228
+	if ($command_line) {
1229
+			echo 'Backing Up Tables.';
1230
+	}
1154 1231
 
1155 1232
 	// If we don't support javascript we backup here.
1156 1233
 	if (!$support_js || isset($_GET['xml']))
@@ -1169,8 +1246,9 @@  discard block
 block discarded – undo
1169 1246
 			backupTable($table_names[$substep]);
1170 1247
 
1171 1248
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1172
-			if (isset($_GET['xml']))
1173
-				return upgradeExit();
1249
+			if (isset($_GET['xml'])) {
1250
+							return upgradeExit();
1251
+			}
1174 1252
 		}
1175 1253
 
1176 1254
 		if ($command_line)
@@ -1203,9 +1281,10 @@  discard block
 block discarded – undo
1203 1281
 
1204 1282
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1205 1283
 
1206
-	if ($command_line)
1207
-		echo ' done.';
1208
-}
1284
+	if ($command_line) {
1285
+			echo ' done.';
1286
+	}
1287
+	}
1209 1288
 
1210 1289
 // Step 2: Everything.
1211 1290
 function DatabaseChanges()
@@ -1214,8 +1293,9 @@  discard block
 block discarded – undo
1214 1293
 	global $upcontext, $support_js, $db_type;
1215 1294
 
1216 1295
 	// Have we just completed this?
1217
-	if (!empty($_POST['database_done']))
1218
-		return true;
1296
+	if (!empty($_POST['database_done'])) {
1297
+			return true;
1298
+	}
1219 1299
 
1220 1300
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1221 1301
 	$upcontext['page_title'] = 'Database Changes';
@@ -1230,15 +1310,16 @@  discard block
 block discarded – undo
1230 1310
 	);
1231 1311
 
1232 1312
 	// How many files are there in total?
1233
-	if (isset($_GET['filecount']))
1234
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1235
-	else
1313
+	if (isset($_GET['filecount'])) {
1314
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1315
+	} else
1236 1316
 	{
1237 1317
 		$upcontext['file_count'] = 0;
1238 1318
 		foreach ($files as $file)
1239 1319
 		{
1240
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1241
-				$upcontext['file_count']++;
1320
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1321
+							$upcontext['file_count']++;
1322
+			}
1242 1323
 		}
1243 1324
 	}
1244 1325
 
@@ -1248,9 +1329,9 @@  discard block
 block discarded – undo
1248 1329
 	$upcontext['cur_file_num'] = 0;
1249 1330
 	foreach ($files as $file)
1250 1331
 	{
1251
-		if ($did_not_do)
1252
-			$did_not_do--;
1253
-		else
1332
+		if ($did_not_do) {
1333
+					$did_not_do--;
1334
+		} else
1254 1335
 		{
1255 1336
 			$upcontext['cur_file_num']++;
1256 1337
 			$upcontext['cur_file_name'] = $file[0];
@@ -1277,12 +1358,13 @@  discard block
 block discarded – undo
1277 1358
 					// Flag to move on to the next.
1278 1359
 					$upcontext['completed_step'] = true;
1279 1360
 					// Did we complete the whole file?
1280
-					if ($nextFile)
1281
-						$upcontext['current_debug_item_num'] = -1;
1361
+					if ($nextFile) {
1362
+											$upcontext['current_debug_item_num'] = -1;
1363
+					}
1282 1364
 					return upgradeExit();
1365
+				} elseif ($support_js) {
1366
+									break;
1283 1367
 				}
1284
-				elseif ($support_js)
1285
-					break;
1286 1368
 			}
1287 1369
 			// Set the progress bar to be right as if we had - even if we hadn't...
1288 1370
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1307,8 +1389,9 @@  discard block
 block discarded – undo
1307 1389
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1308 1390
 
1309 1391
 	// Now it's nice to have some of the basic SMF source files.
1310
-	if (!isset($_GET['ssi']) && !$command_line)
1311
-		redirectLocation('&ssi=1');
1392
+	if (!isset($_GET['ssi']) && !$command_line) {
1393
+			redirectLocation('&ssi=1');
1394
+	}
1312 1395
 
1313 1396
 	$upcontext['sub_template'] = 'upgrade_complete';
1314 1397
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1324,14 +1407,16 @@  discard block
 block discarded – undo
1324 1407
 	// Are we in maintenance mode?
1325 1408
 	if (isset($upcontext['user']['main']))
1326 1409
 	{
1327
-		if ($command_line)
1328
-			echo ' * ';
1410
+		if ($command_line) {
1411
+					echo ' * ';
1412
+		}
1329 1413
 		$upcontext['removed_maintenance'] = true;
1330 1414
 		$changes['maintenance'] = $upcontext['user']['main'];
1331 1415
 	}
1332 1416
 	// Otherwise if somehow we are in 2 let's go to 1.
1333
-	elseif (!empty($maintenance) && $maintenance == 2)
1334
-		$changes['maintenance'] = 1;
1417
+	elseif (!empty($maintenance) && $maintenance == 2) {
1418
+			$changes['maintenance'] = 1;
1419
+	}
1335 1420
 
1336 1421
 	// Wipe this out...
1337 1422
 	$upcontext['user'] = array();
@@ -1346,9 +1431,9 @@  discard block
 block discarded – undo
1346 1431
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1347 1432
 
1348 1433
 	// Now is the perfect time to fetch the SM files.
1349
-	if ($command_line)
1350
-		cli_scheduled_fetchSMfiles();
1351
-	else
1434
+	if ($command_line) {
1435
+			cli_scheduled_fetchSMfiles();
1436
+	} else
1352 1437
 	{
1353 1438
 		require_once($sourcedir . '/ScheduledTasks.php');
1354 1439
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1356,8 +1441,9 @@  discard block
 block discarded – undo
1356 1441
 	}
1357 1442
 
1358 1443
 	// Log what we've done.
1359
-	if (empty($user_info['id']))
1360
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1444
+	if (empty($user_info['id'])) {
1445
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1446
+	}
1361 1447
 
1362 1448
 	// Log the action manually, so CLI still works.
1363 1449
 	$smcFunc['db_insert']('',
@@ -1376,8 +1462,9 @@  discard block
 block discarded – undo
1376 1462
 
1377 1463
 	// Save the current database version.
1378 1464
 	$server_version = $smcFunc['db_server_info']();
1379
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1380
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1465
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1466
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1467
+	}
1381 1468
 
1382 1469
 	if ($command_line)
1383 1470
 	{
@@ -1389,8 +1476,9 @@  discard block
 block discarded – undo
1389 1476
 
1390 1477
 	// Make sure it says we're done.
1391 1478
 	$upcontext['overall_percent'] = 100;
1392
-	if (isset($upcontext['step_progress']))
1393
-		unset($upcontext['step_progress']);
1479
+	if (isset($upcontext['step_progress'])) {
1480
+			unset($upcontext['step_progress']);
1481
+	}
1394 1482
 
1395 1483
 	$_GET['substep'] = 0;
1396 1484
 	return false;
@@ -1401,8 +1489,9 @@  discard block
 block discarded – undo
1401 1489
 {
1402 1490
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1403 1491
 
1404
-	if (empty($modSettings['time_format']))
1405
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1492
+	if (empty($modSettings['time_format'])) {
1493
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1494
+	}
1406 1495
 
1407 1496
 	// What files do we want to get
1408 1497
 	$request = $smcFunc['db_query']('', '
@@ -1436,8 +1525,9 @@  discard block
 block discarded – undo
1436 1525
 		$file_data = fetch_web_data($url);
1437 1526
 
1438 1527
 		// If we got an error - give up - the site might be down.
1439
-		if ($file_data === false)
1440
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1528
+		if ($file_data === false) {
1529
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1530
+		}
1441 1531
 
1442 1532
 		// Save the file to the database.
1443 1533
 		$smcFunc['db_query']('substring', '
@@ -1479,8 +1569,9 @@  discard block
 block discarded – undo
1479 1569
 	$themeData = array();
1480 1570
 	foreach ($values as $variable => $value)
1481 1571
 	{
1482
-		if (!isset($value) || $value === null)
1483
-			$value = 0;
1572
+		if (!isset($value) || $value === null) {
1573
+					$value = 0;
1574
+		}
1484 1575
 
1485 1576
 		$themeData[] = array(0, 1, $variable, $value);
1486 1577
 	}
@@ -1509,8 +1600,9 @@  discard block
 block discarded – undo
1509 1600
 
1510 1601
 	foreach ($values as $variable => $value)
1511 1602
 	{
1512
-		if (empty($modSettings[$value[0]]))
1513
-			continue;
1603
+		if (empty($modSettings[$value[0]])) {
1604
+					continue;
1605
+		}
1514 1606
 
1515 1607
 		$smcFunc['db_query']('', '
1516 1608
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1596,10 +1688,11 @@  discard block
 block discarded – undo
1596 1688
 	set_error_handler(
1597 1689
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1690
 		{
1599
-			if ($support_js)
1600
-				return true;
1601
-			else
1602
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1691
+			if ($support_js) {
1692
+							return true;
1693
+			} else {
1694
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1695
+			}
1603 1696
 		}
1604 1697
 	);
1605 1698
 
@@ -1614,8 +1707,9 @@  discard block
 block discarded – undo
1614 1707
 				'db_error_skip' => true,
1615 1708
 			)
1616 1709
 		);
1617
-		if ($smcFunc['db_num_rows']($request) === 0)
1618
-			die('Unable to find members table!');
1710
+		if ($smcFunc['db_num_rows']($request) === 0) {
1711
+					die('Unable to find members table!');
1712
+		}
1619 1713
 		$table_status = $smcFunc['db_fetch_assoc']($request);
1620 1714
 		$smcFunc['db_free_result']($request);
1621 1715
 
@@ -1630,17 +1724,20 @@  discard block
 block discarded – undo
1630 1724
 				)
1631 1725
 			);
1632 1726
 			// Got something?
1633
-			if ($smcFunc['db_num_rows']($request) !== 0)
1634
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
1727
+			if ($smcFunc['db_num_rows']($request) !== 0) {
1728
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
1729
+			}
1635 1730
 			$smcFunc['db_free_result']($request);
1636 1731
 
1637 1732
 			// Excellent!
1638
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
1639
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1733
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
1734
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1735
+			}
1640 1736
 		}
1641 1737
 	}
1642
-	if (empty($db_collation))
1643
-		$db_collation = '';
1738
+	if (empty($db_collation)) {
1739
+			$db_collation = '';
1740
+	}
1644 1741
 
1645 1742
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1646 1743
 
@@ -1652,8 +1749,9 @@  discard block
 block discarded – undo
1652 1749
 	$last_step = '';
1653 1750
 
1654 1751
 	// Make sure all newly created tables will have the proper characters set.
1655
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1656
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1752
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1753
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1754
+	}
1657 1755
 
1658 1756
 	// Count the total number of steps within this file - for progress.
1659 1757
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1673,15 +1771,18 @@  discard block
 block discarded – undo
1673 1771
 		$do_current = $substep >= $_GET['substep'];
1674 1772
 
1675 1773
 		// Get rid of any comments in the beginning of the line...
1676
-		if (substr(trim($line), 0, 2) === '/*')
1677
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1774
+		if (substr(trim($line), 0, 2) === '/*') {
1775
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1776
+		}
1678 1777
 
1679 1778
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1680
-		if ($is_debug && !$support_js && $command_line)
1681
-			flush();
1779
+		if ($is_debug && !$support_js && $command_line) {
1780
+					flush();
1781
+		}
1682 1782
 
1683
-		if (trim($line) === '')
1684
-			continue;
1783
+		if (trim($line) === '') {
1784
+					continue;
1785
+		}
1685 1786
 
1686 1787
 		if (trim(substr($line, 0, 3)) === '---')
1687 1788
 		{
@@ -1691,8 +1792,9 @@  discard block
 block discarded – undo
1691 1792
 			if (trim($current_data) != '' && $type !== '}')
1692 1793
 			{
1693 1794
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1694
-				if ($command_line)
1695
-					echo $upcontext['error_message'];
1795
+				if ($command_line) {
1796
+									echo $upcontext['error_message'];
1797
+				}
1696 1798
 			}
1697 1799
 
1698 1800
 			if ($type == ' ')
@@ -1710,17 +1812,18 @@  discard block
 block discarded – undo
1710 1812
 				if ($do_current)
1711 1813
 				{
1712 1814
 					$upcontext['actioned_items'][] = $last_step;
1713
-					if ($command_line)
1714
-						echo ' * ';
1815
+					if ($command_line) {
1816
+											echo ' * ';
1817
+					}
1715 1818
 				}
1716
-			}
1717
-			elseif ($type == '#')
1819
+			} elseif ($type == '#')
1718 1820
 			{
1719 1821
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1720 1822
 
1721 1823
 				$upcontext['current_debug_item_num']++;
1722
-				if (trim($line) != '---#')
1723
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1824
+				if (trim($line) != '---#') {
1825
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1826
+				}
1724 1827
 
1725 1828
 				// Have we already done something?
1726 1829
 				if (isset($_GET['xml']) && $done_something)
@@ -1731,34 +1834,36 @@  discard block
 block discarded – undo
1731 1834
 
1732 1835
 				if ($do_current)
1733 1836
 				{
1734
-					if (trim($line) == '---#' && $command_line)
1735
-						echo ' done.', $endl;
1736
-					elseif ($command_line)
1737
-						echo ' +++ ', rtrim(substr($line, 4));
1738
-					elseif (trim($line) != '---#')
1837
+					if (trim($line) == '---#' && $command_line) {
1838
+											echo ' done.', $endl;
1839
+					} elseif ($command_line) {
1840
+											echo ' +++ ', rtrim(substr($line, 4));
1841
+					} elseif (trim($line) != '---#')
1739 1842
 					{
1740
-						if ($is_debug)
1741
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1843
+						if ($is_debug) {
1844
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1845
+						}
1742 1846
 					}
1743 1847
 				}
1744 1848
 
1745 1849
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1746 1850
 				{
1747
-					if ($command_line)
1748
-						echo ' * ';
1749
-					else
1750
-						$upcontext['actioned_items'][] = $last_step;
1851
+					if ($command_line) {
1852
+											echo ' * ';
1853
+					} else {
1854
+											$upcontext['actioned_items'][] = $last_step;
1855
+					}
1751 1856
 				}
1752 1857
 
1753 1858
 				// Small step - only if we're actually doing stuff.
1754
-				if ($do_current)
1755
-					nextSubstep(++$substep);
1756
-				else
1757
-					$substep++;
1758
-			}
1759
-			elseif ($type == '{')
1760
-				$current_type = 'code';
1761
-			elseif ($type == '}')
1859
+				if ($do_current) {
1860
+									nextSubstep(++$substep);
1861
+				} else {
1862
+									$substep++;
1863
+				}
1864
+			} elseif ($type == '{') {
1865
+							$current_type = 'code';
1866
+			} elseif ($type == '}')
1762 1867
 			{
1763 1868
 				$current_type = 'sql';
1764 1869
 
@@ -1771,8 +1876,9 @@  discard block
 block discarded – undo
1771 1876
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1772 1877
 				{
1773 1878
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1774
-					if ($command_line)
1775
-						echo $upcontext['error_message'];
1879
+					if ($command_line) {
1880
+											echo $upcontext['error_message'];
1881
+					}
1776 1882
 				}
1777 1883
 
1778 1884
 				// Done with code!
@@ -1852,8 +1958,9 @@  discard block
 block discarded – undo
1852 1958
 	$db_unbuffered = false;
1853 1959
 
1854 1960
 	// Failure?!
1855
-	if ($result !== false)
1856
-		return $result;
1961
+	if ($result !== false) {
1962
+			return $result;
1963
+	}
1857 1964
 
1858 1965
 	$db_error_message = $smcFunc['db_error']($db_connection);
1859 1966
 	// If MySQL we do something more clever.
@@ -1881,54 +1988,61 @@  discard block
 block discarded – undo
1881 1988
 			{
1882 1989
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1883 1990
 				$result = mysqli_query($db_connection, $string);
1884
-				if ($result !== false)
1885
-					return $result;
1991
+				if ($result !== false) {
1992
+									return $result;
1993
+				}
1886 1994
 			}
1887
-		}
1888
-		elseif ($mysqli_errno == 2013)
1995
+		} elseif ($mysqli_errno == 2013)
1889 1996
 		{
1890 1997
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1891 1998
 			mysqli_select_db($db_connection, $db_name);
1892 1999
 			if ($db_connection)
1893 2000
 			{
1894 2001
 				$result = mysqli_query($db_connection, $string);
1895
-				if ($result !== false)
1896
-					return $result;
2002
+				if ($result !== false) {
2003
+									return $result;
2004
+				}
1897 2005
 			}
1898 2006
 		}
1899 2007
 		// Duplicate column name... should be okay ;).
1900
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1901
-			return false;
2008
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2009
+					return false;
2010
+		}
1902 2011
 		// Duplicate insert... make sure it's the proper type of query ;).
1903
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1904
-			return false;
2012
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2013
+					return false;
2014
+		}
1905 2015
 		// Creating an index on a non-existent column.
1906
-		elseif ($mysqli_errno == 1072)
1907
-			return false;
1908
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1909
-			return false;
2016
+		elseif ($mysqli_errno == 1072) {
2017
+					return false;
2018
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2019
+					return false;
2020
+		}
1910 2021
 	}
1911 2022
 	// If a table already exists don't go potty.
1912 2023
 	else
1913 2024
 	{
1914 2025
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1915 2026
 		{
1916
-			if (strpos($db_error_message, 'exist') !== false)
1917
-				return true;
1918
-		}
1919
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2027
+			if (strpos($db_error_message, 'exist') !== false) {
2028
+							return true;
2029
+			}
2030
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1920 2031
 		{
1921
-			if (strpos($db_error_message, 'duplicate') !== false)
1922
-				return true;
2032
+			if (strpos($db_error_message, 'duplicate') !== false) {
2033
+							return true;
2034
+			}
1923 2035
 		}
1924 2036
 	}
1925 2037
 
1926 2038
 	// Get the query string so we pass everything.
1927 2039
 	$query_string = '';
1928
-	foreach ($_GET as $k => $v)
1929
-		$query_string .= ';' . $k . '=' . $v;
1930
-	if (strlen($query_string) != 0)
1931
-		$query_string = '?' . substr($query_string, 1);
2040
+	foreach ($_GET as $k => $v) {
2041
+			$query_string .= ';' . $k . '=' . $v;
2042
+	}
2043
+	if (strlen($query_string) != 0) {
2044
+			$query_string = '?' . substr($query_string, 1);
2045
+	}
1932 2046
 
1933 2047
 	if ($command_line)
1934 2048
 	{
@@ -1983,16 +2097,18 @@  discard block
 block discarded – undo
1983 2097
 			{
1984 2098
 				$found |= 1;
1985 2099
 				// Do some checks on the data if we have it set.
1986
-				if (isset($change['col_type']))
1987
-					$found &= $change['col_type'] === $column['type'];
1988
-				if (isset($change['null_allowed']))
1989
-					$found &= $column['null'] == $change['null_allowed'];
1990
-				if (isset($change['default']))
1991
-					$found &= $change['default'] === $column['default'];
2100
+				if (isset($change['col_type'])) {
2101
+									$found &= $change['col_type'] === $column['type'];
2102
+				}
2103
+				if (isset($change['null_allowed'])) {
2104
+									$found &= $column['null'] == $change['null_allowed'];
2105
+				}
2106
+				if (isset($change['default'])) {
2107
+									$found &= $change['default'] === $column['default'];
2108
+				}
1992 2109
 			}
1993 2110
 		}
1994
-	}
1995
-	elseif ($change['type'] === 'index')
2111
+	} elseif ($change['type'] === 'index')
1996 2112
 	{
1997 2113
 		$request = upgrade_query('
1998 2114
 			SHOW INDEX
@@ -2001,9 +2117,10 @@  discard block
 block discarded – undo
2001 2117
 		{
2002 2118
 			$cur_index = array();
2003 2119
 
2004
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2005
-				if ($row['Key_name'] === $change['name'])
2120
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2121
+							if ($row['Key_name'] === $change['name'])
2006 2122
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2123
+			}
2007 2124
 
2008 2125
 			ksort($cur_index, SORT_NUMERIC);
2009 2126
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2013,14 +2130,17 @@  discard block
 block discarded – undo
2013 2130
 	}
2014 2131
 
2015 2132
 	// If we're trying to add and it's added, we're done.
2016
-	if ($found && in_array($change['method'], array('add', 'change')))
2017
-		return true;
2133
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2134
+			return true;
2135
+	}
2018 2136
 	// Otherwise if we're removing and it wasn't found we're also done.
2019
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2020
-		return true;
2137
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2138
+			return true;
2139
+	}
2021 2140
 	// Otherwise is it just a test?
2022
-	elseif ($is_test)
2023
-		return false;
2141
+	elseif ($is_test) {
2142
+			return false;
2143
+	}
2024 2144
 
2025 2145
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2026 2146
 	$running = false;
@@ -2031,8 +2151,9 @@  discard block
 block discarded – undo
2031 2151
 			SHOW FULL PROCESSLIST');
2032 2152
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2033 2153
 		{
2034
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2035
-				$found = true;
2154
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2155
+							$found = true;
2156
+			}
2036 2157
 		}
2037 2158
 
2038 2159
 		// Can't find it? Then we need to run it fools!
@@ -2044,8 +2165,9 @@  discard block
 block discarded – undo
2044 2165
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2045 2166
 				' . $change['text'], true) !== false;
2046 2167
 
2047
-			if (!$success)
2048
-				return false;
2168
+			if (!$success) {
2169
+							return false;
2170
+			}
2049 2171
 
2050 2172
 			// Return
2051 2173
 			$running = true;
@@ -2087,8 +2209,9 @@  discard block
 block discarded – undo
2087 2209
 			'db_error_skip' => true,
2088 2210
 		)
2089 2211
 	);
2090
-	if ($smcFunc['db_num_rows']($request) === 0)
2091
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2212
+	if ($smcFunc['db_num_rows']($request) === 0) {
2213
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2214
+	}
2092 2215
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2093 2216
 	$smcFunc['db_free_result']($request);
2094 2217
 
@@ -2110,18 +2233,19 @@  discard block
 block discarded – undo
2110 2233
 			)
2111 2234
 		);
2112 2235
 		// No results? Just forget it all together.
2113
-		if ($smcFunc['db_num_rows']($request) === 0)
2114
-			unset($table_row['Collation']);
2115
-		else
2116
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2236
+		if ($smcFunc['db_num_rows']($request) === 0) {
2237
+					unset($table_row['Collation']);
2238
+		} else {
2239
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2240
+		}
2117 2241
 		$smcFunc['db_free_result']($request);
2118 2242
 	}
2119 2243
 
2120 2244
 	if ($column_fix)
2121 2245
 	{
2122 2246
 		// Make sure there are no NULL's left.
2123
-		if ($null_fix)
2124
-			$smcFunc['db_query']('', '
2247
+		if ($null_fix) {
2248
+					$smcFunc['db_query']('', '
2125 2249
 				UPDATE {db_prefix}' . $change['table'] . '
2126 2250
 				SET ' . $change['column'] . ' = {string:default}
2127 2251
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2130,6 +2254,7 @@  discard block
 block discarded – undo
2130 2254
 					'db_error_skip' => true,
2131 2255
 				)
2132 2256
 			);
2257
+		}
2133 2258
 
2134 2259
 		// Do the actual alteration.
2135 2260
 		$smcFunc['db_query']('', '
@@ -2158,8 +2283,9 @@  discard block
 block discarded – undo
2158 2283
 	}
2159 2284
 
2160 2285
 	// Not a column we need to check on?
2161
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2162
-		return;
2286
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2287
+			return;
2288
+	}
2163 2289
 
2164 2290
 	// Break it up you (six|seven).
2165 2291
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2178,13 +2304,13 @@  discard block
 block discarded – undo
2178 2304
 				'new_name' => $temp[2],
2179 2305
 		));
2180 2306
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2181
-		if ($smcFunc['db_num_rows'] != 1)
2182
-			return;
2307
+		if ($smcFunc['db_num_rows'] != 1) {
2308
+					return;
2309
+		}
2183 2310
 
2184 2311
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2185 2312
 		$smcFunc['db_free_result']($request);
2186
-	}
2187
-	else
2313
+	} else
2188 2314
 	{
2189 2315
 		// Do this the old fashion, sure method way.
2190 2316
 		$request = $smcFunc['db_query']('', '
@@ -2195,21 +2321,24 @@  discard block
 block discarded – undo
2195 2321
 		));
2196 2322
 		// Mayday!
2197 2323
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2198
-		if ($smcFunc['db_num_rows'] == 0)
2199
-			return;
2324
+		if ($smcFunc['db_num_rows'] == 0) {
2325
+					return;
2326
+		}
2200 2327
 
2201 2328
 		// Oh where, oh where has my little field gone. Oh where can it be...
2202
-		while ($row = $smcFunc['db_query']($request))
2203
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2329
+		while ($row = $smcFunc['db_query']($request)) {
2330
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2204 2331
 			{
2205 2332
 				$current_type = $row['Type'];
2333
+		}
2206 2334
 				break;
2207 2335
 			}
2208 2336
 	}
2209 2337
 
2210 2338
 	// If this doesn't match, the column may of been altered for a reason.
2211
-	if (trim($current_type) != trim($temp[3]))
2212
-		$temp[3] = $current_type;
2339
+	if (trim($current_type) != trim($temp[3])) {
2340
+			$temp[3] = $current_type;
2341
+	}
2213 2342
 
2214 2343
 	// Piece this back together.
2215 2344
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2221,8 +2350,9 @@  discard block
 block discarded – undo
2221 2350
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2222 2351
 	global $step_progress, $is_debug, $upcontext;
2223 2352
 
2224
-	if ($_GET['substep'] < $substep)
2225
-		$_GET['substep'] = $substep;
2353
+	if ($_GET['substep'] < $substep) {
2354
+			$_GET['substep'] = $substep;
2355
+	}
2226 2356
 
2227 2357
 	if ($command_line)
2228 2358
 	{
@@ -2235,29 +2365,33 @@  discard block
 block discarded – undo
2235 2365
 	}
2236 2366
 
2237 2367
 	@set_time_limit(300);
2238
-	if (function_exists('apache_reset_timeout'))
2239
-		@apache_reset_timeout();
2368
+	if (function_exists('apache_reset_timeout')) {
2369
+			@apache_reset_timeout();
2370
+	}
2240 2371
 
2241
-	if (time() - $start_time <= $timeLimitThreshold)
2242
-		return;
2372
+	if (time() - $start_time <= $timeLimitThreshold) {
2373
+			return;
2374
+	}
2243 2375
 
2244 2376
 	// Do we have some custom step progress stuff?
2245 2377
 	if (!empty($step_progress))
2246 2378
 	{
2247 2379
 		$upcontext['substep_progress'] = 0;
2248 2380
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2249
-		if ($step_progress['current'] > $step_progress['total'])
2250
-			$upcontext['substep_progress'] = 99.9;
2251
-		else
2252
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2381
+		if ($step_progress['current'] > $step_progress['total']) {
2382
+					$upcontext['substep_progress'] = 99.9;
2383
+		} else {
2384
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2385
+		}
2253 2386
 
2254 2387
 		// Make it nicely rounded.
2255 2388
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2256 2389
 	}
2257 2390
 
2258 2391
 	// If this is XML we just exit right away!
2259
-	if (isset($_GET['xml']))
2260
-		return upgradeExit();
2392
+	if (isset($_GET['xml'])) {
2393
+			return upgradeExit();
2394
+	}
2261 2395
 
2262 2396
 	// We're going to pause after this!
2263 2397
 	$upcontext['pause'] = true;
@@ -2265,13 +2399,15 @@  discard block
 block discarded – undo
2265 2399
 	$upcontext['query_string'] = '';
2266 2400
 	foreach ($_GET as $k => $v)
2267 2401
 	{
2268
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2269
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2402
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2403
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2404
+		}
2270 2405
 	}
2271 2406
 
2272 2407
 	// Custom warning?
2273
-	if (!empty($custom_warning))
2274
-		$upcontext['custom_warning'] = $custom_warning;
2408
+	if (!empty($custom_warning)) {
2409
+			$upcontext['custom_warning'] = $custom_warning;
2410
+	}
2275 2411
 
2276 2412
 	upgradeExit();
2277 2413
 }
@@ -2286,25 +2422,26 @@  discard block
 block discarded – undo
2286 2422
 	ob_implicit_flush(true);
2287 2423
 	@set_time_limit(600);
2288 2424
 
2289
-	if (!isset($_SERVER['argv']))
2290
-		$_SERVER['argv'] = array();
2425
+	if (!isset($_SERVER['argv'])) {
2426
+			$_SERVER['argv'] = array();
2427
+	}
2291 2428
 	$_GET['maint'] = 1;
2292 2429
 
2293 2430
 	foreach ($_SERVER['argv'] as $i => $arg)
2294 2431
 	{
2295
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2296
-			$_GET['lang'] = $match[1];
2297
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2298
-			continue;
2299
-		elseif ($arg == '--no-maintenance')
2300
-			$_GET['maint'] = 0;
2301
-		elseif ($arg == '--debug')
2302
-			$is_debug = true;
2303
-		elseif ($arg == '--backup')
2304
-			$_POST['backup'] = 1;
2305
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2306
-			$_GET['conv'] = 1;
2307
-		elseif ($i != 0)
2432
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2433
+					$_GET['lang'] = $match[1];
2434
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2435
+					continue;
2436
+		} elseif ($arg == '--no-maintenance') {
2437
+					$_GET['maint'] = 0;
2438
+		} elseif ($arg == '--debug') {
2439
+					$is_debug = true;
2440
+		} elseif ($arg == '--backup') {
2441
+					$_POST['backup'] = 1;
2442
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2443
+					$_GET['conv'] = 1;
2444
+		} elseif ($i != 0)
2308 2445
 		{
2309 2446
 			echo 'SMF Command-line Upgrader
2310 2447
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2318,10 +2455,12 @@  discard block
 block discarded – undo
2318 2455
 		}
2319 2456
 	}
2320 2457
 
2321
-	if (!php_version_check())
2322
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2323
-	if (!db_version_check())
2324
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2458
+	if (!php_version_check()) {
2459
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2460
+	}
2461
+	if (!db_version_check()) {
2462
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2463
+	}
2325 2464
 
2326 2465
 	// Do some checks to make sure they have proper privileges
2327 2466
 	db_extend('packages');
@@ -2336,34 +2475,39 @@  discard block
 block discarded – undo
2336 2475
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2337 2476
 
2338 2477
 	// Sorry... we need CREATE, ALTER and DROP
2339
-	if (!$create || !$alter || !$drop)
2340
-		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);
2478
+	if (!$create || !$alter || !$drop) {
2479
+			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);
2480
+	}
2341 2481
 
2342 2482
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2343 2483
 		&& @file_exists($sourcedir . '/QueryString.php')
2344 2484
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2345
-	if (!$check && !isset($modSettings['smfVersion']))
2346
-		print_error('Error: Some files are missing or out-of-date.', true);
2485
+	if (!$check && !isset($modSettings['smfVersion'])) {
2486
+			print_error('Error: Some files are missing or out-of-date.', true);
2487
+	}
2347 2488
 
2348 2489
 	// Do a quick version spot check.
2349 2490
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2350 2491
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2351
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2352
-		print_error('Error: Some files have not yet been updated properly.');
2492
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2493
+			print_error('Error: Some files have not yet been updated properly.');
2494
+	}
2353 2495
 
2354 2496
 	// Make sure Settings.php is writable.
2355 2497
 		quickFileWritable($boarddir . '/Settings.php');
2356
-	if (!is_writable($boarddir . '/Settings.php'))
2357
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2498
+	if (!is_writable($boarddir . '/Settings.php')) {
2499
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2500
+	}
2358 2501
 
2359 2502
 	// Make sure Settings_bak.php is writable.
2360 2503
 		quickFileWritable($boarddir . '/Settings_bak.php');
2361
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2362
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2504
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2505
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2506
+	}
2363 2507
 
2364
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2365
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2366
-	elseif (isset($modSettings['agreement']))
2508
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2509
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2510
+	} elseif (isset($modSettings['agreement']))
2367 2511
 	{
2368 2512
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2369 2513
 		fwrite($fp, $modSettings['agreement']);
@@ -2373,31 +2517,36 @@  discard block
 block discarded – undo
2373 2517
 	// Make sure Themes is writable.
2374 2518
 	quickFileWritable($modSettings['theme_dir']);
2375 2519
 
2376
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2377
-		print_error('Error: Unable to obtain write access to "Themes".');
2520
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2521
+			print_error('Error: Unable to obtain write access to "Themes".');
2522
+	}
2378 2523
 
2379 2524
 	// Make sure cache directory exists and is writable!
2380 2525
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2381
-	if (!file_exists($cachedir_temp))
2382
-		@mkdir($cachedir_temp);
2526
+	if (!file_exists($cachedir_temp)) {
2527
+			@mkdir($cachedir_temp);
2528
+	}
2383 2529
 
2384 2530
 	// Make sure the cache temp dir is writable.
2385 2531
 	quickFileWritable($cachedir_temp);
2386 2532
 
2387
-	if (!is_writable($cachedir_temp))
2388
-		print_error('Error: Unable to obtain write access to "cache".', true);
2533
+	if (!is_writable($cachedir_temp)) {
2534
+			print_error('Error: Unable to obtain write access to "cache".', true);
2535
+	}
2389 2536
 
2390
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2391
-		print_error('Error: Unable to find language files!', true);
2392
-	else
2537
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2538
+			print_error('Error: Unable to find language files!', true);
2539
+	} else
2393 2540
 	{
2394 2541
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2395 2542
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2396 2543
 
2397
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2398
-			print_error('Error: Language files out of date.', true);
2399
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2400
-			print_error('Error: Install language is missing for selected language.', true);
2544
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2545
+					print_error('Error: Language files out of date.', true);
2546
+		}
2547
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2548
+					print_error('Error: Install language is missing for selected language.', true);
2549
+		}
2401 2550
 
2402 2551
 		// Otherwise include it!
2403 2552
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2426,8 +2575,7 @@  discard block
 block discarded – undo
2426 2575
 		);
2427 2576
 
2428 2577
 		return true;
2429
-	}
2430
-	else
2578
+	} else
2431 2579
 	{
2432 2580
 		$upcontext['page_title'] = 'Converting to UTF8';
2433 2581
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2471,8 +2619,9 @@  discard block
 block discarded – undo
2471 2619
 			)
2472 2620
 		);
2473 2621
 		$db_charsets = array();
2474
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2475
-			$db_charsets[] = $row['Charset'];
2622
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2623
+					$db_charsets[] = $row['Charset'];
2624
+		}
2476 2625
 
2477 2626
 		$smcFunc['db_free_result']($request);
2478 2627
 
@@ -2508,13 +2657,15 @@  discard block
 block discarded – undo
2508 2657
 		// If there's a fulltext index, we need to drop it first...
2509 2658
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2510 2659
 		{
2511
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2512
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2660
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2661
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2513 2662
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2663
+			}
2514 2664
 			$smcFunc['db_free_result']($request);
2515 2665
 
2516
-			if (isset($upcontext['fulltext_index']))
2517
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2666
+			if (isset($upcontext['fulltext_index'])) {
2667
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2668
+			}
2518 2669
 		}
2519 2670
 
2520 2671
 		// Drop it and make a note...
@@ -2704,8 +2855,9 @@  discard block
 block discarded – undo
2704 2855
 			$replace = '%field%';
2705 2856
 
2706 2857
 			// Build a huge REPLACE statement...
2707
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2708
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2858
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2859
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2860
+			}
2709 2861
 		}
2710 2862
 
2711 2863
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2739,8 +2891,9 @@  discard block
 block discarded – undo
2739 2891
 			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2740 2892
 
2741 2893
 			// Just to make sure it doesn't time out.
2742
-			if (function_exists('apache_reset_timeout'))
2743
-				@apache_reset_timeout();
2894
+			if (function_exists('apache_reset_timeout')) {
2895
+							@apache_reset_timeout();
2896
+			}
2744 2897
 
2745 2898
 			$table_charsets = array();
2746 2899
 
@@ -2761,8 +2914,9 @@  discard block
 block discarded – undo
2761 2914
 					{
2762 2915
 						list($charset) = explode('_', $collation);
2763 2916
 
2764
-						if (!isset($table_charsets[$charset]))
2765
-							$table_charsets[$charset] = array();
2917
+						if (!isset($table_charsets[$charset])) {
2918
+													$table_charsets[$charset] = array();
2919
+						}
2766 2920
 
2767 2921
 						$table_charsets[$charset][] = $column_info;
2768 2922
 					}
@@ -2802,10 +2956,11 @@  discard block
 block discarded – undo
2802 2956
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2803 2957
 				{
2804 2958
 					$update = '';
2805
-					foreach ($table_charsets as $charset => $columns)
2806
-						foreach ($columns as $column)
2959
+					foreach ($table_charsets as $charset => $columns) {
2960
+											foreach ($columns as $column)
2807 2961
 							$update .= '
2808 2962
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2963
+					}
2809 2964
 
2810 2965
 					$smcFunc['db_query']('', '
2811 2966
 						UPDATE {raw:table_name}
@@ -2830,8 +2985,9 @@  discard block
 block discarded – undo
2830 2985
 			// Now do the actual conversion (if still needed).
2831 2986
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2832 2987
 			{
2833
-				if ($command_line)
2834
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2988
+				if ($command_line) {
2989
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2990
+				}
2835 2991
 
2836 2992
 				$smcFunc['db_query']('', '
2837 2993
 					ALTER TABLE {raw:table_name}
@@ -2841,8 +2997,9 @@  discard block
 block discarded – undo
2841 2997
 						)
2842 2998
 				);
2843 2999
 
2844
-				if ($command_line)
2845
-					echo " done.\n";
3000
+				if ($command_line) {
3001
+									echo " done.\n";
3002
+				}
2846 3003
 			}
2847 3004
 		}
2848 3005
 
@@ -2872,8 +3029,8 @@  discard block
 block discarded – undo
2872 3029
 		);
2873 3030
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2874 3031
 		{
2875
-			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)
2876
-				$smcFunc['db_query']('', '
3032
+			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) {
3033
+							$smcFunc['db_query']('', '
2877 3034
 					UPDATE {db_prefix}log_actions
2878 3035
 					SET extra = {string:extra}
2879 3036
 					WHERE id_action = {int:current_action}',
@@ -2882,6 +3039,7 @@  discard block
 block discarded – undo
2882 3039
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2883 3040
 					)
2884 3041
 				);
3042
+			}
2885 3043
 		}
2886 3044
 		$smcFunc['db_free_result']($request);
2887 3045
 
@@ -2903,15 +3061,17 @@  discard block
 block discarded – undo
2903 3061
 	// First thing's first - did we already do this?
2904 3062
 	if (!empty($modSettings['json_done']))
2905 3063
 	{
2906
-		if ($command_line)
2907
-			return DeleteUpgrade();
2908
-		else
2909
-			return true;
3064
+		if ($command_line) {
3065
+					return DeleteUpgrade();
3066
+		} else {
3067
+					return true;
3068
+		}
2910 3069
 	}
2911 3070
 
2912 3071
 	// Done it already - js wise?
2913
-	if (!empty($_POST['json_done']))
2914
-		return true;
3072
+	if (!empty($_POST['json_done'])) {
3073
+			return true;
3074
+	}
2915 3075
 
2916 3076
 	// List of tables affected by this function
2917 3077
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2942,12 +3102,14 @@  discard block
 block discarded – undo
2942 3102
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2943 3103
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2944 3104
 
2945
-	foreach ($keys as $id => $table)
2946
-		if ($id < $_GET['substep'])
3105
+	foreach ($keys as $id => $table) {
3106
+			if ($id < $_GET['substep'])
2947 3107
 			$upcontext['previous_tables'][] = $table;
3108
+	}
2948 3109
 
2949
-	if ($command_line)
2950
-		echo 'Converting data from serialize() to json_encode().';
3110
+	if ($command_line) {
3111
+			echo 'Converting data from serialize() to json_encode().';
3112
+	}
2951 3113
 
2952 3114
 	if (!$support_js || isset($_GET['xml']))
2953 3115
 	{
@@ -2987,8 +3149,9 @@  discard block
 block discarded – undo
2987 3149
 
2988 3150
 				// Loop through and fix these...
2989 3151
 				$new_settings = array();
2990
-				if ($command_line)
2991
-					echo "\n" . 'Fixing some settings...';
3152
+				if ($command_line) {
3153
+									echo "\n" . 'Fixing some settings...';
3154
+				}
2992 3155
 
2993 3156
 				foreach ($serialized_settings as $var)
2994 3157
 				{
@@ -2996,22 +3159,24 @@  discard block
 block discarded – undo
2996 3159
 					{
2997 3160
 						// Attempt to unserialize the setting
2998 3161
 						$temp = @safe_unserialize($modSettings[$var]);
2999
-						if (!$temp && $command_line)
3000
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3001
-						elseif ($temp !== false)
3002
-							$new_settings[$var] = json_encode($temp);
3162
+						if (!$temp && $command_line) {
3163
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3164
+						} elseif ($temp !== false) {
3165
+													$new_settings[$var] = json_encode($temp);
3166
+						}
3003 3167
 					}
3004 3168
 				}
3005 3169
 
3006 3170
 				// Update everything at once
3007
-				if (!function_exists('cache_put_data'))
3008
-					require_once($sourcedir . '/Load.php');
3171
+				if (!function_exists('cache_put_data')) {
3172
+									require_once($sourcedir . '/Load.php');
3173
+				}
3009 3174
 				updateSettings($new_settings, true);
3010 3175
 
3011
-				if ($command_line)
3012
-					echo ' done.';
3013
-			}
3014
-			elseif ($table == 'themes')
3176
+				if ($command_line) {
3177
+									echo ' done.';
3178
+				}
3179
+			} elseif ($table == 'themes')
3015 3180
 			{
3016 3181
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3017 3182
 				$query = $smcFunc['db_query']('', '
@@ -3030,10 +3195,11 @@  discard block
 block discarded – undo
3030 3195
 
3031 3196
 						if ($command_line)
3032 3197
 						{
3033
-							if ($temp === false)
3034
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3035
-							else
3036
-								echo "\n" . 'Fixing admin preferences...';
3198
+							if ($temp === false) {
3199
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3200
+							} else {
3201
+															echo "\n" . 'Fixing admin preferences...';
3202
+							}
3037 3203
 						}
3038 3204
 
3039 3205
 						if ($temp !== false)
@@ -3053,15 +3219,15 @@  discard block
 block discarded – undo
3053 3219
 								)
3054 3220
 							);
3055 3221
 
3056
-							if ($command_line)
3057
-								echo ' done.';
3222
+							if ($command_line) {
3223
+															echo ' done.';
3224
+							}
3058 3225
 						}
3059 3226
 					}
3060 3227
 
3061 3228
 					$smcFunc['db_free_result']($query);
3062 3229
 				}
3063
-			}
3064
-			else
3230
+			} else
3065 3231
 			{
3066 3232
 				// First item is always the key...
3067 3233
 				$key = $info[0];
@@ -3072,8 +3238,7 @@  discard block
 block discarded – undo
3072 3238
 				{
3073 3239
 					$col_select = $info[1];
3074 3240
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3075
-				}
3076
-				else
3241
+				} else
3077 3242
 				{
3078 3243
 					$col_select = implode(', ', $info);
3079 3244
 				}
@@ -3106,8 +3271,7 @@  discard block
 block discarded – undo
3106 3271
 								if ($temp === false && $command_line)
3107 3272
 								{
3108 3273
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3109
-								}
3110
-								else
3274
+								} else
3111 3275
 								{
3112 3276
 									$row[$col] = json_encode($temp);
3113 3277
 
@@ -3132,16 +3296,18 @@  discard block
 block discarded – undo
3132 3296
 						}
3133 3297
 					}
3134 3298
 
3135
-					if ($command_line)
3136
-						echo ' done.';
3299
+					if ($command_line) {
3300
+											echo ' done.';
3301
+					}
3137 3302
 
3138 3303
 					// Free up some memory...
3139 3304
 					$smcFunc['db_free_result']($query);
3140 3305
 				}
3141 3306
 			}
3142 3307
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3143
-			if (isset($_GET['xml']))
3144
-				return upgradeExit();
3308
+			if (isset($_GET['xml'])) {
3309
+							return upgradeExit();
3310
+			}
3145 3311
 		}
3146 3312
 
3147 3313
 		if ($command_line)
@@ -3156,8 +3322,9 @@  discard block
 block discarded – undo
3156 3322
 
3157 3323
 		$_GET['substep'] = 0;
3158 3324
 		// Make sure we move on!
3159
-		if ($command_line)
3160
-			return DeleteUpgrade();
3325
+		if ($command_line) {
3326
+					return DeleteUpgrade();
3327
+		}
3161 3328
 
3162 3329
 		return true;
3163 3330
 	}
@@ -3177,14 +3344,16 @@  discard block
 block discarded – undo
3177 3344
 	global $upcontext, $txt, $settings;
3178 3345
 
3179 3346
 	// Don't call me twice!
3180
-	if (!empty($upcontext['chmod_called']))
3181
-		return;
3347
+	if (!empty($upcontext['chmod_called'])) {
3348
+			return;
3349
+	}
3182 3350
 
3183 3351
 	$upcontext['chmod_called'] = true;
3184 3352
 
3185 3353
 	// Nothing?
3186
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3187
-		return;
3354
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3355
+			return;
3356
+	}
3188 3357
 
3189 3358
 	// Was it a problem with Windows?
3190 3359
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3216,11 +3385,12 @@  discard block
 block discarded – undo
3216 3385
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\');
3217 3386
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3218 3387
 
3219
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3220
-		echo '
3388
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3389
+			echo '
3221 3390
 					content.write(\'<hr>\n\t\t\t\');
3222 3391
 					content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\');
3223 3392
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3393
+	}
3224 3394
 
3225 3395
 	echo '
3226 3396
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3228,17 +3398,19 @@  discard block
 block discarded – undo
3228 3398
 				}
3229 3399
 		</script>';
3230 3400
 
3231
-	if (!empty($upcontext['chmod']['ftp_error']))
3232
-		echo '
3401
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3402
+			echo '
3233 3403
 			<div class="error_message red">
3234 3404
 				The following error was encountered when trying to connect:<br><br>
3235 3405
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3236 3406
 			</div>
3237 3407
 			<br>';
3408
+	}
3238 3409
 
3239
-	if (empty($upcontext['chmod_in_form']))
3240
-		echo '
3410
+	if (empty($upcontext['chmod_in_form'])) {
3411
+			echo '
3241 3412
 	<form action="', $upcontext['form_url'], '" method="post">';
3413
+	}
3242 3414
 
3243 3415
 	echo '
3244 3416
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3273,10 +3445,11 @@  discard block
 block discarded – undo
3273 3445
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3274 3446
 	</div>';
3275 3447
 
3276
-	if (empty($upcontext['chmod_in_form']))
3277
-		echo '
3448
+	if (empty($upcontext['chmod_in_form'])) {
3449
+			echo '
3278 3450
 	</form>';
3279
-}
3451
+	}
3452
+	}
3280 3453
 
3281 3454
 function template_upgrade_above()
3282 3455
 {
@@ -3336,9 +3509,10 @@  discard block
 block discarded – undo
3336 3509
 				<h2>', $txt['upgrade_progress'], '</h2>
3337 3510
 				<ul>';
3338 3511
 
3339
-	foreach ($upcontext['steps'] as $num => $step)
3340
-		echo '
3512
+	foreach ($upcontext['steps'] as $num => $step) {
3513
+			echo '
3341 3514
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3515
+	}
3342 3516
 
3343 3517
 	echo '
3344 3518
 					</ul>
@@ -3351,8 +3525,8 @@  discard block
 block discarded – undo
3351 3525
 				</div>
3352 3526
 			</div>';
3353 3527
 
3354
-	if (isset($upcontext['step_progress']))
3355
-		echo '
3528
+	if (isset($upcontext['step_progress'])) {
3529
+			echo '
3356 3530
 				<br>
3357 3531
 				<br>
3358 3532
 				<div id="progress_bar_step">
@@ -3361,6 +3535,7 @@  discard block
 block discarded – undo
3361 3535
 						<span>', $txt['upgrade_step_progress'], '</span>
3362 3536
 					</div>
3363 3537
 				</div>';
3538
+	}
3364 3539
 
3365 3540
 	echo '
3366 3541
 				<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>
@@ -3391,32 +3566,36 @@  discard block
 block discarded – undo
3391 3566
 {
3392 3567
 	global $upcontext, $txt;
3393 3568
 
3394
-	if (!empty($upcontext['pause']))
3395
-		echo '
3569
+	if (!empty($upcontext['pause'])) {
3570
+			echo '
3396 3571
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3397 3572
 
3398 3573
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3399 3574
 								<h3>
3400 3575
 									', $txt['upgrade_paused_overload'], '
3401 3576
 								</h3>';
3577
+	}
3402 3578
 
3403
-	if (!empty($upcontext['custom_warning']))
3404
-		echo '
3579
+	if (!empty($upcontext['custom_warning'])) {
3580
+			echo '
3405 3581
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3406 3582
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3407 3583
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3408 3584
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3409 3585
 								</div>';
3586
+	}
3410 3587
 
3411 3588
 	echo '
3412 3589
 								<div class="righttext" style="margin: 1ex;">';
3413 3590
 
3414
-	if (!empty($upcontext['continue']))
3415
-		echo '
3591
+	if (!empty($upcontext['continue'])) {
3592
+			echo '
3416 3593
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3417
-	if (!empty($upcontext['skip']))
3418
-		echo '
3594
+	}
3595
+	if (!empty($upcontext['skip'])) {
3596
+			echo '
3419 3597
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3598
+	}
3420 3599
 
3421 3600
 	echo '
3422 3601
 								</div>
@@ -3466,11 +3645,12 @@  discard block
 block discarded – undo
3466 3645
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3467 3646
 	<smf>';
3468 3647
 
3469
-	if (!empty($upcontext['get_data']))
3470
-		foreach ($upcontext['get_data'] as $k => $v)
3648
+	if (!empty($upcontext['get_data'])) {
3649
+			foreach ($upcontext['get_data'] as $k => $v)
3471 3650
 			echo '
3472 3651
 		<get key="', $k, '">', $v, '</get>';
3473
-}
3652
+	}
3653
+	}
3474 3654
 
3475 3655
 function template_xml_below()
3476 3656
 {
@@ -3511,8 +3691,8 @@  discard block
 block discarded – undo
3511 3691
 	template_chmod();
3512 3692
 
3513 3693
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3514
-	if ($upcontext['is_large_forum'])
3515
-		echo '
3694
+	if ($upcontext['is_large_forum']) {
3695
+			echo '
3516 3696
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3517 3697
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3518 3698
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3520,10 +3700,11 @@  discard block
 block discarded – undo
3520 3700
 				', $txt['upgrade_warning_lots_data'], '
3521 3701
 			</div>
3522 3702
 		</div>';
3703
+	}
3523 3704
 
3524 3705
 	// A warning message?
3525
-	if (!empty($upcontext['warning']))
3526
-		echo '
3706
+	if (!empty($upcontext['warning'])) {
3707
+			echo '
3527 3708
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3528 3709
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3529 3710
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3531,6 +3712,7 @@  discard block
 block discarded – undo
3531 3712
 				', $upcontext['warning'], '
3532 3713
 			</div>
3533 3714
 		</div>';
3715
+	}
3534 3716
 
3535 3717
 	// Paths are incorrect?
3536 3718
 	echo '
@@ -3546,20 +3728,22 @@  discard block
 block discarded – undo
3546 3728
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3547 3729
 	{
3548 3730
 		$ago = time() - $upcontext['started'];
3549
-		if ($ago < 60)
3550
-			$ago = $ago . ' seconds';
3551
-		elseif ($ago < 3600)
3552
-			$ago = (int) ($ago / 60) . ' minutes';
3553
-		else
3554
-			$ago = (int) ($ago / 3600) . ' hours';
3731
+		if ($ago < 60) {
3732
+					$ago = $ago . ' seconds';
3733
+		} elseif ($ago < 3600) {
3734
+					$ago = (int) ($ago / 60) . ' minutes';
3735
+		} else {
3736
+					$ago = (int) ($ago / 3600) . ' hours';
3737
+		}
3555 3738
 
3556 3739
 		$active = time() - $upcontext['updated'];
3557
-		if ($active < 60)
3558
-			$updated = $active . ' seconds';
3559
-		elseif ($active < 3600)
3560
-			$updated = (int) ($active / 60) . ' minutes';
3561
-		else
3562
-			$updated = (int) ($active / 3600) . ' hours';
3740
+		if ($active < 60) {
3741
+					$updated = $active . ' seconds';
3742
+		} elseif ($active < 3600) {
3743
+					$updated = (int) ($active / 60) . ' minutes';
3744
+		} else {
3745
+					$updated = (int) ($active / 3600) . ' hours';
3746
+		}
3563 3747
 
3564 3748
 		echo '
3565 3749
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3568,16 +3752,18 @@  discard block
 block discarded – undo
3568 3752
 			<div style="padding-left: 6ex;">
3569 3753
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3570 3754
 
3571
-		if ($active < 600)
3572
-			echo '
3755
+		if ($active < 600) {
3756
+					echo '
3573 3757
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3758
+		}
3574 3759
 
3575
-		if ($active > $upcontext['inactive_timeout'])
3576
-			echo '
3760
+		if ($active > $upcontext['inactive_timeout']) {
3761
+					echo '
3577 3762
 				<br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
3578
-		else
3579
-			echo '
3763
+		} else {
3764
+					echo '
3580 3765
 				<br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
3766
+		}
3581 3767
 
3582 3768
 		echo '
3583 3769
 			</div>
@@ -3593,9 +3779,10 @@  discard block
 block discarded – undo
3593 3779
 					<td>
3594 3780
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3595 3781
 
3596
-	if (!empty($upcontext['username_incorrect']))
3597
-		echo '
3782
+	if (!empty($upcontext['username_incorrect'])) {
3783
+			echo '
3598 3784
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3785
+	}
3599 3786
 
3600 3787
 	echo '
3601 3788
 					</td>
@@ -3606,9 +3793,10 @@  discard block
 block discarded – undo
3606 3793
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3607 3794
 						<input type="hidden" name="hash_passwrd" value="">';
3608 3795
 
3609
-	if (!empty($upcontext['password_failed']))
3610
-		echo '
3796
+	if (!empty($upcontext['password_failed'])) {
3797
+			echo '
3611 3798
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3799
+	}
3612 3800
 
3613 3801
 	echo '
3614 3802
 					</td>
@@ -3679,8 +3867,8 @@  discard block
 block discarded – undo
3679 3867
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3680 3868
 
3681 3869
 	// Warning message?
3682
-	if (!empty($upcontext['upgrade_options_warning']))
3683
-		echo '
3870
+	if (!empty($upcontext['upgrade_options_warning'])) {
3871
+			echo '
3684 3872
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3685 3873
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3686 3874
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3688,6 +3876,7 @@  discard block
 block discarded – undo
3688 3876
 				', $upcontext['upgrade_options_warning'], '
3689 3877
 			</div>
3690 3878
 		</div>';
3879
+	}
3691 3880
 
3692 3881
 	echo '
3693 3882
 				<table>
@@ -3730,8 +3919,8 @@  discard block
 block discarded – undo
3730 3919
 						</td>
3731 3920
 					</tr>';
3732 3921
 
3733
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3734
-		echo '
3922
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3923
+			echo '
3735 3924
 					<tr valign="top">
3736 3925
 						<td width="2%">
3737 3926
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3740,6 +3929,7 @@  discard block
 block discarded – undo
3740 3929
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3741 3930
 						</td>
3742 3931
 					</tr>';
3932
+	}
3743 3933
 
3744 3934
 	echo '
3745 3935
 					<tr valign="top">
@@ -3775,10 +3965,11 @@  discard block
 block discarded – undo
3775 3965
 			<span id="debuginfo"></span>';
3776 3966
 
3777 3967
 	// Dont any tables so far?
3778
-	if (!empty($upcontext['previous_tables']))
3779
-		foreach ($upcontext['previous_tables'] as $table)
3968
+	if (!empty($upcontext['previous_tables'])) {
3969
+			foreach ($upcontext['previous_tables'] as $table)
3780 3970
 			echo '
3781 3971
 			<br>Completed Table: &quot;', $table, '&quot;.';
3972
+	}
3782 3973
 
3783 3974
 	echo '
3784 3975
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3815,12 +4006,13 @@  discard block
 block discarded – undo
3815 4006
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3816 4007
 
3817 4008
 		// If debug flood the screen.
3818
-		if ($is_debug)
3819
-			echo '
4009
+		if ($is_debug) {
4010
+					echo '
3820 4011
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3821 4012
 
3822 4013
 				if (document.getElementById(\'debuginfo\').scrollHeight)
3823 4014
 					document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;';
4015
+		}
3824 4016
 
3825 4017
 		echo '
3826 4018
 				// Get the next update...
@@ -3852,8 +4044,9 @@  discard block
 block discarded – undo
3852 4044
 {
3853 4045
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3854 4046
 
3855
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3856
-		$is_debug = true;
4047
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4048
+			$is_debug = true;
4049
+	}
3857 4050
 
3858 4051
 	echo '
3859 4052
 		<h3>Executing database changes</h3>
@@ -3868,8 +4061,9 @@  discard block
 block discarded – undo
3868 4061
 	{
3869 4062
 		foreach ($upcontext['actioned_items'] as $num => $item)
3870 4063
 		{
3871
-			if ($num != 0)
3872
-				echo ' Successful!';
4064
+			if ($num != 0) {
4065
+							echo ' Successful!';
4066
+			}
3873 4067
 			echo '<br>' . $item;
3874 4068
 		}
3875 4069
 		if (!empty($upcontext['changes_complete']))
@@ -3882,28 +4076,32 @@  discard block
 block discarded – undo
3882 4076
 				$seconds = intval($active % 60);
3883 4077
 
3884 4078
 				$totalTime = '';
3885
-				if ($hours > 0)
3886
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3887
-				if ($minutes > 0)
3888
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3889
-				if ($seconds > 0)
3890
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4079
+				if ($hours > 0) {
4080
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4081
+				}
4082
+				if ($minutes > 0) {
4083
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4084
+				}
4085
+				if ($seconds > 0) {
4086
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4087
+				}
3891 4088
 			}
3892 4089
 
3893
-			if ($is_debug && !empty($totalTime))
3894
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3895
-			else
3896
-				echo ' Successful!<br><br>';
4090
+			if ($is_debug && !empty($totalTime)) {
4091
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4092
+			} else {
4093
+							echo ' Successful!<br><br>';
4094
+			}
3897 4095
 
3898 4096
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3899 4097
 		}
3900
-	}
3901
-	else
4098
+	} else
3902 4099
 	{
3903 4100
 		// Tell them how many files we have in total.
3904
-		if ($upcontext['file_count'] > 1)
3905
-			echo '
4101
+		if ($upcontext['file_count'] > 1) {
4102
+					echo '
3906 4103
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4104
+		}
3907 4105
 
3908 4106
 		echo '
3909 4107
 		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -3919,19 +4117,23 @@  discard block
 block discarded – undo
3919 4117
 				$seconds = intval($active % 60);
3920 4118
 
3921 4119
 				$totalTime = '';
3922
-				if ($hours > 0)
3923
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3924
-				if ($minutes > 0)
3925
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3926
-				if ($seconds > 0)
3927
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4120
+				if ($hours > 0) {
4121
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4122
+				}
4123
+				if ($minutes > 0) {
4124
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4125
+				}
4126
+				if ($seconds > 0) {
4127
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4128
+				}
3928 4129
 			}
3929 4130
 
3930 4131
 			echo '
3931 4132
 			<br><span id="upgradeCompleted">';
3932 4133
 
3933
-			if (!empty($totalTime))
3934
-				echo 'Completed in ', $totalTime, '<br>';
4134
+			if (!empty($totalTime)) {
4135
+							echo 'Completed in ', $totalTime, '<br>';
4136
+			}
3935 4137
 
3936 4138
 			echo '</span>
3937 4139
 			<div id="debug_section" style="height: 200px; overflow: auto;">
@@ -3968,9 +4170,10 @@  discard block
 block discarded – undo
3968 4170
 			var getData = "";
3969 4171
 			var debugItems = ', $upcontext['debug_items'], ';';
3970 4172
 
3971
-		if ($is_debug)
3972
-			echo '
4173
+		if ($is_debug) {
4174
+					echo '
3973 4175
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4176
+		}
3974 4177
 
3975 4178
 		echo '
3976 4179
 			function getNextItem()
@@ -4010,9 +4213,10 @@  discard block
 block discarded – undo
4010 4213
 						document.getElementById("error_block").style.display = "";
4011 4214
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4012 4215
 
4013
-	if ($is_debug)
4014
-		echo '
4216
+	if ($is_debug) {
4217
+			echo '
4015 4218
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4219
+	}
4016 4220
 
4017 4221
 	echo '
4018 4222
 					}
@@ -4033,9 +4237,10 @@  discard block
 block discarded – undo
4033 4237
 						document.getElementById("error_block").style.display = "";
4034 4238
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4035 4239
 
4036
-	if ($is_debug)
4037
-		echo '
4240
+	if ($is_debug) {
4241
+			echo '
4038 4242
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4243
+	}
4039 4244
 
4040 4245
 	echo '
4041 4246
 					}
@@ -4094,8 +4299,8 @@  discard block
 block discarded – undo
4094 4299
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4095 4300
 				{';
4096 4301
 
4097
-		if ($is_debug)
4098
-			echo '
4302
+		if ($is_debug) {
4303
+					echo '
4099 4304
 					document.getElementById(\'debug_section\').style.display = "none";
4100 4305
 
4101 4306
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4113,6 +4318,7 @@  discard block
 block discarded – undo
4113 4318
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4114 4319
 
4115 4320
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4321
+		}
4116 4322
 
4117 4323
 		echo '
4118 4324
 
@@ -4120,9 +4326,10 @@  discard block
 block discarded – undo
4120 4326
 					document.getElementById(\'contbutt\').disabled = 0;
4121 4327
 					document.getElementById(\'database_done\').value = 1;';
4122 4328
 
4123
-		if ($upcontext['file_count'] > 1)
4124
-			echo '
4329
+		if ($upcontext['file_count'] > 1) {
4330
+					echo '
4125 4331
 					document.getElementById(\'info1\').style.display = "none";';
4332
+		}
4126 4333
 
4127 4334
 		echo '
4128 4335
 					document.getElementById(\'info2\').style.display = "none";
@@ -4135,9 +4342,10 @@  discard block
 block discarded – undo
4135 4342
 					lastItem = 0;
4136 4343
 					prevFile = curFile;';
4137 4344
 
4138
-		if ($is_debug)
4139
-			echo '
4345
+		if ($is_debug) {
4346
+					echo '
4140 4347
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4348
+		}
4141 4349
 
4142 4350
 		echo '
4143 4351
 					getNextItem();
@@ -4145,8 +4353,8 @@  discard block
 block discarded – undo
4145 4353
 				}';
4146 4354
 
4147 4355
 		// If debug scroll the screen.
4148
-		if ($is_debug)
4149
-			echo '
4356
+		if ($is_debug) {
4357
+					echo '
4150 4358
 				if (iLastSubStepProgress == -1)
4151 4359
 				{
4152 4360
 					// Give it consistent dots.
@@ -4165,6 +4373,7 @@  discard block
 block discarded – undo
4165 4373
 
4166 4374
 				if (document.getElementById(\'debug_section\').scrollHeight)
4167 4375
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4376
+		}
4168 4377
 
4169 4378
 		echo '
4170 4379
 				// Update the page.
@@ -4225,9 +4434,10 @@  discard block
 block discarded – undo
4225 4434
 			}';
4226 4435
 
4227 4436
 		// Start things off assuming we've not errored.
4228
-		if (empty($upcontext['error_message']))
4229
-			echo '
4437
+		if (empty($upcontext['error_message'])) {
4438
+					echo '
4230 4439
 			getNextItem();';
4440
+		}
4231 4441
 
4232 4442
 		echo '
4233 4443
 		</script>';
@@ -4244,18 +4454,21 @@  discard block
 block discarded – undo
4244 4454
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4245 4455
 	<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>';
4246 4456
 
4247
-	if (!empty($upcontext['error_message']))
4248
-		echo '
4457
+	if (!empty($upcontext['error_message'])) {
4458
+			echo '
4249 4459
 	<error>', $upcontext['error_message'], '</error>';
4460
+	}
4250 4461
 
4251
-	if (!empty($upcontext['error_string']))
4252
-		echo '
4462
+	if (!empty($upcontext['error_string'])) {
4463
+			echo '
4253 4464
 	<sql>', $upcontext['error_string'], '</sql>';
4465
+	}
4254 4466
 
4255
-	if ($is_debug)
4256
-		echo '
4467
+	if ($is_debug) {
4468
+			echo '
4257 4469
 	<curtime>', time(), '</curtime>';
4258
-}
4470
+	}
4471
+	}
4259 4472
 
4260 4473
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4261 4474
 function template_convert_utf8()
@@ -4272,18 +4485,20 @@  discard block
 block discarded – undo
4272 4485
 			<span id="debuginfo"></span>';
4273 4486
 
4274 4487
 	// Done any tables so far?
4275
-	if (!empty($upcontext['previous_tables']))
4276
-		foreach ($upcontext['previous_tables'] as $table)
4488
+	if (!empty($upcontext['previous_tables'])) {
4489
+			foreach ($upcontext['previous_tables'] as $table)
4277 4490
 			echo '
4278 4491
 			<br>Completed Table: &quot;', $table, '&quot;.';
4492
+	}
4279 4493
 
4280 4494
 	echo '
4281 4495
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4282 4496
 
4283 4497
 	// If we dropped their index, let's let them know
4284
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
4285
-		echo '
4498
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
4499
+			echo '
4286 4500
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
4501
+	}
4287 4502
 
4288 4503
 	echo '
4289 4504
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>';
@@ -4319,9 +4534,10 @@  discard block
 block discarded – undo
4319 4534
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4320 4535
 
4321 4536
 		// If debug flood the screen.
4322
-		if ($is_debug)
4323
-			echo '
4537
+		if ($is_debug) {
4538
+					echo '
4324 4539
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
4540
+		}
4325 4541
 
4326 4542
 		echo '
4327 4543
 				// Get the next update...
@@ -4363,19 +4579,21 @@  discard block
 block discarded – undo
4363 4579
 			<span id="debuginfo"></span>';
4364 4580
 
4365 4581
 	// Dont any tables so far?
4366
-	if (!empty($upcontext['previous_tables']))
4367
-		foreach ($upcontext['previous_tables'] as $table)
4582
+	if (!empty($upcontext['previous_tables'])) {
4583
+			foreach ($upcontext['previous_tables'] as $table)
4368 4584
 			echo '
4369 4585
 			<br>Completed Table: &quot;', $table, '&quot;.';
4586
+	}
4370 4587
 
4371 4588
 	echo '
4372 4589
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4373 4590
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>';
4374 4591
 
4375 4592
 	// Try to make sure substep was reset.
4376
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4377
-		echo '
4593
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4594
+			echo '
4378 4595
 			<input type="hidden" name="substep" id="substep" value="0">';
4596
+	}
4379 4597
 
4380 4598
 	// Continue please!
4381 4599
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4408,9 +4626,10 @@  discard block
 block discarded – undo
4408 4626
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4409 4627
 
4410 4628
 		// If debug flood the screen.
4411
-		if ($is_debug)
4412
-			echo '
4629
+		if ($is_debug) {
4630
+					echo '
4413 4631
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
4632
+		}
4414 4633
 
4415 4634
 		echo '
4416 4635
 				// Get the next update...
@@ -4445,8 +4664,8 @@  discard block
 block discarded – undo
4445 4664
 	<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>
4446 4665
 	<form action="', $boardurl, '/index.php">';
4447 4666
 
4448
-	if (!empty($upcontext['can_delete_script']))
4449
-		echo '
4667
+	if (!empty($upcontext['can_delete_script'])) {
4668
+			echo '
4450 4669
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em>
4451 4670
 			<script>
4452 4671
 				function doTheDelete(theCheck)
@@ -4458,6 +4677,7 @@  discard block
 block discarded – undo
4458 4677
 				}
4459 4678
 			</script>
4460 4679
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4680
+	}
4461 4681
 
4462 4682
 	$active = time() - $upcontext['started'];
4463 4683
 	$hours = floor($active / 3600);
@@ -4467,16 +4687,20 @@  discard block
 block discarded – undo
4467 4687
 	if ($is_debug)
4468 4688
 	{
4469 4689
 		$totalTime = '';
4470
-		if ($hours > 0)
4471
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4472
-		if ($minutes > 0)
4473
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4474
-		if ($seconds > 0)
4475
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4690
+		if ($hours > 0) {
4691
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4692
+		}
4693
+		if ($minutes > 0) {
4694
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4695
+		}
4696
+		if ($seconds > 0) {
4697
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4698
+		}
4476 4699
 	}
4477 4700
 
4478
-	if ($is_debug && !empty($totalTime))
4479
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4701
+	if ($is_debug && !empty($totalTime)) {
4702
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4703
+	}
4480 4704
 
4481 4705
 	echo '<br>
4482 4706
 			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br>
@@ -4543,16 +4767,19 @@  discard block
 block discarded – undo
4543 4767
 				'empty' => '',
4544 4768
 				'limit' => $limit,
4545 4769
 		));
4546
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4547
-			$arIp[] = $row[$oldCol];
4770
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4771
+					$arIp[] = $row[$oldCol];
4772
+		}
4548 4773
 		$smcFunc['db_free_result']($request);
4549 4774
 
4550 4775
 		// Special case, null ip could keep us in a loop.
4551
-		if (is_null($arIp[0]))
4552
-			unset($arIp[0]);
4776
+		if (is_null($arIp[0])) {
4777
+					unset($arIp[0]);
4778
+		}
4553 4779
 
4554
-		if (empty($arIp))
4555
-			$is_done = true;
4780
+		if (empty($arIp)) {
4781
+					$is_done = true;
4782
+		}
4556 4783
 
4557 4784
 		$updates = array();
4558 4785
 		$cases = array();
@@ -4561,16 +4788,18 @@  discard block
 block discarded – undo
4561 4788
 		{
4562 4789
 			$arIp[$i] = trim($arIp[$i]);
4563 4790
 
4564
-			if (empty($arIp[$i]))
4565
-				continue;
4791
+			if (empty($arIp[$i])) {
4792
+							continue;
4793
+			}
4566 4794
 
4567 4795
 			$updates['ip' . $i] = $arIp[$i];
4568 4796
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4569 4797
 
4570 4798
 			if ($setSize > 0 && $i % $setSize === 0)
4571 4799
 			{
4572
-				if (count($updates) == 1)
4573
-					continue;
4800
+				if (count($updates) == 1) {
4801
+									continue;
4802
+				}
4574 4803
 
4575 4804
 				$updates['whereSet'] = array_values($updates);
4576 4805
 				$smcFunc['db_query']('', '
@@ -4604,8 +4833,7 @@  discard block
 block discarded – undo
4604 4833
 							'ip' => $ip
4605 4834
 					));
4606 4835
 				}
4607
-			}
4608
-			else
4836
+			} else
4609 4837
 			{
4610 4838
 				$updates['whereSet'] = array_values($updates);
4611 4839
 				$smcFunc['db_query']('', '
@@ -4619,9 +4847,9 @@  discard block
 block discarded – undo
4619 4847
 					$updates
4620 4848
 				);
4621 4849
 			}
4850
+		} else {
4851
+					$is_done = true;
4622 4852
 		}
4623
-		else
4624
-			$is_done = true;
4625 4853
 
4626 4854
 		$_GET['a'] += $limit;
4627 4855
 		$step_progress['current'] = $_GET['a'];
Please login to merge, or discard this patch.