Completed
Pull Request — release-2.1 (#3890)
by Fran
12:33 queued 05:26
created
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 4 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.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84 84
 if (!file_exists($upgrade_path . '/upgrade-helper.php'))
85
-    die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
85
+	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
86 86
 
87 87
 require_once($upgrade_path . '/upgrade-helper.php');
88 88
 
Please login to merge, or discard this patch.
Braces   +859 added lines, -629 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 $upcontext['inactive_timeout'] = 10;
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
84
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
85 85
     die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
86
+}
86 87
 
87 88
 require_once($upgrade_path . '/upgrade-helper.php');
88 89
 
@@ -106,11 +107,14 @@  discard block
 block discarded – undo
106 107
 	ini_set('default_socket_timeout', 900);
107 108
 }
108 109
 // Clean the upgrade path if this is from the client.
109
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
110
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
110
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
111
+	for ($i = 1;
112
+}
113
+$i < $_SERVER['argc']; $i++)
111 114
 	{
112
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
113
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
115
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
116
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
117
+		}
114 118
 	}
115 119
 
116 120
 // Are we from the client?
@@ -118,9 +122,9 @@  discard block
 block discarded – undo
118 122
 {
119 123
 	$command_line = true;
120 124
 	$disable_security = true;
121
-}
122
-else
125
+} else {
123 126
 	$command_line = false;
127
+}
124 128
 
125 129
 // Load this now just because we can.
126 130
 require_once($upgrade_path . '/Settings.php');
@@ -131,10 +135,12 @@  discard block
 block discarded – undo
131 135
 	$upcontext['user'] = unserialize(base64_decode($upgradeData));
132 136
 
133 137
 	// Check for sensible values.
134
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
135
-		$upcontext['user']['started'] = time();
136
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
137
-		$upcontext['user']['updated'] = 0;
138
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
139
+			$upcontext['user']['started'] = time();
140
+	}
141
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
142
+			$upcontext['user']['updated'] = 0;
143
+	}
138 144
 
139 145
 	$upcontext['started'] = $upcontext['user']['started'];
140 146
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -192,8 +198,9 @@  discard block
 block discarded – undo
192 198
 			'db_error_skip' => true,
193 199
 		)
194 200
 	);
195
-	while ($row = $smcFunc['db_fetch_assoc']($request))
196
-		$modSettings[$row['variable']] = $row['value'];
201
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
202
+			$modSettings[$row['variable']] = $row['value'];
203
+	}
197 204
 	$smcFunc['db_free_result']($request);
198 205
 }
199 206
 
@@ -203,10 +210,12 @@  discard block
 block discarded – undo
203 210
 	$modSettings['theme_url'] = 'Themes/default';
204 211
 	$modSettings['images_url'] = 'Themes/default/images';
205 212
 }
206
-if (!isset($settings['default_theme_url']))
213
+if (!isset($settings['default_theme_url'])) {
207 214
 	$settings['default_theme_url'] = $modSettings['theme_url'];
208
-if (!isset($settings['default_theme_dir']))
215
+}
216
+if (!isset($settings['default_theme_dir'])) {
209 217
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
218
+}
210 219
 
211 220
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
212 221
 // Default title...
@@ -224,13 +233,15 @@  discard block
 block discarded – undo
224 233
 	$support_js = $upcontext['upgrade_status']['js'];
225 234
 
226 235
 	// Only set this if the upgrader status says so.
227
-	if (empty($is_debug))
228
-		$is_debug = $upcontext['upgrade_status']['debug'];
236
+	if (empty($is_debug)) {
237
+			$is_debug = $upcontext['upgrade_status']['debug'];
238
+	}
229 239
 
230 240
 	// Load the language.
231
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
232
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
233
-}
241
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
242
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
243
+	}
244
+	}
234 245
 // Set the defaults.
235 246
 else
236 247
 {
@@ -248,15 +259,18 @@  discard block
 block discarded – undo
248 259
 }
249 260
 
250 261
 // If this isn't the first stage see whether they are logging in and resuming.
251
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
262
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
252 263
 	checkLogin();
264
+}
253 265
 
254
-if ($command_line)
266
+if ($command_line) {
255 267
 	cmdStep0();
268
+}
256 269
 
257 270
 // Don't error if we're using xml.
258
-if (isset($_GET['xml']))
271
+if (isset($_GET['xml'])) {
259 272
 	$upcontext['return_error'] = true;
273
+}
260 274
 
261 275
 // Loop through all the steps doing each one as required.
262 276
 $upcontext['overall_percent'] = 0;
@@ -277,10 +291,11 @@  discard block
 block discarded – undo
277 291
 		}
278 292
 
279 293
 		// Call the step and if it returns false that means pause!
280
-		if (function_exists($step[2]) && $step[2]() === false)
281
-			break;
282
-		elseif (function_exists($step[2]))
283
-			$upcontext['current_step']++;
294
+		if (function_exists($step[2]) && $step[2]() === false) {
295
+					break;
296
+		} elseif (function_exists($step[2])) {
297
+					$upcontext['current_step']++;
298
+		}
284 299
 	}
285 300
 	$upcontext['overall_percent'] += $step[3];
286 301
 }
@@ -319,17 +334,18 @@  discard block
 block discarded – undo
319 334
 		// This should not happen my dear... HELP ME DEVELOPERS!!
320 335
 		if (!empty($command_line))
321 336
 		{
322
-			if (function_exists('debug_print_backtrace'))
323
-				debug_print_backtrace();
337
+			if (function_exists('debug_print_backtrace')) {
338
+							debug_print_backtrace();
339
+			}
324 340
 
325 341
 			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.';
326 342
 			flush();
327 343
 			die();
328 344
 		}
329 345
 
330
-		if (!isset($_GET['xml']))
331
-			template_upgrade_above();
332
-		else
346
+		if (!isset($_GET['xml'])) {
347
+					template_upgrade_above();
348
+		} else
333 349
 		{
334 350
 			header('Content-Type: text/xml; charset=UTF-8');
335 351
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -351,21 +367,24 @@  discard block
 block discarded – undo
351 367
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(safe_serialize($upcontext['upgrade_status']));
352 368
 
353 369
 			// Custom stuff to pass back?
354
-			if (!empty($upcontext['query_string']))
355
-				$upcontext['form_url'] .= $upcontext['query_string'];
370
+			if (!empty($upcontext['query_string'])) {
371
+							$upcontext['form_url'] .= $upcontext['query_string'];
372
+			}
356 373
 
357 374
 			call_user_func('template_' . $upcontext['sub_template']);
358 375
 		}
359 376
 
360 377
 		// Was there an error?
361
-		if (!empty($upcontext['forced_error_message']))
362
-			echo $upcontext['forced_error_message'];
378
+		if (!empty($upcontext['forced_error_message'])) {
379
+					echo $upcontext['forced_error_message'];
380
+		}
363 381
 
364 382
 		// Show the footer.
365
-		if (!isset($_GET['xml']))
366
-			template_upgrade_below();
367
-		else
368
-			template_xml_below();
383
+		if (!isset($_GET['xml'])) {
384
+					template_upgrade_below();
385
+		} else {
386
+					template_xml_below();
387
+		}
369 388
 	}
370 389
 
371 390
 
@@ -377,15 +396,19 @@  discard block
 block discarded – undo
377 396
 		$seconds = intval($active % 60);
378 397
 
379 398
 		$totalTime = '';
380
-		if ($hours > 0)
381
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
382
-		if ($minutes > 0)
383
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
384
-		if ($seconds > 0)
385
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
399
+		if ($hours > 0) {
400
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
401
+		}
402
+		if ($minutes > 0) {
403
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
404
+		}
405
+		if ($seconds > 0) {
406
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
407
+		}
386 408
 
387
-		if (!empty($totalTime))
388
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
409
+		if (!empty($totalTime)) {
410
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
411
+		}
389 412
 	}
390 413
 
391 414
 	// Bang - gone!
@@ -398,8 +421,9 @@  discard block
 block discarded – undo
398 421
 	global $upgradeurl, $upcontext, $command_line;
399 422
 
400 423
 	// Command line users can't be redirected.
401
-	if ($command_line)
402
-		upgradeExit(true);
424
+	if ($command_line) {
425
+			upgradeExit(true);
426
+	}
403 427
 
404 428
 	// Are we providing the core info?
405 429
 	if ($addForm)
@@ -422,19 +446,22 @@  discard block
 block discarded – undo
422 446
 	global $modSettings, $sourcedir, $smcFunc;
423 447
 
424 448
 	// Do the non-SSI stuff...
425
-	if (function_exists('set_magic_quotes_runtime'))
426
-		@set_magic_quotes_runtime(0);
449
+	if (function_exists('set_magic_quotes_runtime')) {
450
+			@set_magic_quotes_runtime(0);
451
+	}
427 452
 
428 453
 	error_reporting(E_ALL);
429 454
 	define('SMF', 1);
430 455
 
431 456
 	// Start the session.
432
-	if (@ini_get('session.save_handler') == 'user')
433
-		@ini_set('session.save_handler', 'files');
457
+	if (@ini_get('session.save_handler') == 'user') {
458
+			@ini_set('session.save_handler', 'files');
459
+	}
434 460
 	@session_start();
435 461
 
436
-	if (empty($smcFunc))
437
-		$smcFunc = array();
462
+	if (empty($smcFunc)) {
463
+			$smcFunc = array();
464
+	}
438 465
 
439 466
 	// We need this for authentication and some upgrade code
440 467
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -446,8 +473,9 @@  discard block
 block discarded – undo
446 473
 	initialize_inputs();
447 474
 
448 475
 	// Get the database going!
449
-	if (empty($db_type) || $db_type == 'mysqli')
450
-		$db_type = 'mysql';
476
+	if (empty($db_type) || $db_type == 'mysqli') {
477
+			$db_type = 'mysql';
478
+	}
451 479
 
452 480
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
453 481
 	{
@@ -457,17 +485,19 @@  discard block
 block discarded – undo
457 485
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
458 486
 
459 487
 		// Oh dear god!!
460
-		if ($db_connection === null)
461
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
488
+		if ($db_connection === null) {
489
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
490
+		}
462 491
 
463
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
464
-			$smcFunc['db_query']('', '
492
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
493
+					$smcFunc['db_query']('', '
465 494
 			SET NAMES {string:db_character_set}',
466 495
 			array(
467 496
 				'db_error_skip' => true,
468 497
 				'db_character_set' => $db_character_set,
469 498
 			)
470 499
 		);
500
+		}
471 501
 
472 502
 		// Load the modSettings data...
473 503
 		$request = $smcFunc['db_query']('', '
@@ -478,11 +508,11 @@  discard block
 block discarded – undo
478 508
 			)
479 509
 		);
480 510
 		$modSettings = array();
481
-		while ($row = $smcFunc['db_fetch_assoc']($request))
482
-			$modSettings[$row['variable']] = $row['value'];
511
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
512
+					$modSettings[$row['variable']] = $row['value'];
513
+		}
483 514
 		$smcFunc['db_free_result']($request);
484
-	}
485
-	else
515
+	} else
486 516
 	{
487 517
 		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.');
488 518
 	}
@@ -496,9 +526,10 @@  discard block
 block discarded – undo
496 526
 		cleanRequest();
497 527
 	}
498 528
 
499
-	if (!isset($_GET['substep']))
500
-		$_GET['substep'] = 0;
501
-}
529
+	if (!isset($_GET['substep'])) {
530
+			$_GET['substep'] = 0;
531
+	}
532
+	}
502 533
 
503 534
 function initialize_inputs()
504 535
 {
@@ -528,8 +559,9 @@  discard block
 block discarded – undo
528 559
 		$dh = opendir(dirname(__FILE__));
529 560
 		while ($file = readdir($dh))
530 561
 		{
531
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
532
-				@unlink(dirname(__FILE__) . '/' . $file);
562
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
563
+							@unlink(dirname(__FILE__) . '/' . $file);
564
+			}
533 565
 		}
534 566
 		closedir($dh);
535 567
 
@@ -559,8 +591,9 @@  discard block
 block discarded – undo
559 591
 	{
560 592
 		$upcontext['remote_files_available'] = false;
561 593
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
562
-		if ($test)
563
-			$upcontext['remote_files_available'] = true;
594
+		if ($test) {
595
+					$upcontext['remote_files_available'] = true;
596
+		}
564 597
 		@fclose($test);
565 598
 	}
566 599
 
@@ -568,8 +601,9 @@  discard block
 block discarded – undo
568 601
 	$temp = 'upgrade_php?step';
569 602
 	while (strlen($temp) > 4)
570 603
 	{
571
-		if (isset($_GET[$temp]))
572
-			unset($_GET[$temp]);
604
+		if (isset($_GET[$temp])) {
605
+					unset($_GET[$temp]);
606
+		}
573 607
 		$temp = substr($temp, 1);
574 608
 	}
575 609
 
@@ -596,32 +630,39 @@  discard block
 block discarded – undo
596 630
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
597 631
 
598 632
 	// Need legacy scripts?
599
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
600
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
601
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
602
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
603
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
604
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
633
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
634
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
635
+	}
636
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
637
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
638
+	}
639
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
640
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
641
+	}
605 642
 
606 643
 	// We don't need "-utf8" files anymore...
607 644
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
608 645
 
609 646
 	// This needs to exist!
610
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
611
-		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>]');
612
-	else
613
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
647
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
648
+			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>]');
649
+	} else {
650
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
651
+	}
614 652
 
615
-	if (!$check)
616
-		// 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.
653
+	if (!$check) {
654
+			// 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.
617 655
 		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.');
656
+	}
618 657
 
619 658
 	// Do they meet the install requirements?
620
-	if (!php_version_check())
621
-		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.');
659
+	if (!php_version_check()) {
660
+			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.');
661
+	}
622 662
 
623
-	if (!db_version_check())
624
-		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.');
663
+	if (!db_version_check()) {
664
+			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.');
665
+	}
625 666
 
626 667
 	// Do some checks to make sure they have proper privileges
627 668
 	db_extend('packages');
@@ -636,14 +677,16 @@  discard block
 block discarded – undo
636 677
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
637 678
 
638 679
 	// Sorry... we need CREATE, ALTER and DROP
639
-	if (!$create || !$alter || !$drop)
640
-		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.');
680
+	if (!$create || !$alter || !$drop) {
681
+			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.');
682
+	}
641 683
 
642 684
 	// Do a quick version spot check.
643 685
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
644 686
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
645
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
646
-		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.');
687
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
688
+			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.');
689
+	}
647 690
 
648 691
 	// What absolutely needs to be writable?
649 692
 	$writable_files = array(
@@ -665,12 +708,13 @@  discard block
 block discarded – undo
665 708
 	quickFileWritable($custom_av_dir);
666 709
 
667 710
 	// Are we good now?
668
-	if (!is_writable($custom_av_dir))
669
-		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));
670
-	elseif ($need_settings_update)
711
+	if (!is_writable($custom_av_dir)) {
712
+			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));
713
+	} elseif ($need_settings_update)
671 714
 	{
672
-		if (!function_exists('cache_put_data'))
673
-			require_once($sourcedir . '/Load.php');
715
+		if (!function_exists('cache_put_data')) {
716
+					require_once($sourcedir . '/Load.php');
717
+		}
674 718
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
675 719
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
676 720
 	}
@@ -679,28 +723,33 @@  discard block
 block discarded – undo
679 723
 
680 724
 	// Check the cache directory.
681 725
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
682
-	if (!file_exists($cachedir_temp))
683
-		@mkdir($cachedir_temp);
684
-	if (!file_exists($cachedir_temp))
685
-		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.');
686
-
687
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
688
-		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>.');
689
-	elseif (!isset($_GET['skiplang']))
726
+	if (!file_exists($cachedir_temp)) {
727
+			@mkdir($cachedir_temp);
728
+	}
729
+	if (!file_exists($cachedir_temp)) {
730
+			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.');
731
+	}
732
+
733
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
734
+			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>.');
735
+	} elseif (!isset($_GET['skiplang']))
690 736
 	{
691 737
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
692 738
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
693 739
 
694
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
695
-			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>]');
740
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
741
+					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>]');
742
+		}
696 743
 	}
697 744
 
698
-	if (!makeFilesWritable($writable_files))
699
-		return false;
745
+	if (!makeFilesWritable($writable_files)) {
746
+			return false;
747
+	}
700 748
 
701 749
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
702
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
703
-		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.');
750
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
751
+			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.');
752
+	}
704 753
 
705 754
 	// Upgrade the agreement.
706 755
 	elseif (isset($modSettings['agreement']))
@@ -711,8 +760,8 @@  discard block
 block discarded – undo
711 760
 	}
712 761
 
713 762
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
714
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
715
-		$upcontext['warning'] = '
763
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
764
+			$upcontext['warning'] = '
716 765
 			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>
717 766
 			<ul>
718 767
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -720,10 +769,12 @@  discard block
 block discarded – undo
720 769
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
721 770
 			</ul>
722 771
 			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.';
772
+	}
723 773
 
724 774
 	// Either we're logged in or we're going to present the login.
725
-	if (checkLogin())
726
-		return true;
775
+	if (checkLogin()) {
776
+			return true;
777
+	}
727 778
 
728 779
 	$upcontext += createToken('login');
729 780
 
@@ -737,15 +788,17 @@  discard block
 block discarded – undo
737 788
 	global $smcFunc, $db_type, $support_js;
738 789
 
739 790
 	// Don't bother if the security is disabled.
740
-	if ($disable_security)
741
-		return true;
791
+	if ($disable_security) {
792
+			return true;
793
+	}
742 794
 
743 795
 	// Are we trying to login?
744 796
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
745 797
 	{
746 798
 		// If we've disabled security pick a suitable name!
747
-		if (empty($_POST['user']))
748
-			$_POST['user'] = 'Administrator';
799
+		if (empty($_POST['user'])) {
800
+					$_POST['user'] = 'Administrator';
801
+		}
749 802
 
750 803
 		// Before 2.0 these column names were different!
751 804
 		$oldDB = false;
@@ -760,16 +813,17 @@  discard block
 block discarded – undo
760 813
 					'db_error_skip' => true,
761 814
 				)
762 815
 			);
763
-			if ($smcFunc['db_num_rows']($request) != 0)
764
-				$oldDB = true;
816
+			if ($smcFunc['db_num_rows']($request) != 0) {
817
+							$oldDB = true;
818
+			}
765 819
 			$smcFunc['db_free_result']($request);
766 820
 		}
767 821
 
768 822
 		// Get what we believe to be their details.
769 823
 		if (!$disable_security)
770 824
 		{
771
-			if ($oldDB)
772
-				$request = $smcFunc['db_query']('', '
825
+			if ($oldDB) {
826
+							$request = $smcFunc['db_query']('', '
773 827
 					SELECT id_member, memberName AS member_name, passwd, id_group,
774 828
 					additionalGroups AS additional_groups, lngfile
775 829
 					FROM {db_prefix}members
@@ -779,8 +833,8 @@  discard block
 block discarded – undo
779 833
 						'db_error_skip' => true,
780 834
 					)
781 835
 				);
782
-			else
783
-				$request = $smcFunc['db_query']('', '
836
+			} else {
837
+							$request = $smcFunc['db_query']('', '
784 838
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
785 839
 					FROM {db_prefix}members
786 840
 					WHERE member_name = {string:member_name}',
@@ -789,6 +843,7 @@  discard block
 block discarded – undo
789 843
 						'db_error_skip' => true,
790 844
 					)
791 845
 				);
846
+			}
792 847
 			if ($smcFunc['db_num_rows']($request) != 0)
793 848
 			{
794 849
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -796,13 +851,14 @@  discard block
 block discarded – undo
796 851
 				$groups = explode(',', $addGroups);
797 852
 				$groups[] = $id_group;
798 853
 
799
-				foreach ($groups as $k => $v)
800
-					$groups[$k] = (int) $v;
854
+				foreach ($groups as $k => $v) {
855
+									$groups[$k] = (int) $v;
856
+				}
801 857
 
802 858
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
859
+			} else {
860
+							$upcontext['username_incorrect'] = true;
803 861
 			}
804
-			else
805
-				$upcontext['username_incorrect'] = true;
806 862
 			$smcFunc['db_free_result']($request);
807 863
 		}
808 864
 		$upcontext['username'] = $_POST['user'];
@@ -812,13 +868,14 @@  discard block
 block discarded – undo
812 868
 		{
813 869
 			$upcontext['upgrade_status']['js'] = 1;
814 870
 			$support_js = 1;
871
+		} else {
872
+					$support_js = 0;
815 873
 		}
816
-		else
817
-			$support_js = 0;
818 874
 
819 875
 		// Note down the version we are coming from.
820
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
821
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
876
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
877
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
878
+		}
822 879
 
823 880
 		// Didn't get anywhere?
824 881
 		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']))
@@ -852,15 +909,15 @@  discard block
 block discarded – undo
852 909
 							'db_error_skip' => true,
853 910
 						)
854 911
 					);
855
-					if ($smcFunc['db_num_rows']($request) == 0)
856
-						return throw_error('You need to be an admin to perform an upgrade!');
912
+					if ($smcFunc['db_num_rows']($request) == 0) {
913
+											return throw_error('You need to be an admin to perform an upgrade!');
914
+					}
857 915
 					$smcFunc['db_free_result']($request);
858 916
 				}
859 917
 
860 918
 				$upcontext['user']['id'] = $id_member;
861 919
 				$upcontext['user']['name'] = $name;
862
-			}
863
-			else
920
+			} else
864 921
 			{
865 922
 				$upcontext['user']['id'] = 1;
866 923
 				$upcontext['user']['name'] = 'Administrator';
@@ -876,11 +933,11 @@  discard block
 block discarded – undo
876 933
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
877 934
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
878 935
 
879
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
880
-					$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'] . '.';
881
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
882
-					$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'] . '.';
883
-				else
936
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
937
+									$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'] . '.';
938
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
939
+									$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'] . '.';
940
+				} else
884 941
 				{
885 942
 					// Set this as the new language.
886 943
 					$upcontext['language'] = $user_language;
@@ -924,8 +981,9 @@  discard block
 block discarded – undo
924 981
 	unset($member_columns);
925 982
 
926 983
 	// If we've not submitted then we're done.
927
-	if (empty($_POST['upcont']))
928
-		return false;
984
+	if (empty($_POST['upcont'])) {
985
+			return false;
986
+	}
929 987
 
930 988
 	// Firstly, if they're enabling SM stat collection just do it.
931 989
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']))
@@ -940,25 +998,26 @@  discard block
 block discarded – undo
940 998
 			fwrite($fp, $out);
941 999
 
942 1000
 			$return_data = '';
943
-			while (!feof($fp))
944
-				$return_data .= fgets($fp, 128);
1001
+			while (!feof($fp)) {
1002
+							$return_data .= fgets($fp, 128);
1003
+			}
945 1004
 
946 1005
 			fclose($fp);
947 1006
 
948 1007
 			// Get the unique site ID.
949 1008
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
950 1009
 
951
-			if (!empty($ID[1]))
952
-				$smcFunc['db_insert']('replace',
1010
+			if (!empty($ID[1])) {
1011
+							$smcFunc['db_insert']('replace',
953 1012
 					$db_prefix . 'settings',
954 1013
 					array('variable' => 'string', 'value' => 'string'),
955 1014
 					array('allow_sm_stats', $ID[1]),
956 1015
 					array('variable')
957 1016
 				);
1017
+			}
958 1018
 		}
959
-	}
960
-	else
961
-		$smcFunc['db_query']('', '
1019
+	} else {
1020
+			$smcFunc['db_query']('', '
962 1021
 			DELETE FROM {db_prefix}settings
963 1022
 			WHERE variable = {string:allow_sm_stats}',
964 1023
 			array(
@@ -966,6 +1025,7 @@  discard block
 block discarded – undo
966 1025
 				'db_error_skip' => true,
967 1026
 			)
968 1027
 		);
1028
+	}
969 1029
 
970 1030
 	// Deleting old karma stuff?
971 1031
 	if (!empty($_POST['delete_karma']))
@@ -980,20 +1040,22 @@  discard block
 block discarded – undo
980 1040
 		);
981 1041
 
982 1042
 		// Cleaning up old karma member settings.
983
-		if ($upcontext['karma_installed']['good'])
984
-			$smcFunc['db_query']('', '
1043
+		if ($upcontext['karma_installed']['good']) {
1044
+					$smcFunc['db_query']('', '
985 1045
 				ALTER TABLE {db_prefix}members
986 1046
 				DROP karma_good',
987 1047
 				array()
988 1048
 			);
1049
+		}
989 1050
 
990 1051
 		// Does karma bad was enable?
991
-		if ($upcontext['karma_installed']['bad'])
992
-			$smcFunc['db_query']('', '
1052
+		if ($upcontext['karma_installed']['bad']) {
1053
+					$smcFunc['db_query']('', '
993 1054
 				ALTER TABLE {db_prefix}members
994 1055
 				DROP karma_bad',
995 1056
 				array()
996 1057
 			);
1058
+		}
997 1059
 
998 1060
 		// Cleaning up old karma permissions.
999 1061
 		$smcFunc['db_query']('', '
@@ -1006,26 +1068,29 @@  discard block
 block discarded – undo
1006 1068
 	}
1007 1069
 
1008 1070
 	// Emptying the error log?
1009
-	if (!empty($_POST['empty_error']))
1010
-		$smcFunc['db_query']('truncate_table', '
1071
+	if (!empty($_POST['empty_error'])) {
1072
+			$smcFunc['db_query']('truncate_table', '
1011 1073
 			TRUNCATE {db_prefix}log_errors',
1012 1074
 			array(
1013 1075
 			)
1014 1076
 		);
1077
+	}
1015 1078
 
1016 1079
 	$changes = array();
1017 1080
 
1018 1081
 	// Add proxy settings.
1019
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1020
-		$changes += array(
1082
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1083
+			$changes += array(
1021 1084
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1022 1085
 			'image_proxy_maxsize' => 5190,
1023 1086
 			'image_proxy_enabled' => 0,
1024 1087
 		);
1088
+	}
1025 1089
 
1026 1090
 	// If we're overriding the language follow it through.
1027
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1028
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1091
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1092
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1093
+	}
1029 1094
 
1030 1095
 	if (!empty($_POST['maint']))
1031 1096
 	{
@@ -1037,30 +1102,34 @@  discard block
 block discarded – undo
1037 1102
 		{
1038 1103
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1039 1104
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1040
-		}
1041
-		else
1105
+		} else
1042 1106
 		{
1043 1107
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1044 1108
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1045 1109
 		}
1046 1110
 	}
1047 1111
 
1048
-	if ($command_line)
1049
-		echo ' * Updating Settings.php...';
1112
+	if ($command_line) {
1113
+			echo ' * Updating Settings.php...';
1114
+	}
1050 1115
 
1051 1116
 	// Fix some old paths.
1052
-	if (substr($boarddir, 0, 1) == '.')
1053
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1117
+	if (substr($boarddir, 0, 1) == '.') {
1118
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1119
+	}
1054 1120
 
1055
-	if (substr($sourcedir, 0, 1) == '.')
1056
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1121
+	if (substr($sourcedir, 0, 1) == '.') {
1122
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1123
+	}
1057 1124
 
1058
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1059
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1125
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1126
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1127
+	}
1060 1128
 
1061 1129
 	// Not had the database type added before?
1062
-	if (empty($db_type))
1063
-		$changes['db_type'] = 'mysql';
1130
+	if (empty($db_type)) {
1131
+			$changes['db_type'] = 'mysql';
1132
+	}
1064 1133
 
1065 1134
 	// If they have a "host:port" setup for the host, split that into separate values
1066 1135
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1071,32 +1140,36 @@  discard block
 block discarded – undo
1071 1140
 		$changes['db_server'] = '\'' . $db_server . '\'';
1072 1141
 
1073 1142
 		// Only set this if we're not using the default port
1074
-		if ($db_port != ini_get('mysqli.default_port'))
1075
-			$changes['db_port'] = (int) $db_port;
1076
-	}
1077
-	elseif (!empty($db_port))
1143
+		if ($db_port != ini_get('mysqli.default_port')) {
1144
+					$changes['db_port'] = (int) $db_port;
1145
+		}
1146
+	} elseif (!empty($db_port))
1078 1147
 	{
1079 1148
 		// If db_port is set and is the same as the default, set it to ''
1080 1149
 		if ($db_type == 'mysql')
1081 1150
 		{
1082
-			if ($db_port == ini_get('mysqli.default_port'))
1083
-				$changes['db_port'] = '\'\'';
1084
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1085
-				$changes['db_port'] = '\'\'';
1151
+			if ($db_port == ini_get('mysqli.default_port')) {
1152
+							$changes['db_port'] = '\'\'';
1153
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1154
+							$changes['db_port'] = '\'\'';
1155
+			}
1086 1156
 		}
1087 1157
 	}
1088 1158
 
1089 1159
 	// Maybe we haven't had this option yet?
1090
-	if (empty($packagesdir))
1091
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1160
+	if (empty($packagesdir)) {
1161
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1162
+	}
1092 1163
 
1093 1164
 	// Add support for $tasksdir var.
1094
-	if (empty($tasksdir))
1095
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1165
+	if (empty($tasksdir)) {
1166
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1167
+	}
1096 1168
 
1097 1169
 	// Make sure we fix the language as well.
1098
-	if (stristr($language, '-utf8'))
1099
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1170
+	if (stristr($language, '-utf8')) {
1171
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1172
+	}
1100 1173
 
1101 1174
 	// @todo Maybe change the cookie name if going to 1.1, too?
1102 1175
 
@@ -1104,8 +1177,9 @@  discard block
 block discarded – undo
1104 1177
 	require_once($sourcedir . '/Subs-Admin.php');
1105 1178
 	updateSettingsFile($changes);
1106 1179
 
1107
-	if ($command_line)
1108
-		echo ' Successful.' . "\n";
1180
+	if ($command_line) {
1181
+			echo ' Successful.' . "\n";
1182
+	}
1109 1183
 
1110 1184
 	// Are we doing debug?
1111 1185
 	if (isset($_POST['debug']))
@@ -1115,8 +1189,9 @@  discard block
 block discarded – undo
1115 1189
 	}
1116 1190
 
1117 1191
 	// If we're not backing up then jump one.
1118
-	if (empty($_POST['backup']))
1119
-		$upcontext['current_step']++;
1192
+	if (empty($_POST['backup'])) {
1193
+			$upcontext['current_step']++;
1194
+	}
1120 1195
 
1121 1196
 	// If we've got here then let's proceed to the next step!
1122 1197
 	return true;
@@ -1131,8 +1206,9 @@  discard block
 block discarded – undo
1131 1206
 	$upcontext['page_title'] = 'Backup Database';
1132 1207
 
1133 1208
 	// Done it already - js wise?
1134
-	if (!empty($_POST['backup_done']))
1135
-		return true;
1209
+	if (!empty($_POST['backup_done'])) {
1210
+			return true;
1211
+	}
1136 1212
 
1137 1213
 	// Some useful stuff here.
1138 1214
 	db_extend();
@@ -1146,9 +1222,10 @@  discard block
 block discarded – undo
1146 1222
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1147 1223
 
1148 1224
 	$table_names = array();
1149
-	foreach ($tables as $table)
1150
-		if (substr($table, 0, 7) !== 'backup_')
1225
+	foreach ($tables as $table) {
1226
+			if (substr($table, 0, 7) !== 'backup_')
1151 1227
 			$table_names[] = $table;
1228
+	}
1152 1229
 
1153 1230
 	$upcontext['table_count'] = count($table_names);
1154 1231
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1158,12 +1235,14 @@  discard block
 block discarded – undo
1158 1235
 	$file_steps = $upcontext['table_count'];
1159 1236
 
1160 1237
 	// What ones have we already done?
1161
-	foreach ($table_names as $id => $table)
1162
-		if ($id < $_GET['substep'])
1238
+	foreach ($table_names as $id => $table) {
1239
+			if ($id < $_GET['substep'])
1163 1240
 			$upcontext['previous_tables'][] = $table;
1241
+	}
1164 1242
 
1165
-	if ($command_line)
1166
-		echo 'Backing Up Tables.';
1243
+	if ($command_line) {
1244
+			echo 'Backing Up Tables.';
1245
+	}
1167 1246
 
1168 1247
 	// If we don't support javascript we backup here.
1169 1248
 	if (!$support_js || isset($_GET['xml']))
@@ -1182,8 +1261,9 @@  discard block
 block discarded – undo
1182 1261
 			backupTable($table_names[$substep]);
1183 1262
 
1184 1263
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1185
-			if (isset($_GET['xml']))
1186
-				return upgradeExit();
1264
+			if (isset($_GET['xml'])) {
1265
+							return upgradeExit();
1266
+			}
1187 1267
 		}
1188 1268
 
1189 1269
 		if ($command_line)
@@ -1216,9 +1296,10 @@  discard block
 block discarded – undo
1216 1296
 
1217 1297
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1218 1298
 
1219
-	if ($command_line)
1220
-		echo ' done.';
1221
-}
1299
+	if ($command_line) {
1300
+			echo ' done.';
1301
+	}
1302
+	}
1222 1303
 
1223 1304
 // Step 2: Everything.
1224 1305
 function DatabaseChanges()
@@ -1227,8 +1308,9 @@  discard block
 block discarded – undo
1227 1308
 	global $upcontext, $support_js, $db_type;
1228 1309
 
1229 1310
 	// Have we just completed this?
1230
-	if (!empty($_POST['database_done']))
1231
-		return true;
1311
+	if (!empty($_POST['database_done'])) {
1312
+			return true;
1313
+	}
1232 1314
 
1233 1315
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1234 1316
 	$upcontext['page_title'] = 'Database Changes';
@@ -1243,15 +1325,16 @@  discard block
 block discarded – undo
1243 1325
 	);
1244 1326
 
1245 1327
 	// How many files are there in total?
1246
-	if (isset($_GET['filecount']))
1247
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1248
-	else
1328
+	if (isset($_GET['filecount'])) {
1329
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1330
+	} else
1249 1331
 	{
1250 1332
 		$upcontext['file_count'] = 0;
1251 1333
 		foreach ($files as $file)
1252 1334
 		{
1253
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1254
-				$upcontext['file_count']++;
1335
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1336
+							$upcontext['file_count']++;
1337
+			}
1255 1338
 		}
1256 1339
 	}
1257 1340
 
@@ -1261,9 +1344,9 @@  discard block
 block discarded – undo
1261 1344
 	$upcontext['cur_file_num'] = 0;
1262 1345
 	foreach ($files as $file)
1263 1346
 	{
1264
-		if ($did_not_do)
1265
-			$did_not_do--;
1266
-		else
1347
+		if ($did_not_do) {
1348
+					$did_not_do--;
1349
+		} else
1267 1350
 		{
1268 1351
 			$upcontext['cur_file_num']++;
1269 1352
 			$upcontext['cur_file_name'] = $file[0];
@@ -1290,12 +1373,13 @@  discard block
 block discarded – undo
1290 1373
 					// Flag to move on to the next.
1291 1374
 					$upcontext['completed_step'] = true;
1292 1375
 					// Did we complete the whole file?
1293
-					if ($nextFile)
1294
-						$upcontext['current_debug_item_num'] = -1;
1376
+					if ($nextFile) {
1377
+											$upcontext['current_debug_item_num'] = -1;
1378
+					}
1295 1379
 					return upgradeExit();
1380
+				} elseif ($support_js) {
1381
+									break;
1296 1382
 				}
1297
-				elseif ($support_js)
1298
-					break;
1299 1383
 			}
1300 1384
 			// Set the progress bar to be right as if we had - even if we hadn't...
1301 1385
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1320,8 +1404,9 @@  discard block
 block discarded – undo
1320 1404
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1321 1405
 
1322 1406
 	// Now it's nice to have some of the basic SMF source files.
1323
-	if (!isset($_GET['ssi']) && !$command_line)
1324
-		redirectLocation('&ssi=1');
1407
+	if (!isset($_GET['ssi']) && !$command_line) {
1408
+			redirectLocation('&ssi=1');
1409
+	}
1325 1410
 
1326 1411
 	$upcontext['sub_template'] = 'upgrade_complete';
1327 1412
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1337,14 +1422,16 @@  discard block
 block discarded – undo
1337 1422
 	// Are we in maintenance mode?
1338 1423
 	if (isset($upcontext['user']['main']))
1339 1424
 	{
1340
-		if ($command_line)
1341
-			echo ' * ';
1425
+		if ($command_line) {
1426
+					echo ' * ';
1427
+		}
1342 1428
 		$upcontext['removed_maintenance'] = true;
1343 1429
 		$changes['maintenance'] = $upcontext['user']['main'];
1344 1430
 	}
1345 1431
 	// Otherwise if somehow we are in 2 let's go to 1.
1346
-	elseif (!empty($maintenance) && $maintenance == 2)
1347
-		$changes['maintenance'] = 1;
1432
+	elseif (!empty($maintenance) && $maintenance == 2) {
1433
+			$changes['maintenance'] = 1;
1434
+	}
1348 1435
 
1349 1436
 	// Wipe this out...
1350 1437
 	$upcontext['user'] = array();
@@ -1359,9 +1446,9 @@  discard block
 block discarded – undo
1359 1446
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1360 1447
 
1361 1448
 	// Now is the perfect time to fetch the SM files.
1362
-	if ($command_line)
1363
-		cli_scheduled_fetchSMfiles();
1364
-	else
1449
+	if ($command_line) {
1450
+			cli_scheduled_fetchSMfiles();
1451
+	} else
1365 1452
 	{
1366 1453
 		require_once($sourcedir . '/ScheduledTasks.php');
1367 1454
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1369,8 +1456,9 @@  discard block
 block discarded – undo
1369 1456
 	}
1370 1457
 
1371 1458
 	// Log what we've done.
1372
-	if (empty($user_info['id']))
1373
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1459
+	if (empty($user_info['id'])) {
1460
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1461
+	}
1374 1462
 
1375 1463
 	// Log the action manually, so CLI still works.
1376 1464
 	$smcFunc['db_insert']('',
@@ -1389,8 +1477,9 @@  discard block
 block discarded – undo
1389 1477
 
1390 1478
 	// Save the current database version.
1391 1479
 	$server_version = $smcFunc['db_server_info']();
1392
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1393
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1480
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1481
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1482
+	}
1394 1483
 
1395 1484
 	if ($command_line)
1396 1485
 	{
@@ -1402,8 +1491,9 @@  discard block
 block discarded – undo
1402 1491
 
1403 1492
 	// Make sure it says we're done.
1404 1493
 	$upcontext['overall_percent'] = 100;
1405
-	if (isset($upcontext['step_progress']))
1406
-		unset($upcontext['step_progress']);
1494
+	if (isset($upcontext['step_progress'])) {
1495
+			unset($upcontext['step_progress']);
1496
+	}
1407 1497
 
1408 1498
 	$_GET['substep'] = 0;
1409 1499
 	return false;
@@ -1414,8 +1504,9 @@  discard block
 block discarded – undo
1414 1504
 {
1415 1505
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1416 1506
 
1417
-	if (empty($modSettings['time_format']))
1418
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1507
+	if (empty($modSettings['time_format'])) {
1508
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1509
+	}
1419 1510
 
1420 1511
 	// What files do we want to get
1421 1512
 	$request = $smcFunc['db_query']('', '
@@ -1449,8 +1540,9 @@  discard block
 block discarded – undo
1449 1540
 		$file_data = fetch_web_data($url);
1450 1541
 
1451 1542
 		// If we got an error - give up - the site might be down.
1452
-		if ($file_data === false)
1453
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1543
+		if ($file_data === false) {
1544
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1545
+		}
1454 1546
 
1455 1547
 		// Save the file to the database.
1456 1548
 		$smcFunc['db_query']('substring', '
@@ -1492,8 +1584,9 @@  discard block
 block discarded – undo
1492 1584
 	$themeData = array();
1493 1585
 	foreach ($values as $variable => $value)
1494 1586
 	{
1495
-		if (!isset($value) || $value === null)
1496
-			$value = 0;
1587
+		if (!isset($value) || $value === null) {
1588
+					$value = 0;
1589
+		}
1497 1590
 
1498 1591
 		$themeData[] = array(0, 1, $variable, $value);
1499 1592
 	}
@@ -1522,8 +1615,9 @@  discard block
 block discarded – undo
1522 1615
 
1523 1616
 	foreach ($values as $variable => $value)
1524 1617
 	{
1525
-		if (empty($modSettings[$value[0]]))
1526
-			continue;
1618
+		if (empty($modSettings[$value[0]])) {
1619
+					continue;
1620
+		}
1527 1621
 
1528 1622
 		$smcFunc['db_query']('', '
1529 1623
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1609,10 +1703,11 @@  discard block
 block discarded – undo
1609 1703
 	set_error_handler(
1610 1704
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1611 1705
 		{
1612
-			if ($support_js)
1613
-				return true;
1614
-			else
1615
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1706
+			if ($support_js) {
1707
+							return true;
1708
+			} else {
1709
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1710
+			}
1616 1711
 		}
1617 1712
 	);
1618 1713
 
@@ -1627,8 +1722,9 @@  discard block
 block discarded – undo
1627 1722
 				'db_error_skip' => true,
1628 1723
 			)
1629 1724
 		);
1630
-		if ($smcFunc['db_num_rows']($request) === 0)
1631
-			die('Unable to find members table!');
1725
+		if ($smcFunc['db_num_rows']($request) === 0) {
1726
+					die('Unable to find members table!');
1727
+		}
1632 1728
 		$table_status = $smcFunc['db_fetch_assoc']($request);
1633 1729
 		$smcFunc['db_free_result']($request);
1634 1730
 
@@ -1643,17 +1739,20 @@  discard block
 block discarded – undo
1643 1739
 				)
1644 1740
 			);
1645 1741
 			// Got something?
1646
-			if ($smcFunc['db_num_rows']($request) !== 0)
1647
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
1742
+			if ($smcFunc['db_num_rows']($request) !== 0) {
1743
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
1744
+			}
1648 1745
 			$smcFunc['db_free_result']($request);
1649 1746
 
1650 1747
 			// Excellent!
1651
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
1652
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1748
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
1749
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1750
+			}
1653 1751
 		}
1654 1752
 	}
1655
-	if (empty($db_collation))
1656
-		$db_collation = '';
1753
+	if (empty($db_collation)) {
1754
+			$db_collation = '';
1755
+	}
1657 1756
 
1658 1757
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1659 1758
 
@@ -1665,8 +1764,9 @@  discard block
 block discarded – undo
1665 1764
 	$last_step = '';
1666 1765
 
1667 1766
 	// Make sure all newly created tables will have the proper characters set.
1668
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1669
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1767
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1768
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1769
+	}
1670 1770
 
1671 1771
 	// Count the total number of steps within this file - for progress.
1672 1772
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1686,15 +1786,18 @@  discard block
 block discarded – undo
1686 1786
 		$do_current = $substep >= $_GET['substep'];
1687 1787
 
1688 1788
 		// Get rid of any comments in the beginning of the line...
1689
-		if (substr(trim($line), 0, 2) === '/*')
1690
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1789
+		if (substr(trim($line), 0, 2) === '/*') {
1790
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1791
+		}
1691 1792
 
1692 1793
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1693
-		if ($is_debug && !$support_js && $command_line)
1694
-			flush();
1794
+		if ($is_debug && !$support_js && $command_line) {
1795
+					flush();
1796
+		}
1695 1797
 
1696
-		if (trim($line) === '')
1697
-			continue;
1798
+		if (trim($line) === '') {
1799
+					continue;
1800
+		}
1698 1801
 
1699 1802
 		if (trim(substr($line, 0, 3)) === '---')
1700 1803
 		{
@@ -1704,8 +1807,9 @@  discard block
 block discarded – undo
1704 1807
 			if (trim($current_data) != '' && $type !== '}')
1705 1808
 			{
1706 1809
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1707
-				if ($command_line)
1708
-					echo $upcontext['error_message'];
1810
+				if ($command_line) {
1811
+									echo $upcontext['error_message'];
1812
+				}
1709 1813
 			}
1710 1814
 
1711 1815
 			if ($type == ' ')
@@ -1723,17 +1827,18 @@  discard block
 block discarded – undo
1723 1827
 				if ($do_current)
1724 1828
 				{
1725 1829
 					$upcontext['actioned_items'][] = $last_step;
1726
-					if ($command_line)
1727
-						echo ' * ';
1830
+					if ($command_line) {
1831
+											echo ' * ';
1832
+					}
1728 1833
 				}
1729
-			}
1730
-			elseif ($type == '#')
1834
+			} elseif ($type == '#')
1731 1835
 			{
1732 1836
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1733 1837
 
1734 1838
 				$upcontext['current_debug_item_num']++;
1735
-				if (trim($line) != '---#')
1736
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1839
+				if (trim($line) != '---#') {
1840
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1841
+				}
1737 1842
 
1738 1843
 				// Have we already done something?
1739 1844
 				if (isset($_GET['xml']) && $done_something)
@@ -1744,34 +1849,36 @@  discard block
 block discarded – undo
1744 1849
 
1745 1850
 				if ($do_current)
1746 1851
 				{
1747
-					if (trim($line) == '---#' && $command_line)
1748
-						echo ' done.', $endl;
1749
-					elseif ($command_line)
1750
-						echo ' +++ ', rtrim(substr($line, 4));
1751
-					elseif (trim($line) != '---#')
1852
+					if (trim($line) == '---#' && $command_line) {
1853
+											echo ' done.', $endl;
1854
+					} elseif ($command_line) {
1855
+											echo ' +++ ', rtrim(substr($line, 4));
1856
+					} elseif (trim($line) != '---#')
1752 1857
 					{
1753
-						if ($is_debug)
1754
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1858
+						if ($is_debug) {
1859
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1860
+						}
1755 1861
 					}
1756 1862
 				}
1757 1863
 
1758 1864
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1759 1865
 				{
1760
-					if ($command_line)
1761
-						echo ' * ';
1762
-					else
1763
-						$upcontext['actioned_items'][] = $last_step;
1866
+					if ($command_line) {
1867
+											echo ' * ';
1868
+					} else {
1869
+											$upcontext['actioned_items'][] = $last_step;
1870
+					}
1764 1871
 				}
1765 1872
 
1766 1873
 				// Small step - only if we're actually doing stuff.
1767
-				if ($do_current)
1768
-					nextSubstep(++$substep);
1769
-				else
1770
-					$substep++;
1771
-			}
1772
-			elseif ($type == '{')
1773
-				$current_type = 'code';
1774
-			elseif ($type == '}')
1874
+				if ($do_current) {
1875
+									nextSubstep(++$substep);
1876
+				} else {
1877
+									$substep++;
1878
+				}
1879
+			} elseif ($type == '{') {
1880
+							$current_type = 'code';
1881
+			} elseif ($type == '}')
1775 1882
 			{
1776 1883
 				$current_type = 'sql';
1777 1884
 
@@ -1784,8 +1891,9 @@  discard block
 block discarded – undo
1784 1891
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1785 1892
 				{
1786 1893
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1787
-					if ($command_line)
1788
-						echo $upcontext['error_message'];
1894
+					if ($command_line) {
1895
+											echo $upcontext['error_message'];
1896
+					}
1789 1897
 				}
1790 1898
 
1791 1899
 				// Done with code!
@@ -1865,8 +1973,9 @@  discard block
 block discarded – undo
1865 1973
 	$db_unbuffered = false;
1866 1974
 
1867 1975
 	// Failure?!
1868
-	if ($result !== false)
1869
-		return $result;
1976
+	if ($result !== false) {
1977
+			return $result;
1978
+	}
1870 1979
 
1871 1980
 	$db_error_message = $smcFunc['db_error']($db_connection);
1872 1981
 	// If MySQL we do something more clever.
@@ -1894,54 +2003,61 @@  discard block
 block discarded – undo
1894 2003
 			{
1895 2004
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1896 2005
 				$result = mysqli_query($db_connection, $string);
1897
-				if ($result !== false)
1898
-					return $result;
2006
+				if ($result !== false) {
2007
+									return $result;
2008
+				}
1899 2009
 			}
1900
-		}
1901
-		elseif ($mysqli_errno == 2013)
2010
+		} elseif ($mysqli_errno == 2013)
1902 2011
 		{
1903 2012
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1904 2013
 			mysqli_select_db($db_connection, $db_name);
1905 2014
 			if ($db_connection)
1906 2015
 			{
1907 2016
 				$result = mysqli_query($db_connection, $string);
1908
-				if ($result !== false)
1909
-					return $result;
2017
+				if ($result !== false) {
2018
+									return $result;
2019
+				}
1910 2020
 			}
1911 2021
 		}
1912 2022
 		// Duplicate column name... should be okay ;).
1913
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1914
-			return false;
2023
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2024
+					return false;
2025
+		}
1915 2026
 		// Duplicate insert... make sure it's the proper type of query ;).
1916
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1917
-			return false;
2027
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2028
+					return false;
2029
+		}
1918 2030
 		// Creating an index on a non-existent column.
1919
-		elseif ($mysqli_errno == 1072)
1920
-			return false;
1921
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1922
-			return false;
2031
+		elseif ($mysqli_errno == 1072) {
2032
+					return false;
2033
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2034
+					return false;
2035
+		}
1923 2036
 	}
1924 2037
 	// If a table already exists don't go potty.
1925 2038
 	else
1926 2039
 	{
1927 2040
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1928 2041
 		{
1929
-			if (strpos($db_error_message, 'exist') !== false)
1930
-				return true;
1931
-		}
1932
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2042
+			if (strpos($db_error_message, 'exist') !== false) {
2043
+							return true;
2044
+			}
2045
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1933 2046
 		{
1934
-			if (strpos($db_error_message, 'duplicate') !== false)
1935
-				return true;
2047
+			if (strpos($db_error_message, 'duplicate') !== false) {
2048
+							return true;
2049
+			}
1936 2050
 		}
1937 2051
 	}
1938 2052
 
1939 2053
 	// Get the query string so we pass everything.
1940 2054
 	$query_string = '';
1941
-	foreach ($_GET as $k => $v)
1942
-		$query_string .= ';' . $k . '=' . $v;
1943
-	if (strlen($query_string) != 0)
1944
-		$query_string = '?' . substr($query_string, 1);
2055
+	foreach ($_GET as $k => $v) {
2056
+			$query_string .= ';' . $k . '=' . $v;
2057
+	}
2058
+	if (strlen($query_string) != 0) {
2059
+			$query_string = '?' . substr($query_string, 1);
2060
+	}
1945 2061
 
1946 2062
 	if ($command_line)
1947 2063
 	{
@@ -1996,16 +2112,18 @@  discard block
 block discarded – undo
1996 2112
 			{
1997 2113
 				$found |= 1;
1998 2114
 				// Do some checks on the data if we have it set.
1999
-				if (isset($change['col_type']))
2000
-					$found &= $change['col_type'] === $column['type'];
2001
-				if (isset($change['null_allowed']))
2002
-					$found &= $column['null'] == $change['null_allowed'];
2003
-				if (isset($change['default']))
2004
-					$found &= $change['default'] === $column['default'];
2115
+				if (isset($change['col_type'])) {
2116
+									$found &= $change['col_type'] === $column['type'];
2117
+				}
2118
+				if (isset($change['null_allowed'])) {
2119
+									$found &= $column['null'] == $change['null_allowed'];
2120
+				}
2121
+				if (isset($change['default'])) {
2122
+									$found &= $change['default'] === $column['default'];
2123
+				}
2005 2124
 			}
2006 2125
 		}
2007
-	}
2008
-	elseif ($change['type'] === 'index')
2126
+	} elseif ($change['type'] === 'index')
2009 2127
 	{
2010 2128
 		$request = upgrade_query('
2011 2129
 			SHOW INDEX
@@ -2014,9 +2132,10 @@  discard block
 block discarded – undo
2014 2132
 		{
2015 2133
 			$cur_index = array();
2016 2134
 
2017
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2018
-				if ($row['Key_name'] === $change['name'])
2135
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2136
+							if ($row['Key_name'] === $change['name'])
2019 2137
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2138
+			}
2020 2139
 
2021 2140
 			ksort($cur_index, SORT_NUMERIC);
2022 2141
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2026,14 +2145,17 @@  discard block
 block discarded – undo
2026 2145
 	}
2027 2146
 
2028 2147
 	// If we're trying to add and it's added, we're done.
2029
-	if ($found && in_array($change['method'], array('add', 'change')))
2030
-		return true;
2148
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2149
+			return true;
2150
+	}
2031 2151
 	// Otherwise if we're removing and it wasn't found we're also done.
2032
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2033
-		return true;
2152
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2153
+			return true;
2154
+	}
2034 2155
 	// Otherwise is it just a test?
2035
-	elseif ($is_test)
2036
-		return false;
2156
+	elseif ($is_test) {
2157
+			return false;
2158
+	}
2037 2159
 
2038 2160
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2039 2161
 	$running = false;
@@ -2044,8 +2166,9 @@  discard block
 block discarded – undo
2044 2166
 			SHOW FULL PROCESSLIST');
2045 2167
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2046 2168
 		{
2047
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2048
-				$found = true;
2169
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2170
+							$found = true;
2171
+			}
2049 2172
 		}
2050 2173
 
2051 2174
 		// Can't find it? Then we need to run it fools!
@@ -2057,8 +2180,9 @@  discard block
 block discarded – undo
2057 2180
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2058 2181
 				' . $change['text'], true) !== false;
2059 2182
 
2060
-			if (!$success)
2061
-				return false;
2183
+			if (!$success) {
2184
+							return false;
2185
+			}
2062 2186
 
2063 2187
 			// Return
2064 2188
 			$running = true;
@@ -2100,8 +2224,9 @@  discard block
 block discarded – undo
2100 2224
 			'db_error_skip' => true,
2101 2225
 		)
2102 2226
 	);
2103
-	if ($smcFunc['db_num_rows']($request) === 0)
2104
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2227
+	if ($smcFunc['db_num_rows']($request) === 0) {
2228
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2229
+	}
2105 2230
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2106 2231
 	$smcFunc['db_free_result']($request);
2107 2232
 
@@ -2123,18 +2248,19 @@  discard block
 block discarded – undo
2123 2248
 			)
2124 2249
 		);
2125 2250
 		// No results? Just forget it all together.
2126
-		if ($smcFunc['db_num_rows']($request) === 0)
2127
-			unset($table_row['Collation']);
2128
-		else
2129
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2251
+		if ($smcFunc['db_num_rows']($request) === 0) {
2252
+					unset($table_row['Collation']);
2253
+		} else {
2254
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2255
+		}
2130 2256
 		$smcFunc['db_free_result']($request);
2131 2257
 	}
2132 2258
 
2133 2259
 	if ($column_fix)
2134 2260
 	{
2135 2261
 		// Make sure there are no NULL's left.
2136
-		if ($null_fix)
2137
-			$smcFunc['db_query']('', '
2262
+		if ($null_fix) {
2263
+					$smcFunc['db_query']('', '
2138 2264
 				UPDATE {db_prefix}' . $change['table'] . '
2139 2265
 				SET ' . $change['column'] . ' = {string:default}
2140 2266
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2143,6 +2269,7 @@  discard block
 block discarded – undo
2143 2269
 					'db_error_skip' => true,
2144 2270
 				)
2145 2271
 			);
2272
+		}
2146 2273
 
2147 2274
 		// Do the actual alteration.
2148 2275
 		$smcFunc['db_query']('', '
@@ -2171,8 +2298,9 @@  discard block
 block discarded – undo
2171 2298
 	}
2172 2299
 
2173 2300
 	// Not a column we need to check on?
2174
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2175
-		return;
2301
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2302
+			return;
2303
+	}
2176 2304
 
2177 2305
 	// Break it up you (six|seven).
2178 2306
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2191,13 +2319,13 @@  discard block
 block discarded – undo
2191 2319
 				'new_name' => $temp[2],
2192 2320
 		));
2193 2321
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2194
-		if ($smcFunc['db_num_rows'] != 1)
2195
-			return;
2322
+		if ($smcFunc['db_num_rows'] != 1) {
2323
+					return;
2324
+		}
2196 2325
 
2197 2326
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2198 2327
 		$smcFunc['db_free_result']($request);
2199
-	}
2200
-	else
2328
+	} else
2201 2329
 	{
2202 2330
 		// Do this the old fashion, sure method way.
2203 2331
 		$request = $smcFunc['db_query']('', '
@@ -2208,21 +2336,24 @@  discard block
 block discarded – undo
2208 2336
 		));
2209 2337
 		// Mayday!
2210 2338
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2211
-		if ($smcFunc['db_num_rows'] == 0)
2212
-			return;
2339
+		if ($smcFunc['db_num_rows'] == 0) {
2340
+					return;
2341
+		}
2213 2342
 
2214 2343
 		// Oh where, oh where has my little field gone. Oh where can it be...
2215
-		while ($row = $smcFunc['db_query']($request))
2216
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2344
+		while ($row = $smcFunc['db_query']($request)) {
2345
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2217 2346
 			{
2218 2347
 				$current_type = $row['Type'];
2348
+		}
2219 2349
 				break;
2220 2350
 			}
2221 2351
 	}
2222 2352
 
2223 2353
 	// If this doesn't match, the column may of been altered for a reason.
2224
-	if (trim($current_type) != trim($temp[3]))
2225
-		$temp[3] = $current_type;
2354
+	if (trim($current_type) != trim($temp[3])) {
2355
+			$temp[3] = $current_type;
2356
+	}
2226 2357
 
2227 2358
 	// Piece this back together.
2228 2359
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2234,8 +2365,9 @@  discard block
 block discarded – undo
2234 2365
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2235 2366
 	global $step_progress, $is_debug, $upcontext;
2236 2367
 
2237
-	if ($_GET['substep'] < $substep)
2238
-		$_GET['substep'] = $substep;
2368
+	if ($_GET['substep'] < $substep) {
2369
+			$_GET['substep'] = $substep;
2370
+	}
2239 2371
 
2240 2372
 	if ($command_line)
2241 2373
 	{
@@ -2248,29 +2380,33 @@  discard block
 block discarded – undo
2248 2380
 	}
2249 2381
 
2250 2382
 	@set_time_limit(300);
2251
-	if (function_exists('apache_reset_timeout'))
2252
-		@apache_reset_timeout();
2383
+	if (function_exists('apache_reset_timeout')) {
2384
+			@apache_reset_timeout();
2385
+	}
2253 2386
 
2254
-	if (time() - $start_time <= $timeLimitThreshold)
2255
-		return;
2387
+	if (time() - $start_time <= $timeLimitThreshold) {
2388
+			return;
2389
+	}
2256 2390
 
2257 2391
 	// Do we have some custom step progress stuff?
2258 2392
 	if (!empty($step_progress))
2259 2393
 	{
2260 2394
 		$upcontext['substep_progress'] = 0;
2261 2395
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2262
-		if ($step_progress['current'] > $step_progress['total'])
2263
-			$upcontext['substep_progress'] = 99.9;
2264
-		else
2265
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2396
+		if ($step_progress['current'] > $step_progress['total']) {
2397
+					$upcontext['substep_progress'] = 99.9;
2398
+		} else {
2399
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2400
+		}
2266 2401
 
2267 2402
 		// Make it nicely rounded.
2268 2403
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2269 2404
 	}
2270 2405
 
2271 2406
 	// If this is XML we just exit right away!
2272
-	if (isset($_GET['xml']))
2273
-		return upgradeExit();
2407
+	if (isset($_GET['xml'])) {
2408
+			return upgradeExit();
2409
+	}
2274 2410
 
2275 2411
 	// We're going to pause after this!
2276 2412
 	$upcontext['pause'] = true;
@@ -2278,13 +2414,15 @@  discard block
 block discarded – undo
2278 2414
 	$upcontext['query_string'] = '';
2279 2415
 	foreach ($_GET as $k => $v)
2280 2416
 	{
2281
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2282
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2417
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2418
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2419
+		}
2283 2420
 	}
2284 2421
 
2285 2422
 	// Custom warning?
2286
-	if (!empty($custom_warning))
2287
-		$upcontext['custom_warning'] = $custom_warning;
2423
+	if (!empty($custom_warning)) {
2424
+			$upcontext['custom_warning'] = $custom_warning;
2425
+	}
2288 2426
 
2289 2427
 	upgradeExit();
2290 2428
 }
@@ -2299,25 +2437,26 @@  discard block
 block discarded – undo
2299 2437
 	ob_implicit_flush(true);
2300 2438
 	@set_time_limit(600);
2301 2439
 
2302
-	if (!isset($_SERVER['argv']))
2303
-		$_SERVER['argv'] = array();
2440
+	if (!isset($_SERVER['argv'])) {
2441
+			$_SERVER['argv'] = array();
2442
+	}
2304 2443
 	$_GET['maint'] = 1;
2305 2444
 
2306 2445
 	foreach ($_SERVER['argv'] as $i => $arg)
2307 2446
 	{
2308
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2309
-			$_GET['lang'] = $match[1];
2310
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2311
-			continue;
2312
-		elseif ($arg == '--no-maintenance')
2313
-			$_GET['maint'] = 0;
2314
-		elseif ($arg == '--debug')
2315
-			$is_debug = true;
2316
-		elseif ($arg == '--backup')
2317
-			$_POST['backup'] = 1;
2318
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2319
-			$_GET['conv'] = 1;
2320
-		elseif ($i != 0)
2447
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2448
+					$_GET['lang'] = $match[1];
2449
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2450
+					continue;
2451
+		} elseif ($arg == '--no-maintenance') {
2452
+					$_GET['maint'] = 0;
2453
+		} elseif ($arg == '--debug') {
2454
+					$is_debug = true;
2455
+		} elseif ($arg == '--backup') {
2456
+					$_POST['backup'] = 1;
2457
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2458
+					$_GET['conv'] = 1;
2459
+		} elseif ($i != 0)
2321 2460
 		{
2322 2461
 			echo 'SMF Command-line Upgrader
2323 2462
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2331,10 +2470,12 @@  discard block
 block discarded – undo
2331 2470
 		}
2332 2471
 	}
2333 2472
 
2334
-	if (!php_version_check())
2335
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2336
-	if (!db_version_check())
2337
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2473
+	if (!php_version_check()) {
2474
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2475
+	}
2476
+	if (!db_version_check()) {
2477
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2478
+	}
2338 2479
 
2339 2480
 	// Do some checks to make sure they have proper privileges
2340 2481
 	db_extend('packages');
@@ -2349,34 +2490,39 @@  discard block
 block discarded – undo
2349 2490
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2350 2491
 
2351 2492
 	// Sorry... we need CREATE, ALTER and DROP
2352
-	if (!$create || !$alter || !$drop)
2353
-		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);
2493
+	if (!$create || !$alter || !$drop) {
2494
+			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);
2495
+	}
2354 2496
 
2355 2497
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2356 2498
 		&& @file_exists($sourcedir . '/QueryString.php')
2357 2499
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2358
-	if (!$check && !isset($modSettings['smfVersion']))
2359
-		print_error('Error: Some files are missing or out-of-date.', true);
2500
+	if (!$check && !isset($modSettings['smfVersion'])) {
2501
+			print_error('Error: Some files are missing or out-of-date.', true);
2502
+	}
2360 2503
 
2361 2504
 	// Do a quick version spot check.
2362 2505
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2363 2506
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2364
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2365
-		print_error('Error: Some files have not yet been updated properly.');
2507
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2508
+			print_error('Error: Some files have not yet been updated properly.');
2509
+	}
2366 2510
 
2367 2511
 	// Make sure Settings.php is writable.
2368 2512
 		quickFileWritable($boarddir . '/Settings.php');
2369
-	if (!is_writable($boarddir . '/Settings.php'))
2370
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2513
+	if (!is_writable($boarddir . '/Settings.php')) {
2514
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2515
+	}
2371 2516
 
2372 2517
 	// Make sure Settings_bak.php is writable.
2373 2518
 		quickFileWritable($boarddir . '/Settings_bak.php');
2374
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2375
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2519
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2520
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2521
+	}
2376 2522
 
2377
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2378
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2379
-	elseif (isset($modSettings['agreement']))
2523
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2524
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2525
+	} elseif (isset($modSettings['agreement']))
2380 2526
 	{
2381 2527
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2382 2528
 		fwrite($fp, $modSettings['agreement']);
@@ -2386,31 +2532,36 @@  discard block
 block discarded – undo
2386 2532
 	// Make sure Themes is writable.
2387 2533
 	quickFileWritable($modSettings['theme_dir']);
2388 2534
 
2389
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2390
-		print_error('Error: Unable to obtain write access to "Themes".');
2535
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2536
+			print_error('Error: Unable to obtain write access to "Themes".');
2537
+	}
2391 2538
 
2392 2539
 	// Make sure cache directory exists and is writable!
2393 2540
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2394
-	if (!file_exists($cachedir_temp))
2395
-		@mkdir($cachedir_temp);
2541
+	if (!file_exists($cachedir_temp)) {
2542
+			@mkdir($cachedir_temp);
2543
+	}
2396 2544
 
2397 2545
 	// Make sure the cache temp dir is writable.
2398 2546
 	quickFileWritable($cachedir_temp);
2399 2547
 
2400
-	if (!is_writable($cachedir_temp))
2401
-		print_error('Error: Unable to obtain write access to "cache".', true);
2548
+	if (!is_writable($cachedir_temp)) {
2549
+			print_error('Error: Unable to obtain write access to "cache".', true);
2550
+	}
2402 2551
 
2403
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2404
-		print_error('Error: Unable to find language files!', true);
2405
-	else
2552
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2553
+			print_error('Error: Unable to find language files!', true);
2554
+	} else
2406 2555
 	{
2407 2556
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2408 2557
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2409 2558
 
2410
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2411
-			print_error('Error: Language files out of date.', true);
2412
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2413
-			print_error('Error: Install language is missing for selected language.', true);
2559
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2560
+					print_error('Error: Language files out of date.', true);
2561
+		}
2562
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2563
+					print_error('Error: Install language is missing for selected language.', true);
2564
+		}
2414 2565
 
2415 2566
 		// Otherwise include it!
2416 2567
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2439,8 +2590,7 @@  discard block
 block discarded – undo
2439 2590
 		);
2440 2591
 
2441 2592
 		return true;
2442
-	}
2443
-	else
2593
+	} else
2444 2594
 	{
2445 2595
 		$upcontext['page_title'] = 'Converting to UTF8';
2446 2596
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2484,8 +2634,9 @@  discard block
 block discarded – undo
2484 2634
 			)
2485 2635
 		);
2486 2636
 		$db_charsets = array();
2487
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2488
-			$db_charsets[] = $row['Charset'];
2637
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2638
+					$db_charsets[] = $row['Charset'];
2639
+		}
2489 2640
 
2490 2641
 		$smcFunc['db_free_result']($request);
2491 2642
 
@@ -2521,13 +2672,15 @@  discard block
 block discarded – undo
2521 2672
 		// If there's a fulltext index, we need to drop it first...
2522 2673
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2523 2674
 		{
2524
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2525
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2675
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2676
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2526 2677
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2678
+			}
2527 2679
 			$smcFunc['db_free_result']($request);
2528 2680
 
2529
-			if (isset($upcontext['fulltext_index']))
2530
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2681
+			if (isset($upcontext['fulltext_index'])) {
2682
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2683
+			}
2531 2684
 		}
2532 2685
 
2533 2686
 		// Drop it and make a note...
@@ -2717,8 +2870,9 @@  discard block
 block discarded – undo
2717 2870
 			$replace = '%field%';
2718 2871
 
2719 2872
 			// Build a huge REPLACE statement...
2720
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2721
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2873
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2874
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2875
+			}
2722 2876
 		}
2723 2877
 
2724 2878
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2752,8 +2906,9 @@  discard block
 block discarded – undo
2752 2906
 			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2753 2907
 
2754 2908
 			// Just to make sure it doesn't time out.
2755
-			if (function_exists('apache_reset_timeout'))
2756
-				@apache_reset_timeout();
2909
+			if (function_exists('apache_reset_timeout')) {
2910
+							@apache_reset_timeout();
2911
+			}
2757 2912
 
2758 2913
 			$table_charsets = array();
2759 2914
 
@@ -2774,8 +2929,9 @@  discard block
 block discarded – undo
2774 2929
 					{
2775 2930
 						list($charset) = explode('_', $collation);
2776 2931
 
2777
-						if (!isset($table_charsets[$charset]))
2778
-							$table_charsets[$charset] = array();
2932
+						if (!isset($table_charsets[$charset])) {
2933
+													$table_charsets[$charset] = array();
2934
+						}
2779 2935
 
2780 2936
 						$table_charsets[$charset][] = $column_info;
2781 2937
 					}
@@ -2815,10 +2971,11 @@  discard block
 block discarded – undo
2815 2971
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2816 2972
 				{
2817 2973
 					$update = '';
2818
-					foreach ($table_charsets as $charset => $columns)
2819
-						foreach ($columns as $column)
2974
+					foreach ($table_charsets as $charset => $columns) {
2975
+											foreach ($columns as $column)
2820 2976
 							$update .= '
2821 2977
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2978
+					}
2822 2979
 
2823 2980
 					$smcFunc['db_query']('', '
2824 2981
 						UPDATE {raw:table_name}
@@ -2843,8 +3000,9 @@  discard block
 block discarded – undo
2843 3000
 			// Now do the actual conversion (if still needed).
2844 3001
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2845 3002
 			{
2846
-				if ($command_line)
2847
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3003
+				if ($command_line) {
3004
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3005
+				}
2848 3006
 
2849 3007
 				$smcFunc['db_query']('', '
2850 3008
 					ALTER TABLE {raw:table_name}
@@ -2854,8 +3012,9 @@  discard block
 block discarded – undo
2854 3012
 					)
2855 3013
 				);
2856 3014
 
2857
-				if ($command_line)
2858
-					echo " done.\n";
3015
+				if ($command_line) {
3016
+									echo " done.\n";
3017
+				}
2859 3018
 			}
2860 3019
 		}
2861 3020
 
@@ -2885,8 +3044,8 @@  discard block
 block discarded – undo
2885 3044
 		);
2886 3045
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2887 3046
 		{
2888
-			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)
2889
-				$smcFunc['db_query']('', '
3047
+			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) {
3048
+							$smcFunc['db_query']('', '
2890 3049
 					UPDATE {db_prefix}log_actions
2891 3050
 					SET extra = {string:extra}
2892 3051
 					WHERE id_action = {int:current_action}',
@@ -2895,6 +3054,7 @@  discard block
 block discarded – undo
2895 3054
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2896 3055
 					)
2897 3056
 				);
3057
+			}
2898 3058
 		}
2899 3059
 		$smcFunc['db_free_result']($request);
2900 3060
 
@@ -2916,15 +3076,17 @@  discard block
 block discarded – undo
2916 3076
 	// First thing's first - did we already do this?
2917 3077
 	if (!empty($modSettings['json_done']))
2918 3078
 	{
2919
-		if ($command_line)
2920
-			return DeleteUpgrade();
2921
-		else
2922
-			return true;
3079
+		if ($command_line) {
3080
+					return DeleteUpgrade();
3081
+		} else {
3082
+					return true;
3083
+		}
2923 3084
 	}
2924 3085
 
2925 3086
 	// Done it already - js wise?
2926
-	if (!empty($_POST['json_done']))
2927
-		return true;
3087
+	if (!empty($_POST['json_done'])) {
3088
+			return true;
3089
+	}
2928 3090
 
2929 3091
 	// List of tables affected by this function
2930 3092
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2955,12 +3117,14 @@  discard block
 block discarded – undo
2955 3117
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2956 3118
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2957 3119
 
2958
-	foreach ($keys as $id => $table)
2959
-		if ($id < $_GET['substep'])
3120
+	foreach ($keys as $id => $table) {
3121
+			if ($id < $_GET['substep'])
2960 3122
 			$upcontext['previous_tables'][] = $table;
3123
+	}
2961 3124
 
2962
-	if ($command_line)
2963
-		echo 'Converting data from serialize() to json_encode().';
3125
+	if ($command_line) {
3126
+			echo 'Converting data from serialize() to json_encode().';
3127
+	}
2964 3128
 
2965 3129
 	if (!$support_js || isset($_GET['xml']))
2966 3130
 	{
@@ -3000,8 +3164,9 @@  discard block
 block discarded – undo
3000 3164
 
3001 3165
 				// Loop through and fix these...
3002 3166
 				$new_settings = array();
3003
-				if ($command_line)
3004
-					echo "\n" . 'Fixing some settings...';
3167
+				if ($command_line) {
3168
+									echo "\n" . 'Fixing some settings...';
3169
+				}
3005 3170
 
3006 3171
 				foreach ($serialized_settings as $var)
3007 3172
 				{
@@ -3009,22 +3174,24 @@  discard block
 block discarded – undo
3009 3174
 					{
3010 3175
 						// Attempt to unserialize the setting
3011 3176
 						$temp = @safe_unserialize($modSettings[$var]);
3012
-						if (!$temp && $command_line)
3013
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3014
-						elseif ($temp !== false)
3015
-							$new_settings[$var] = json_encode($temp);
3177
+						if (!$temp && $command_line) {
3178
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3179
+						} elseif ($temp !== false) {
3180
+													$new_settings[$var] = json_encode($temp);
3181
+						}
3016 3182
 					}
3017 3183
 				}
3018 3184
 
3019 3185
 				// Update everything at once
3020
-				if (!function_exists('cache_put_data'))
3021
-					require_once($sourcedir . '/Load.php');
3186
+				if (!function_exists('cache_put_data')) {
3187
+									require_once($sourcedir . '/Load.php');
3188
+				}
3022 3189
 				updateSettings($new_settings, true);
3023 3190
 
3024
-				if ($command_line)
3025
-					echo ' done.';
3026
-			}
3027
-			elseif ($table == 'themes')
3191
+				if ($command_line) {
3192
+									echo ' done.';
3193
+				}
3194
+			} elseif ($table == 'themes')
3028 3195
 			{
3029 3196
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3030 3197
 				$query = $smcFunc['db_query']('', '
@@ -3043,10 +3210,11 @@  discard block
 block discarded – undo
3043 3210
 
3044 3211
 						if ($command_line)
3045 3212
 						{
3046
-							if ($temp === false)
3047
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3048
-							else
3049
-								echo "\n" . 'Fixing admin preferences...';
3213
+							if ($temp === false) {
3214
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3215
+							} else {
3216
+															echo "\n" . 'Fixing admin preferences...';
3217
+							}
3050 3218
 						}
3051 3219
 
3052 3220
 						if ($temp !== false)
@@ -3068,15 +3236,15 @@  discard block
 block discarded – undo
3068 3236
 								)
3069 3237
 							);
3070 3238
 
3071
-							if ($command_line)
3072
-								echo ' done.';
3239
+							if ($command_line) {
3240
+															echo ' done.';
3241
+							}
3073 3242
 						}
3074 3243
 					}
3075 3244
 
3076 3245
 					$smcFunc['db_free_result']($query);
3077 3246
 				}
3078
-			}
3079
-			else
3247
+			} else
3080 3248
 			{
3081 3249
 				// First item is always the key...
3082 3250
 				$key = $info[0];
@@ -3087,8 +3255,7 @@  discard block
 block discarded – undo
3087 3255
 				{
3088 3256
 					$col_select = $info[1];
3089 3257
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3090
-				}
3091
-				else
3258
+				} else
3092 3259
 				{
3093 3260
 					$col_select = implode(', ', $info);
3094 3261
 				}
@@ -3121,8 +3288,7 @@  discard block
 block discarded – undo
3121 3288
 								if ($temp === false && $command_line)
3122 3289
 								{
3123 3290
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3124
-								}
3125
-								else
3291
+								} else
3126 3292
 								{
3127 3293
 									$row[$col] = json_encode($temp);
3128 3294
 
@@ -3147,16 +3313,18 @@  discard block
 block discarded – undo
3147 3313
 						}
3148 3314
 					}
3149 3315
 
3150
-					if ($command_line)
3151
-						echo ' done.';
3316
+					if ($command_line) {
3317
+											echo ' done.';
3318
+					}
3152 3319
 
3153 3320
 					// Free up some memory...
3154 3321
 					$smcFunc['db_free_result']($query);
3155 3322
 				}
3156 3323
 			}
3157 3324
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3158
-			if (isset($_GET['xml']))
3159
-				return upgradeExit();
3325
+			if (isset($_GET['xml'])) {
3326
+							return upgradeExit();
3327
+			}
3160 3328
 		}
3161 3329
 
3162 3330
 		if ($command_line)
@@ -3171,8 +3339,9 @@  discard block
 block discarded – undo
3171 3339
 
3172 3340
 		$_GET['substep'] = 0;
3173 3341
 		// Make sure we move on!
3174
-		if ($command_line)
3175
-			return DeleteUpgrade();
3342
+		if ($command_line) {
3343
+					return DeleteUpgrade();
3344
+		}
3176 3345
 
3177 3346
 		return true;
3178 3347
 	}
@@ -3192,14 +3361,16 @@  discard block
 block discarded – undo
3192 3361
 	global $upcontext, $txt, $settings;
3193 3362
 
3194 3363
 	// Don't call me twice!
3195
-	if (!empty($upcontext['chmod_called']))
3196
-		return;
3364
+	if (!empty($upcontext['chmod_called'])) {
3365
+			return;
3366
+	}
3197 3367
 
3198 3368
 	$upcontext['chmod_called'] = true;
3199 3369
 
3200 3370
 	// Nothing?
3201
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3202
-		return;
3371
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3372
+			return;
3373
+	}
3203 3374
 
3204 3375
 	// Was it a problem with Windows?
3205 3376
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3231,11 +3402,12 @@  discard block
 block discarded – undo
3231 3402
 					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\');
3232 3403
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3233 3404
 
3234
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3235
-		echo '
3405
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3406
+			echo '
3236 3407
 					content.write(\'<hr>\n\t\t\t\');
3237 3408
 					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\');
3238 3409
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3410
+	}
3239 3411
 
3240 3412
 	echo '
3241 3413
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3243,17 +3415,19 @@  discard block
 block discarded – undo
3243 3415
 				}
3244 3416
 		</script>';
3245 3417
 
3246
-	if (!empty($upcontext['chmod']['ftp_error']))
3247
-		echo '
3418
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3419
+			echo '
3248 3420
 			<div class="error_message red">
3249 3421
 				The following error was encountered when trying to connect:<br><br>
3250 3422
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3251 3423
 			</div>
3252 3424
 			<br>';
3425
+	}
3253 3426
 
3254
-	if (empty($upcontext['chmod_in_form']))
3255
-		echo '
3427
+	if (empty($upcontext['chmod_in_form'])) {
3428
+			echo '
3256 3429
 	<form action="', $upcontext['form_url'], '" method="post">';
3430
+	}
3257 3431
 
3258 3432
 	echo '
3259 3433
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3288,10 +3462,11 @@  discard block
 block discarded – undo
3288 3462
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3289 3463
 	</div>';
3290 3464
 
3291
-	if (empty($upcontext['chmod_in_form']))
3292
-		echo '
3465
+	if (empty($upcontext['chmod_in_form'])) {
3466
+			echo '
3293 3467
 	</form>';
3294
-}
3468
+	}
3469
+	}
3295 3470
 
3296 3471
 function template_upgrade_above()
3297 3472
 {
@@ -3351,9 +3526,10 @@  discard block
 block discarded – undo
3351 3526
 				<h2>', $txt['upgrade_progress'], '</h2>
3352 3527
 				<ul>';
3353 3528
 
3354
-	foreach ($upcontext['steps'] as $num => $step)
3355
-		echo '
3529
+	foreach ($upcontext['steps'] as $num => $step) {
3530
+			echo '
3356 3531
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3532
+	}
3357 3533
 
3358 3534
 	echo '
3359 3535
 					</ul>
@@ -3366,8 +3542,8 @@  discard block
 block discarded – undo
3366 3542
 				</div>
3367 3543
 			</div>';
3368 3544
 
3369
-	if (isset($upcontext['step_progress']))
3370
-		echo '
3545
+	if (isset($upcontext['step_progress'])) {
3546
+			echo '
3371 3547
 				<br>
3372 3548
 				<br>
3373 3549
 				<div id="progress_bar_step">
@@ -3376,6 +3552,7 @@  discard block
 block discarded – undo
3376 3552
 						<span>', $txt['upgrade_step_progress'], '</span>
3377 3553
 					</div>
3378 3554
 				</div>';
3555
+	}
3379 3556
 
3380 3557
 	echo '
3381 3558
 				<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>
@@ -3406,32 +3583,36 @@  discard block
 block discarded – undo
3406 3583
 {
3407 3584
 	global $upcontext, $txt;
3408 3585
 
3409
-	if (!empty($upcontext['pause']))
3410
-		echo '
3586
+	if (!empty($upcontext['pause'])) {
3587
+			echo '
3411 3588
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3412 3589
 
3413 3590
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3414 3591
 								<h3>
3415 3592
 									', $txt['upgrade_paused_overload'], '
3416 3593
 								</h3>';
3594
+	}
3417 3595
 
3418
-	if (!empty($upcontext['custom_warning']))
3419
-		echo '
3596
+	if (!empty($upcontext['custom_warning'])) {
3597
+			echo '
3420 3598
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3421 3599
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3422 3600
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3423 3601
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3424 3602
 								</div>';
3603
+	}
3425 3604
 
3426 3605
 	echo '
3427 3606
 								<div class="righttext" style="margin: 1ex;">';
3428 3607
 
3429
-	if (!empty($upcontext['continue']))
3430
-		echo '
3608
+	if (!empty($upcontext['continue'])) {
3609
+			echo '
3431 3610
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3432
-	if (!empty($upcontext['skip']))
3433
-		echo '
3611
+	}
3612
+	if (!empty($upcontext['skip'])) {
3613
+			echo '
3434 3614
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3615
+	}
3435 3616
 
3436 3617
 	echo '
3437 3618
 								</div>
@@ -3481,11 +3662,12 @@  discard block
 block discarded – undo
3481 3662
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3482 3663
 	<smf>';
3483 3664
 
3484
-	if (!empty($upcontext['get_data']))
3485
-		foreach ($upcontext['get_data'] as $k => $v)
3665
+	if (!empty($upcontext['get_data'])) {
3666
+			foreach ($upcontext['get_data'] as $k => $v)
3486 3667
 			echo '
3487 3668
 		<get key="', $k, '">', $v, '</get>';
3488
-}
3669
+	}
3670
+	}
3489 3671
 
3490 3672
 function template_xml_below()
3491 3673
 {
@@ -3526,8 +3708,8 @@  discard block
 block discarded – undo
3526 3708
 	template_chmod();
3527 3709
 
3528 3710
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3529
-	if ($upcontext['is_large_forum'])
3530
-		echo '
3711
+	if ($upcontext['is_large_forum']) {
3712
+			echo '
3531 3713
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3532 3714
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3533 3715
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3535,10 +3717,11 @@  discard block
 block discarded – undo
3535 3717
 				', $txt['upgrade_warning_lots_data'], '
3536 3718
 			</div>
3537 3719
 		</div>';
3720
+	}
3538 3721
 
3539 3722
 	// A warning message?
3540
-	if (!empty($upcontext['warning']))
3541
-		echo '
3723
+	if (!empty($upcontext['warning'])) {
3724
+			echo '
3542 3725
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3543 3726
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3544 3727
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3546,6 +3729,7 @@  discard block
 block discarded – undo
3546 3729
 				', $upcontext['warning'], '
3547 3730
 			</div>
3548 3731
 		</div>';
3732
+	}
3549 3733
 
3550 3734
 	// Paths are incorrect?
3551 3735
 	echo '
@@ -3561,20 +3745,22 @@  discard block
 block discarded – undo
3561 3745
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3562 3746
 	{
3563 3747
 		$ago = time() - $upcontext['started'];
3564
-		if ($ago < 60)
3565
-			$ago = $ago . ' seconds';
3566
-		elseif ($ago < 3600)
3567
-			$ago = (int) ($ago / 60) . ' minutes';
3568
-		else
3569
-			$ago = (int) ($ago / 3600) . ' hours';
3748
+		if ($ago < 60) {
3749
+					$ago = $ago . ' seconds';
3750
+		} elseif ($ago < 3600) {
3751
+					$ago = (int) ($ago / 60) . ' minutes';
3752
+		} else {
3753
+					$ago = (int) ($ago / 3600) . ' hours';
3754
+		}
3570 3755
 
3571 3756
 		$active = time() - $upcontext['updated'];
3572
-		if ($active < 60)
3573
-			$updated = $active . ' seconds';
3574
-		elseif ($active < 3600)
3575
-			$updated = (int) ($active / 60) . ' minutes';
3576
-		else
3577
-			$updated = (int) ($active / 3600) . ' hours';
3757
+		if ($active < 60) {
3758
+					$updated = $active . ' seconds';
3759
+		} elseif ($active < 3600) {
3760
+					$updated = (int) ($active / 60) . ' minutes';
3761
+		} else {
3762
+					$updated = (int) ($active / 3600) . ' hours';
3763
+		}
3578 3764
 
3579 3765
 		echo '
3580 3766
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3583,16 +3769,18 @@  discard block
 block discarded – undo
3583 3769
 			<div style="padding-left: 6ex;">
3584 3770
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3585 3771
 
3586
-		if ($active < 600)
3587
-			echo '
3772
+		if ($active < 600) {
3773
+					echo '
3588 3774
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3775
+		}
3589 3776
 
3590
-		if ($active > $upcontext['inactive_timeout'])
3591
-			echo '
3777
+		if ($active > $upcontext['inactive_timeout']) {
3778
+					echo '
3592 3779
 				<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.';
3593
-		else
3594
-			echo '
3780
+		} else {
3781
+					echo '
3595 3782
 				<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!');
3783
+		}
3596 3784
 
3597 3785
 		echo '
3598 3786
 			</div>
@@ -3608,9 +3796,10 @@  discard block
 block discarded – undo
3608 3796
 					<td>
3609 3797
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3610 3798
 
3611
-	if (!empty($upcontext['username_incorrect']))
3612
-		echo '
3799
+	if (!empty($upcontext['username_incorrect'])) {
3800
+			echo '
3613 3801
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3802
+	}
3614 3803
 
3615 3804
 	echo '
3616 3805
 					</td>
@@ -3621,9 +3810,10 @@  discard block
 block discarded – undo
3621 3810
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3622 3811
 						<input type="hidden" name="hash_passwrd" value="">';
3623 3812
 
3624
-	if (!empty($upcontext['password_failed']))
3625
-		echo '
3813
+	if (!empty($upcontext['password_failed'])) {
3814
+			echo '
3626 3815
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3816
+	}
3627 3817
 
3628 3818
 	echo '
3629 3819
 					</td>
@@ -3694,8 +3884,8 @@  discard block
 block discarded – undo
3694 3884
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3695 3885
 
3696 3886
 	// Warning message?
3697
-	if (!empty($upcontext['upgrade_options_warning']))
3698
-		echo '
3887
+	if (!empty($upcontext['upgrade_options_warning'])) {
3888
+			echo '
3699 3889
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3700 3890
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3701 3891
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3703,6 +3893,7 @@  discard block
 block discarded – undo
3703 3893
 				', $upcontext['upgrade_options_warning'], '
3704 3894
 			</div>
3705 3895
 		</div>';
3896
+	}
3706 3897
 
3707 3898
 	echo '
3708 3899
 				<table>
@@ -3745,8 +3936,8 @@  discard block
 block discarded – undo
3745 3936
 						</td>
3746 3937
 					</tr>';
3747 3938
 
3748
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3749
-		echo '
3939
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3940
+			echo '
3750 3941
 					<tr valign="top">
3751 3942
 						<td width="2%">
3752 3943
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3755,6 +3946,7 @@  discard block
 block discarded – undo
3755 3946
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3756 3947
 						</td>
3757 3948
 					</tr>';
3949
+	}
3758 3950
 
3759 3951
 	echo '
3760 3952
 					<tr valign="top">
@@ -3792,10 +3984,11 @@  discard block
 block discarded – undo
3792 3984
 			</div>';
3793 3985
 
3794 3986
 	// Dont any tables so far?
3795
-	if (!empty($upcontext['previous_tables']))
3796
-		foreach ($upcontext['previous_tables'] as $table)
3987
+	if (!empty($upcontext['previous_tables'])) {
3988
+			foreach ($upcontext['previous_tables'] as $table)
3797 3989
 			echo '
3798 3990
 			<br>Completed Table: &quot;', $table, '&quot;.';
3991
+	}
3799 3992
 
3800 3993
 	echo '
3801 3994
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3832,12 +4025,13 @@  discard block
 block discarded – undo
3832 4025
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3833 4026
 
3834 4027
 		// If debug flood the screen.
3835
-		if ($is_debug)
3836
-			echo '
4028
+		if ($is_debug) {
4029
+					echo '
3837 4030
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3838 4031
 
3839 4032
 				if (document.getElementById(\'debug_section\').scrollHeight)
3840 4033
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4034
+		}
3841 4035
 
3842 4036
 		echo '
3843 4037
 				// Get the next update...
@@ -3869,8 +4063,9 @@  discard block
 block discarded – undo
3869 4063
 {
3870 4064
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3871 4065
 
3872
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3873
-		$is_debug = true;
4066
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4067
+			$is_debug = true;
4068
+	}
3874 4069
 
3875 4070
 	echo '
3876 4071
 		<h3>Executing database changes</h3>
@@ -3885,8 +4080,9 @@  discard block
 block discarded – undo
3885 4080
 	{
3886 4081
 		foreach ($upcontext['actioned_items'] as $num => $item)
3887 4082
 		{
3888
-			if ($num != 0)
3889
-				echo ' Successful!';
4083
+			if ($num != 0) {
4084
+							echo ' Successful!';
4085
+			}
3890 4086
 			echo '<br>' . $item;
3891 4087
 		}
3892 4088
 		if (!empty($upcontext['changes_complete']))
@@ -3899,28 +4095,32 @@  discard block
 block discarded – undo
3899 4095
 				$seconds = intval($active % 60);
3900 4096
 
3901 4097
 				$totalTime = '';
3902
-				if ($hours > 0)
3903
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3904
-				if ($minutes > 0)
3905
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3906
-				if ($seconds > 0)
3907
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4098
+				if ($hours > 0) {
4099
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4100
+				}
4101
+				if ($minutes > 0) {
4102
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4103
+				}
4104
+				if ($seconds > 0) {
4105
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4106
+				}
3908 4107
 			}
3909 4108
 
3910
-			if ($is_debug && !empty($totalTime))
3911
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3912
-			else
3913
-				echo ' Successful!<br><br>';
4109
+			if ($is_debug && !empty($totalTime)) {
4110
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4111
+			} else {
4112
+							echo ' Successful!<br><br>';
4113
+			}
3914 4114
 
3915 4115
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3916 4116
 		}
3917
-	}
3918
-	else
4117
+	} else
3919 4118
 	{
3920 4119
 		// Tell them how many files we have in total.
3921
-		if ($upcontext['file_count'] > 1)
3922
-			echo '
4120
+		if ($upcontext['file_count'] > 1) {
4121
+					echo '
3923 4122
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4123
+		}
3924 4124
 
3925 4125
 		echo '
3926 4126
 		<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>
@@ -3936,19 +4136,23 @@  discard block
 block discarded – undo
3936 4136
 				$seconds = intval($active % 60);
3937 4137
 
3938 4138
 				$totalTime = '';
3939
-				if ($hours > 0)
3940
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3941
-				if ($minutes > 0)
3942
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3943
-				if ($seconds > 0)
3944
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4139
+				if ($hours > 0) {
4140
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4141
+				}
4142
+				if ($minutes > 0) {
4143
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4144
+				}
4145
+				if ($seconds > 0) {
4146
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4147
+				}
3945 4148
 			}
3946 4149
 
3947 4150
 			echo '
3948 4151
 			<br><span id="upgradeCompleted">';
3949 4152
 
3950
-			if (!empty($totalTime))
3951
-				echo 'Completed in ', $totalTime, '<br>';
4153
+			if (!empty($totalTime)) {
4154
+							echo 'Completed in ', $totalTime, '<br>';
4155
+			}
3952 4156
 
3953 4157
 			echo '</span>
3954 4158
 			<div id="debug_section" style="height: 200px; overflow: auto;">
@@ -3985,9 +4189,10 @@  discard block
 block discarded – undo
3985 4189
 			var getData = "";
3986 4190
 			var debugItems = ', $upcontext['debug_items'], ';';
3987 4191
 
3988
-		if ($is_debug)
3989
-			echo '
4192
+		if ($is_debug) {
4193
+					echo '
3990 4194
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4195
+		}
3991 4196
 
3992 4197
 		echo '
3993 4198
 			function getNextItem()
@@ -4027,9 +4232,10 @@  discard block
 block discarded – undo
4027 4232
 						document.getElementById("error_block").style.display = "";
4028 4233
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4029 4234
 
4030
-	if ($is_debug)
4031
-		echo '
4235
+	if ($is_debug) {
4236
+			echo '
4032 4237
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4238
+	}
4033 4239
 
4034 4240
 	echo '
4035 4241
 					}
@@ -4050,9 +4256,10 @@  discard block
 block discarded – undo
4050 4256
 						document.getElementById("error_block").style.display = "";
4051 4257
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4052 4258
 
4053
-	if ($is_debug)
4054
-		echo '
4259
+	if ($is_debug) {
4260
+			echo '
4055 4261
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4262
+	}
4056 4263
 
4057 4264
 	echo '
4058 4265
 					}
@@ -4111,8 +4318,8 @@  discard block
 block discarded – undo
4111 4318
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4112 4319
 				{';
4113 4320
 
4114
-		if ($is_debug)
4115
-			echo '
4321
+		if ($is_debug) {
4322
+					echo '
4116 4323
 					document.getElementById(\'debug_section\').style.display = "none";
4117 4324
 
4118 4325
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4130,6 +4337,7 @@  discard block
 block discarded – undo
4130 4337
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4131 4338
 
4132 4339
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4340
+		}
4133 4341
 
4134 4342
 		echo '
4135 4343
 
@@ -4137,9 +4345,10 @@  discard block
 block discarded – undo
4137 4345
 					document.getElementById(\'contbutt\').disabled = 0;
4138 4346
 					document.getElementById(\'database_done\').value = 1;';
4139 4347
 
4140
-		if ($upcontext['file_count'] > 1)
4141
-			echo '
4348
+		if ($upcontext['file_count'] > 1) {
4349
+					echo '
4142 4350
 					document.getElementById(\'info1\').style.display = "none";';
4351
+		}
4143 4352
 
4144 4353
 		echo '
4145 4354
 					document.getElementById(\'info2\').style.display = "none";
@@ -4152,9 +4361,10 @@  discard block
 block discarded – undo
4152 4361
 					lastItem = 0;
4153 4362
 					prevFile = curFile;';
4154 4363
 
4155
-		if ($is_debug)
4156
-			echo '
4364
+		if ($is_debug) {
4365
+					echo '
4157 4366
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4367
+		}
4158 4368
 
4159 4369
 		echo '
4160 4370
 					getNextItem();
@@ -4162,8 +4372,8 @@  discard block
 block discarded – undo
4162 4372
 				}';
4163 4373
 
4164 4374
 		// If debug scroll the screen.
4165
-		if ($is_debug)
4166
-			echo '
4375
+		if ($is_debug) {
4376
+					echo '
4167 4377
 				if (iLastSubStepProgress == -1)
4168 4378
 				{
4169 4379
 					// Give it consistent dots.
@@ -4182,6 +4392,7 @@  discard block
 block discarded – undo
4182 4392
 
4183 4393
 				if (document.getElementById(\'debug_section\').scrollHeight)
4184 4394
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4395
+		}
4185 4396
 
4186 4397
 		echo '
4187 4398
 				// Update the page.
@@ -4242,9 +4453,10 @@  discard block
 block discarded – undo
4242 4453
 			}';
4243 4454
 
4244 4455
 		// Start things off assuming we've not errored.
4245
-		if (empty($upcontext['error_message']))
4246
-			echo '
4456
+		if (empty($upcontext['error_message'])) {
4457
+					echo '
4247 4458
 			getNextItem();';
4459
+		}
4248 4460
 
4249 4461
 		echo '
4250 4462
 		</script>';
@@ -4261,18 +4473,21 @@  discard block
 block discarded – undo
4261 4473
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4262 4474
 	<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>';
4263 4475
 
4264
-	if (!empty($upcontext['error_message']))
4265
-		echo '
4476
+	if (!empty($upcontext['error_message'])) {
4477
+			echo '
4266 4478
 	<error>', $upcontext['error_message'], '</error>';
4479
+	}
4267 4480
 
4268
-	if (!empty($upcontext['error_string']))
4269
-		echo '
4481
+	if (!empty($upcontext['error_string'])) {
4482
+			echo '
4270 4483
 	<sql>', $upcontext['error_string'], '</sql>';
4484
+	}
4271 4485
 
4272
-	if ($is_debug)
4273
-		echo '
4486
+	if ($is_debug) {
4487
+			echo '
4274 4488
 	<curtime>', time(), '</curtime>';
4275
-}
4489
+	}
4490
+	}
4276 4491
 
4277 4492
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4278 4493
 function template_convert_utf8()
@@ -4289,18 +4504,20 @@  discard block
 block discarded – undo
4289 4504
 			<span id="debuginfo"></span>';
4290 4505
 
4291 4506
 	// Done any tables so far?
4292
-	if (!empty($upcontext['previous_tables']))
4293
-		foreach ($upcontext['previous_tables'] as $table)
4507
+	if (!empty($upcontext['previous_tables'])) {
4508
+			foreach ($upcontext['previous_tables'] as $table)
4294 4509
 			echo '
4295 4510
 			<br>Completed Table: &quot;', $table, '&quot;.';
4511
+	}
4296 4512
 
4297 4513
 	echo '
4298 4514
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4299 4515
 
4300 4516
 	// If we dropped their index, let's let them know
4301
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
4302
-		echo '
4517
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
4518
+			echo '
4303 4519
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
4520
+	}
4304 4521
 
4305 4522
 	echo '
4306 4523
 			<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>';
@@ -4336,9 +4553,10 @@  discard block
 block discarded – undo
4336 4553
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4337 4554
 
4338 4555
 		// If debug flood the screen.
4339
-		if ($is_debug)
4340
-			echo '
4556
+		if ($is_debug) {
4557
+					echo '
4341 4558
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
4559
+		}
4342 4560
 
4343 4561
 		echo '
4344 4562
 				// Get the next update...
@@ -4380,19 +4598,21 @@  discard block
 block discarded – undo
4380 4598
 			<span id="debuginfo"></span>';
4381 4599
 
4382 4600
 	// Dont any tables so far?
4383
-	if (!empty($upcontext['previous_tables']))
4384
-		foreach ($upcontext['previous_tables'] as $table)
4601
+	if (!empty($upcontext['previous_tables'])) {
4602
+			foreach ($upcontext['previous_tables'] as $table)
4385 4603
 			echo '
4386 4604
 			<br>Completed Table: &quot;', $table, '&quot;.';
4605
+	}
4387 4606
 
4388 4607
 	echo '
4389 4608
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4390 4609
 			<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>';
4391 4610
 
4392 4611
 	// Try to make sure substep was reset.
4393
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4394
-		echo '
4612
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4613
+			echo '
4395 4614
 			<input type="hidden" name="substep" id="substep" value="0">';
4615
+	}
4396 4616
 
4397 4617
 	// Continue please!
4398 4618
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4425,9 +4645,10 @@  discard block
 block discarded – undo
4425 4645
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4426 4646
 
4427 4647
 		// If debug flood the screen.
4428
-		if ($is_debug)
4429
-			echo '
4648
+		if ($is_debug) {
4649
+					echo '
4430 4650
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
4651
+		}
4431 4652
 
4432 4653
 		echo '
4433 4654
 				// Get the next update...
@@ -4462,8 +4683,8 @@  discard block
 block discarded – undo
4462 4683
 	<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>
4463 4684
 	<form action="', $boardurl, '/index.php">';
4464 4685
 
4465
-	if (!empty($upcontext['can_delete_script']))
4466
-		echo '
4686
+	if (!empty($upcontext['can_delete_script'])) {
4687
+			echo '
4467 4688
 			<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>
4468 4689
 			<script>
4469 4690
 				function doTheDelete(theCheck)
@@ -4475,6 +4696,7 @@  discard block
 block discarded – undo
4475 4696
 				}
4476 4697
 			</script>
4477 4698
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4699
+	}
4478 4700
 
4479 4701
 	$active = time() - $upcontext['started'];
4480 4702
 	$hours = floor($active / 3600);
@@ -4484,16 +4706,20 @@  discard block
 block discarded – undo
4484 4706
 	if ($is_debug)
4485 4707
 	{
4486 4708
 		$totalTime = '';
4487
-		if ($hours > 0)
4488
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4489
-		if ($minutes > 0)
4490
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4491
-		if ($seconds > 0)
4492
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4709
+		if ($hours > 0) {
4710
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4711
+		}
4712
+		if ($minutes > 0) {
4713
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4714
+		}
4715
+		if ($seconds > 0) {
4716
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4717
+		}
4493 4718
 	}
4494 4719
 
4495
-	if ($is_debug && !empty($totalTime))
4496
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4720
+	if ($is_debug && !empty($totalTime)) {
4721
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4722
+	}
4497 4723
 
4498 4724
 	echo '<br>
4499 4725
 			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>
@@ -4560,16 +4786,19 @@  discard block
 block discarded – undo
4560 4786
 				'empty' => '',
4561 4787
 				'limit' => $limit,
4562 4788
 		));
4563
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4564
-			$arIp[] = $row[$oldCol];
4789
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4790
+					$arIp[] = $row[$oldCol];
4791
+		}
4565 4792
 		$smcFunc['db_free_result']($request);
4566 4793
 
4567 4794
 		// Special case, null ip could keep us in a loop.
4568
-		if (is_null($arIp[0]))
4569
-			unset($arIp[0]);
4795
+		if (is_null($arIp[0])) {
4796
+					unset($arIp[0]);
4797
+		}
4570 4798
 
4571
-		if (empty($arIp))
4572
-			$is_done = true;
4799
+		if (empty($arIp)) {
4800
+					$is_done = true;
4801
+		}
4573 4802
 
4574 4803
 		$updates = array();
4575 4804
 		$cases = array();
@@ -4578,16 +4807,18 @@  discard block
 block discarded – undo
4578 4807
 		{
4579 4808
 			$arIp[$i] = trim($arIp[$i]);
4580 4809
 
4581
-			if (empty($arIp[$i]))
4582
-				continue;
4810
+			if (empty($arIp[$i])) {
4811
+							continue;
4812
+			}
4583 4813
 
4584 4814
 			$updates['ip' . $i] = $arIp[$i];
4585 4815
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4586 4816
 
4587 4817
 			if ($setSize > 0 && $i % $setSize === 0)
4588 4818
 			{
4589
-				if (count($updates) == 1)
4590
-					continue;
4819
+				if (count($updates) == 1) {
4820
+									continue;
4821
+				}
4591 4822
 
4592 4823
 				$updates['whereSet'] = array_values($updates);
4593 4824
 				$smcFunc['db_query']('', '
@@ -4621,8 +4852,7 @@  discard block
 block discarded – undo
4621 4852
 							'ip' => $ip
4622 4853
 					));
4623 4854
 				}
4624
-			}
4625
-			else
4855
+			} else
4626 4856
 			{
4627 4857
 				$updates['whereSet'] = array_values($updates);
4628 4858
 				$smcFunc['db_query']('', '
@@ -4636,9 +4866,9 @@  discard block
 block discarded – undo
4636 4866
 					$updates
4637 4867
 				);
4638 4868
 			}
4869
+		} else {
4870
+					$is_done = true;
4639 4871
 		}
4640
-		else
4641
-			$is_done = true;
4642 4872
 
4643 4873
 		$_GET['a'] += $limit;
4644 4874
 		$step_progress['current'] = $_GET['a'];
Please login to merge, or discard this patch.
Sources/Subs-Attachments.php 1 patch
Braces   +297 added lines, -224 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Check if the current directory is still valid or not.
@@ -28,22 +29,24 @@  discard block
 block discarded – undo
28 29
 	global $boarddir, $modSettings, $context;
29 30
 
30 31
 	// Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found.
31
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
32
-		$doit = true;
33
-	elseif (empty($modSettings['automanage_attachments']))
34
-		return;
35
-	elseif (!isset($_FILES))
36
-		return;
37
-	elseif (isset($_FILES['attachment']))
38
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
32
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') {
33
+			$doit = true;
34
+	} elseif (empty($modSettings['automanage_attachments'])) {
35
+			return;
36
+	} elseif (!isset($_FILES)) {
37
+			return;
38
+	} elseif (isset($_FILES['attachment'])) {
39
+			foreach ($_FILES['attachment']['tmp_name'] as $dummy)
39 40
 			if (!empty($dummy))
40 41
 			{
41 42
 				$doit = true;
43
+	}
42 44
 				break;
43 45
 			}
44 46
 
45
-	if (!isset($doit))
46
-		return;
47
+	if (!isset($doit)) {
48
+			return;
49
+	}
47 50
 
48 51
 	$year = date('Y');
49 52
 	$month = date('m');
@@ -54,21 +57,25 @@  discard block
 block discarded – undo
54 57
 
55 58
 	if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments']))
56 59
 	{
57
-			if (!is_array($modSettings['attachment_basedirectories']))
58
-				$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
60
+			if (!is_array($modSettings['attachment_basedirectories'])) {
61
+							$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
62
+			}
59 63
 			$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
64
+	} else {
65
+			$base_dir = 0;
60 66
 	}
61
-	else
62
-		$base_dir = 0;
63 67
 
64 68
 	if ($modSettings['automanage_attachments'] == 1)
65 69
 	{
66
-		if (!isset($modSettings['last_attachments_directory']))
67
-			$modSettings['last_attachments_directory'] = array();
68
-		if (!is_array($modSettings['last_attachments_directory']))
69
-			$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
70
-		if (!isset($modSettings['last_attachments_directory'][$base_dir]))
71
-			$modSettings['last_attachments_directory'][$base_dir] = 0;
70
+		if (!isset($modSettings['last_attachments_directory'])) {
71
+					$modSettings['last_attachments_directory'] = array();
72
+		}
73
+		if (!is_array($modSettings['last_attachments_directory'])) {
74
+					$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
75
+		}
76
+		if (!isset($modSettings['last_attachments_directory'][$base_dir])) {
77
+					$modSettings['last_attachments_directory'][$base_dir] = 0;
78
+		}
72 79
 	}
73 80
 
74 81
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
@@ -97,12 +104,14 @@  discard block
 block discarded – undo
97 104
 			$updir = '';
98 105
 	}
99 106
 
100
-	if (!is_array($modSettings['attachmentUploadDir']))
101
-		$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
102
-	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir))
103
-		$outputCreation = automanage_attachments_create_directory($updir);
104
-	elseif (in_array($updir, $modSettings['attachmentUploadDir']))
105
-		$outputCreation = true;
107
+	if (!is_array($modSettings['attachmentUploadDir'])) {
108
+			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
109
+	}
110
+	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) {
111
+			$outputCreation = automanage_attachments_create_directory($updir);
112
+	} elseif (in_array($updir, $modSettings['attachmentUploadDir'])) {
113
+			$outputCreation = true;
114
+	}
106 115
 
107 116
 	if ($outputCreation)
108 117
 	{
@@ -139,8 +148,9 @@  discard block
 block discarded – undo
139 148
 		$count = count($tree);
140 149
 
141 150
 		$directory = attachments_init_dir($tree, $count);
142
-		if ($directory === false)
143
-			return false;
151
+		if ($directory === false) {
152
+					return false;
153
+		}
144 154
 	}
145 155
 
146 156
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
@@ -168,8 +178,9 @@  discard block
 block discarded – undo
168 178
 	}
169 179
 
170 180
 	// Everything seems fine...let's create the .htaccess
171
-	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
172
-		secureDirectory($updir, true);
181
+	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) {
182
+			secureDirectory($updir, true);
183
+	}
173 184
 
174 185
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
175 186
 	$updir = rtrim($updir, $sep);
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 {
202 213
 	global $modSettings, $boarddir;
203 214
 
204
-	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
205
-		return;
215
+	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) {
216
+			return;
217
+	}
206 218
 
207 219
 	$basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir;
208 220
 	// Just to be sure: I don't want directory separators at the end
@@ -214,13 +226,14 @@  discard block
 block discarded – undo
214 226
 	{
215 227
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
216 228
 		$base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0;
229
+	} else {
230
+			$base_dir = 0;
217 231
 	}
218
-	else
219
-		$base_dir = 0;
220 232
 
221 233
 	// Get the last attachment directory for that base directory
222
-	if (empty($modSettings['last_attachments_directory'][$base_dir]))
223
-		$modSettings['last_attachments_directory'][$base_dir] = 0;
234
+	if (empty($modSettings['last_attachments_directory'][$base_dir])) {
235
+			$modSettings['last_attachments_directory'][$base_dir] = 0;
236
+	}
224 237
 	// And increment it.
225 238
 	$modSettings['last_attachments_directory'][$base_dir]++;
226 239
 
@@ -235,10 +248,10 @@  discard block
 block discarded – undo
235 248
 		$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
236 249
 
237 250
 		return true;
251
+	} else {
252
+			return false;
253
+	}
238 254
 	}
239
-	else
240
-		return false;
241
-}
242 255
 
243 256
 /**
244 257
  * Split a path into a list of all directories and subdirectories
@@ -256,12 +269,13 @@  discard block
 block discarded – undo
256 269
 			* in Windows we need to explode for both \ and /
257 270
 			* while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR)
258 271
 	*/
259
-	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
260
-		$tree = preg_split('#[\\\/]#', $directory);
261
-	else
272
+	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
273
+			$tree = preg_split('#[\\\/]#', $directory);
274
+	} else
262 275
 	{
263
-		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
264
-			return false;
276
+		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
277
+					return false;
278
+		}
265 279
 
266 280
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR));
267 281
 	}
@@ -285,10 +299,11 @@  discard block
 block discarded – undo
285 299
 		 //Better be sure that the first part of the path is actually a drive letter...
286 300
 		 //...even if, I should check this in the admin page...isn't it?
287 301
 		 //...NHAAA Let's leave space for users' complains! :P
288
-		if (preg_match('/^[a-z]:$/i', $tree[0]))
289
-			$directory = array_shift($tree);
290
-		else
291
-			return false;
302
+		if (preg_match('/^[a-z]:$/i', $tree[0])) {
303
+					$directory = array_shift($tree);
304
+		} else {
305
+					return false;
306
+		}
292 307
 
293 308
 		$count--;
294 309
 	}
@@ -303,18 +318,20 @@  discard block
 block discarded – undo
303 318
 	global $context, $modSettings, $smcFunc, $txt, $user_info;
304 319
 
305 320
 	// Make sure we're uploading to the right place.
306
-	if (!empty($modSettings['automanage_attachments']))
307
-		automanage_attachments_check_directory();
321
+	if (!empty($modSettings['automanage_attachments'])) {
322
+			automanage_attachments_check_directory();
323
+	}
308 324
 
309
-	if (!is_array($modSettings['attachmentUploadDir']))
310
-		$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
325
+	if (!is_array($modSettings['attachmentUploadDir'])) {
326
+			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
327
+	}
311 328
 
312 329
 	$context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
313 330
 
314 331
 	// Is the attachments folder actualy there?
315
-	if (!empty($context['dir_creation_error']))
316
-		$initial_error = $context['dir_creation_error'];
317
-	elseif (!is_dir($context['attach_dir']))
332
+	if (!empty($context['dir_creation_error'])) {
333
+			$initial_error = $context['dir_creation_error'];
334
+	} elseif (!is_dir($context['attach_dir']))
318 335
 	{
319 336
 		$initial_error = 'attach_folder_warning';
320 337
 		log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical');
@@ -337,12 +354,12 @@  discard block
 block discarded – undo
337 354
 			);
338 355
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
339 356
 			$smcFunc['db_free_result']($request);
340
-		}
341
-		else
342
-			$context['attachments'] = array(
357
+		} else {
358
+					$context['attachments'] = array(
343 359
 				'quantity' => 0,
344 360
 				'total_size' => 0,
345 361
 			);
362
+		}
346 363
 	}
347 364
 
348 365
 	// Hmm. There are still files in session.
@@ -352,39 +369,44 @@  discard block
 block discarded – undo
352 369
 		// Let's try to keep them. But...
353 370
 		$ignore_temp = true;
354 371
 		// If new files are being added. We can't ignore those
355
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
356
-			if (!empty($dummy))
372
+		foreach ($_FILES['attachment']['tmp_name'] as $dummy) {
373
+					if (!empty($dummy))
357 374
 			{
358 375
 				$ignore_temp = false;
376
+		}
359 377
 				break;
360 378
 			}
361 379
 
362 380
 		// Need to make space for the new files. So, bye bye.
363 381
 		if (!$ignore_temp)
364 382
 		{
365
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
366
-				if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
383
+			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
384
+							if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
367 385
 					unlink($attachment['tmp_name']);
386
+			}
368 387
 
369 388
 			$context['we_are_history'] = $txt['error_temp_attachments_flushed'];
370 389
 			$_SESSION['temp_attachments'] = array();
371 390
 		}
372 391
 	}
373 392
 
374
-	if (!isset($_FILES['attachment']['name']))
375
-		$_FILES['attachment']['tmp_name'] = array();
393
+	if (!isset($_FILES['attachment']['name'])) {
394
+			$_FILES['attachment']['tmp_name'] = array();
395
+	}
376 396
 
377
-	if (!isset($_SESSION['temp_attachments']))
378
-		$_SESSION['temp_attachments'] = array();
397
+	if (!isset($_SESSION['temp_attachments'])) {
398
+			$_SESSION['temp_attachments'] = array();
399
+	}
379 400
 
380 401
 	// Remember where we are at. If it's anywhere at all.
381
-	if (!$ignore_temp)
382
-		$_SESSION['temp_attachments']['post'] = array(
402
+	if (!$ignore_temp) {
403
+			$_SESSION['temp_attachments']['post'] = array(
383 404
 			'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0,
384 405
 			'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0,
385 406
 			'topic' => !empty($topic) ? $topic : 0,
386 407
 			'board' => !empty($board) ? $board : 0,
387 408
 		);
409
+	}
388 410
 
389 411
 	// If we have an initial error, lets just display it.
390 412
 	if (!empty($initial_error))
@@ -392,9 +414,10 @@  discard block
 block discarded – undo
392 414
 		$_SESSION['temp_attachments']['initial_error'] = $initial_error;
393 415
 
394 416
 		// And delete the files 'cos they ain't going nowhere.
395
-		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
396
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
417
+		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
418
+					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
397 419
 				unlink($_FILES['attachment']['tmp_name'][$n]);
420
+		}
398 421
 
399 422
 		$_FILES['attachment']['tmp_name'] = array();
400 423
 	}
@@ -402,21 +425,24 @@  discard block
 block discarded – undo
402 425
 	// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
403 426
 	foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
404 427
 	{
405
-		if ($_FILES['attachment']['name'][$n] == '')
406
-			continue;
428
+		if ($_FILES['attachment']['name'][$n] == '') {
429
+					continue;
430
+		}
407 431
 
408 432
 		// First, let's first check for PHP upload errors.
409 433
 		$errors = array();
410 434
 		if (!empty($_FILES['attachment']['error'][$n]))
411 435
 		{
412
-			if ($_FILES['attachment']['error'][$n] == 2)
413
-				$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
414
-			elseif ($_FILES['attachment']['error'][$n] == 6)
415
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
416
-			else
417
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
418
-			if (empty($errors))
419
-				$errors[] = 'attach_php_error';
436
+			if ($_FILES['attachment']['error'][$n] == 2) {
437
+							$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
438
+			} elseif ($_FILES['attachment']['error'][$n] == 6) {
439
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
440
+			} else {
441
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
442
+			}
443
+			if (empty($errors)) {
444
+							$errors[] = 'attach_php_error';
445
+			}
420 446
 		}
421 447
 
422 448
 		// Try to move and rename the file before doing any more checks on it.
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 		{
427 453
 			// The reported MIME type of the attachment might not be reliable.
428 454
 			// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
429
-			if (function_exists('mime_content_type'))
430
-				$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
455
+			if (function_exists('mime_content_type')) {
456
+							$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
457
+			}
431 458
 
432 459
 			$_SESSION['temp_attachments'][$attachID] = array(
433 460
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -439,16 +466,16 @@  discard block
 block discarded – undo
439 466
 			);
440 467
 
441 468
 			// Move the file to the attachments folder with a temp name for now.
442
-			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
443
-				smf_chmod($destName, 0644);
444
-			else
469
+			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
470
+							smf_chmod($destName, 0644);
471
+			} else
445 472
 			{
446 473
 				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
447
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
448
-					unlink($_FILES['attachment']['tmp_name'][$n]);
474
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
475
+									unlink($_FILES['attachment']['tmp_name'][$n]);
476
+				}
449 477
 			}
450
-		}
451
-		else
478
+		} else
452 479
 		{
453 480
 			$_SESSION['temp_attachments'][$attachID] = array(
454 481
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -456,12 +483,14 @@  discard block
 block discarded – undo
456 483
 				'errors' => $errors,
457 484
 			);
458 485
 
459
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
460
-				unlink($_FILES['attachment']['tmp_name'][$n]);
486
+			if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
487
+							unlink($_FILES['attachment']['tmp_name'][$n]);
488
+			}
461 489
 		}
462 490
 		// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
463
-		if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
464
-			attachmentChecks($attachID);
491
+		if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
492
+					attachmentChecks($attachID);
493
+		}
465 494
 	}
466 495
 	// Mod authors, finally a hook to hang an alternate attachment upload system upon
467 496
 	// Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand())
@@ -488,21 +517,20 @@  discard block
 block discarded – undo
488 517
 	global $modSettings, $context, $sourcedir, $smcFunc;
489 518
 
490 519
 	// No data or missing data .... Not necessarily needed, but in case a mod author missed something.
491
-	if (empty($_SESSION['temp_attachments'][$attachID]))
492
-		$error = '$_SESSION[\'temp_attachments\'][$attachID]';
493
-
494
-	elseif (empty($attachID))
495
-		$error = '$attachID';
496
-
497
-	elseif (empty($context['attachments']))
498
-		$error = '$context[\'attachments\']';
499
-
500
-	elseif (empty($context['attach_dir']))
501
-		$error = '$context[\'attach_dir\']';
520
+	if (empty($_SESSION['temp_attachments'][$attachID])) {
521
+			$error = '$_SESSION[\'temp_attachments\'][$attachID]';
522
+	} elseif (empty($attachID)) {
523
+			$error = '$attachID';
524
+	} elseif (empty($context['attachments'])) {
525
+			$error = '$context[\'attachments\']';
526
+	} elseif (empty($context['attach_dir'])) {
527
+			$error = '$context[\'attach_dir\']';
528
+	}
502 529
 
503 530
 	// Let's get their attention.
504
-	if (!empty($error))
505
-		fatal_lang_error('attach_check_nag', 'debug', array($error));
531
+	if (!empty($error)) {
532
+			fatal_lang_error('attach_check_nag', 'debug', array($error));
533
+	}
506 534
 
507 535
 	// Just in case this slipped by the first checks, we stop it here and now
508 536
 	if ($_SESSION['temp_attachments'][$attachID]['size'] == 0)
@@ -531,8 +559,9 @@  discard block
 block discarded – undo
531 559
 			$size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']);
532 560
 			if (!(empty($size)) && ($size[2] != $old_format))
533 561
 			{
534
-				if (isset($context['validImageTypes'][$size[2]]))
535
-					$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]];
562
+				if (isset($context['validImageTypes'][$size[2]])) {
563
+									$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]];
564
+				}
536 565
 			}
537 566
 		}
538 567
 	}
@@ -586,42 +615,48 @@  discard block
 block discarded – undo
586 615
 				// Or, let the user know that it ain't gonna happen.
587 616
 				else
588 617
 				{
589
-					if (isset($context['dir_creation_error']))
590
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
591
-					else
592
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
618
+					if (isset($context['dir_creation_error'])) {
619
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
620
+					} else {
621
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
622
+					}
593 623
 				}
624
+			} else {
625
+							$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
594 626
 			}
595
-			else
596
-				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
597 627
 		}
598 628
 	}
599 629
 
600 630
 	// Is the file too big?
601 631
 	$context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size'];
602
-	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024)
603
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
632
+	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) {
633
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
634
+	}
604 635
 
605 636
 	// Check the total upload size for this post...
606
-	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024)
607
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
637
+	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) {
638
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
639
+	}
608 640
 
609 641
 	// Have we reached the maximum number of files we are allowed?
610 642
 	$context['attachments']['quantity']++;
611 643
 
612 644
 	// Set a max limit if none exists
613
-	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50)
614
-		$modSettings['attachmentNumPerPostLimit'] = 50;
645
+	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) {
646
+			$modSettings['attachmentNumPerPostLimit'] = 50;
647
+	}
615 648
 
616
-	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit'])
617
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
649
+	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) {
650
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
651
+	}
618 652
 
619 653
 	// File extension check
620 654
 	if (!empty($modSettings['attachmentCheckExtensions']))
621 655
 	{
622 656
 		$allowed = explode(',', strtolower($modSettings['attachmentExtensions']));
623
-		foreach ($allowed as $k => $dummy)
624
-			$allowed[$k] = trim($dummy);
657
+		foreach ($allowed as $k => $dummy) {
658
+					$allowed[$k] = trim($dummy);
659
+		}
625 660
 
626 661
 		if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed))
627 662
 		{
@@ -633,10 +668,12 @@  discard block
 block discarded – undo
633 668
 	// Undo the math if there's an error
634 669
 	if (!empty($_SESSION['temp_attachments'][$attachID]['errors']))
635 670
 	{
636
-		if (isset($context['dir_size']))
637
-			$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
638
-		if (isset($context['dir_files']))
639
-			$context['dir_files']--;
671
+		if (isset($context['dir_size'])) {
672
+					$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
673
+		}
674
+		if (isset($context['dir_files'])) {
675
+					$context['dir_files']--;
676
+		}
640 677
 		$context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
641 678
 		$context['attachments']['quantity']--;
642 679
 		return false;
@@ -668,12 +705,14 @@  discard block
 block discarded – undo
668 705
 	if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
669 706
 	{
670 707
 		// Got a proper mime type?
671
-		if (!empty($size['mime']))
672
-			$attachmentOptions['mime_type'] = $size['mime'];
708
+		if (!empty($size['mime'])) {
709
+					$attachmentOptions['mime_type'] = $size['mime'];
710
+		}
673 711
 
674 712
 		// Otherwise a valid one?
675
-		elseif (isset($context['validImageTypes'][$size[2]]))
676
-			$attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]];
713
+		elseif (isset($context['validImageTypes'][$size[2]])) {
714
+					$attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]];
715
+		}
677 716
 	}
678 717
 
679 718
 	// It is possible we might have a MIME type that isn't actually an image but still have a size.
@@ -685,15 +724,17 @@  discard block
 block discarded – undo
685 724
 	}
686 725
 
687 726
 	// Get the hash if no hash has been given yet.
688
-	if (empty($attachmentOptions['file_hash']))
689
-		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
727
+	if (empty($attachmentOptions['file_hash'])) {
728
+			$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
729
+	}
690 730
 
691 731
 	// Assuming no-one set the extension let's take a look at it.
692 732
 	if (empty($attachmentOptions['fileext']))
693 733
 	{
694 734
 		$attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : '');
695
-		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name'])
696
-			$attachmentOptions['fileext'] = '';
735
+		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) {
736
+					$attachmentOptions['fileext'] = '';
737
+		}
697 738
 	}
698 739
 
699 740
 	// Last chance to change stuff!
@@ -702,8 +743,9 @@  discard block
 block discarded – undo
702 743
 	// Make sure the folder is valid...
703 744
 	$tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : smf_json_decode($modSettings['attachmentUploadDir'], true);
704 745
 	$folders = array_keys($tmp);
705
-	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders))
706
-		$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
746
+	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) {
747
+			$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
748
+	}
707 749
 
708 750
 	$attachmentOptions['id'] = $smcFunc['db_insert']('',
709 751
 		'{db_prefix}attachments',
@@ -734,8 +776,8 @@  discard block
 block discarded – undo
734 776
 	rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']);
735 777
 
736 778
 	// If it's not approved then add to the approval queue.
737
-	if (!$attachmentOptions['approved'])
738
-		$smcFunc['db_insert']('',
779
+	if (!$attachmentOptions['approved']) {
780
+			$smcFunc['db_insert']('',
739 781
 			'{db_prefix}approval_queue',
740 782
 			array(
741 783
 				'id_attach' => 'int', 'id_msg' => 'int',
@@ -745,9 +787,11 @@  discard block
 block discarded – undo
745 787
 			),
746 788
 			array()
747 789
 		);
790
+	}
748 791
 
749
-	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height'])))
750
-		return true;
792
+	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) {
793
+			return true;
794
+	}
751 795
 
752 796
 	// Like thumbnails, do we?
753 797
 	if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight']))
@@ -758,13 +802,15 @@  discard block
 block discarded – undo
758 802
 			$size = @getimagesize($attachmentOptions['destination'] . '_thumb');
759 803
 			list ($thumb_width, $thumb_height) = $size;
760 804
 
761
-			if (!empty($size['mime']))
762
-				$thumb_mime = $size['mime'];
763
-			elseif (isset($context['validImageTypes'][$size[2]]))
764
-				$thumb_mime = 'image/' . $context['validImageTypes'][$size[2]];
805
+			if (!empty($size['mime'])) {
806
+							$thumb_mime = $size['mime'];
807
+			} elseif (isset($context['validImageTypes'][$size[2]])) {
808
+							$thumb_mime = 'image/' . $context['validImageTypes'][$size[2]];
809
+			}
765 810
 			// Lord only knows how this happened...
766
-			else
767
-				$thumb_mime = '';
811
+			else {
812
+							$thumb_mime = '';
813
+			}
768 814
 
769 815
 			$thumb_filename = $attachmentOptions['name'] . '_thumb';
770 816
 			$thumb_size = filesize($attachmentOptions['destination'] . '_thumb');
@@ -844,15 +890,17 @@  discard block
 block discarded – undo
844 890
 	global $smcFunc;
845 891
 
846 892
 	// Oh, come on!
847
-	if (empty($attachIDs) || empty($msgID))
848
-		return false;
893
+	if (empty($attachIDs) || empty($msgID)) {
894
+			return false;
895
+	}
849 896
 
850 897
 	// "I see what is right and approve, but I do what is wrong."
851 898
 	call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID));
852 899
 
853 900
 	// One last check
854
-	if (empty($attachIDs))
855
-		return false;
901
+	if (empty($attachIDs)) {
902
+			return false;
903
+	}
856 904
 
857 905
 	// Perform.
858 906
 	$smcFunc['db_query']('', '
@@ -882,8 +930,9 @@  discard block
 block discarded – undo
882 930
 	$externalParse = false;
883 931
 
884 932
 	// Meh...
885
-	if (empty($attachID))
886
-		return 'attachments_no_data_loaded';
933
+	if (empty($attachID)) {
934
+			return 'attachments_no_data_loaded';
935
+	}
887 936
 
888 937
 	// Make it easy.
889 938
 	$msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0;
@@ -892,20 +941,23 @@  discard block
 block discarded – undo
892 941
 	$externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID));
893 942
 
894 943
 	// "I am innocent of the blood of this just person: see ye to it."
895
-	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse)))
896
-		return $externalParse;
944
+	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) {
945
+			return $externalParse;
946
+	}
897 947
 
898 948
 	//Are attachments enable?
899
-	if (empty($modSettings['attachmentEnable']))
900
-		return 'attachments_not_enable';
949
+	if (empty($modSettings['attachmentEnable'])) {
950
+			return 'attachments_not_enable';
951
+	}
901 952
 
902 953
 	// Previewing much? no msg ID has been set yet.
903 954
 	if (!empty($context['preview_message']))
904 955
 	{
905 956
 		$allAttachments = getAttachsByMsg(0);
906 957
 
907
-		if (empty($allAttachments[0][$attachID]))
908
-			return 'attachments_no_data_loaded';
958
+		if (empty($allAttachments[0][$attachID])) {
959
+					return 'attachments_no_data_loaded';
960
+		}
909 961
 
910 962
 		$attachLoaded = loadAttachmentContext(0, $allAttachments);
911 963
 
@@ -917,57 +969,66 @@  discard block
 block discarded – undo
917 969
 		$attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>';
918 970
 
919 971
 		// Fix the thumbnail too, if the image has one.
920
-		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb']))
921
-			$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
972
+		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) {
973
+					$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
974
+		}
922 975
 
923 976
 		return $attachContext;
924 977
 	}
925 978
 
926 979
 	// There is always the chance someone else has already done our dirty work...
927 980
 	// If so, all pertinent checks were already done. Hopefully...
928
-	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID]))
929
-		return $context['current_attachments'][$attachID];
981
+	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) {
982
+			return $context['current_attachments'][$attachID];
983
+	}
930 984
 
931 985
 	// If we are lucky enough to be in $board's scope then check it!
932
-	if (!empty($board) && !allowedTo('view_attachments', $board))
933
-		return 'attachments_not_allowed_to_see';
986
+	if (!empty($board) && !allowedTo('view_attachments', $board)) {
987
+			return 'attachments_not_allowed_to_see';
988
+	}
934 989
 
935 990
 	// Get the message info associated with this particular attach ID.
936 991
 	$attachInfo = getAttachMsgInfo($attachID);
937 992
 
938 993
 	// There is always the chance this attachment no longer exists or isn't associated to a message anymore...
939
-	if (empty($attachInfo) || empty($attachInfo['msg']))
940
-		return 'attachments_no_msg_associated';
994
+	if (empty($attachInfo) || empty($attachInfo['msg'])) {
995
+			return 'attachments_no_msg_associated';
996
+	}
941 997
 
942 998
 	// Hold it! got the info now check if you can see this attachment.
943
-	if (!allowedTo('view_attachments', $attachInfo['board']))
944
-		return 'attachments_not_allowed_to_see';
999
+	if (!allowedTo('view_attachments', $attachInfo['board'])) {
1000
+			return 'attachments_not_allowed_to_see';
1001
+	}
945 1002
 
946 1003
 	$allAttachments = getAttachsByMsg($attachInfo['msg']);
947 1004
 	$attachContext = $allAttachments[$attachInfo['msg']][$attachID];
948 1005
 
949 1006
 	// No point in keep going further.
950
-	if (!allowedTo('view_attachments', $attachContext['board']))
951
-		return 'attachments_not_allowed_to_see';
1007
+	if (!allowedTo('view_attachments', $attachContext['board'])) {
1008
+			return 'attachments_not_allowed_to_see';
1009
+	}
952 1010
 
953 1011
 	// Load this particular attach's context.
954
-	if (!empty($attachContext))
955
-		$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1012
+	if (!empty($attachContext)) {
1013
+			$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1014
+	}
956 1015
 
957 1016
 	// One last check, you know, gotta be paranoid...
958
-	else
959
-		return 'attachments_no_data_loaded';
1017
+	else {
1018
+			return 'attachments_no_data_loaded';
1019
+	}
960 1020
 
961 1021
 	// This is the last "if" I promise!
962
-	if (empty($attachLoaded))
963
-		return 'attachments_no_data_loaded';
964
-
965
-	else
966
-		$attachContext = $attachLoaded[$attachID];
1022
+	if (empty($attachLoaded)) {
1023
+			return 'attachments_no_data_loaded';
1024
+	} else {
1025
+			$attachContext = $attachLoaded[$attachID];
1026
+	}
967 1027
 
968 1028
 	// You may or may not want to show this under the post.
969
-	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID]))
970
-		$context['show_attach_under_post'][$attachID] = $attachID;
1029
+	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) {
1030
+			$context['show_attach_under_post'][$attachID] = $attachID;
1031
+	}
971 1032
 
972 1033
 	// Last minute changes?
973 1034
 	call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext));
@@ -987,8 +1048,9 @@  discard block
 block discarded – undo
987 1048
 {
988 1049
 	global $smcFunc, $modSettings;
989 1050
 
990
-	if (empty($attachIDs))
991
-		return array();
1051
+	if (empty($attachIDs)) {
1052
+			return array();
1053
+	}
992 1054
 
993 1055
 	$return = array();
994 1056
 
@@ -1004,11 +1066,12 @@  discard block
 block discarded – undo
1004 1066
 		)
1005 1067
 	);
1006 1068
 
1007
-	if ($smcFunc['db_num_rows']($request) != 1)
1008
-		return array();
1069
+	if ($smcFunc['db_num_rows']($request) != 1) {
1070
+			return array();
1071
+	}
1009 1072
 
1010
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1011
-		$return[$row['id_attach']] = array(
1073
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1074
+			$return[$row['id_attach']] = array(
1012 1075
 			'name' => $smcFunc['htmlspecialchars']($row['filename']),
1013 1076
 			'size' => $row['size'],
1014 1077
 			'attachID' => $row['id_attach'],
@@ -1017,6 +1080,7 @@  discard block
 block discarded – undo
1017 1080
 			'mime_type' => $row['mime_type'],
1018 1081
 			'thumb' => $row['id_thumb'],
1019 1082
 		);
1083
+	}
1020 1084
 	$smcFunc['db_free_result']($request);
1021 1085
 
1022 1086
 	return $return;
@@ -1033,8 +1097,9 @@  discard block
 block discarded – undo
1033 1097
 {
1034 1098
 	global $smcFunc;
1035 1099
 
1036
-	if (empty($attachID))
1037
-		return array();
1100
+	if (empty($attachID)) {
1101
+			return array();
1102
+	}
1038 1103
 
1039 1104
 	$request = $smcFunc['db_query']('', '
1040 1105
 		SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board
@@ -1047,8 +1112,9 @@  discard block
 block discarded – undo
1047 1112
 		)
1048 1113
 	);
1049 1114
 
1050
-	if ($smcFunc['db_num_rows']($request) != 1)
1051
-		return array();
1115
+	if ($smcFunc['db_num_rows']($request) != 1) {
1116
+			return array();
1117
+	}
1052 1118
 
1053 1119
 	$row = $smcFunc['db_fetch_assoc']($request);
1054 1120
 	$smcFunc['db_free_result']($request);
@@ -1089,8 +1155,9 @@  discard block
 block discarded – undo
1089 1155
 		$temp = array();
1090 1156
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1091 1157
 		{
1092
-			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1093
-				continue;
1158
+			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1159
+							continue;
1160
+			}
1094 1161
 
1095 1162
 			$temp[$row['id_attach']] = $row;
1096 1163
 		}
@@ -1119,8 +1186,9 @@  discard block
 block discarded – undo
1119 1186
 {
1120 1187
 	global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc;
1121 1188
 
1122
-	if (empty($attachments) || empty($attachments[$id_msg]))
1123
-		return array();
1189
+	if (empty($attachments) || empty($attachments[$id_msg])) {
1190
+			return array();
1191
+	}
1124 1192
 
1125 1193
 	// Set up the attachment info - based on code by Meriadoc.
1126 1194
 	$attachmentData = array();
@@ -1144,11 +1212,13 @@  discard block
 block discarded – undo
1144 1212
 			);
1145 1213
 
1146 1214
 			// If something is unapproved we'll note it so we can sort them.
1147
-			if (!$attachment['approved'])
1148
-				$have_unapproved = true;
1215
+			if (!$attachment['approved']) {
1216
+							$have_unapproved = true;
1217
+			}
1149 1218
 
1150
-			if (!$attachmentData[$i]['is_image'])
1151
-				continue;
1219
+			if (!$attachmentData[$i]['is_image']) {
1220
+							continue;
1221
+			}
1152 1222
 
1153 1223
 			$attachmentData[$i]['real_width'] = $attachment['width'];
1154 1224
 			$attachmentData[$i]['width'] = $attachment['width'];
@@ -1169,12 +1239,12 @@  discard block
 block discarded – undo
1169 1239
 						// So what folder are we putting this image in?
1170 1240
 						if (!empty($modSettings['currentAttachmentUploadDir']))
1171 1241
 						{
1172
-							if (!is_array($modSettings['attachmentUploadDir']))
1173
-								$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1242
+							if (!is_array($modSettings['attachmentUploadDir'])) {
1243
+															$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1244
+							}
1174 1245
 							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
1175 1246
 							$id_folder_thumb = $modSettings['currentAttachmentUploadDir'];
1176
-						}
1177
-						else
1247
+						} else
1178 1248
 						{
1179 1249
 							$path = $modSettings['attachmentUploadDir'];
1180 1250
 							$id_folder_thumb = 1;
@@ -1189,10 +1259,11 @@  discard block
 block discarded – undo
1189 1259
 						$thumb_ext = isset($context['validImageTypes'][$size[2]]) ? $context['validImageTypes'][$size[2]] : '';
1190 1260
 
1191 1261
 						// Figure out the mime type.
1192
-						if (!empty($size['mime']))
1193
-							$thumb_mime = $size['mime'];
1194
-						else
1195
-							$thumb_mime = 'image/' . $thumb_ext;
1262
+						if (!empty($size['mime'])) {
1263
+													$thumb_mime = $size['mime'];
1264
+						} else {
1265
+													$thumb_mime = 'image/' . $thumb_ext;
1266
+						}
1196 1267
 
1197 1268
 						$thumb_filename = $attachment['filename'] . '_thumb';
1198 1269
 						$thumb_hash = getAttachmentFilename($thumb_filename, false, null, true);
@@ -1239,11 +1310,12 @@  discard block
 block discarded – undo
1239 1310
 				}
1240 1311
 			}
1241 1312
 
1242
-			if (!empty($attachment['id_thumb']))
1243
-				$attachmentData[$i]['thumbnail'] = array(
1313
+			if (!empty($attachment['id_thumb'])) {
1314
+							$attachmentData[$i]['thumbnail'] = array(
1244 1315
 					'id' => $attachment['id_thumb'],
1245 1316
 					'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image',
1246 1317
 				);
1318
+			}
1247 1319
 			$attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']);
1248 1320
 
1249 1321
 			// If thumbnails are disabled, check the maximum size of the image.
@@ -1253,30 +1325,31 @@  discard block
 block discarded – undo
1253 1325
 				{
1254 1326
 					$attachmentData[$i]['width'] = $modSettings['max_image_width'];
1255 1327
 					$attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']);
1256
-				}
1257
-				elseif (!empty($modSettings['max_image_width']))
1328
+				} elseif (!empty($modSettings['max_image_width']))
1258 1329
 				{
1259 1330
 					$attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']);
1260 1331
 					$attachmentData[$i]['height'] = $modSettings['max_image_height'];
1261 1332
 				}
1262
-			}
1263
-			elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1333
+			} elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1264 1334
 			{
1265 1335
 				// If the image is too large to show inline, make it a popup.
1266
-				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
1267
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1268
-				else
1269
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1336
+				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) {
1337
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1338
+				} else {
1339
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1340
+				}
1270 1341
 			}
1271 1342
 
1272
-			if (!$attachmentData[$i]['thumbnail']['has_thumb'])
1273
-				$attachmentData[$i]['downloads']++;
1343
+			if (!$attachmentData[$i]['thumbnail']['has_thumb']) {
1344
+							$attachmentData[$i]['downloads']++;
1345
+			}
1274 1346
 		}
1275 1347
 	}
1276 1348
 
1277 1349
 	// Do we need to instigate a sort?
1278
-	if ($have_unapproved)
1279
-		usort($attachmentData, 'approved_attach_sort');
1350
+	if ($have_unapproved) {
1351
+			usort($attachmentData, 'approved_attach_sort');
1352
+	}
1280 1353
 
1281 1354
 	return $attachmentData;
1282 1355
 }
Please login to merge, or discard this patch.
Sources/News.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -497,6 +497,7 @@
 block discarded – undo
497 497
  * @param string $xml_format The format to use ('atom', 'rss', 'rss2' or empty for plain XML)
498 498
  * @param array $forceCdataKeys A list of keys on which to force cdata wrapping (used by mods, maybe)
499 499
  * @param array $nsKeys Key-value pairs of namespace prefixes to pass to cdata_parse() (used by mods, maybe)
500
+ * @param string $tag
500 501
  */
501 502
 function dumpTags($data, $i, $tag = null, $xml_format = '', $forceCdataKeys = array(), $nsKeys = array())
502 503
 {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			{
838 838
 				uasort($loaded_attachments, function($a, $b) {
839 839
 					if ($a['filesize'] == $b['filesize'])
840
-					        return 0;
840
+							return 0;
841 841
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
842 842
 				});
843 843
 			}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			{
1243 1243
 				uasort($loaded_attachments, function($a, $b) {
1244 1244
 					if ($a['filesize'] == $b['filesize'])
1245
-					        return 0;
1245
+							return 0;
1246 1246
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
1247 1247
 				});
1248 1248
 			}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -346,7 +346,7 @@
 block discarded – undo
346 346
 
347 347
 		foreach ($xml as $item)
348 348
 		{
349
-			$link = array_filter($item['content'], function ($e) { return ($e['tag'] == 'link'); });
349
+			$link = array_filter($item['content'], function($e) { return ($e['tag'] == 'link'); });
350 350
 			$link = array_pop($link);
351 351
 
352 352
 			echo '
Please login to merge, or discard this patch.
Braces   +220 added lines, -181 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Outputs xml data representing recent information or a profile.
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 	global $query_this_board, $smcFunc, $forum_version;
38 39
 
39 40
 	// If it's not enabled, die.
40
-	if (empty($modSettings['xmlnews_enable']))
41
-		obExit(false);
41
+	if (empty($modSettings['xmlnews_enable'])) {
42
+			obExit(false);
43
+	}
42 44
 
43 45
 	loadLanguage('Stats');
44 46
 
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
 	if (!empty($_REQUEST['c']) && empty($board))
64 66
 	{
65 67
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
66
-		foreach ($_REQUEST['c'] as $i => $c)
67
-			$_REQUEST['c'][$i] = (int) $c;
68
+		foreach ($_REQUEST['c'] as $i => $c) {
69
+					$_REQUEST['c'][$i] = (int) $c;
70
+		}
68 71
 
69 72
 		if (count($_REQUEST['c']) == 1)
70 73
 		{
@@ -100,18 +103,20 @@  discard block
 block discarded – undo
100 103
 		}
101 104
 		$smcFunc['db_free_result']($request);
102 105
 
103
-		if (!empty($boards))
104
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
106
+		if (!empty($boards)) {
107
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
108
+		}
105 109
 
106 110
 		// Try to limit the number of messages we look through.
107
-		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15)
108
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
109
-	}
110
-	elseif (!empty($_REQUEST['boards']))
111
+		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) {
112
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
113
+		}
114
+	} elseif (!empty($_REQUEST['boards']))
111 115
 	{
112 116
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
113
-		foreach ($_REQUEST['boards'] as $i => $b)
114
-			$_REQUEST['boards'][$i] = (int) $b;
117
+		foreach ($_REQUEST['boards'] as $i => $b) {
118
+					$_REQUEST['boards'][$i] = (int) $b;
119
+		}
115 120
 
116 121
 		$request = $smcFunc['db_query']('', '
117 122
 			SELECT b.id_board, b.num_posts, b.name
@@ -127,29 +132,32 @@  discard block
 block discarded – undo
127 132
 
128 133
 		// Either the board specified doesn't exist or you have no access.
129 134
 		$num_boards = $smcFunc['db_num_rows']($request);
130
-		if ($num_boards == 0)
131
-			fatal_lang_error('no_board');
135
+		if ($num_boards == 0) {
136
+					fatal_lang_error('no_board');
137
+		}
132 138
 
133 139
 		$total_posts = 0;
134 140
 		$boards = array();
135 141
 		while ($row = $smcFunc['db_fetch_assoc']($request))
136 142
 		{
137
-			if ($num_boards == 1)
138
-				$feed_meta['title'] = ' - ' . strip_tags($row['name']);
143
+			if ($num_boards == 1) {
144
+							$feed_meta['title'] = ' - ' . strip_tags($row['name']);
145
+			}
139 146
 
140 147
 			$boards[] = $row['id_board'];
141 148
 			$total_posts += $row['num_posts'];
142 149
 		}
143 150
 		$smcFunc['db_free_result']($request);
144 151
 
145
-		if (!empty($boards))
146
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
152
+		if (!empty($boards)) {
153
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
154
+		}
147 155
 
148 156
 		// The more boards, the more we're going to look through...
149
-		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12)
150
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
151
-	}
152
-	elseif (!empty($board))
157
+		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) {
158
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
159
+		}
160
+	} elseif (!empty($board))
153 161
 	{
154 162
 		$request = $smcFunc['db_query']('', '
155 163
 			SELECT num_posts
@@ -168,10 +176,10 @@  discard block
 block discarded – undo
168 176
 		$query_this_board = 'b.id_board = ' . $board;
169 177
 
170 178
 		// Try to look through just a few messages, if at all possible.
171
-		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10)
172
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
173
-	}
174
-	else
179
+		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) {
180
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
181
+		}
182
+	} else
175 183
 	{
176 184
 		$query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
177 185
 			AND b.id_board != ' . $modSettings['recycle_board'] : '');
@@ -194,30 +202,35 @@  discard block
 block discarded – undo
194 202
 	// Easy adding of sub actions
195 203
  	call_integration_hook('integrate_xmlfeeds', array(&$subActions));
196 204
 
197
-	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
198
-		$_GET['sa'] = 'recent';
205
+	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
206
+			$_GET['sa'] = 'recent';
207
+	}
199 208
 
200 209
 	// We only want some information, not all of it.
201 210
 	$cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']);
202
-	foreach (array('board', 'boards', 'c') as $var)
203
-		if (isset($_REQUEST[$var]))
211
+	foreach (array('board', 'boards', 'c') as $var) {
212
+			if (isset($_REQUEST[$var]))
204 213
 			$cachekey[] = $_REQUEST[$var];
214
+	}
205 215
 	$cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : ''));
206 216
 	$cache_t = microtime();
207 217
 
208 218
 	// Get the associative array representing the xml.
209
-	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3))
210
-		$xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
219
+	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) {
220
+			$xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
221
+	}
211 222
 	if (empty($xml))
212 223
 	{
213 224
 		$call = call_helper($subActions[$_GET['sa']][0], true);
214 225
 
215
-		if (!empty($call))
216
-			$xml = call_user_func($call, $xml_format);
226
+		if (!empty($call)) {
227
+					$xml = call_user_func($call, $xml_format);
228
+		}
217 229
 
218 230
 		if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3)
219
-		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2))))
220
-			cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240);
231
+		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) {
232
+					cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240);
233
+		}
221 234
 	}
222 235
 
223 236
 	$feed_meta['title'] = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_meta['title']) ? $feed_meta['title'] : '');
@@ -272,32 +285,36 @@  discard block
 block discarded – undo
272 285
 	$ns_string = '';
273 286
 	if (!empty($namespaces[$xml_format]))
274 287
 	{
275
-		foreach ($namespaces[$xml_format] as $nsprefix => $nsurl)
276
-			$ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"';
288
+		foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) {
289
+					$ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"';
290
+		}
277 291
 	}
278 292
 
279 293
 	$extraFeedTags_string = '';
280 294
 	if (!empty($extraFeedTags[$xml_format]))
281 295
 	{
282
-		foreach ($extraFeedTags[$xml_format] as $extraTag)
283
-			$extraFeedTags_string .= "\n\t\t" . $extraTag;
296
+		foreach ($extraFeedTags[$xml_format] as $extraTag) {
297
+					$extraFeedTags_string .= "\n\t\t" . $extraTag;
298
+		}
284 299
 	}
285 300
 
286 301
 	// This is an xml file....
287 302
 	ob_end_clean();
288
-	if (!empty($modSettings['enableCompressedOutput']))
289
-		@ob_start('ob_gzhandler');
290
-	else
291
-		ob_start();
303
+	if (!empty($modSettings['enableCompressedOutput'])) {
304
+			@ob_start('ob_gzhandler');
305
+	} else {
306
+			ob_start();
307
+	}
292 308
 
293
-	if ($xml_format == 'smf' || isset($_REQUEST['debug']))
294
-		header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
295
-	elseif ($xml_format == 'rss' || $xml_format == 'rss2')
296
-		header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
297
-	elseif ($xml_format == 'atom')
298
-		header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
299
-	elseif ($xml_format == 'rdf')
300
-		header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
309
+	if ($xml_format == 'smf' || isset($_REQUEST['debug'])) {
310
+			header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
311
+	} elseif ($xml_format == 'rss' || $xml_format == 'rss2') {
312
+			header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
313
+	} elseif ($xml_format == 'atom') {
314
+			header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
315
+	} elseif ($xml_format == 'rdf') {
316
+			header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
317
+	}
301 318
 
302 319
 	// First, output the xml header.
303 320
 	echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>';
@@ -305,10 +322,11 @@  discard block
 block discarded – undo
305 322
 	// Are we outputting an rss feed or one with more information?
306 323
 	if ($xml_format == 'rss' || $xml_format == 'rss2')
307 324
 	{
308
-		if ($xml_format == 'rss2')
309
-			foreach ($_REQUEST as $var => $val)
325
+		if ($xml_format == 'rss2') {
326
+					foreach ($_REQUEST as $var => $val)
310 327
 				if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
311 328
 					$url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val);
329
+		}
312 330
 
313 331
 		// Start with an RSS 2.0 header.
314 332
 		echo '
@@ -327,9 +345,10 @@  discard block
 block discarded – undo
327 345
 		<copyright>' . $feed_meta['rights'] . '</copyright>' : '';
328 346
 
329 347
 		// RSS2 calls for this.
330
-		if ($xml_format == 'rss2')
331
-			echo '
348
+		if ($xml_format == 'rss2') {
349
+					echo '
332 350
 		<atom:link rel="self" type="application/rss+xml" href="', $scripturl, !empty($url_parts) ? '?' . implode(';', $url_parts) : '', '" />';
351
+		}
333 352
 
334 353
 		echo $extraFeedTags_string;
335 354
 
@@ -340,12 +359,12 @@  discard block
 block discarded – undo
340 359
 		echo '
341 360
 	</channel>
342 361
 </rss>';
343
-	}
344
-	elseif ($xml_format == 'atom')
362
+	} elseif ($xml_format == 'atom')
345 363
 	{
346
-		foreach ($_REQUEST as $var => $val)
347
-			if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
364
+		foreach ($_REQUEST as $var => $val) {
365
+					if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
348 366
 				$url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val);
367
+		}
349 368
 
350 369
 		echo '
351 370
 <feed', $ns_string, '>
@@ -371,8 +390,7 @@  discard block
 block discarded – undo
371 390
 
372 391
 		echo '
373 392
 </feed>';
374
-	}
375
-	elseif ($xml_format == 'rdf')
393
+	} elseif ($xml_format == 'rdf')
376 394
 	{
377 395
 		echo '
378 396
 <rdf:RDF', $ns_string, '>
@@ -437,13 +455,15 @@  discard block
 block discarded – undo
437 455
 {
438 456
 	global $modSettings, $context, $scripturl;
439 457
 
440
-	if (substr($val, 0, strlen($scripturl)) != $scripturl)
441
-		return $val;
458
+	if (substr($val, 0, strlen($scripturl)) != $scripturl) {
459
+			return $val;
460
+	}
442 461
 
443 462
 	call_integration_hook('integrate_fix_url', array(&$val));
444 463
 
445
-	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
446
-		return $val;
464
+	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) {
465
+			return $val;
466
+	}
447 467
 
448 468
 	$val = preg_replace_callback('~\b' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl)
449 469
 		{
@@ -466,8 +486,9 @@  discard block
 block discarded – undo
466 486
 	global $smcFunc;
467 487
 
468 488
 	// Do we even need to do this?
469
-	if (strpbrk($data, '<>&') == false && $force !== true)
470
-		return $data;
489
+	if (strpbrk($data, '<>&') == false && $force !== true) {
490
+			return $data;
491
+	}
471 492
 
472 493
 	$cdata = '<![CDATA[';
473 494
 
@@ -477,49 +498,55 @@  discard block
 block discarded – undo
477 498
 			$smcFunc['strpos']($data, '&', $pos),
478 499
 			$smcFunc['strpos']($data, ']', $pos),
479 500
 		);
480
-		if ($ns != '')
481
-			$positions[] = $smcFunc['strpos']($data, '<', $pos);
501
+		if ($ns != '') {
502
+					$positions[] = $smcFunc['strpos']($data, '<', $pos);
503
+		}
482 504
 		foreach ($positions as $k => $dummy)
483 505
 		{
484
-			if ($dummy === false)
485
-				unset($positions[$k]);
506
+			if ($dummy === false) {
507
+							unset($positions[$k]);
508
+			}
486 509
 		}
487 510
 
488 511
 		$old = $pos;
489 512
 		$pos = empty($positions) ? $n : min($positions);
490 513
 
491
-		if ($pos - $old > 0)
492
-			$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
493
-		if ($pos >= $n)
494
-			break;
514
+		if ($pos - $old > 0) {
515
+					$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
516
+		}
517
+		if ($pos >= $n) {
518
+					break;
519
+		}
495 520
 
496 521
 		if ($smcFunc['substr']($data, $pos, 1) == '<')
497 522
 		{
498 523
 			$pos2 = $smcFunc['strpos']($data, '>', $pos);
499
-			if ($pos2 === false)
500
-				$pos2 = $n;
501
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '/')
502
-				$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
503
-			else
504
-				$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
524
+			if ($pos2 === false) {
525
+							$pos2 = $n;
526
+			}
527
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '/') {
528
+							$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
529
+			} else {
530
+							$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
531
+			}
505 532
 			$pos = $pos2 + 1;
506
-		}
507
-		elseif ($smcFunc['substr']($data, $pos, 1) == ']')
533
+		} elseif ($smcFunc['substr']($data, $pos, 1) == ']')
508 534
 		{
509 535
 			$cdata .= ']]>&#093;<![CDATA[';
510 536
 			$pos++;
511
-		}
512
-		elseif ($smcFunc['substr']($data, $pos, 1) == '&')
537
+		} elseif ($smcFunc['substr']($data, $pos, 1) == '&')
513 538
 		{
514 539
 			$pos2 = $smcFunc['strpos']($data, ';', $pos);
515
-			if ($pos2 === false)
516
-				$pos2 = $n;
540
+			if ($pos2 === false) {
541
+							$pos2 = $n;
542
+			}
517 543
 			$ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1);
518 544
 
519
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '#')
520
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
521
-			elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot')))
522
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
545
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '#') {
546
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
547
+			} elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) {
548
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
549
+			}
523 550
 
524 551
 			$pos = $pos2 + 1;
525 552
 		}
@@ -558,8 +585,9 @@  discard block
 block discarded – undo
558 585
 		'gender',
559 586
 		'blurb',
560 587
 	);
561
-	if ($xml_format != 'atom')
562
-		$keysToCdata[] = 'category';
588
+	if ($xml_format != 'atom') {
589
+			$keysToCdata[] = 'category';
590
+	}
563 591
 
564 592
 	if (!empty($forceCdataKeys))
565 593
 	{
@@ -576,8 +604,9 @@  discard block
 block discarded – undo
576 604
 		$attrs = isset($element['attributes']) ? $element['attributes'] : null;
577 605
 
578 606
 		// Skip it, it's been set to null.
579
-		if ($key === null || ($val === null && $attrs === null))
580
-			continue;
607
+		if ($key === null || ($val === null && $attrs === null)) {
608
+					continue;
609
+		}
581 610
 
582 611
 		$forceCdata = in_array($key, $forceCdataKeys);
583 612
 		$ns = !empty($nsKeys[$key]) ? $nsKeys[$key] : '';
@@ -590,16 +619,16 @@  discard block
 block discarded – undo
590 619
 
591 620
 		if (!empty($attrs))
592 621
 		{
593
-			foreach ($attrs as $attr_key => $attr_value)
594
-				echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"';
622
+			foreach ($attrs as $attr_key => $attr_value) {
623
+							echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"';
624
+			}
595 625
 		}
596 626
 
597 627
 		// If it's empty, simply output an empty element.
598 628
 		if (empty($val))
599 629
 		{
600 630
 			echo ' />';
601
-		}
602
-		else
631
+		} else
603 632
 		{
604 633
 			echo '>';
605 634
 
@@ -611,11 +640,13 @@  discard block
 block discarded – undo
611 640
 				echo "\n", str_repeat("\t", $i);
612 641
 			}
613 642
 			// A string with returns in it.... show this as a multiline element.
614
-			elseif (strpos($val, "\n") !== false)
615
-				echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i);
643
+			elseif (strpos($val, "\n") !== false) {
644
+							echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i);
645
+			}
616 646
 			// A simple string.
617
-			else
618
-				echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val);
647
+			else {
648
+							echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val);
649
+			}
619 650
 
620 651
 			// Ending tag.
621 652
 			echo '</', $key, '>';
@@ -635,8 +666,9 @@  discard block
 block discarded – undo
635 666
 {
636 667
 	global $scripturl, $smcFunc;
637 668
 
638
-	if (!allowedTo('view_mlist'))
639
-		return array();
669
+	if (!allowedTo('view_mlist')) {
670
+			return array();
671
+	}
640 672
 
641 673
 	// Find the most recent members.
642 674
 	$request = $smcFunc['db_query']('', '
@@ -652,8 +684,8 @@  discard block
 block discarded – undo
652 684
 	while ($row = $smcFunc['db_fetch_assoc']($request))
653 685
 	{
654 686
 		// Make the data look rss-ish.
655
-		if ($xml_format == 'rss' || $xml_format == 'rss2')
656
-			$data[] = array(
687
+		if ($xml_format == 'rss' || $xml_format == 'rss2') {
688
+					$data[] = array(
657 689
 				'tag' => 'item',
658 690
 				'content' => array(
659 691
 					array(
@@ -678,8 +710,8 @@  discard block
 block discarded – undo
678 710
 					),
679 711
 				),
680 712
 			);
681
-		elseif ($xml_format == 'rdf')
682
-			$data[] = array(
713
+		} elseif ($xml_format == 'rdf') {
714
+					$data[] = array(
683 715
 				'tag' => 'item',
684 716
 				'attributes' => array('rdf:about' => $scripturl . '?action=profile;u=' . $row['id_member']),
685 717
 				'content' => array(
@@ -697,8 +729,8 @@  discard block
 block discarded – undo
697 729
 					),
698 730
 				),
699 731
 			);
700
-		elseif ($xml_format == 'atom')
701
-			$data[] = array(
732
+		} elseif ($xml_format == 'atom') {
733
+					$data[] = array(
702 734
 				'tag' => 'entry',
703 735
 				'content' => array(
704 736
 					array(
@@ -727,9 +759,10 @@  discard block
 block discarded – undo
727 759
 					),
728 760
 				),
729 761
 			);
762
+		}
730 763
 		// More logical format for the data, but harder to apply.
731
-		else
732
-			$data[] = array(
764
+		else {
765
+					$data[] = array(
733 766
 				'tag' => 'member',
734 767
 				'content' => array(
735 768
 					array(
@@ -750,6 +783,7 @@  discard block
 block discarded – undo
750 783
 					),
751 784
 				),
752 785
 			);
786
+		}
753 787
 	}
754 788
 	$smcFunc['db_free_result']($request);
755 789
 
@@ -810,22 +844,24 @@  discard block
 block discarded – undo
810 844
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
811 845
 		{
812 846
 			$smcFunc['db_free_result']($request);
813
-			if (empty($_REQUEST['boards']) && empty($board))
814
-				unset($context['optimize_msg']['lowest']);
815
-			else
816
-				$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
847
+			if (empty($_REQUEST['boards']) && empty($board)) {
848
+							unset($context['optimize_msg']['lowest']);
849
+			} else {
850
+							$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
851
+			}
817 852
 			$context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg';
818 853
 			$loops++;
854
+		} else {
855
+					$done = true;
819 856
 		}
820
-		else
821
-			$done = true;
822 857
 	}
823 858
 	$data = array();
824 859
 	while ($row = $smcFunc['db_fetch_assoc']($request))
825 860
 	{
826 861
 		// Limit the length of the message, if the option is set.
827
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
828
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
862
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
863
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
864
+		}
829 865
 
830 866
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
831 867
 
@@ -852,8 +888,9 @@  discard block
 block discarded – undo
852 888
 			while ($attach = $smcFunc['db_fetch_assoc']($attach_request))
853 889
 			{
854 890
 				// Include approved attachments only
855
-				if ($attach['approved'])
856
-					$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
891
+				if ($attach['approved']) {
892
+									$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
893
+				}
857 894
 			}
858 895
 			$smcFunc['db_free_result']($attach_request);
859 896
 
@@ -861,16 +898,17 @@  discard block
 block discarded – undo
861 898
 			if (!empty($loaded_attachments))
862 899
 			{
863 900
 				uasort($loaded_attachments, function($a, $b) {
864
-					if ($a['filesize'] == $b['filesize'])
865
-					        return 0;
901
+					if ($a['filesize'] == $b['filesize']) {
902
+										        return 0;
903
+					}
866 904
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
867 905
 				});
906
+			} else {
907
+							$loaded_attachments = null;
868 908
 			}
869
-			else
870
-				$loaded_attachments = null;
909
+		} else {
910
+					$loaded_attachments = null;
871 911
 		}
872
-		else
873
-			$loaded_attachments = null;
874 912
 
875 913
 		// Being news, this actually makes sense in rss format.
876 914
 		if ($xml_format == 'rss' || $xml_format == 'rss2')
@@ -884,9 +922,9 @@  discard block
 block discarded – undo
884 922
 					'length' => $attachment['filesize'],
885 923
 					'type' => $attachment['mime_type'],
886 924
 				);
925
+			} else {
926
+							$enclosure = null;
887 927
 			}
888
-			else
889
-				$enclosure = null;
890 928
 
891 929
 			$data[] = array(
892 930
 				'tag' => 'item',
@@ -929,8 +967,7 @@  discard block
 block discarded – undo
929 967
 					),
930 968
 				),
931 969
 			);
932
-		}
933
-		elseif ($xml_format == 'rdf')
970
+		} elseif ($xml_format == 'rdf')
934 971
 		{
935 972
 			$data[] = array(
936 973
 				'tag' => 'item',
@@ -954,8 +991,7 @@  discard block
 block discarded – undo
954 991
 					),
955 992
 				),
956 993
 			);
957
-		}
958
-		elseif ($xml_format == 'atom')
994
+		} elseif ($xml_format == 'atom')
959 995
 		{
960 996
 			// Only one attachment allowed
961 997
 			if (!empty($loaded_attachments))
@@ -967,9 +1003,9 @@  discard block
 block discarded – undo
967 1003
 					'length' => $attachment['filesize'],
968 1004
 					'type' => $attachment['mime_type'],
969 1005
 				);
1006
+			} else {
1007
+							$enclosure = null;
970 1008
 			}
971
-			else
972
-				$enclosure = null;
973 1009
 
974 1010
 			$data[] = array(
975 1011
 				'tag' => 'entry',
@@ -1069,9 +1105,9 @@  discard block
 block discarded – undo
1069 1105
 						)
1070 1106
 					);
1071 1107
 				}
1108
+			} else {
1109
+							$attachments = null;
1072 1110
 			}
1073
-			else
1074
-				$attachments = null;
1075 1111
 
1076 1112
 			$data[] = array(
1077 1113
 				'tag' => 'article',
@@ -1189,22 +1225,25 @@  discard block
 block discarded – undo
1189 1225
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
1190 1226
 		{
1191 1227
 			$smcFunc['db_free_result']($request);
1192
-			if (empty($_REQUEST['boards']) && empty($board))
1193
-				unset($context['optimize_msg']['lowest']);
1194
-			else
1195
-				$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
1228
+			if (empty($_REQUEST['boards']) && empty($board)) {
1229
+							unset($context['optimize_msg']['lowest']);
1230
+			} else {
1231
+							$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
1232
+			}
1196 1233
 			$loops++;
1234
+		} else {
1235
+					$done = true;
1197 1236
 		}
1198
-		else
1199
-			$done = true;
1200 1237
 	}
1201 1238
 	$messages = array();
1202
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1203
-		$messages[] = $row['id_msg'];
1239
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1240
+			$messages[] = $row['id_msg'];
1241
+	}
1204 1242
 	$smcFunc['db_free_result']($request);
1205 1243
 
1206
-	if (empty($messages))
1207
-		return array();
1244
+	if (empty($messages)) {
1245
+			return array();
1246
+	}
1208 1247
 
1209 1248
 	// Find the most recent posts this user can see.
1210 1249
 	$request = $smcFunc['db_query']('', '
@@ -1234,8 +1273,9 @@  discard block
 block discarded – undo
1234 1273
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1235 1274
 	{
1236 1275
 		// Limit the length of the message, if the option is set.
1237
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
1238
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
1276
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
1277
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
1278
+		}
1239 1279
 
1240 1280
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1241 1281
 
@@ -1262,8 +1302,9 @@  discard block
 block discarded – undo
1262 1302
 			while ($attach = $smcFunc['db_fetch_assoc']($attach_request))
1263 1303
 			{
1264 1304
 				// Include approved attachments only
1265
-				if ($attach['approved'])
1266
-					$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
1305
+				if ($attach['approved']) {
1306
+									$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
1307
+				}
1267 1308
 			}
1268 1309
 			$smcFunc['db_free_result']($attach_request);
1269 1310
 
@@ -1271,16 +1312,17 @@  discard block
 block discarded – undo
1271 1312
 			if (!empty($loaded_attachments))
1272 1313
 			{
1273 1314
 				uasort($loaded_attachments, function($a, $b) {
1274
-					if ($a['filesize'] == $b['filesize'])
1275
-					        return 0;
1315
+					if ($a['filesize'] == $b['filesize']) {
1316
+										        return 0;
1317
+					}
1276 1318
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
1277 1319
 				});
1320
+			} else {
1321
+							$loaded_attachments = null;
1278 1322
 			}
1279
-			else
1280
-				$loaded_attachments = null;
1323
+		} else {
1324
+					$loaded_attachments = null;
1281 1325
 		}
1282
-		else
1283
-			$loaded_attachments = null;
1284 1326
 
1285 1327
 		// Doesn't work as well as news, but it kinda does..
1286 1328
 		if ($xml_format == 'rss' || $xml_format == 'rss2')
@@ -1294,9 +1336,9 @@  discard block
 block discarded – undo
1294 1336
 					'length' => $attachment['filesize'],
1295 1337
 					'type' => $attachment['mime_type'],
1296 1338
 				);
1339
+			} else {
1340
+							$enclosure = null;
1297 1341
 			}
1298
-			else
1299
-				$enclosure = null;
1300 1342
 
1301 1343
 			$data[] = array(
1302 1344
 				'tag' => 'item',
@@ -1339,8 +1381,7 @@  discard block
 block discarded – undo
1339 1381
 					),
1340 1382
 				),
1341 1383
 			);
1342
-		}
1343
-		elseif ($xml_format == 'rdf')
1384
+		} elseif ($xml_format == 'rdf')
1344 1385
 		{
1345 1386
 			$data[] = array(
1346 1387
 				'tag' => 'item',
@@ -1364,8 +1405,7 @@  discard block
 block discarded – undo
1364 1405
 					),
1365 1406
 				),
1366 1407
 			);
1367
-		}
1368
-		elseif ($xml_format == 'atom')
1408
+		} elseif ($xml_format == 'atom')
1369 1409
 		{
1370 1410
 			// Only one attachment allowed
1371 1411
 			if (!empty($loaded_attachments))
@@ -1377,9 +1417,9 @@  discard block
 block discarded – undo
1377 1417
 					'length' => $attachment['filesize'],
1378 1418
 					'type' => $attachment['mime_type'],
1379 1419
 				);
1420
+			} else {
1421
+							$enclosure = null;
1380 1422
 			}
1381
-			else
1382
-				$enclosure = null;
1383 1423
 
1384 1424
 			$data[] = array(
1385 1425
 				'tag' => 'entry',
@@ -1479,9 +1519,9 @@  discard block
 block discarded – undo
1479 1519
 						)
1480 1520
 					);
1481 1521
 				}
1522
+			} else {
1523
+							$attachments = null;
1482 1524
 			}
1483
-			else
1484
-				$attachments = null;
1485 1525
 
1486 1526
 			$data[] = array(
1487 1527
 				'tag' => 'recent-post',
@@ -1600,14 +1640,16 @@  discard block
 block discarded – undo
1600 1640
 	global $scripturl, $memberContext, $user_profile, $user_info;
1601 1641
 
1602 1642
 	// You must input a valid user....
1603
-	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u']))
1604
-		return array();
1643
+	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) {
1644
+			return array();
1645
+	}
1605 1646
 
1606 1647
 	// Make sure the id is a number and not "I like trying to hack the database".
1607 1648
 	$_GET['u'] = (int) $_GET['u'];
1608 1649
 	// Load the member's contextual information!
1609
-	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view'))
1610
-		return array();
1650
+	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) {
1651
+			return array();
1652
+	}
1611 1653
 
1612 1654
 	// Okay, I admit it, I'm lazy.  Stupid $_GET['u'] is long and hard to type.
1613 1655
 	$profile = &$memberContext[$_GET['u']];
@@ -1643,8 +1685,7 @@  discard block
 block discarded – undo
1643 1685
 				),
1644 1686
 			)
1645 1687
 		);
1646
-	}
1647
-	elseif ($xml_format == 'rdf')
1688
+	} elseif ($xml_format == 'rdf')
1648 1689
 	{
1649 1690
 		$data[] = array(
1650 1691
 			'tag' => 'item',
@@ -1668,8 +1709,7 @@  discard block
 block discarded – undo
1668 1709
 				),
1669 1710
 			)
1670 1711
 		);
1671
-	}
1672
-	elseif ($xml_format == 'atom')
1712
+	} elseif ($xml_format == 'atom')
1673 1713
 	{
1674 1714
 		$data[] = array(
1675 1715
 			'tag' => 'entry',
@@ -1722,8 +1762,7 @@  discard block
 block discarded – undo
1722 1762
 				),
1723 1763
 			)
1724 1764
 		);
1725
-	}
1726
-	else
1765
+	} else
1727 1766
 	{
1728 1767
 		$data = array(
1729 1768
 			array(
Please login to merge, or discard this patch.
other/buildtools/check-smf-languages.php 1 patch
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,25 +17,29 @@  discard block
 block discarded – undo
17 17
 );
18 18
 
19 19
 // No file? Thats bad.
20
-if (!isset($_SERVER['argv'], $_SERVER['argv'][1]))
20
+if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) {
21 21
 	die('Error: No File specified' . "\n");
22
+}
22 23
 
23 24
 // The file has to exist.
24 25
 $currentFile = $_SERVER['argv'][1];
25
-if (!file_exists($currentFile))
26
+if (!file_exists($currentFile)) {
26 27
 	die('Error: File does not exist' . "\n");
28
+}
27 29
 
28 30
 // Is this ignored?
29
-foreach ($ignoreFiles as $if)
31
+foreach ($ignoreFiles as $if) {
30 32
 	if (preg_match('~' . $if . '~i', $currentFile))
31 33
 		die;
34
+}
32 35
 
33 36
 // Lets get the main index.php for $forum_version and $software_year.
34 37
 $upgradeFile = fopen('./other/upgrade.php', 'r');
35 38
 $upgradeContents = fread($upgradeFile, 500);
36 39
 
37
-if (!preg_match('~define\(\'SMF_LANG_VERSION\', \'([^\']+)\'\);~i', $upgradeContents, $versionResults))
40
+if (!preg_match('~define\(\'SMF_LANG_VERSION\', \'([^\']+)\'\);~i', $upgradeContents, $versionResults)) {
38 41
 	die('Error: Could not locate SMF_LANG_VERSION' . "\n");
42
+}
39 43
 $currentVersion = $versionResults[1];
40 44
 
41 45
 $file = fopen($currentFile, 'r');
@@ -44,15 +48,18 @@  discard block
 block discarded – undo
44 48
 
45 49
 // Just see if the basic match is there.
46 50
 $match = '// Version: ' . $currentVersion;
47
-if (!preg_match('~' . $match . '~i', $contents))
51
+if (!preg_match('~' . $match . '~i', $contents)) {
48 52
 	die('Error: The version is missing or incorrect in ' . $currentFile . "\n");
53
+}
49 54
 
50 55
 // Get the file prefix.
51 56
 preg_match('~([A-Za-z]+)\.english\.php~i', $currentFile, $fileMatch);
52
-if (empty($fileMatch))
57
+if (empty($fileMatch)) {
53 58
 	die('Error: Could not locate locate the file name in ' . $currentFile . "\n");
59
+}
54 60
 
55 61
 // Now match that prefix in a more strict mode.
56 62
 $match = '// Version: ' . $currentVersion . '; ' . $fileMatch[1];
57
-if (!preg_match('~' . $match . '~i', $contents))
58
-	die('Error: The version with file name is missing or incorrect in ' . $currentFile . "\n");
59 63
\ No newline at end of file
64
+if (!preg_match('~' . $match . '~i', $contents)) {
65
+	die('Error: The version with file name is missing or incorrect in ' . $currentFile . "\n");
66
+}
Please login to merge, or discard this patch.
other/buildtools/check-smf-license.php 1 patch
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,29 +47,34 @@  discard block
 block discarded – undo
47 47
 );
48 48
 
49 49
 // No file? Thats bad.
50
-if (!isset($_SERVER['argv'], $_SERVER['argv'][1]))
50
+if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) {
51 51
 	die('Error: No File specified' . "\n");
52
+}
52 53
 
53 54
 // The file has to exist.
54 55
 $currentFile = $_SERVER['argv'][1];
55
-if (!file_exists($currentFile))
56
+if (!file_exists($currentFile)) {
56 57
 	die('Error: File does not exist' . "\n");
58
+}
57 59
 
58 60
 // Is this ignored?
59
-foreach ($ignoreFiles as $if)
61
+foreach ($ignoreFiles as $if) {
60 62
 	if (preg_match('~' . $if . '~i', $currentFile))
61 63
 		die;
64
+}
62 65
 
63 66
 // Lets get the main index.php for $forum_version and $software_year.
64 67
 $indexFile = fopen('./index.php', 'r');
65 68
 $indexContents = fread($indexFile, 850);
66 69
 
67
-if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults))
70
+if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults)) {
68 71
 	die('Error: Could not locate $forum_version' . "\n");
72
+}
69 73
 $currentVersion = $versionResults[1];
70 74
 
71
-if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults))
75
+if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults)) {
72 76
 	die('Error: Could not locate $software_year' . "\n");
77
+}
73 78
 $currentSoftwareYear = (int) $yearResults[1];
74 79
 
75 80
 $file = fopen($currentFile, 'r');
@@ -90,17 +95,20 @@  discard block
 block discarded – undo
90 95
 );
91 96
 
92 97
 // Just see if the license is there.
93
-if (!preg_match('~' . implode('', $match) . '~i', $contents))
98
+if (!preg_match('~' . implode('', $match) . '~i', $contents)) {
94 99
 	die('Error: License File is invalid or not found in ' . $currentFile . "\n");
100
+}
95 101
 
96 102
 // Check the year is correct.
97 103
 $yearMatch = $match;
98 104
 $yearMatch[4] = ' \* @copyright ' . $currentSoftwareYear . ' Simple Machines and individual contributors' . '[\r]?\n';
99
-if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents))
105
+if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents)) {
100 106
 	die('Error: The software year is incorrect in ' . $currentFile . "\n");
107
+}
101 108
 
102 109
 // Check the version is correct.
103 110
 $versionMatch = $match;
104 111
 $versionMatch[7] = ' \* @version ' . $currentVersion . '[\r]?\n';
105
-if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents))
106
-	die('Error: The version is incorrect in ' . $currentFile . "\n");
107 112
\ No newline at end of file
113
+if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents)) {
114
+	die('Error: The version is incorrect in ' . $currentFile . "\n");
115
+}
Please login to merge, or discard this patch.
other/buildtools/check-signed-off.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,6 +21,7 @@
 block discarded – undo
21 21
 {
22 22
 	// Try 2.
23 23
 	$result2 = stripos($lastLine, 'Signed by');
24
-	if ($result2 === false)
25
-		die('Error: Signed-off-by not found in commit message [' . $lastLine . ']' . '[' . $message . ']' . "\n");
26
-}
27 24
\ No newline at end of file
25
+	if ($result2 === false) {
26
+			die('Error: Signed-off-by not found in commit message [' . $lastLine . ']' . '[' . $message . ']' . "\n");
27
+	}
28
+	}
28 29
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/index.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 			//In maintenance mode, only login is allowed and don't show OverlayDiv
230 230
 			echo '
231 231
 			<ul class="floatleft welcome">
232
-				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
232
+				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li>
233 233
 			</ul>';
234 234
 
235 235
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
Please login to merge, or discard this patch.
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disable for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 		echo '
112 113
 	<meta';
113 114
 
114
-		foreach ($meta_tag as $meta_key => $meta_value)
115
-			echo ' ', $meta_key, '="', $meta_value, '"';
115
+		foreach ($meta_tag as $meta_key => $meta_value) {
116
+					echo ' ', $meta_key, '="', $meta_value, '"';
117
+		}
116 118
 
117 119
 		echo '>';
118 120
 	}
@@ -123,14 +125,16 @@  discard block
 block discarded – undo
123 125
 	<meta name="theme-color" content="#557EA0">';
124 126
 
125 127
 	// Please don't index these Mr Robot.
126
-	if (!empty($context['robot_no_index']))
127
-		echo '
128
+	if (!empty($context['robot_no_index'])) {
129
+			echo '
128 130
 	<meta name="robots" content="noindex">';
131
+	}
129 132
 
130 133
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
131
-	if (!empty($context['canonical_url']))
132
-		echo '
134
+	if (!empty($context['canonical_url'])) {
135
+			echo '
133 136
 	<link rel="canonical" href="', $context['canonical_url'], '">';
137
+	}
134 138
 
135 139
 	// Show all the relative links, such as help, search, contents, and the like.
136 140
 	echo '
@@ -139,10 +143,11 @@  discard block
 block discarded – undo
139 143
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
140 144
 
141 145
 	// If RSS feeds are enabled, advertise the presence of one.
142
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
143
-		echo '
146
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
147
+			echo '
144 148
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml">
145 149
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml">';
150
+	}
146 151
 
147 152
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
148 153
 	if (!empty($context['links']['next']))
@@ -158,9 +163,10 @@  discard block
 block discarded – undo
158 163
 	}
159 164
 
160 165
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
161
-	if (!empty($context['current_board']))
162
-		echo '
166
+	if (!empty($context['current_board'])) {
167
+			echo '
163 168
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
169
+	}
164 170
 
165 171
 	// Output any remaining HTML headers. (from mods, maybe?)
166 172
 	echo $context['html_headers'];
@@ -191,8 +197,9 @@  discard block
 block discarded – undo
191 197
 		<ul class="floatleft" id="top_info">
192 198
 			<li>
193 199
 				<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
194
-					if (!empty($context['user']['avatar']))
195
-						echo $context['user']['avatar']['image'];
200
+					if (!empty($context['user']['avatar'])) {
201
+											echo $context['user']['avatar']['image'];
202
+					}
196 203
 					echo $context['user']['name'], '</a>
197 204
 				<div id="profile_menu" class="top_menu"></div>
198 205
 			</li>';
@@ -220,17 +227,18 @@  discard block
 block discarded – undo
220 227
 	}
221 228
 	// Otherwise they're a guest. Ask them to either register or login.
222 229
 	else
223
-		if (empty($maintenance)) 
224
-			echo '
230
+		if (empty($maintenance)) {
231
+					echo '
225 232
 			<ul class="floatleft welcome">
226 233
 				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
227 234
 			</ul>';
228
-		else 
229
-			//In maintenance mode, only login is allowed and don't show OverlayDiv
235
+		} else {
236
+					//In maintenance mode, only login is allowed and don't show OverlayDiv
230 237
 			echo '
231 238
 			<ul class="floatleft welcome">
232 239
 				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
233 240
 			</ul>';
241
+		}
234 242
 
235 243
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
236 244
 	{
@@ -238,9 +246,10 @@  discard block
 block discarded – undo
238 246
 		<form id="languages_form" method="get" class="floatright">
239 247
 			<select id="language_select" name="language" onchange="this.form.submit()">';
240 248
 
241
-		foreach ($context['languages'] as $language)
242
-			echo '
249
+		foreach ($context['languages'] as $language) {
250
+					echo '
243 251
 				<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
252
+		}
244 253
 
245 254
 		echo '
246 255
 			</select>
@@ -264,31 +273,36 @@  discard block
 block discarded – undo
264 273
 				<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
265 274
 
266 275
 		// Can't limit it to a specific topic if we are not in one
267
-		if (!empty($context['current_topic']))
268
-			echo '
276
+		if (!empty($context['current_topic'])) {
277
+					echo '
269 278
 				<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
279
+		}
270 280
 
271 281
 		// Can't limit it to a specific board if we are not in one
272
-		if (!empty($context['current_board']))
273
-			echo '
282
+		if (!empty($context['current_board'])) {
283
+					echo '
274 284
 				<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
285
+		}
275 286
 		
276 287
 		// Can't search for members if we can't see the memberlist
277
-		if (!empty($context['allow_memberlist']))
278
-			echo '
288
+		if (!empty($context['allow_memberlist'])) {
289
+					echo '
279 290
 				<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
291
+		}
280 292
 				
281 293
 		echo '
282 294
 			</select>';
283 295
 
284 296
 		// Search within current topic?
285
-		if (!empty($context['current_topic']))
286
-			echo '
297
+		if (!empty($context['current_topic'])) {
298
+					echo '
287 299
 			<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
300
+		}
288 301
 		// If we're on a certain board, limit it to this board ;).
289
-		elseif (!empty($context['current_board']))
290
-			echo '
302
+		elseif (!empty($context['current_board'])) {
303
+					echo '
291 304
 			<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
305
+		}
292 306
 
293 307
 		echo '
294 308
 			<input type="submit" name="search2" value="', $txt['search'], '" class="button_submit">
@@ -318,12 +332,13 @@  discard block
 block discarded – undo
318 332
 						', $context['current_time'], '
319 333
 					</div>';
320 334
 	// Show a random news item? (or you could pick one from news_lines...)
321
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
322
-		echo '
335
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
336
+			echo '
323 337
 					<div class="news">
324 338
 						<h2>', $txt['news'], ': </h2>
325 339
 						<p>', $context['random_news_line'], '</p>
326 340
 					</div>';
341
+	}
327 342
 
328 343
 	echo '
329 344
 					<hr class="clear">
@@ -386,9 +401,10 @@  discard block
 block discarded – undo
386 401
 		</ul>';
387 402
 
388 403
 	// Show the load time?
389
-	if ($context['show_load_time'])
390
-		echo '
404
+	if ($context['show_load_time']) {
405
+			echo '
391 406
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
407
+	}
392 408
 
393 409
 	echo '
394 410
 	</div>';
@@ -418,19 +434,21 @@  discard block
 block discarded – undo
418 434
 	global $context, $shown_linktree, $scripturl, $txt;
419 435
 
420 436
 	// If linktree is empty, just return - also allow an override.
421
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
422
-		return;
437
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
438
+			return;
439
+	}
423 440
 
424 441
 	echo '
425 442
 				<div class="navigate_section">
426 443
 					<ul>';
427 444
 
428
-	if ($context['user']['is_logged'])
429
-	echo '
445
+	if ($context['user']['is_logged']) {
446
+		echo '
430 447
 						<li class="unread_links">
431 448
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
432 449
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
433 450
 						</li>';
451
+	}
434 452
 
435 453
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
436 454
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -441,25 +459,29 @@  discard block
 block discarded – undo
441 459
 		// Don't show a separator for the first one.
442 460
 		// Better here. Always points to the next level when the linktree breaks to a second line.
443 461
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
444
-		if ($link_num != 0)
445
-			echo '
462
+		if ($link_num != 0) {
463
+					echo '
446 464
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
465
+		}
447 466
 
448 467
 		// Show something before the link?
449
-		if (isset($tree['extra_before']))
450
-			echo $tree['extra_before'], ' ';
468
+		if (isset($tree['extra_before'])) {
469
+					echo $tree['extra_before'], ' ';
470
+		}
451 471
 
452 472
 		// Show the link, including a URL if it should have one.
453
-		if (isset($tree['url']))
454
-			echo '
473
+		if (isset($tree['url'])) {
474
+					echo '
455 475
 					<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
456
-		else
457
-			echo '
476
+		} else {
477
+					echo '
458 478
 					<span>' . $tree['name'] . '</span>';
479
+		}
459 480
 
460 481
 		// Show something after the link...?
461
-		if (isset($tree['extra_after']))
462
-			echo ' ', $tree['extra_after'];
482
+		if (isset($tree['extra_after'])) {
483
+					echo ' ', $tree['extra_after'];
484
+		}
463 485
 
464 486
 		echo '
465 487
 						</li>';
@@ -509,13 +531,14 @@  discard block
 block discarded – undo
509 531
 					echo '
510 532
 									<ul>';
511 533
 
512
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
513
-						echo '
534
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
535
+											echo '
514 536
 										<li>
515 537
 											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
516 538
 												', $grandchildbutton['title'], '
517 539
 											</a>
518 540
 										</li>';
541
+					}
519 542
 
520 543
 					echo '
521 544
 									</ul>';
@@ -546,8 +569,9 @@  discard block
 block discarded – undo
546 569
 {
547 570
 	global $context, $txt;
548 571
 
549
-	if (!is_array($strip_options))
550
-		$strip_options = array();
572
+	if (!is_array($strip_options)) {
573
+			$strip_options = array();
574
+	}
551 575
 
552 576
 	// Create the buttons...
553 577
 	$buttons = array();
@@ -556,8 +580,9 @@  discard block
 block discarded – undo
556 580
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
557 581
 		if (!isset($value['test']) || !empty($context[$value['test']]))
558 582
 		{
559
-			if (!isset($value['id']))
560
-				$value['id'] = $key;
583
+			if (!isset($value['id'])) {
584
+							$value['id'] = $key;
585
+			}
561 586
 
562 587
 			$button = '
563 588
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -570,13 +595,15 @@  discard block
 block discarded – undo
570 595
 							<div class="overview">';
571 596
 				foreach ($value['sub_buttons'] as $element)
572 597
 				{
573
-					if (isset($element['test']) && empty($context[$element['test']]))
574
-						continue;
598
+					if (isset($element['test']) && empty($context[$element['test']])) {
599
+											continue;
600
+					}
575 601
 
576 602
 					$button .= '
577 603
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
578
-					if (isset($txt[$element['text'] . '_desc']))
579
-						$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
604
+					if (isset($txt[$element['text'] . '_desc'])) {
605
+											$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
606
+					}
580 607
 					$button .= '</a>';
581 608
 				}
582 609
 				$button .= '
@@ -590,8 +617,9 @@  discard block
 block discarded – undo
590 617
 	}
591 618
 
592 619
 	// No buttons? No button strip either.
593
-	if (empty($buttons))
594
-		return;
620
+	if (empty($buttons)) {
621
+			return;
622
+	}
595 623
 
596 624
 	echo '
597 625
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
Please login to merge, or discard this patch.