Completed
Push — release-2.1 ( 392972...04d843 )
by Jeremy
68:03 queued 20:53
created
Sources/RepairBoards.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
247 247
 				WHERE t.id_topic IS NULL
248 248
 				GROUP BY m.id_topic, m.id_board',
249
-			'fix_processing' => function ($row) use ($smcFunc)
249
+			'fix_processing' => function($row) use ($smcFunc)
250 250
 			{
251 251
 				global $salvageBoardID;
252 252
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			// Remove all topics that have zero messages in the messages table.
333 333
 			'fix_collect' => array(
334 334
 				'index' => 'id_topic',
335
-				'process' => function ($topics) use ($smcFunc)
335
+				'process' => function($topics) use ($smcFunc)
336 336
 				{
337 337
 					$smcFunc['db_query']('', '
338 338
 						DELETE FROM {db_prefix}topics
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 				  AND p.id_poll IS NULL
370 370
 				GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name
371 371
 				  ',
372
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
372
+			'fix_processing' => function($row) use ($smcFunc, $txt)
373 373
 			{
374 374
 				global $salvageBoardID;
375 375
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll)
507 507
 				WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
508 508
 					AND t.id_poll IS NULL',
509
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
509
+			'fix_processing' => function($row) use ($smcFunc, $txt)
510 510
 			{
511 511
 				global $salvageBoardID;
512 512
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
618 618
 				GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved
619 619
 				ORDER BY t.id_topic',
620
-			'fix_processing' => function ($row) use ($smcFunc)
620
+			'fix_processing' => function($row) use ($smcFunc)
621 621
 			{
622 622
 				$row['firstmsg_approved'] = (int) $row['firstmsg_approved'];
623 623
 				$row['myid_first_msg'] = (int) $row['myid_first_msg'];
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 					)
647 647
 				);
648 648
 			},
649
-			'message_function' => function ($row) use ($txt, &$context)
649
+			'message_function' => function($row) use ($txt, &$context)
650 650
 			{
651 651
 				// A pretend error?
652 652
 				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
681 681
 				GROUP BY t.id_topic, t.num_replies, mf.approved
682 682
 				ORDER BY t.id_topic',
683
-			'fix_processing' => function ($row)
683
+			'fix_processing' => function($row)
684 684
 			{
685 685
 				global $smcFunc;
686 686
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 					)
700 700
 				);
701 701
 			},
702
-			'message_function' => function ($row)
702
+			'message_function' => function($row)
703 703
 			{
704 704
 				global $txt, $context;
705 705
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 				GROUP BY t.id_topic, t.unapproved_posts
731 731
 				HAVING unapproved_posts != COUNT(mu.id_msg)
732 732
 				ORDER BY t.id_topic',
733
-			'fix_processing' => function ($row)
733
+			'fix_processing' => function($row)
734 734
 			{
735 735
 				global $smcFunc;
736 736
 				$row['my_unapproved_posts'] = (int) $row['my_unapproved_posts'];
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 				WHERE b.id_board IS NULL
771 771
 					AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
772 772
 				GROUP BY t.id_board',
773
-			'fix_processing' => function ($row)
773
+			'fix_processing' => function($row)
774 774
 			{
775 775
 				global $smcFunc, $salvageCatID, $txt;
776 776
 				createSalvageArea();
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 				ORDER BY b.id_cat, b.id_board',
818 818
 			'fix_collect' => array(
819 819
 				'index' => 'id_cat',
820
-				'process' => function ($cats)
820
+				'process' => function($cats)
821 821
 				{
822 822
 					global $smcFunc, $salvageCatID;
823 823
 					createSalvageArea();
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 			// Last step-make sure all non-guest posters still exist.
854 854
 			'fix_collect' => array(
855 855
 				'index' => 'id_msg',
856
-				'process' => function ($msgs)
856
+				'process' => function($msgs)
857 857
 				{
858 858
 					global $smcFunc;
859 859
 					$smcFunc['db_query']('', '
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 				ORDER BY b.id_parent, b.id_board',
881 881
 			'fix_collect' => array(
882 882
 				'index' => 'id_parent',
883
-				'process' => function ($parents)
883
+				'process' => function($parents)
884 884
 				{
885 885
 					global $smcFunc, $salvageBoardID, $salvageCatID;
886 886
 
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 					AND p.id_poll IS NULL',
918 918
 			'fix_collect' => array(
919 919
 				'index' => 'id_poll',
920
-				'process' => function ($polls)
920
+				'process' => function($polls)
921 921
 				{
922 922
 					global $smcFunc;
923 923
 					$smcFunc['db_query']('', '
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 				ORDER BY cal.id_topic',
950 950
 			'fix_collect' => array(
951 951
 				'index' => 'id_topic',
952
-				'process' => function ($events)
952
+				'process' => function($events)
953 953
 				{
954 954
 					global $smcFunc;
955 955
 					$smcFunc['db_query']('', '
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 					AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}',
980 980
 			'fix_collect' => array(
981 981
 				'index' => 'id_topic',
982
-				'process' => function ($topics)
982
+				'process' => function($topics)
983 983
 				{
984 984
 					global $smcFunc;
985 985
 					$smcFunc['db_query']('', '
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 				GROUP BY lt.id_member',
1010 1010
 			'fix_collect' => array(
1011 1011
 				'index' => 'id_member',
1012
-				'process' => function ($members)
1012
+				'process' => function($members)
1013 1013
 				{
1014 1014
 					global $smcFunc;
1015 1015
 					$smcFunc['db_query']('', '
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 				GROUP BY lb.id_board',
1040 1040
 			'fix_collect' => array(
1041 1041
 				'index' => 'id_board',
1042
-				'process' => function ($boards)
1042
+				'process' => function($boards)
1043 1043
 				{
1044 1044
 					global $smcFunc;
1045 1045
 					$smcFunc['db_query']('', '
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 				GROUP BY lb.id_member',
1070 1070
 			'fix_collect' => array(
1071 1071
 				'index' => 'id_member',
1072
-				'process' => function ($members) use ($smcFunc)
1072
+				'process' => function($members) use ($smcFunc)
1073 1073
 				{
1074 1074
 					$smcFunc['db_query']('', '
1075 1075
 						DELETE FROM {db_prefix}log_boards
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 				GROUP BY lmr.id_board',
1099 1099
 			'fix_collect' => array(
1100 1100
 				'index' => 'id_board',
1101
-				'process' => function ($boards) use ($smcFunc)
1101
+				'process' => function($boards) use ($smcFunc)
1102 1102
 				{
1103 1103
 					$smcFunc['db_query']('', '
1104 1104
 						DELETE FROM {db_prefix}log_mark_read
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 				GROUP BY lmr.id_member',
1128 1128
 			'fix_collect' => array(
1129 1129
 				'index' => 'id_member',
1130
-				'process' => function ($members) use ($smcFunc)
1130
+				'process' => function($members) use ($smcFunc)
1131 1131
 				{
1132 1132
 					$smcFunc['db_query']('', '
1133 1133
 						DELETE FROM {db_prefix}log_mark_read
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 				GROUP BY pmr.id_pm',
1157 1157
 			'fix_collect' => array(
1158 1158
 				'index' => 'id_pm',
1159
-				'process' => function ($pms) use ($smcFunc)
1159
+				'process' => function($pms) use ($smcFunc)
1160 1160
 				{
1161 1161
 					$smcFunc['db_query']('', '
1162 1162
 						DELETE FROM {db_prefix}pm_recipients
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 				GROUP BY pmr.id_member',
1187 1187
 			'fix_collect' => array(
1188 1188
 				'index' => 'id_member',
1189
-				'process' => function ($members)
1189
+				'process' => function($members)
1190 1190
 				{
1191 1191
 					global $smcFunc;
1192 1192
 					$smcFunc['db_query']('', '
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 					AND mem.id_member IS NULL',
1217 1217
 			'fix_collect' => array(
1218 1218
 				'index' => 'id_pm',
1219
-				'process' => function ($guestMessages)
1219
+				'process' => function($guestMessages)
1220 1220
 				{
1221 1221
 					global $smcFunc;
1222 1222
 					$smcFunc['db_query']('', '
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				GROUP BY ln.id_member',
1247 1247
 			'fix_collect' => array(
1248 1248
 				'index' => 'id_member',
1249
-				'process' => function ($members) use ($smcFunc)
1249
+				'process' => function($members) use ($smcFunc)
1250 1250
 				{
1251 1251
 					$smcFunc['db_query']('', '
1252 1252
 						DELETE FROM {db_prefix}log_notify
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 					LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic)
1274 1274
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
1275 1275
 					AND lss.id_topic IS NULL',
1276
-			'fix_full_processing' => function ($result)
1276
+			'fix_full_processing' => function($result)
1277 1277
 			{
1278 1278
 				global $smcFunc;
1279 1279
 
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 						array('word', 'id_topic')
1303 1303
 					);
1304 1304
 			},
1305
-			'message_function' => function ($row)
1305
+			'message_function' => function($row)
1306 1306
 			{
1307 1307
 				global $txt, $context;
1308 1308
 
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 					AND t.id_topic IS NULL',
1331 1331
 			'fix_collect' => array(
1332 1332
 				'index' => 'id_topic',
1333
-				'process' => function ($deleteTopics)
1333
+				'process' => function($deleteTopics)
1334 1334
 				{
1335 1335
 					global $smcFunc;
1336 1336
 					$smcFunc['db_query']('', '
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 					AND mem.id_member IS NULL',
1361 1361
 			'fix_collect' => array(
1362 1362
 				'index' => 'id_member',
1363
-				'process' => function ($members)
1363
+				'process' => function($members)
1364 1364
 				{
1365 1365
 					global $smcFunc;
1366 1366
 					$smcFunc['db_query']('', '
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 					AND p.id_poll IS NULL',
1390 1390
 			'fix_collect' => array(
1391 1391
 				'index' => 'id_poll',
1392
-				'process' => function ($polls)
1392
+				'process' => function($polls)
1393 1393
 				{
1394 1394
 					global $smcFunc;
1395 1395
 					$smcFunc['db_query']('', '
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 					AND lrc.id_report IS NULL',
1419 1419
 			'fix_collect' => array(
1420 1420
 				'index' => 'id_report',
1421
-				'process' => function ($reports)
1421
+				'process' => function($reports)
1422 1422
 				{
1423 1423
 					global $smcFunc;
1424 1424
 					$smcFunc['db_query']('', '
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 					AND lr.id_report IS NULL',
1448 1448
 			'fix_collect' => array(
1449 1449
 				'index' => 'id_report',
1450
-				'process' => function ($reports)
1450
+				'process' => function($reports)
1451 1451
 				{
1452 1452
 					global $smcFunc;
1453 1453
 					$smcFunc['db_query']('', '
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 				GROUP BY lgr.id_member',
1478 1478
 			'fix_collect' => array(
1479 1479
 				'index' => 'id_member',
1480
-				'process' => function ($members)
1480
+				'process' => function($members)
1481 1481
 				{
1482 1482
 					global $smcFunc;
1483 1483
 					$smcFunc['db_query']('', '
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 				GROUP BY lgr.id_group',
1508 1508
 			'fix_collect' => array(
1509 1509
 				'index' => 'id_group',
1510
-				'process' => function ($groups)
1510
+				'process' => function($groups)
1511 1511
 				{
1512 1512
 					global $smcFunc;
1513 1513
 					$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Braces   +119 added lines, -85 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
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
  * Finds or repairs errors in the database to fix possible problems.
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	);
51 52
 
52 53
 	// Start displaying errors without fixing them.
53
-	if (isset($_GET['fixErrors']))
54
-		checkSession('get');
54
+	if (isset($_GET['fixErrors'])) {
55
+			checkSession('get');
56
+	}
55 57
 
56 58
 	// Will want this.
57 59
 	loadForumTests();
@@ -69,14 +71,14 @@  discard block
 block discarded – undo
69 71
 			$_SESSION['repairboards_to_fix'] = $context['to_fix'];
70 72
 			$_SESSION['repairboards_to_fix2'] = null;
71 73
 
72
-			if (empty($context['repair_errors']))
73
-				$context['repair_errors'][] = '???';
74
+			if (empty($context['repair_errors'])) {
75
+							$context['repair_errors'][] = '???';
76
+			}
74 77
 		}
75 78
 
76 79
 		// Need a token here.
77 80
 		createToken('admin-repairboards', 'request');
78
-	}
79
-	else
81
+	} else
80 82
 	{
81 83
 		// Validate the token, create a new one and tell the not done template.
82 84
 		validateToken('admin-repairboards', 'request');
@@ -134,16 +136,19 @@  discard block
 block discarded – undo
134 136
 
135 137
 	// More time, I need more time!
136 138
 	@set_time_limit(600);
137
-	if (function_exists('apache_reset_timeout'))
138
-		@apache_reset_timeout();
139
+	if (function_exists('apache_reset_timeout')) {
140
+			@apache_reset_timeout();
141
+	}
139 142
 
140 143
 	// Errr, wait.  How much time has this taken already?
141
-	if (!$force && (time() - $time_start) < 3)
142
-		return;
144
+	if (!$force && (time() - $time_start) < 3) {
145
+			return;
146
+	}
143 147
 
144 148
 	// Restore the query cache if interested.
145
-	if (!empty($db_temp_cache))
146
-		$db_cache = $db_temp_cache;
149
+	if (!empty($db_temp_cache)) {
150
+			$db_cache = $db_temp_cache;
151
+	}
147 152
 
148 153
 	$context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
149 154
 	$context['page_title'] = $txt['not_done_title'];
@@ -152,10 +157,11 @@  discard block
 block discarded – undo
152 157
 	$context['sub_template'] = 'not_done';
153 158
 
154 159
 	// Change these two if more steps are added!
155
-	if (empty($max_substep))
156
-		$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
157
-	else
158
-		$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
160
+	if (empty($max_substep)) {
161
+			$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
162
+	} else {
163
+			$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
164
+	}
159 165
 
160 166
 	// Never more than 100%!
161 167
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -624,8 +630,9 @@  discard block
 block discarded – undo
624 630
 				$row['myid_last_msg'] = (int) $row['myid_last_msg'];
625 631
 
626 632
 				// Not really a problem?
627
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
628
-					return false;
633
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
634
+									return false;
635
+				}
629 636
 
630 637
 				$memberStartedID = (int) getMsgMemberID($row['myid_first_msg']);
631 638
 				$memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']);
@@ -649,15 +656,19 @@  discard block
 block discarded – undo
649 656
 			'message_function' => function ($row) use ($txt, &$context)
650 657
 			{
651 658
 				// A pretend error?
652
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
653
-					return false;
659
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
660
+									return false;
661
+				}
654 662
 
655
-				if ($row['id_first_msg'] != $row['myid_first_msg'])
656
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
657
-				if ($row['id_last_msg'] != $row['myid_last_msg'])
658
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
659
-				if ($row['approved'] != $row['firstmsg_approved'])
660
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
663
+				if ($row['id_first_msg'] != $row['myid_first_msg']) {
664
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
665
+				}
666
+				if ($row['id_last_msg'] != $row['myid_last_msg']) {
667
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
668
+				}
669
+				if ($row['approved'] != $row['firstmsg_approved']) {
670
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
671
+				}
661 672
 
662 673
 				return true;
663 674
 			},
@@ -686,8 +697,9 @@  discard block
 block discarded – undo
686 697
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
687 698
 
688 699
 				// Not really a problem?
689
-				if ($row['my_num_replies'] == $row['num_replies'])
690
-					return false;
700
+				if ($row['my_num_replies'] == $row['num_replies']) {
701
+									return false;
702
+				}
691 703
 
692 704
 				$smcFunc['db_query']('', '
693 705
 					UPDATE {db_prefix}topics
@@ -704,11 +716,13 @@  discard block
 block discarded – undo
704 716
 				global $txt, $context;
705 717
 
706 718
 				// Just joking?
707
-				if ($row['my_num_replies'] == $row['num_replies'])
708
-					return false;
719
+				if ($row['my_num_replies'] == $row['num_replies']) {
720
+									return false;
721
+				}
709 722
 
710
-				if ($row['num_replies'] != $row['my_num_replies'])
711
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
723
+				if ($row['num_replies'] != $row['my_num_replies']) {
724
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
725
+				}
712 726
 
713 727
 				return true;
714 728
 			},
@@ -1280,8 +1294,9 @@  discard block
 block discarded – undo
1280 1294
 				$inserts = array();
1281 1295
 				while ($row = $smcFunc['db_fetch_assoc']($result))
1282 1296
 				{
1283
-					foreach (text2words($row['subject']) as $word)
1284
-						$inserts[] = array($word, $row['id_topic']);
1297
+					foreach (text2words($row['subject']) as $word) {
1298
+											$inserts[] = array($word, $row['id_topic']);
1299
+					}
1285 1300
 					if (count($inserts) > 500)
1286 1301
 					{
1287 1302
 						$smcFunc['db_insert']('ignore',
@@ -1294,13 +1309,14 @@  discard block
 block discarded – undo
1294 1309
 					}
1295 1310
 				}
1296 1311
 
1297
-				if (!empty($inserts))
1298
-					$smcFunc['db_insert']('ignore',
1312
+				if (!empty($inserts)) {
1313
+									$smcFunc['db_insert']('ignore',
1299 1314
 						'{db_prefix}log_search_subjects',
1300 1315
 						array('word' => 'string', 'id_topic' => 'int'),
1301 1316
 						$inserts,
1302 1317
 						array('word', 'id_topic')
1303 1318
 					);
1319
+				}
1304 1320
 			},
1305 1321
 			'message_function' => function ($row)
1306 1322
 			{
@@ -1559,8 +1575,9 @@  discard block
 block discarded – undo
1559 1575
 		$current_step++;
1560 1576
 
1561 1577
 		// Already done this?
1562
-		if ($_GET['step'] > $current_step)
1563
-			continue;
1578
+		if ($_GET['step'] > $current_step) {
1579
+					continue;
1580
+		}
1564 1581
 
1565 1582
 		// If we're fixing it but it ain't broke why try?
1566 1583
 		if ($do_fix && !in_array($error_type, $to_fix))
@@ -1589,14 +1606,16 @@  discard block
 block discarded – undo
1589 1606
 		while (!$done)
1590 1607
 		{
1591 1608
 			// Make sure there's at least one ID to test.
1592
-			if (isset($test['substeps']) && empty($step_max))
1593
-				break;
1609
+			if (isset($test['substeps']) && empty($step_max)) {
1610
+							break;
1611
+			}
1594 1612
 
1595 1613
 			// What is the testing query (Changes if we are testing or fixing)
1596
-			if (!$do_fix)
1597
-				$test_query = 'check_query';
1598
-			else
1599
-				$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1614
+			if (!$do_fix) {
1615
+							$test_query = 'check_query';
1616
+			} else {
1617
+							$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1618
+			}
1600 1619
 
1601 1620
 			// Do the test...
1602 1621
 			$request = $smcFunc['db_query']('',
@@ -1606,10 +1625,11 @@  discard block
 block discarded – undo
1606 1625
 			);
1607 1626
 
1608 1627
 			// Does it need a fix?
1609
-			if (!empty($test['check_type']) && $test['check_type'] == 'count')
1610
-				list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1611
-			else
1612
-				$needs_fix = $smcFunc['db_num_rows']($request);
1628
+			if (!empty($test['check_type']) && $test['check_type'] == 'count') {
1629
+							list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1630
+			} else {
1631
+							$needs_fix = $smcFunc['db_num_rows']($request);
1632
+			}
1613 1633
 
1614 1634
 			$total_queries++;
1615 1635
 
@@ -1621,8 +1641,9 @@  discard block
 block discarded – undo
1621 1641
 					// Assume need to fix.
1622 1642
 					$found_errors = true;
1623 1643
 
1624
-					if (isset($test['message']))
1625
-						$context['repair_errors'][] = $txt[$test['message']];
1644
+					if (isset($test['message'])) {
1645
+											$context['repair_errors'][] = $txt[$test['message']];
1646
+					}
1626 1647
 
1627 1648
 					// One per row!
1628 1649
 					elseif (isset($test['messages']))
@@ -1632,10 +1653,11 @@  discard block
 block discarded – undo
1632 1653
 							$variables = $test['messages'];
1633 1654
 							foreach ($variables as $k => $v)
1634 1655
 							{
1635
-								if ($k == 0 && isset($txt[$v]))
1636
-									$variables[$k] = $txt[$v];
1637
-								elseif ($k > 0 && isset($row[$v]))
1638
-									$variables[$k] = $row[$v];
1656
+								if ($k == 0 && isset($txt[$v])) {
1657
+																	$variables[$k] = $txt[$v];
1658
+								} elseif ($k > 0 && isset($row[$v])) {
1659
+																	$variables[$k] = $row[$v];
1660
+								}
1639 1661
 							}
1640 1662
 							$context['repair_errors'][] = call_user_func_array('sprintf', $variables);
1641 1663
 						}
@@ -1646,13 +1668,15 @@  discard block
 block discarded – undo
1646 1668
 					{
1647 1669
 						// Find out if there are actually errors.
1648 1670
 						$found_errors = false;
1649
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1650
-							$found_errors |= $test['message_function']($row);
1671
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1672
+													$found_errors |= $test['message_function']($row);
1673
+						}
1651 1674
 					}
1652 1675
 
1653 1676
 					// Actually have something to fix?
1654
-					if ($found_errors)
1655
-						$to_fix[] = $error_type;
1677
+					if ($found_errors) {
1678
+											$to_fix[] = $error_type;
1679
+					}
1656 1680
 				}
1657 1681
 
1658 1682
 				// We want to fix, we need to fix - so work out what exactly to do!
@@ -1662,8 +1686,9 @@  discard block
 block discarded – undo
1662 1686
 					if (isset($test['fix_collect']))
1663 1687
 					{
1664 1688
 						$ids = array();
1665
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1666
-							$ids[] = $row[$test['fix_collect']['index']];
1689
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1690
+													$ids[] = $row[$test['fix_collect']['index']];
1691
+						}
1667 1692
 						if (!empty($ids))
1668 1693
 						{
1669 1694
 							// Fix it!
@@ -1672,30 +1697,34 @@  discard block
 block discarded – undo
1672 1697
 					}
1673 1698
 
1674 1699
 					// Simply executing a fix it query?
1675
-					elseif (isset($test['fix_it_query']))
1676
-						$smcFunc['db_query']('',
1700
+					elseif (isset($test['fix_it_query'])) {
1701
+											$smcFunc['db_query']('',
1677 1702
 							$test['fix_it_query'],
1678 1703
 							array(
1679 1704
 							)
1680 1705
 						);
1706
+					}
1681 1707
 
1682 1708
 					// Do we have some processing to do?
1683 1709
 					elseif (isset($test['fix_processing']))
1684 1710
 					{
1685
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1686
-							$test['fix_processing']($row);
1711
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1712
+													$test['fix_processing']($row);
1713
+						}
1687 1714
 					}
1688 1715
 
1689 1716
 					// What about the full set of processing?
1690
-					elseif (isset($test['fix_full_processing']))
1691
-						$test['fix_full_processing']($request);
1717
+					elseif (isset($test['fix_full_processing'])) {
1718
+											$test['fix_full_processing']($request);
1719
+					}
1692 1720
 
1693 1721
 					// Do we have other things we need to fix as a result?
1694 1722
 					if (!empty($test['force_fix']))
1695 1723
 					{
1696
-						foreach ($test['force_fix'] as $item)
1697
-							if (!in_array($item, $to_fix))
1724
+						foreach ($test['force_fix'] as $item) {
1725
+													if (!in_array($item, $to_fix))
1698 1726
 								$to_fix[] = $item;
1727
+						}
1699 1728
 					}
1700 1729
 				}
1701 1730
 			}
@@ -1713,16 +1742,17 @@  discard block
 block discarded – undo
1713 1742
 				if ($_GET['substep'] <= $step_max)
1714 1743
 				{
1715 1744
 					pauseRepairProcess($to_fix, $error_type, $step_max);
1745
+				} else {
1746
+									$done = true;
1716 1747
 				}
1717
-				else
1718
-					$done = true;
1748
+			} else {
1749
+							$done = true;
1719 1750
 			}
1720
-			else
1721
-				$done = true;
1722 1751
 
1723 1752
 			// Don't allow more than 1000 queries at a time.
1724
-			if ($total_queries >= 1000)
1725
-				pauseRepairProcess($to_fix, $error_type, $step_max, true);
1753
+			if ($total_queries >= 1000) {
1754
+							pauseRepairProcess($to_fix, $error_type, $step_max, true);
1755
+			}
1726 1756
 		}
1727 1757
 
1728 1758
 		// Keep going.
@@ -1735,8 +1765,9 @@  discard block
 block discarded – undo
1735 1765
 		if ($do_fix)
1736 1766
 		{
1737 1767
 			$key = array_search($error_type, $to_fix);
1738
-			if ($key !== false && isset($to_fix[$key]))
1739
-				unset($to_fix[$key]);
1768
+			if ($key !== false && isset($to_fix[$key])) {
1769
+							unset($to_fix[$key]);
1770
+			}
1740 1771
 		}
1741 1772
 
1742 1773
 		// Are we done?
@@ -1759,10 +1790,11 @@  discard block
 block discarded – undo
1759 1790
 	static $createOnce = false;
1760 1791
 
1761 1792
 	// Have we already created it?
1762
-	if ($createOnce)
1763
-		return;
1764
-	else
1765
-		$createOnce = true;
1793
+	if ($createOnce) {
1794
+			return;
1795
+	} else {
1796
+			$createOnce = true;
1797
+	}
1766 1798
 
1767 1799
 	// Back to the forum's default language.
1768 1800
 	loadLanguage('Admin', $language);
@@ -1777,8 +1809,9 @@  discard block
 block discarded – undo
1777 1809
 			'cat_name' => $txt['salvaged_category_name'],
1778 1810
 		)
1779 1811
 	);
1780
-	if ($smcFunc['db_num_rows']($result) != 0)
1781
-		list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1812
+	if ($smcFunc['db_num_rows']($result) != 0) {
1813
+			list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1814
+	}
1782 1815
 	$smcFunc['db_free_result']($result);
1783 1816
 
1784 1817
 	if (empty($salvageCatID))
@@ -1810,8 +1843,9 @@  discard block
 block discarded – undo
1810 1843
 			'board_name' => $txt['salvaged_board_name'],
1811 1844
 		)
1812 1845
 	);
1813
-	if ($smcFunc['db_num_rows']($result) != 0)
1814
-		list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1846
+	if ($smcFunc['db_num_rows']($result) != 0) {
1847
+			list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1848
+	}
1815 1849
 	$smcFunc['db_free_result']($result);
1816 1850
 
1817 1851
 	if (empty($salvageBoardID))
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +255 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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 user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -298,14 +315,15 @@  discard block
 block discarded – undo
298 315
 	if (isset($_SESSION['ban']['cannot_access']))
299 316
 	{
300 317
 		// We don't wanna see you!
301
-		if (!$user_info['is_guest'])
302
-			$smcFunc['db_query']('', '
318
+		if (!$user_info['is_guest']) {
319
+					$smcFunc['db_query']('', '
303 320
 				DELETE FROM {db_prefix}log_online
304 321
 				WHERE id_member = {int:current_member}',
305 322
 				array(
306 323
 					'current_member' => $user_info['id'],
307 324
 				)
308 325
 			);
326
+		}
309 327
 
310 328
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
311 329
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -391,9 +409,10 @@  discard block
 block discarded – undo
391 409
 	}
392 410
 
393 411
 	// Fix up the banning permissions.
394
-	if (isset($user_info['permissions']))
395
-		banPermissions();
396
-}
412
+	if (isset($user_info['permissions'])) {
413
+			banPermissions();
414
+	}
415
+	}
397 416
 
398 417
 /**
399 418
  * Fix permissions according to ban status.
@@ -404,8 +423,9 @@  discard block
 block discarded – undo
404 423
 	global $user_info, $sourcedir, $modSettings, $context;
405 424
 
406 425
 	// Somehow they got here, at least take away all permissions...
407
-	if (isset($_SESSION['ban']['cannot_access']))
408
-		$user_info['permissions'] = array();
426
+	if (isset($_SESSION['ban']['cannot_access'])) {
427
+			$user_info['permissions'] = array();
428
+	}
409 429
 	// Okay, well, you can watch, but don't touch a thing.
410 430
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
411 431
 	{
@@ -447,19 +467,20 @@  discard block
 block discarded – undo
447 467
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
448 468
 		foreach ($permission_change as $old => $new)
449 469
 		{
450
-			if (!in_array($old, $user_info['permissions']))
451
-				unset($permission_change[$old]);
452
-			else
453
-				$user_info['permissions'][] = $new;
470
+			if (!in_array($old, $user_info['permissions'])) {
471
+							unset($permission_change[$old]);
472
+			} else {
473
+							$user_info['permissions'][] = $new;
474
+			}
454 475
 		}
455 476
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
456 477
 	}
457 478
 
458 479
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
459 480
 	// Finally, some bits we cache in the session because it saves queries.
460
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
461
-		$user_info['mod_cache'] = $_SESSION['mc'];
462
-	else
481
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
482
+			$user_info['mod_cache'] = $_SESSION['mc'];
483
+	} else
463 484
 	{
464 485
 		require_once($sourcedir . '/Subs-Auth.php');
465 486
 		rebuildModCache();
@@ -470,14 +491,12 @@  discard block
 block discarded – undo
470 491
 	{
471 492
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
472 493
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
473
-	}
474
-	elseif ($_SESSION['mc']['bq'] != '0=1')
494
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
475 495
 	{
476 496
 		require_once($sourcedir . '/Subs-ReportedContent.php');
477 497
 		$context['open_mod_reports'] = recountOpenReports('posts');
478 498
 		$context['open_member_reports'] = recountOpenReports('members');
479
-	}
480
-	else
499
+	} else
481 500
 	{
482 501
 		$context['open_mod_reports'] = 0;
483 502
 		$context['open_member_reports'] = 0;
@@ -497,8 +516,9 @@  discard block
 block discarded – undo
497 516
 	global $user_info, $smcFunc;
498 517
 
499 518
 	// Don't log web accelerators, it's very confusing...
500
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
501
-		return;
519
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
520
+			return;
521
+	}
502 522
 
503 523
 	$smcFunc['db_insert']('',
504 524
 		'{db_prefix}log_banned',
@@ -508,8 +528,8 @@  discard block
 block discarded – undo
508 528
 	);
509 529
 
510 530
 	// One extra point for these bans.
511
-	if (!empty($ban_ids))
512
-		$smcFunc['db_query']('', '
531
+	if (!empty($ban_ids)) {
532
+			$smcFunc['db_query']('', '
513 533
 			UPDATE {db_prefix}ban_items
514 534
 			SET hits = hits + 1
515 535
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -517,7 +537,8 @@  discard block
 block discarded – undo
517 537
 				'ban_ids' => $ban_ids,
518 538
 			)
519 539
 		);
520
-}
540
+	}
541
+	}
521 542
 
522 543
 /**
523 544
  * Checks if a given email address might be banned.
@@ -533,8 +554,9 @@  discard block
 block discarded – undo
533 554
 	global $txt, $smcFunc;
534 555
 
535 556
 	// Can't ban an empty email
536
-	if (empty($email) || trim($email) == '')
537
-		return;
557
+	if (empty($email) || trim($email) == '') {
558
+			return;
559
+	}
538 560
 
539 561
 	// Let's start with the bans based on your IP/hostname/memberID...
540 562
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -607,16 +629,18 @@  discard block
 block discarded – undo
607 629
 	if ($type == 'post')
608 630
 	{
609 631
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
610
-		if ($check !== $sc)
611
-			$error = 'session_timeout';
632
+		if ($check !== $sc) {
633
+					$error = 'session_timeout';
634
+		}
612 635
 	}
613 636
 
614 637
 	// How about $_GET['sesc']?
615 638
 	elseif ($type == 'get')
616 639
 	{
617 640
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
618
-		if ($check !== $sc)
619
-			$error = 'session_verify_fail';
641
+		if ($check !== $sc) {
642
+					$error = 'session_verify_fail';
643
+		}
620 644
 	}
621 645
 
622 646
 	// Or can it be in either?
@@ -624,13 +648,15 @@  discard block
 block discarded – undo
624 648
 	{
625 649
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
626 650
 
627
-		if ($check !== $sc)
628
-			$error = 'session_verify_fail';
651
+		if ($check !== $sc) {
652
+					$error = 'session_verify_fail';
653
+		}
629 654
 	}
630 655
 
631 656
 	// Verify that they aren't changing user agents on us - that could be bad.
632
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
633
-		$error = 'session_verify_fail';
657
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
658
+			$error = 'session_verify_fail';
659
+	}
634 660
 
635 661
 	// Make sure a page with session check requirement is not being prefetched.
636 662
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -641,30 +667,35 @@  discard block
 block discarded – undo
641 667
 	}
642 668
 
643 669
 	// Check the referring site - it should be the same server at least!
644
-	if (isset($_SESSION['request_referer']))
645
-		$referrer = $_SESSION['request_referer'];
646
-	else
647
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
670
+	if (isset($_SESSION['request_referer'])) {
671
+			$referrer = $_SESSION['request_referer'];
672
+	} else {
673
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
674
+	}
648 675
 	if (!empty($referrer['host']))
649 676
 	{
650
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
651
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
652
-		else
653
-			$real_host = $_SERVER['HTTP_HOST'];
677
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
678
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
679
+		} else {
680
+					$real_host = $_SERVER['HTTP_HOST'];
681
+		}
654 682
 
655 683
 		$parsed_url = parse_url($boardurl);
656 684
 
657 685
 		// Are global cookies on?  If so, let's check them ;).
658 686
 		if (!empty($modSettings['globalCookies']))
659 687
 		{
660
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
661
-				$parsed_url['host'] = $parts[1];
688
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
689
+							$parsed_url['host'] = $parts[1];
690
+			}
662 691
 
663
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
664
-				$referrer['host'] = $parts[1];
692
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
693
+							$referrer['host'] = $parts[1];
694
+			}
665 695
 
666
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
667
-				$real_host = $parts[1];
696
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
697
+							$real_host = $parts[1];
698
+			}
668 699
 		}
669 700
 
670 701
 		// Okay: referrer must either match parsed_url or real_host.
@@ -682,12 +713,14 @@  discard block
 block discarded – undo
682 713
 		$log_error = true;
683 714
 	}
684 715
 
685
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
686
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
716
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
717
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
718
+	}
687 719
 
688 720
 	// Everything is ok, return an empty string.
689
-	if (!isset($error))
690
-		return '';
721
+	if (!isset($error)) {
722
+			return '';
723
+	}
691 724
 	// A session error occurred, show the error.
692 725
 	elseif ($is_fatal)
693 726
 	{
@@ -696,13 +729,14 @@  discard block
 block discarded – undo
696 729
 			ob_end_clean();
697 730
 			send_http_status(403, 'Forbidden - Session timeout');
698 731
 			die;
732
+		} else {
733
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
699 734
 		}
700
-		else
701
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
702 735
 	}
703 736
 	// A session error occurred, return the error to the calling function.
704
-	else
705
-		return $error;
737
+	else {
738
+			return $error;
739
+	}
706 740
 
707 741
 	// We really should never fall through here, for very important reasons.  Let's make sure.
708 742
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -718,10 +752,9 @@  discard block
 block discarded – undo
718 752
 {
719 753
 	global $modSettings;
720 754
 
721
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
722
-		return true;
723
-
724
-	else
755
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
756
+			return true;
757
+	} else
725 758
 	{
726 759
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
727 760
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -772,9 +805,9 @@  discard block
 block discarded – undo
772 805
 			$return = $_SESSION['token'][$type . '-' . $action][3];
773 806
 			unset($_SESSION['token'][$type . '-' . $action]);
774 807
 			return $return;
808
+		} else {
809
+					return '';
775 810
 		}
776
-		else
777
-			return '';
778 811
 	}
779 812
 
780 813
 	// This nasty piece of code validates a token.
@@ -805,12 +838,14 @@  discard block
 block discarded – undo
805 838
 		fatal_lang_error('token_verify_fail', false);
806 839
 	}
807 840
 	// Remove this token as its useless
808
-	else
809
-		unset($_SESSION['token'][$type . '-' . $action]);
841
+	else {
842
+			unset($_SESSION['token'][$type . '-' . $action]);
843
+	}
810 844
 
811 845
 	// Randomly check if we should remove some older tokens.
812
-	if (mt_rand(0, 138) == 23)
813
-		cleanTokens();
846
+	if (mt_rand(0, 138) == 23) {
847
+			cleanTokens();
848
+	}
814 849
 
815 850
 	return false;
816 851
 }
@@ -825,14 +860,16 @@  discard block
 block discarded – undo
825 860
 function cleanTokens($complete = false)
826 861
 {
827 862
 	// We appreciate cleaning up after yourselves.
828
-	if (!isset($_SESSION['token']))
829
-		return;
863
+	if (!isset($_SESSION['token'])) {
864
+			return;
865
+	}
830 866
 
831 867
 	// Clean up tokens, trying to give enough time still.
832
-	foreach ($_SESSION['token'] as $key => $data)
833
-		if ($data[2] + 10800 < time() || $complete)
868
+	foreach ($_SESSION['token'] as $key => $data) {
869
+			if ($data[2] + 10800 < time() || $complete)
834 870
 			unset($_SESSION['token'][$key]);
835
-}
871
+	}
872
+	}
836 873
 
837 874
 /**
838 875
  * Check whether a form has been submitted twice.
@@ -850,37 +887,40 @@  discard block
 block discarded – undo
850 887
 {
851 888
 	global $context;
852 889
 
853
-	if (!isset($_SESSION['forms']))
854
-		$_SESSION['forms'] = array();
890
+	if (!isset($_SESSION['forms'])) {
891
+			$_SESSION['forms'] = array();
892
+	}
855 893
 
856 894
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
857 895
 	if ($action == 'register')
858 896
 	{
859 897
 		$context['form_sequence_number'] = 0;
860
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
861
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
898
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
899
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
900
+		}
862 901
 	}
863 902
 	// Check whether the submitted number can be found in the session.
864 903
 	elseif ($action == 'check')
865 904
 	{
866
-		if (!isset($_REQUEST['seqnum']))
867
-			return true;
868
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
905
+		if (!isset($_REQUEST['seqnum'])) {
906
+					return true;
907
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
869 908
 		{
870 909
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
871 910
 			return true;
911
+		} elseif ($is_fatal) {
912
+					fatal_lang_error('error_form_already_submitted', false);
913
+		} else {
914
+					return false;
872 915
 		}
873
-		elseif ($is_fatal)
874
-			fatal_lang_error('error_form_already_submitted', false);
875
-		else
876
-			return false;
877 916
 	}
878 917
 	// Don't check, just free the stack number.
879
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
880
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
881
-	elseif ($action != 'free')
882
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
883
-}
918
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
919
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
920
+	} elseif ($action != 'free') {
921
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
922
+	}
923
+	}
884 924
 
885 925
 /**
886 926
  * Check the user's permissions.
@@ -899,16 +939,19 @@  discard block
 block discarded – undo
899 939
 	global $user_info, $smcFunc;
900 940
 
901 941
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
902
-	if (empty($permission))
903
-		return true;
942
+	if (empty($permission)) {
943
+			return true;
944
+	}
904 945
 
905 946
 	// You're never allowed to do something if your data hasn't been loaded yet!
906
-	if (empty($user_info))
907
-		return false;
947
+	if (empty($user_info)) {
948
+			return false;
949
+	}
908 950
 
909 951
 	// Administrators are supermen :P.
910
-	if ($user_info['is_admin'])
911
-		return true;
952
+	if ($user_info['is_admin']) {
953
+			return true;
954
+	}
912 955
 
913 956
 	// Let's ensure this is an array.
914 957
 	$permission = (array) $permission;
@@ -916,14 +959,16 @@  discard block
 block discarded – undo
916 959
 	// Are we checking the _current_ board, or some other boards?
917 960
 	if ($boards === null)
918 961
 	{
919
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
920
-			return true;
962
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
963
+					return true;
964
+		}
921 965
 		// You aren't allowed, by default.
922
-		else
923
-			return false;
966
+		else {
967
+					return false;
968
+		}
969
+	} elseif (!is_array($boards)) {
970
+			$boards = array($boards);
924 971
 	}
925
-	elseif (!is_array($boards))
926
-		$boards = array($boards);
927 972
 
928 973
 	$request = $smcFunc['db_query']('', '
929 974
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -951,20 +996,23 @@  discard block
 block discarded – undo
951 996
 		while ($row = $smcFunc['db_fetch_assoc']($request))
952 997
 		{
953 998
 			$result = !empty($row['add_deny']);
954
-			if ($result == true)
955
-				break;
999
+			if ($result == true) {
1000
+							break;
1001
+			}
956 1002
 		}
957 1003
 		$smcFunc['db_free_result']($request);
958 1004
 		return $result;
959 1005
 	}
960 1006
 
961 1007
 	// Make sure they can do it on all of the boards.
962
-	if ($smcFunc['db_num_rows']($request) != count($boards))
963
-		return false;
1008
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1009
+			return false;
1010
+	}
964 1011
 
965 1012
 	$result = true;
966
-	while ($row = $smcFunc['db_fetch_assoc']($request))
967
-		$result &= !empty($row['add_deny']);
1013
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1014
+			$result &= !empty($row['add_deny']);
1015
+	}
968 1016
 	$smcFunc['db_free_result']($request);
969 1017
 
970 1018
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1031,9 +1079,10 @@  discard block
 block discarded – undo
1031 1079
 
1032 1080
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1033 1081
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1034
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1035
-		validateSession();
1036
-}
1082
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1083
+			validateSession();
1084
+	}
1085
+	}
1037 1086
 
1038 1087
 /**
1039 1088
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1064,13 +1113,14 @@  discard block
 block discarded – undo
1064 1113
 	// Administrators are all powerful, sorry.
1065 1114
 	if ($user_info['is_admin'])
1066 1115
 	{
1067
-		if ($simple)
1068
-			return array(0);
1069
-		else
1116
+		if ($simple) {
1117
+					return array(0);
1118
+		} else
1070 1119
 		{
1071 1120
 			$boards = array();
1072
-			foreach ($permissions as $permission)
1073
-				$boards[$permission] = array(0);
1121
+			foreach ($permissions as $permission) {
1122
+							$boards[$permission] = array(0);
1123
+			}
1074 1124
 
1075 1125
 			return $boards;
1076 1126
 		}
@@ -1102,31 +1152,32 @@  discard block
 block discarded – undo
1102 1152
 	{
1103 1153
 		if ($simple)
1104 1154
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$deny_boards[] = $row['id_board'];
1107
-			else
1108
-				$boards[] = $row['id_board'];
1109
-		}
1110
-		else
1155
+			if (empty($row['add_deny'])) {
1156
+							$deny_boards[] = $row['id_board'];
1157
+			} else {
1158
+							$boards[] = $row['id_board'];
1159
+			}
1160
+		} else
1111 1161
 		{
1112
-			if (empty($row['add_deny']))
1113
-				$deny_boards[$row['permission']][] = $row['id_board'];
1114
-			else
1115
-				$boards[$row['permission']][] = $row['id_board'];
1162
+			if (empty($row['add_deny'])) {
1163
+							$deny_boards[$row['permission']][] = $row['id_board'];
1164
+			} else {
1165
+							$boards[$row['permission']][] = $row['id_board'];
1166
+			}
1116 1167
 		}
1117 1168
 	}
1118 1169
 	$smcFunc['db_free_result']($request);
1119 1170
 
1120
-	if ($simple)
1121
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1122
-	else
1171
+	if ($simple) {
1172
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1173
+	} else
1123 1174
 	{
1124 1175
 		foreach ($permissions as $permission)
1125 1176
 		{
1126 1177
 			// never had it to start with
1127
-			if (empty($boards[$permission]))
1128
-				$boards[$permission] = array();
1129
-			else
1178
+			if (empty($boards[$permission])) {
1179
+							$boards[$permission] = array();
1180
+			} else
1130 1181
 			{
1131 1182
 				// Or it may have been removed
1132 1183
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1162,10 +1213,11 @@  discard block
 block discarded – undo
1162 1213
 
1163 1214
 
1164 1215
 	// Moderators are free...
1165
-	if (!allowedTo('moderate_board'))
1166
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1167
-	else
1168
-		$timeLimit = 2;
1216
+	if (!allowedTo('moderate_board')) {
1217
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1218
+	} else {
1219
+			$timeLimit = 2;
1220
+	}
1169 1221
 
1170 1222
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1171 1223
 
@@ -1192,8 +1244,9 @@  discard block
 block discarded – undo
1192 1244
 	if ($smcFunc['db_affected_rows']() != 1)
1193 1245
 	{
1194 1246
 		// Spammer!  You only have to wait a *few* seconds!
1195
-		if (!$only_return_result)
1196
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1247
+		if (!$only_return_result) {
1248
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1249
+		}
1197 1250
 
1198 1251
 		return true;
1199 1252
 	}
@@ -1211,11 +1264,13 @@  discard block
 block discarded – undo
1211 1264
  */
1212 1265
 function secureDirectory($path, $attachments = false)
1213 1266
 {
1214
-	if (empty($path))
1215
-		return 'empty_path';
1267
+	if (empty($path)) {
1268
+			return 'empty_path';
1269
+	}
1216 1270
 
1217
-	if (!is_writable($path))
1218
-		return 'path_not_writable';
1271
+	if (!is_writable($path)) {
1272
+			return 'path_not_writable';
1273
+	}
1219 1274
 
1220 1275
 	$directoryname = basename($path);
1221 1276
 
@@ -1227,9 +1282,9 @@  discard block
 block discarded – undo
1227 1282
 
1228 1283
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1229 1284
 
1230
-	if (file_exists($path . '/.htaccess'))
1231
-		$errors[] = 'htaccess_exists';
1232
-	else
1285
+	if (file_exists($path . '/.htaccess')) {
1286
+			$errors[] = 'htaccess_exists';
1287
+	} else
1233 1288
 	{
1234 1289
 		$fh = @fopen($path . '/.htaccess', 'w');
1235 1290
 		if ($fh)
@@ -1242,9 +1297,9 @@  discard block
 block discarded – undo
1242 1297
 		$errors[] = 'htaccess_cannot_create_file';
1243 1298
 	}
1244 1299
 
1245
-	if (file_exists($path . '/index.php'))
1246
-		$errors[] = 'index-php_exists';
1247
-	else
1300
+	if (file_exists($path . '/index.php')) {
1301
+			$errors[] = 'index-php_exists';
1302
+	} else
1248 1303
 	{
1249 1304
 		$fh = @fopen($path . '/index.php', 'w');
1250 1305
 		if ($fh)
@@ -1272,11 +1327,12 @@  discard block
 block discarded – undo
1272 1327
 		$errors[] = 'index-php_cannot_create_file';
1273 1328
 	}
1274 1329
 
1275
-	if (!empty($errors))
1276
-		return $errors;
1277
-	else
1278
-		return true;
1279
-}
1330
+	if (!empty($errors)) {
1331
+			return $errors;
1332
+	} else {
1333
+			return true;
1334
+	}
1335
+	}
1280 1336
 
1281 1337
 /**
1282 1338
 * This sets the X-Frame-Options header.
@@ -1289,14 +1345,16 @@  discard block
 block discarded – undo
1289 1345
 	global $modSettings;
1290 1346
 
1291 1347
 	$option = 'SAMEORIGIN';
1292
-	if (is_null($override) && !empty($modSettings['frame_security']))
1293
-		$option = $modSettings['frame_security'];
1294
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1295
-		$option = $override;
1348
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1349
+			$option = $modSettings['frame_security'];
1350
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1351
+			$option = $override;
1352
+	}
1296 1353
 
1297 1354
 	// Don't bother setting the header if we have disabled it.
1298
-	if ($option == 'DISABLE')
1299
-		return;
1355
+	if ($option == 'DISABLE') {
1356
+			return;
1357
+	}
1300 1358
 
1301 1359
 	// Finally set it.
1302 1360
 	header('x-frame-options: ' . $option);
Please login to merge, or discard this patch.
Themes/default/ManageSmileys.template.php 1 patch
Braces   +56 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,11 +34,12 @@  discard block
 block discarded – undo
34 34
 		</div>';
35 35
 
36 36
 	// If this is an existing set, and there are still un-added smileys - offer an import opportunity.
37
-	if (!empty($context['current_set']['can_import']))
38
-		echo '
37
+	if (!empty($context['current_set']['can_import'])) {
38
+			echo '
39 39
 		<div class="information noup">
40 40
 			', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), '
41 41
 		</div>';
42
+	}
42 43
 
43 44
 	echo '
44 45
 		<div class="windowbg noup">
@@ -67,17 +68,18 @@  discard block
 block discarded – undo
67 68
 				<dd>
68 69
 					', $modSettings['smileys_url'], '/';
69 70
 
70
-	if (empty($context['smiley_set_dirs']))
71
-		echo '
71
+	if (empty($context['smiley_set_dirs'])) {
72
+			echo '
72 73
 					<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
73
-	else
74
+	} else
74 75
 	{
75 76
 		echo '
76 77
 					<select name="smiley_sets_path" id="smiley_sets_path">';
77 78
 
78
-		foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
79
-			echo '
79
+		foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
80
+					echo '
80 81
 						<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
82
+		}
81 83
 		echo '
82 84
 					</select> ';
83 85
 	}
@@ -92,14 +94,15 @@  discard block
 block discarded – undo
92 94
 				</dd>';
93 95
 
94 96
 	// If this is a new smiley set they have the option to import smileys already in the directory.
95
-	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
96
-		echo '
97
+	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
98
+			echo '
97 99
 				<dt>
98 100
 					<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
99 101
 				</dt>
100 102
 				<dd>
101 103
 					<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
102 104
 				</dd>';
105
+	}
103 106
 
104 107
 	echo '
105 108
 			</dl>
@@ -131,9 +134,10 @@  discard block
 block discarded – undo
131 134
 				<dd>
132 135
 					<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'] . $context['user']['smiley_set_default_ext'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();">';
133 136
 
134
-	foreach ($context['smiley_sets'] as $smiley_set)
135
-		echo '
137
+	foreach ($context['smiley_sets'] as $smiley_set) {
138
+			echo '
136 139
 					<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
140
+	}
137 141
 
138 142
 	echo '
139 143
 					</select>
@@ -149,17 +153,18 @@  discard block
 block discarded – undo
149 153
 				</dt>
150 154
 				<dd>';
151 155
 
152
-	if (empty($context['filenames']))
153
-		echo '
156
+	if (empty($context['filenames'])) {
157
+			echo '
154 158
 					<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
155
-	else
159
+	} else
156 160
 	{
157 161
 		echo '
158 162
 					<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
159 163
 
160
-		foreach ($context['filenames'] as $filename)
161
-			echo '
164
+		foreach ($context['filenames'] as $filename) {
165
+					echo '
162 166
 						<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
167
+		}
163 168
 		echo '
164 169
 					</select>';
165 170
 	}
@@ -226,9 +231,10 @@  discard block
 block discarded – undo
226 231
 					<dd>
227 232
 						', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();selectMethod(\'existing\');">';
228 233
 
229
-	foreach ($context['smiley_sets'] as $smiley_set)
230
-		echo '
234
+	foreach ($context['smiley_sets'] as $smiley_set) {
235
+			echo '
231 236
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
237
+	}
232 238
 
233 239
 	echo '
234 240
 						</select>
@@ -238,17 +244,18 @@  discard block
 block discarded – undo
238 244
 					</dt>
239 245
 					<dd>';
240 246
 
241
-	if (empty($context['filenames']))
242
-		echo '
247
+	if (empty($context['filenames'])) {
248
+			echo '
243 249
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
244
-	else
250
+	} else
245 251
 	{
246 252
 		echo '
247 253
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
248 254
 
249
-		foreach ($context['filenames'] as $filename)
250
-			echo '
255
+		foreach ($context['filenames'] as $filename) {
256
+					echo '
251 257
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
258
+		}
252 259
 		echo '
253 260
 						</select>';
254 261
 	}
@@ -261,14 +268,15 @@  discard block
 block discarded – undo
261 268
 
262 269
 			<dl id="uploadMore" class="settings">';
263 270
 
264
-	foreach ($context['smiley_sets'] as $smiley_set)
265
-		echo '
271
+	foreach ($context['smiley_sets'] as $smiley_set) {
272
+			echo '
266 273
 				<dt>
267 274
 					', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
268 275
 				</dt>
269 276
 				<dd>
270 277
 					<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
271 278
 				</dd>';
279
+	}
272 280
 
273 281
 	echo '
274 282
 			</dl>
@@ -336,27 +344,30 @@  discard block
 block discarded – undo
336 344
 
337 345
 		foreach ($location['rows'] as $row)
338 346
 		{
339
-			if (!empty($context['move_smiley']))
340
-				echo '
347
+			if (!empty($context['move_smiley'])) {
348
+							echo '
341 349
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
350
+			}
342 351
 
343 352
 			foreach ($row as $smiley)
344 353
 			{
345
-				if (empty($context['move_smiley']))
346
-					echo '
354
+				if (empty($context['move_smiley'])) {
355
+									echo '
347 356
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '"></a>';
348
-				else
349
-					echo '
357
+				} else {
358
+									echo '
350 359
 			<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '>
351 360
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
361
+				}
352 362
 			}
353 363
 
354 364
 			echo '
355 365
 			<br>';
356 366
 		}
357
-		if (!empty($context['move_smiley']))
358
-			echo '
367
+		if (!empty($context['move_smiley'])) {
368
+					echo '
359 369
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
370
+		}
360 371
 		echo '
361 372
 		</div><!-- .windowbg -->
362 373
 		<input type="hidden" name="reorder" value="1">
@@ -389,14 +400,15 @@  discard block
 block discarded – undo
389 400
 		<div class="windowbg">
390 401
 			<dl class="settings">';
391 402
 
392
-	if (!$context['new_icon'])
393
-		echo '
403
+	if (!$context['new_icon']) {
404
+			echo '
394 405
 				<dt>
395 406
 					<strong>', $txt['smiley_preview'], ': </strong>
396 407
 				</dt>
397 408
 				<dd>
398 409
 					<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
399 410
 				</dd>';
411
+	}
400 412
 
401 413
 	echo '
402 414
 				<dt>
@@ -423,9 +435,10 @@  discard block
 block discarded – undo
423 435
 		echo '
424 436
 						<optgroup label="', $category['name'], '">';
425 437
 
426
-		foreach ($category['boards'] as $board)
427
-			echo '
438
+		foreach ($category['boards'] as $board) {
439
+					echo '
428 440
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
441
+		}
429 442
 
430 443
 		echo '
431 444
 						</optgroup>';
@@ -442,19 +455,21 @@  discard block
 block discarded – undo
442 455
 						<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
443 456
 
444 457
 	// Print the list of all the icons it can be put after...
445
-	foreach ($context['icons'] as $id => $data)
446
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
458
+	foreach ($context['icons'] as $id => $data) {
459
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
447 460
 			echo '
448 461
 						<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
462
+	}
449 463
 
450 464
 	echo '
451 465
 					</select>
452 466
 				</dd>
453 467
 			</dl>';
454 468
 
455
-	if (!$context['new_icon'])
456
-		echo '
469
+	if (!$context['new_icon']) {
470
+			echo '
457 471
 			<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
472
+	}
458 473
 
459 474
 	echo '
460 475
 			<input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button">
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +154 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
84 87
 
85 88
 	// Check to ensure we're forcing SSL for authentication
86
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -98,23 +102,26 @@  discard block
 block discarded – undo
98 102
 	if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
99 103
 	{
100 104
 		// First check for 2.1 json-format cookie in $_COOKIE
101
-		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1)
102
-			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
105
+		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) {
106
+					list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
107
+		}
103 108
 
104 109
 		// Try checking for 2.1 json-format cookie in $_SESSION
105
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1)
106
-			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
110
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) {
111
+					list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
112
+		}
107 113
 
108 114
 		// Next, try checking for 2.0 serialized string cookie in $_COOKIE
109
-		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1)
110
-			list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
115
+		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) {
116
+					list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
117
+		}
111 118
 
112 119
 		// Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION
113
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1)
114
-			list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
115
-
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
120
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) {
121
+					list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
122
+		} else {
123
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
124
+		}
118 125
 
119 126
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 127
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -134,24 +141,23 @@  discard block
 block discarded – undo
134 141
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
135 142
 	{
136 143
 		// Strike!  You're outta there!
137
-		if ($_GET['member'] != $user_info['id'])
138
-			fatal_lang_error('login_cookie_error', false);
144
+		if ($_GET['member'] != $user_info['id']) {
145
+					fatal_lang_error('login_cookie_error', false);
146
+		}
139 147
 
140 148
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
141 149
 
142 150
 		// Some whitelisting for login_url...
143
-		if (empty($_SESSION['login_url']))
144
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
145
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
151
+		if (empty($_SESSION['login_url'])) {
152
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
153
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
146 154
 		{
147 155
 			unset ($_SESSION['login_url']);
148 156
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
149
-		}
150
-		elseif (!empty($user_settings['tfa_secret']))
157
+		} elseif (!empty($user_settings['tfa_secret']))
151 158
 		{
152 159
 			redirectexit('action=logintfa');
153
-		}
154
-		else
160
+		} else
155 161
 		{
156 162
 			// Best not to clutter the session data too much...
157 163
 			$temp = $_SESSION['login_url'];
@@ -162,8 +168,9 @@  discard block
 block discarded – undo
162 168
 	}
163 169
 
164 170
 	// Beyond this point you are assumed to be a guest trying to login.
165
-	if (!$user_info['is_guest'])
166
-		redirectexit();
171
+	if (!$user_info['is_guest']) {
172
+			redirectexit();
173
+	}
167 174
 
168 175
 	// Are you guessing with a script?
169 176
 	checkSession();
@@ -171,18 +178,21 @@  discard block
 block discarded – undo
171 178
 	spamProtection('login');
172 179
 
173 180
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
174
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
175
-		$_SESSION['login_url'] = $_SESSION['old_url'];
181
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
182
+			$_SESSION['login_url'] = $_SESSION['old_url'];
183
+	}
176 184
 
177 185
 	// Been guessing a lot, haven't we?
178
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
179
-		fatal_lang_error('login_threshold_fail', 'login');
186
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
187
+			fatal_lang_error('login_threshold_fail', 'login');
188
+	}
180 189
 
181 190
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
182
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
183
-		$modSettings['cookieTime'] = 3153600;
184
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600))
185
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
191
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
192
+			$modSettings['cookieTime'] = 3153600;
193
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) {
194
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
195
+	}
186 196
 
187 197
 	loadLanguage('Login');
188 198
 	// Load the template stuff.
@@ -302,8 +312,9 @@  discard block
 block discarded – undo
302 312
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
303 313
 
304 314
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
305
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
306
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
315
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
316
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
317
+			}
307 318
 
308 319
 			// phpBB3 users new hashing.  We now support it as well ;).
309 320
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -323,27 +334,29 @@  discard block
 block discarded – undo
323 334
 			// Some common md5 ones.
324 335
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
325 336
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
326
-		}
327
-		elseif (strlen($user_settings['passwd']) == 40)
337
+		} elseif (strlen($user_settings['passwd']) == 40)
328 338
 		{
329 339
 			// Maybe they are using a hash from before the password fix.
330 340
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
331 341
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
332 342
 
333 343
 			// BurningBoard3 style of hashing.
334
-			if (!empty($modSettings['enable_password_conversion']))
335
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
344
+			if (!empty($modSettings['enable_password_conversion'])) {
345
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
346
+			}
336 347
 
337 348
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
338 349
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
339 350
 			{
340 351
 				// Try iconv first, for no particular reason.
341
-				if (function_exists('iconv'))
342
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
352
+				if (function_exists('iconv')) {
353
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
354
+				}
343 355
 
344 356
 				// Say it aint so, iconv failed!
345
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
346
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
357
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
358
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
359
+				}
347 360
 			}
348 361
 		}
349 362
 
@@ -373,8 +386,9 @@  discard block
 block discarded – undo
373 386
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
374 387
 
375 388
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
376
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
377
-				redirectexit('action=reminder');
389
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
390
+							redirectexit('action=reminder');
391
+			}
378 392
 			// We'll give you another chance...
379 393
 			else
380 394
 			{
@@ -385,8 +399,7 @@  discard block
 block discarded – undo
385 399
 				return;
386 400
 			}
387 401
 		}
388
-	}
389
-	elseif (!empty($user_settings['passwd_flood']))
402
+	} elseif (!empty($user_settings['passwd_flood']))
390 403
 	{
391 404
 		// Let's be sure they weren't a little hacker.
392 405
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -403,8 +416,9 @@  discard block
 block discarded – undo
403 416
 	}
404 417
 
405 418
 	// Check their activation status.
406
-	if (!checkActivation())
407
-		return;
419
+	if (!checkActivation()) {
420
+			return;
421
+	}
408 422
 
409 423
 	DoLogin();
410 424
 }
@@ -416,8 +430,9 @@  discard block
 block discarded – undo
416 430
 {
417 431
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
418 432
 
419
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
420
-		fatal_lang_error('no_access', false);
433
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
434
+			fatal_lang_error('no_access', false);
435
+	}
421 436
 
422 437
 	loadLanguage('Profile');
423 438
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -425,8 +440,9 @@  discard block
 block discarded – undo
425 440
 	$member = $context['tfa_member'];
426 441
 
427 442
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
428
-	if (time() - $member['last_login'] < 120)
429
-		fatal_lang_error('tfa_wait', false);
443
+	if (time() - $member['last_login'] < 120) {
444
+			fatal_lang_error('tfa_wait', false);
445
+	}
430 446
 
431 447
 	$totp = new \TOTP\Auth($member['tfa_secret']);
432 448
 	$totp->setRange(1);
@@ -440,8 +456,9 @@  discard block
 block discarded – undo
440 456
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
441 457
 	{
442 458
 		// Check to ensure we're forcing SSL for authentication
443
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
444
-			fatal_lang_error('login_ssl_required');
459
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
460
+					fatal_lang_error('login_ssl_required');
461
+		}
445 462
 
446 463
 		$code = $_POST['tfa_code'];
447 464
 
@@ -451,20 +468,19 @@  discard block
 block discarded – undo
451 468
 
452 469
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
453 470
 			redirectexit();
454
-		}
455
-		else
471
+		} else
456 472
 		{
457 473
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
458 474
 
459 475
 			$context['tfa_error'] = true;
460 476
 			$context['tfa_value'] = $_POST['tfa_code'];
461 477
 		}
462
-	}
463
-	elseif (!empty($_POST['tfa_backup']))
478
+	} elseif (!empty($_POST['tfa_backup']))
464 479
 	{
465 480
 		// Check to ensure we're forcing SSL for authentication
466
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
467
-			fatal_lang_error('login_ssl_required');
481
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
482
+					fatal_lang_error('login_ssl_required');
483
+		}
468 484
 
469 485
 		$backup = $_POST['tfa_backup'];
470 486
 
@@ -478,8 +494,7 @@  discard block
 block discarded – undo
478 494
 			));
479 495
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
480 496
 			redirectexit('action=profile;area=tfasetup;backup');
481
-		}
482
-		else
497
+		} else
483 498
 		{
484 499
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
485 500
 
@@ -502,8 +517,9 @@  discard block
 block discarded – undo
502 517
 {
503 518
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
504 519
 
505
-	if (!isset($context['login_errors']))
506
-		$context['login_errors'] = array();
520
+	if (!isset($context['login_errors'])) {
521
+			$context['login_errors'] = array();
522
+	}
507 523
 
508 524
 	// What is the true activation status of this account?
509 525
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -515,8 +531,9 @@  discard block
 block discarded – undo
515 531
 		return false;
516 532
 	}
517 533
 	// Awaiting approval still?
518
-	elseif ($activation_status == 3)
519
-		fatal_lang_error('still_awaiting_approval', 'user');
534
+	elseif ($activation_status == 3) {
535
+			fatal_lang_error('still_awaiting_approval', 'user');
536
+	}
520 537
 	// Awaiting deletion, changed their mind?
521 538
 	elseif ($activation_status == 4)
522 539
 	{
@@ -524,8 +541,7 @@  discard block
 block discarded – undo
524 541
 		{
525 542
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
526 543
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
527
-		}
528
-		else
544
+		} else
529 545
 		{
530 546
 			$context['disable_login_hashing'] = true;
531 547
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -565,8 +581,9 @@  discard block
 block discarded – undo
565 581
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
566 582
 
567 583
 	// Reset the login threshold.
568
-	if (isset($_SESSION['failed_login']))
569
-		unset($_SESSION['failed_login']);
584
+	if (isset($_SESSION['failed_login'])) {
585
+			unset($_SESSION['failed_login']);
586
+	}
570 587
 
571 588
 	$user_info['is_guest'] = false;
572 589
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -588,16 +605,18 @@  discard block
 block discarded – undo
588 605
 			'id_member' => $user_info['id'],
589 606
 		)
590 607
 	);
591
-	if ($smcFunc['db_num_rows']($request) == 1)
592
-		$_SESSION['first_login'] = true;
593
-	else
594
-		unset($_SESSION['first_login']);
608
+	if ($smcFunc['db_num_rows']($request) == 1) {
609
+			$_SESSION['first_login'] = true;
610
+	} else {
611
+			unset($_SESSION['first_login']);
612
+	}
595 613
 	$smcFunc['db_free_result']($request);
596 614
 
597 615
 	// You've logged in, haven't you?
598 616
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
599
-	if (empty($user_settings['tfa_secret']))
600
-		$update['last_login'] = time();
617
+	if (empty($user_settings['tfa_secret'])) {
618
+			$update['last_login'] = time();
619
+	}
601 620
 	updateMemberData($user_info['id'], $update);
602 621
 
603 622
 	// Get rid of the online entry for that old guest....
@@ -611,8 +630,8 @@  discard block
 block discarded – undo
611 630
 	$_SESSION['log_time'] = 0;
612 631
 
613 632
 	// Log this entry, only if we have it enabled.
614
-	if (!empty($modSettings['loginHistoryDays']))
615
-		$smcFunc['db_insert']('insert',
633
+	if (!empty($modSettings['loginHistoryDays'])) {
634
+			$smcFunc['db_insert']('insert',
616 635
 			'{db_prefix}member_logins',
617 636
 			array(
618 637
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -624,13 +643,15 @@  discard block
 block discarded – undo
624 643
 				'id_member', 'time'
625 644
 			)
626 645
 		);
646
+	}
627 647
 
628 648
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
629
-	if (empty($maintenance) || allowedTo('admin_forum'))
630
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
631
-	else
632
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
633
-}
649
+	if (empty($maintenance) || allowedTo('admin_forum')) {
650
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
651
+	} else {
652
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
653
+	}
654
+	}
634 655
 
635 656
 /**
636 657
  * Logs the current user out of their account.
@@ -646,13 +667,15 @@  discard block
 block discarded – undo
646 667
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
647 668
 
648 669
 	// Make sure they aren't being auto-logged out.
649
-	if (!$internal)
650
-		checkSession('get');
670
+	if (!$internal) {
671
+			checkSession('get');
672
+	}
651 673
 
652 674
 	require_once($sourcedir . '/Subs-Auth.php');
653 675
 
654
-	if (isset($_SESSION['pack_ftp']))
655
-		$_SESSION['pack_ftp'] = null;
676
+	if (isset($_SESSION['pack_ftp'])) {
677
+			$_SESSION['pack_ftp'] = null;
678
+	}
656 679
 
657 680
 	// It won't be first login anymore.
658 681
 	unset($_SESSION['first_login']);
@@ -680,8 +703,9 @@  discard block
 block discarded – undo
680 703
 
681 704
 	// And some other housekeeping while we're at it.
682 705
 	$salt = substr(md5(mt_rand()), 0, 4);
683
-	if (!empty($user_info['id']))
684
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
706
+	if (!empty($user_info['id'])) {
707
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
708
+	}
685 709
 
686 710
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
687 711
 	{
@@ -694,14 +718,13 @@  discard block
 block discarded – undo
694 718
 	// Off to the merry board index we go!
695 719
 	if ($redirect)
696 720
 	{
697
-		if (empty($_SESSION['logout_url']))
698
-			redirectexit('', $context['server']['needs_login_fix']);
699
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
721
+		if (empty($_SESSION['logout_url'])) {
722
+					redirectexit('', $context['server']['needs_login_fix']);
723
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
700 724
 		{
701 725
 			unset ($_SESSION['logout_url']);
702 726
 			redirectexit();
703
-		}
704
-		else
727
+		} else
705 728
 		{
706 729
 			$temp = $_SESSION['logout_url'];
707 730
 			unset($_SESSION['logout_url']);
@@ -734,8 +757,9 @@  discard block
 block discarded – undo
734 757
 function phpBB3_password_check($passwd, $passwd_hash)
735 758
 {
736 759
 	// Too long or too short?
737
-	if (strlen($passwd_hash) != 34)
738
-		return;
760
+	if (strlen($passwd_hash) != 34) {
761
+			return;
762
+	}
739 763
 
740 764
 	// Range of characters allowed.
741 765
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -746,8 +770,9 @@  discard block
 block discarded – undo
746 770
 	$salt = substr($passwd_hash, 4, 8);
747 771
 
748 772
 	$hash = md5($salt . $passwd, true);
749
-	for (; $count != 0; --$count)
750
-		$hash = md5($hash . $passwd, true);
773
+	for (; $count != 0; --$count) {
774
+			$hash = md5($hash . $passwd, true);
775
+	}
751 776
 
752 777
 	$output = substr($passwd_hash, 0, 12);
753 778
 	$i = 0;
@@ -756,21 +781,25 @@  discard block
 block discarded – undo
756 781
 		$value = ord($hash[$i++]);
757 782
 		$output .= $range[$value & 0x3f];
758 783
 
759
-		if ($i < 16)
760
-			$value |= ord($hash[$i]) << 8;
784
+		if ($i < 16) {
785
+					$value |= ord($hash[$i]) << 8;
786
+		}
761 787
 
762 788
 		$output .= $range[($value >> 6) & 0x3f];
763 789
 
764
-		if ($i++ >= 16)
765
-			break;
790
+		if ($i++ >= 16) {
791
+					break;
792
+		}
766 793
 
767
-		if ($i < 16)
768
-			$value |= ord($hash[$i]) << 16;
794
+		if ($i < 16) {
795
+					$value |= ord($hash[$i]) << 16;
796
+		}
769 797
 
770 798
 		$output .= $range[($value >> 12) & 0x3f];
771 799
 
772
-		if ($i++ >= 16)
773
-			break;
800
+		if ($i++ >= 16) {
801
+					break;
802
+		}
774 803
 
775 804
 		$output .= $range[($value >> 18) & 0x3f];
776 805
 	}
@@ -802,8 +831,9 @@  discard block
 block discarded – undo
802 831
 		require_once($sourcedir . '/Subs-Auth.php');
803 832
 		setLoginCookie(-3600, 0);
804 833
 
805
-		if (isset($_SESSION['login_' . $cookiename]))
806
-			unset($_SESSION['login_' . $cookiename]);
834
+		if (isset($_SESSION['login_' . $cookiename])) {
835
+					unset($_SESSION['login_' . $cookiename]);
836
+		}
807 837
 	}
808 838
 
809 839
 	// We need a member!
@@ -817,8 +847,9 @@  discard block
 block discarded – undo
817 847
 	}
818 848
 
819 849
 	// Right, have we got a flood value?
820
-	if ($password_flood_value !== false)
821
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
850
+	if ($password_flood_value !== false) {
851
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
852
+	}
822 853
 
823 854
 	// Timestamp or number of tries invalid?
824 855
 	if (empty($number_tries) || empty($time_stamp))
@@ -834,15 +865,17 @@  discard block
 block discarded – undo
834 865
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
835 866
 
836 867
 		// They are trying too fast, make them wait longer
837
-		if ($time_stamp < time() - 10)
838
-			$time_stamp = time();
868
+		if ($time_stamp < time() - 10) {
869
+					$time_stamp = time();
870
+		}
839 871
 	}
840 872
 
841 873
 	$number_tries++;
842 874
 
843 875
 	// Broken the law?
844
-	if ($number_tries > 5)
845
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
876
+	if ($number_tries > 5) {
877
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
878
+	}
846 879
 
847 880
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
848 881
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
Themes/default/Post.template.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 										<div class="bar"></div>
402 402
 									</div>
403 403
 									<div class="attach-ui">
404
-										<a data-dz-remove class="button cancel">', $txt['modify_cancel'] ,'</a>
405
-										<a class="button upload">', $txt['upload'] ,'</a>
404
+										<a data-dz-remove class="button cancel">', $txt['modify_cancel'], '</a>
405
+										<a class="button upload">', $txt['upload'], '</a>
406 406
 									</div>
407 407
 								</div><!-- .attach-info -->
408 408
 							</div><!-- #au-template -->
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 							</dt>
420 420
 							<dd class="smalltext fallback">
421 421
 								<div id="attachUpload" class="descbox">
422
-									<h5>', $txt['attach_drop_zone'] ,'</h5>
423
-									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a>
424
-									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a>
425
-									<a class="button fileinput-button">', $txt['attach_add'] ,'</a>
422
+									<h5>', $txt['attach_drop_zone'], '</h5>
423
+									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a>
424
+									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a>
425
+									<a class="button fileinput-button">', $txt['attach_add'], '</a>
426 426
 									<div id="total-progress" class="progress_bar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
427 427
 										<div class="bar"></div>
428 428
 									</div>
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	// Option to delete an event if user is editing one.
533 533
 	if ($context['make_event'] && !$context['event']['new'])
534 534
 		echo '
535
-						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
535
+						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button you_sure">';
536 536
 
537 537
 	echo '
538 538
 					</span>
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
 	$newPostsHTML .= '
576 576
 			<br class="clear">
577
-			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] .  '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
577
+			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] . '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
578 578
 			<div class="list_posts smalltext" id="msg_%PostID%_body">%PostBody%</div>
579 579
 		</div>';
580 580
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			});';
661 661
 
662 662
 	echo '
663
-			var oEditorID = "', $context['post_box_name'] ,'";
663
+			var oEditorID = "', $context['post_box_name'], '";
664 664
 			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
665 665
 		</script>';
666 666
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			if ($context['can_quote'])
693 693
 				echo '
694 694
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695
-						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
695
+						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>
696 696
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 697
 					</ul>';
698 698
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	<head>
778 778
 		<meta charset="', $context['character_set'], '">
779 779
 		<title>', $txt['spell_check'], '</title>
780
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
780
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
781 781
 		<style>
782 782
 			body, td {
783 783
 				font-size: small;
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 			var spell_formname = window.opener.spell_formname;
808 808
 			var spell_fieldname = window.opener.spell_fieldname;
809 809
 		</script>
810
-		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script>
811
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
810
+		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script>
811
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
812 812
 		<script>
813 813
 			', $context['spell_js'], '
814 814
 		</script>
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 	<head>
853 853
 		<meta charset="', $context['character_set'], '">
854 854
 		<title>', $txt['retrieving_quote'], '</title>
855
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
855
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
856 856
 	</head>
857 857
 	<body>
858 858
 		', $txt['retrieving_quote'], '
Please login to merge, or discard this patch.
Braces   +184 added lines, -131 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	template_post_header();
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 				echo '
163 171
 										<optgroup label="', $category['name'], '">';
164 172
 
165
-				foreach ($category['boards'] as $board)
166
-					echo '
173
+				foreach ($category['boards'] as $board) {
174
+									echo '
167 175
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
176
+				}
168 177
 				echo '
169 178
 										</optgroup>';
170 179
 			}
@@ -200,9 +209,10 @@  discard block
 block discarded – undo
200 209
 									<span class="label">', $txt['calendar_timezone'], '</span>
201 210
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
202 211
 
203
-		foreach ($context['all_timezones'] as $tz => $tzname)
204
-			echo '
212
+		foreach ($context['all_timezones'] as $tz => $tzname) {
213
+					echo '
205 214
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
215
+		}
206 216
 
207 217
 		echo '
208 218
 									</select>
@@ -231,14 +241,15 @@  discard block
 block discarded – undo
231 241
 								</dd>';
232 242
 
233 243
 		// Loop through all the choices and print them out.
234
-		foreach ($context['choices'] as $choice)
235
-			echo '
244
+		foreach ($context['choices'] as $choice) {
245
+					echo '
236 246
 								<dt>
237 247
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
238 248
 								</dt>
239 249
 								<dd>
240 250
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
241 251
 								</dd>';
252
+		}
242 253
 
243 254
 		echo '
244 255
 								<p id="pollMoreOptions"></p>
@@ -268,14 +279,15 @@  discard block
 block discarded – undo
268 279
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
269 280
 								</dd>';
270 281
 
271
-		if ($context['poll_options']['guest_vote_enabled'])
272
-			echo '
282
+		if ($context['poll_options']['guest_vote_enabled']) {
283
+					echo '
273 284
 								<dt>
274 285
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
275 286
 								</dt>
276 287
 								<dd>
277 288
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
278 289
 								</dd>';
290
+		}
279 291
 
280 292
 		echo '
281 293
 								<dt>
@@ -296,8 +308,8 @@  discard block
 block discarded – undo
296 308
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
297 309
 
298 310
 	// If we're editing and displaying edit details, show a box where they can say why
299
-	if (isset($context['editing']) && $modSettings['show_modify'])
300
-		echo '
311
+	if (isset($context['editing']) && $modSettings['show_modify']) {
312
+			echo '
301 313
 					<dl>
302 314
 						<dt class="clear">
303 315
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -306,20 +318,23 @@  discard block
 block discarded – undo
306 318
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
307 319
 						</dd>
308 320
 					</dl>';
321
+	}
309 322
 
310 323
 	// If this message has been edited in the past - display when it was.
311
-	if (isset($context['last_modified']))
312
-		echo '
324
+	if (isset($context['last_modified'])) {
325
+			echo '
313 326
 					<div class="padding smalltext">
314 327
 						', $context['last_modified_text'], '
315 328
 					</div>';
329
+	}
316 330
 
317 331
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
318
-	if (!empty($modSettings['additional_options_collapsable']))
319
-		echo '
332
+	if (!empty($modSettings['additional_options_collapsable'])) {
333
+			echo '
320 334
 					<div id="postAdditionalOptionsHeader">
321 335
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
322 336
 					</div>';
337
+	}
323 338
 
324 339
 	echo '
325 340
 					<div id="postAdditionalOptions">';
@@ -352,19 +367,21 @@  discard block
 block discarded – undo
352 367
 								', $txt['uncheck_unwatchd_attach'], ':
353 368
 							</dd>';
354 369
 
355
-		foreach ($context['current_attachments'] as $attachment)
356
-			echo '
370
+		foreach ($context['current_attachments'] as $attachment) {
371
+					echo '
357 372
 							<dd class="smalltext">
358 373
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
359 374
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
360 375
 							</dd>';
376
+		}
361 377
 
362 378
 		echo '
363 379
 						</dl>';
364 380
 
365
-		if (!empty($context['files_in_session_warning']))
366
-			echo '
381
+		if (!empty($context['files_in_session_warning'])) {
382
+					echo '
367 383
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
384
+		}
368 385
 	}
369 386
 
370 387
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -429,13 +446,14 @@  discard block
 block discarded – undo
429 446
 									<div class="fallback">
430 447
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
431 448
 
432
-		if (!empty($modSettings['attachmentSizeLimit']))
433
-			echo '
449
+		if (!empty($modSettings['attachmentSizeLimit'])) {
450
+					echo '
434 451
 										<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';
452
+		}
435 453
 
436 454
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
455
+		if ($context['num_allowed_attachments'] > 1) {
456
+					echo '
439 457
 										<script>
440 458
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 459
 											var current_attachment = 1;
@@ -455,6 +473,7 @@  discard block
 block discarded – undo
455 473
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
456 474
 									</div><!-- .fallback -->
457 475
 								</div><!-- #attachUpload -->';
476
+		}
458 477
 
459 478
 		echo '
460 479
 							</dd>';
@@ -466,21 +485,25 @@  discard block
 block discarded – undo
466 485
 							<dd class="smalltext">';
467 486
 
468 487
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
469
-		if (!empty($modSettings['attachmentCheckExtensions']))
470
-			echo '
488
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
489
+					echo '
471 490
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
491
+		}
472 492
 
473
-		if (!empty($context['attachment_restrictions']))
474
-			echo '
493
+		if (!empty($context['attachment_restrictions'])) {
494
+					echo '
475 495
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
496
+		}
476 497
 
477
-		if ($context['num_allowed_attachments'] == 0)
478
-			echo '
498
+		if ($context['num_allowed_attachments'] == 0) {
499
+					echo '
479 500
 								', $txt['attach_limit_nag'], '<br>';
501
+		}
480 502
 
481
-		if (!$context['can_post_attachment_unapproved'])
482
-			echo '
503
+		if (!$context['can_post_attachment_unapproved']) {
504
+					echo '
483 505
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
506
+		}
484 507
 
485 508
 		echo '
486 509
 							</dd>
@@ -504,24 +527,26 @@  discard block
 block discarded – undo
504 527
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 528
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 529
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
530
+		foreach ($context['drafts'] as $draft) {
531
+					echo '
509 532
 							<dt>', $draft['link'], '</dt>
510 533
 							<dd>', $draft['poster_time'], '</dd>';
534
+		}
511 535
 		echo '
512 536
 						</dl>
513 537
 					</div>';
514 538
 	}
515 539
 
516 540
 	// Is visual verification enabled?
517
-	if ($context['require_verification'])
518
-		echo '
541
+	if ($context['require_verification']) {
542
+			echo '
519 543
 					<div class="post_verification">
520 544
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
521 545
 							<strong>', $txt['verification'], ':</strong>
522 546
 						</span>
523 547
 						', template_control_verification($context['visual_verification_id'], 'all'), '
524 548
 					</div>';
549
+	}
525 550
 
526 551
 	// Finally, the submit buttons.
527 552
 	echo '
@@ -530,9 +555,10 @@  discard block
 block discarded – undo
530 555
 						', template_control_richedit_buttons($context['post_box_name']);
531 556
 
532 557
 	// Option to delete an event if user is editing one.
533
-	if ($context['make_event'] && !$context['event']['new'])
534
-		echo '
558
+	if ($context['make_event'] && !$context['event']['new']) {
559
+			echo '
535 560
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
561
+	}
536 562
 
537 563
 	echo '
538 564
 					</span>
@@ -541,9 +567,10 @@  discard block
 block discarded – undo
541 567
 			<br class="clear">';
542 568
 
543 569
 	// Assuming this isn't a new topic pass across the last message id.
544
-	if (isset($context['topic_last_message']))
545
-		echo '
570
+	if (isset($context['topic_last_message'])) {
571
+			echo '
546 572
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
573
+	}
547 574
 
548 575
 	echo '
549 576
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -564,13 +591,14 @@  discard block
 block discarded – undo
564 591
 			</h5>
565 592
 			&nbsp;-&nbsp;%PostTime%&nbsp;&#187; <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>';
566 593
 
567
-	if ($context['can_quote'])
568
-		$newPostsHTML .= '
594
+	if ($context['can_quote']) {
595
+			$newPostsHTML .= '
569 596
 			<ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;">
570 597
 				<li id="post_modify">
571 598
 					<a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a>
572 599
 				</li>
573 600
 			</ul>';
601
+	}
574 602
 
575 603
 	$newPostsHTML .= '
576 604
 			<br class="clear">
@@ -596,16 +624,17 @@  discard block
 block discarded – undo
596 624
 				sSessionVar: ', JavaScriptEscape($context['session_var']), ',
597 625
 				newPostsTemplate:', JavaScriptEscape($newPostsHTML);
598 626
 
599
-	if (!empty($context['current_board']))
600
-		echo ',
627
+	if (!empty($context['current_board'])) {
628
+			echo ',
601 629
 				iCurrentBoard: ', $context['current_board'], '';
630
+	}
602 631
 
603 632
 	echo '
604 633
 			});';
605 634
 
606 635
 	// Code for showing and hiding additional options.
607
-	if (!empty($modSettings['additional_options_collapsable']))
608
-		echo '
636
+	if (!empty($modSettings['additional_options_collapsable'])) {
637
+			echo '
609 638
 			var oSwapAdditionalOptions = new smc_Toggle({
610 639
 				bToggleEnabled: true,
611 640
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -633,10 +662,11 @@  discard block
 block discarded – undo
633 662
 					}
634 663
 				]
635 664
 			});';
665
+	}
636 666
 
637 667
 	// Code for showing and hiding drafts
638
-	if (!empty($context['drafts']))
639
-		echo '
668
+	if (!empty($context['drafts'])) {
669
+			echo '
640 670
 			var oSwapDraftOptions = new smc_Toggle({
641 671
 				bToggleEnabled: true,
642 672
 				bCurrentlyCollapsed: true,
@@ -658,6 +688,7 @@  discard block
 block discarded – undo
658 688
 					}
659 689
 				]
660 690
 			});';
691
+	}
661 692
 
662 693
 	echo '
663 694
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -678,8 +709,9 @@  discard block
 block discarded – undo
678 709
 		foreach ($context['previous_posts'] as $post)
679 710
 		{
680 711
 			$ignoring = false;
681
-			if (!empty($post['is_ignored']))
682
-				$ignored_posts[] = $ignoring = $post['id'];
712
+			if (!empty($post['is_ignored'])) {
713
+							$ignored_posts[] = $ignoring = $post['id'];
714
+			}
683 715
 
684 716
 			echo '
685 717
 			<div class="windowbg">
@@ -689,22 +721,24 @@  discard block
 block discarded – undo
689 721
 					</h5>
690 722
 					&nbsp;-&nbsp;', $post['time'];
691 723
 
692
-			if ($context['can_quote'])
693
-				echo '
724
+			if ($context['can_quote']) {
725
+							echo '
694 726
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695 727
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
696 728
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 729
 					</ul>';
730
+			}
698 731
 
699 732
 			echo '
700 733
 					<br class="clear">';
701 734
 
702
-			if ($ignoring)
703
-				echo '
735
+			if ($ignoring) {
736
+							echo '
704 737
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
705 738
 						', $txt['ignoring_user'], '
706 739
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
707 740
 					</div>';
741
+			}
708 742
 
709 743
 			echo '
710 744
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -859,10 +893,10 @@  discard block
 block discarded – undo
859 893
 		<div id="temporary_posting_area" style="display: none;"></div>
860 894
 		<script>';
861 895
 
862
-	if ($context['close_window'])
863
-		echo '
896
+	if ($context['close_window']) {
897
+			echo '
864 898
 			window.close();';
865
-	else
899
+	} else
866 900
 	{
867 901
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
868 902
 		echo '
@@ -916,11 +950,12 @@  discard block
 block discarded – undo
916 950
 				</p>
917 951
 				<ul>';
918 952
 
919
-	foreach ($context['groups'] as $group)
920
-		echo '
953
+	foreach ($context['groups'] as $group) {
954
+			echo '
921 955
 					<li>
922 956
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
923 957
 					</li>';
958
+	}
924 959
 
925 960
 	echo '
926 961
 					<li>
@@ -1027,28 +1062,32 @@  discard block
 block discarded – undo
1027 1062
 	foreach ($context['posting_fields'] as $pfid => $pf)
1028 1063
 	{
1029 1064
 		// We need both a label and an input
1030
-		if (empty($pf['label']) || empty($pf['input']))
1031
-			continue;
1065
+		if (empty($pf['label']) || empty($pf['input'])) {
1066
+					continue;
1067
+		}
1032 1068
 
1033 1069
 		// The labels are pretty simple...
1034 1070
 		echo '
1035 1071
 						<dt class="clear pf_', $pfid, '">';
1036 1072
 
1037 1073
 		// Any leading HTML before the label
1038
-		if (!empty($pf['label']['before']))
1039
-			echo '
1074
+		if (!empty($pf['label']['before'])) {
1075
+					echo '
1040 1076
 							', $pf['label']['before'];
1077
+		}
1041 1078
 
1042
-		if (!empty($pf['label']['html']))
1043
-			echo $pf['label']['html'];
1044
-		else
1045
-			echo '
1079
+		if (!empty($pf['label']['html'])) {
1080
+					echo $pf['label']['html'];
1081
+		} else {
1082
+					echo '
1046 1083
 							<label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>';
1084
+		}
1047 1085
 
1048 1086
 		// Any trailing HTML after the label
1049
-		if (!empty($pf['label']['after']))
1050
-			echo '
1087
+		if (!empty($pf['label']['after'])) {
1088
+					echo '
1051 1089
 							', $pf['label']['after'];
1090
+		}
1052 1091
 
1053 1092
 		echo '
1054 1093
 						</dt>';
@@ -1058,9 +1097,10 @@  discard block
 block discarded – undo
1058 1097
 						<dd class="pf_', $pfid, '">';
1059 1098
 
1060 1099
 		// Any leading HTML before the main input
1061
-		if (!empty($pf['input']['before']))
1062
-			echo '
1100
+		if (!empty($pf['input']['before'])) {
1101
+					echo '
1063 1102
 							', $pf['input']['before'];
1103
+		}
1064 1104
 
1065 1105
 		// If there is a literal HTML string already defined, just print it.
1066 1106
 		if (!empty($pf['input']['html']))
@@ -1073,17 +1113,19 @@  discard block
 block discarded – undo
1073 1113
 			echo '
1074 1114
 							<input type="', $pf['input']['type'], '"';
1075 1115
 
1076
-			if (empty($pf['input']['attributes']['name']))
1077
-				echo ' name="', $pfid, '"';
1116
+			if (empty($pf['input']['attributes']['name'])) {
1117
+							echo ' name="', $pfid, '"';
1118
+			}
1078 1119
 
1079 1120
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1080 1121
 			{
1081 1122
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1082 1123
 				{
1083
-					if (is_bool($value))
1084
-						echo $value ? ' ' . $attribute : '';
1085
-					else
1086
-						echo ' ', $attribute, '="', $value, '"';
1124
+					if (is_bool($value)) {
1125
+											echo $value ? ' ' . $attribute : '';
1126
+					} else {
1127
+											echo ' ', $attribute, '="', $value, '"';
1128
+					}
1087 1129
 				}
1088 1130
 			}
1089 1131
 
@@ -1095,19 +1137,21 @@  discard block
 block discarded – undo
1095 1137
 			echo '
1096 1138
 							<textarea';
1097 1139
 
1098
-			if (empty($pf['input']['attributes']['name']))
1099
-				echo ' name="', $pfid, '"';
1140
+			if (empty($pf['input']['attributes']['name'])) {
1141
+							echo ' name="', $pfid, '"';
1142
+			}
1100 1143
 
1101 1144
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1102 1145
 			{
1103 1146
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1104 1147
 				{
1105
-					if ($attribute === 'value')
1106
-						continue;
1107
-					elseif (is_bool($value))
1108
-						echo $value ? ' ' . $attribute : '';
1109
-					else
1110
-						echo ' ', $attribute, '="', $value, '"';
1148
+					if ($attribute === 'value') {
1149
+											continue;
1150
+					} elseif (is_bool($value)) {
1151
+											echo $value ? ' ' . $attribute : '';
1152
+					} else {
1153
+											echo ' ', $attribute, '="', $value, '"';
1154
+					}
1111 1155
 				}
1112 1156
 			}
1113 1157
 
@@ -1120,17 +1164,19 @@  discard block
 block discarded – undo
1120 1164
 			echo '
1121 1165
 							<select';
1122 1166
 
1123
-			if (empty($pf['input']['attributes']['name']))
1124
-				echo ' name="', $pfid, '"';
1167
+			if (empty($pf['input']['attributes']['name'])) {
1168
+							echo ' name="', $pfid, '"';
1169
+			}
1125 1170
 
1126 1171
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1127 1172
 			{
1128 1173
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1129 1174
 				{
1130
-					if (is_bool($value))
1131
-						echo $value ? ' ' . $attribute : '';
1132
-					else
1133
-						echo ' ', $attribute, '="', $value, '"';
1175
+					if (is_bool($value)) {
1176
+											echo $value ? ' ' . $attribute : '';
1177
+					} else {
1178
+											echo ' ', $attribute, '="', $value, '"';
1179
+					}
1134 1180
 				}
1135 1181
 			}
1136 1182
 
@@ -1145,17 +1191,19 @@  discard block
 block discarded – undo
1145 1191
 					echo '
1146 1192
 								<optgroup';
1147 1193
 
1148
-					if (empty($option['attributes']['label']))
1149
-						echo ' label="', $optlabel, '"';
1194
+					if (empty($option['attributes']['label'])) {
1195
+											echo ' label="', $optlabel, '"';
1196
+					}
1150 1197
 
1151 1198
 					if (!empty($option['attributes']) && is_array($option['attributes']))
1152 1199
 					{
1153 1200
 						foreach ($option['attributes'] as $attribute => $value)
1154 1201
 						{
1155
-							if (is_bool($value))
1156
-								echo $value ? ' ' . $attribute : '';
1157
-							else
1158
-								echo ' ', $attribute, '="', $value, '"';
1202
+							if (is_bool($value)) {
1203
+															echo $value ? ' ' . $attribute : '';
1204
+							} else {
1205
+															echo ' ', $attribute, '="', $value, '"';
1206
+							}
1159 1207
 						}
1160 1208
 					}
1161 1209
 
@@ -1168,10 +1216,11 @@  discard block
 block discarded – undo
1168 1216
 
1169 1217
 						foreach ($grouped_option['attributes'] as $attribute => $value)
1170 1218
 						{
1171
-							if (is_bool($value))
1172
-								echo $value ? ' ' . $attribute : '';
1173
-							else
1174
-								echo ' ', $attribute, '="', $value, '"';
1219
+							if (is_bool($value)) {
1220
+															echo $value ? ' ' . $attribute : '';
1221
+							} else {
1222
+															echo ' ', $attribute, '="', $value, '"';
1223
+							}
1175 1224
 						}
1176 1225
 
1177 1226
 						echo '>', $grouped_optlabel, '</option>';
@@ -1189,10 +1238,11 @@  discard block
 block discarded – undo
1189 1238
 
1190 1239
 					foreach ($option['attributes'] as $attribute => $value)
1191 1240
 					{
1192
-						if (is_bool($value))
1193
-							echo $value ? ' ' . $attribute : '';
1194
-						else
1195
-							echo ' ', $attribute, '="', $value, '"';
1241
+						if (is_bool($value)) {
1242
+													echo $value ? ' ' . $attribute : '';
1243
+						} else {
1244
+													echo ' ', $attribute, '="', $value, '"';
1245
+						}
1196 1246
 					}
1197 1247
 
1198 1248
 					echo '>', $optlabel, '</option>';
@@ -1213,12 +1263,13 @@  discard block
 block discarded – undo
1213 1263
 			{
1214 1264
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1215 1265
 				{
1216
-					if ($attribute === 'name')
1217
-						continue;
1218
-					elseif (is_bool($value))
1219
-						echo $value ? ' ' . $attribute : '';
1220
-					else
1221
-						echo ' ', $attribute, '="', $value, '"';
1266
+					if ($attribute === 'name') {
1267
+											continue;
1268
+					} elseif (is_bool($value)) {
1269
+											echo $value ? ' ' . $attribute : '';
1270
+					} else {
1271
+											echo ' ', $attribute, '="', $value, '"';
1272
+					}
1222 1273
 				}
1223 1274
 			}
1224 1275
 
@@ -1231,10 +1282,11 @@  discard block
 block discarded – undo
1231 1282
 
1232 1283
 				foreach ($option['attributes'] as $attribute => $value)
1233 1284
 				{
1234
-					if (is_bool($value))
1235
-						echo $value ? ' ' . $attribute : '';
1236
-					else
1237
-						echo ' ', $attribute, '="', $value, '"';
1285
+					if (is_bool($value)) {
1286
+											echo $value ? ' ' . $attribute : '';
1287
+					} else {
1288
+											echo ' ', $attribute, '="', $value, '"';
1289
+					}
1238 1290
 				}
1239 1291
 
1240 1292
 				echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>';
@@ -1245,9 +1297,10 @@  discard block
 block discarded – undo
1245 1297
 		}
1246 1298
 
1247 1299
 		// Any trailing HTML after the main input
1248
-		if (!empty($pf['input']['after']))
1249
-			echo '
1300
+		if (!empty($pf['input']['after'])) {
1301
+					echo '
1250 1302
 							', $pf['input']['after'];
1303
+		}
1251 1304
 
1252 1305
 		echo '
1253 1306
 						</dd>';
Please login to merge, or discard this patch.
Sources/Themes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1744,9 +1744,9 @@
 block discarded – undo
1744 1744
 			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1745
 		
1746 1746
 		// Do not list minified_ files
1747
-		foreach($context['theme_files'] as $key=>$file)
1747
+		foreach ($context['theme_files'] as $key=>$file)
1748 1748
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1749
+			if (strpos($file['filename'], 'minified_') !== FALSE)
1750 1750
 				unset($context['theme_files'][$key]);
1751 1751
 		}
1752 1752
 
Please login to merge, or discard this patch.
Braces   +348 added lines, -271 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 4
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -581,13 +593,13 @@  discard block
 block discarded – undo
581 593
 			)
582 594
 		);
583 595
 		$context['theme_options'] = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$context['theme_options'][$row['variable']] = $row['value'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$context['theme_options'][$row['variable']] = $row['value'];
598
+		}
586 599
 		$smcFunc['db_free_result']($request);
587 600
 
588 601
 		$context['theme_options_reset'] = false;
589
-	}
590
-	else
602
+	} else
591 603
 	{
592 604
 		$context['theme_options'] = array();
593 605
 		$context['theme_options_reset'] = true;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	foreach ($context['options'] as $i => $setting)
597 609
 	{
598 610
 		// Just skip separators
599
-		if (!is_array($setting))
600
-			continue;
611
+		if (!is_array($setting)) {
612
+					continue;
613
+		}
601 614
 
602 615
 		// Is this disabled?
603 616
 		if (isset($setting['enabled']) && $setting['enabled'] === false)
@@ -606,15 +619,17 @@  discard block
 block discarded – undo
606 619
 			continue;
607 620
 		}
608 621
 
609
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
610
-			$context['options'][$i]['type'] = 'checkbox';
611
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
612
-			$context['options'][$i]['type'] = 'number';
613
-		elseif ($setting['type'] == 'string')
614
-			$context['options'][$i]['type'] = 'text';
622
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
623
+					$context['options'][$i]['type'] = 'checkbox';
624
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
625
+					$context['options'][$i]['type'] = 'number';
626
+		} elseif ($setting['type'] == 'string') {
627
+					$context['options'][$i]['type'] = 'text';
628
+		}
615 629
 
616
-		if (isset($setting['options']))
617
-			$context['options'][$i]['type'] = 'list';
630
+		if (isset($setting['options'])) {
631
+					$context['options'][$i]['type'] = 'list';
632
+		}
618 633
 
619 634
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
620 635
 	}
@@ -639,8 +654,9 @@  discard block
 block discarded – undo
639 654
 {
640 655
 	global $txt, $context, $settings, $modSettings, $smcFunc;
641 656
 
642
-	if (empty($_GET['th']) && empty($_GET['id']))
643
-		return ThemeAdmin();
657
+	if (empty($_GET['th']) && empty($_GET['id'])) {
658
+			return ThemeAdmin();
659
+	}
644 660
 
645 661
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
646 662
 
@@ -651,8 +667,9 @@  discard block
 block discarded – undo
651 667
 	isAllowedTo('admin_forum');
652 668
 
653 669
 	// Validate inputs/user.
654
-	if (empty($_GET['th']))
655
-		fatal_lang_error('no_theme', false);
670
+	if (empty($_GET['th'])) {
671
+			fatal_lang_error('no_theme', false);
672
+	}
656 673
 
657 674
 	// Fetch the smiley sets...
658 675
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -660,8 +677,9 @@  discard block
 block discarded – undo
660 677
 	$context['smiley_sets'] = array(
661 678
 		'' => $txt['smileys_no_default']
662 679
 	);
663
-	foreach ($sets as $i => $set)
664
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
680
+	foreach ($sets as $i => $set) {
681
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
682
+	}
665 683
 
666 684
 	$old_id = $settings['theme_id'];
667 685
 	$old_settings = $settings;
@@ -686,8 +704,9 @@  discard block
 block discarded – undo
686 704
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
687 705
 	{
688 706
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
689
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
690
-				eval('global $settings;' . $matches[0]);
707
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
708
+						eval('global $settings;' . $matches[0]);
709
+		}
691 710
 	}
692 711
 
693 712
 	// Let mods hook into the theme settings.
@@ -699,37 +718,45 @@  discard block
 block discarded – undo
699 718
 		checkSession();
700 719
 		validateToken('admin-sts');
701 720
 
702
-		if (empty($_POST['options']))
703
-			$_POST['options'] = array();
704
-		if (empty($_POST['default_options']))
705
-			$_POST['default_options'] = array();
721
+		if (empty($_POST['options'])) {
722
+					$_POST['options'] = array();
723
+		}
724
+		if (empty($_POST['default_options'])) {
725
+					$_POST['default_options'] = array();
726
+		}
706 727
 
707 728
 		// Make sure items are cast correctly.
708 729
 		foreach ($context['theme_settings'] as $item)
709 730
 		{
710 731
 			// Disregard this item if this is just a separator.
711
-			if (!is_array($item))
712
-				continue;
732
+			if (!is_array($item)) {
733
+							continue;
734
+			}
713 735
 
714 736
 			foreach (array('options', 'default_options') as $option)
715 737
 			{
716
-				if (!isset($_POST[$option][$item['id']]))
717
-					continue;
738
+				if (!isset($_POST[$option][$item['id']])) {
739
+									continue;
740
+				}
718 741
 				// Checkbox.
719
-				elseif (empty($item['type']))
720
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				elseif (empty($item['type'])) {
743
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
744
+				}
721 745
 				// Number
722
-				elseif ($item['type'] == 'number')
723
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				elseif ($item['type'] == 'number') {
747
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
748
+				}
724 749
 			}
725 750
 		}
726 751
 
727 752
 		// Set up the sql query.
728 753
 		$inserts = array();
729
-		foreach ($_POST['options'] as $opt => $val)
730
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
731
-		foreach ($_POST['default_options'] as $opt => $val)
732
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
754
+		foreach ($_POST['options'] as $opt => $val) {
755
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
756
+		}
757
+		foreach ($_POST['default_options'] as $opt => $val) {
758
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
759
+		}
733 760
 		// If we're actually inserting something..
734 761
 		if (!empty($inserts))
735 762
 		{
@@ -755,8 +782,9 @@  discard block
 block discarded – undo
755 782
 
756 783
 	foreach ($settings as $setting => $dummy)
757 784
 	{
758
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
759
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
786
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
787
+		}
760 788
 	}
761 789
 
762 790
 	$context['settings'] = $context['theme_settings'];
@@ -765,18 +793,21 @@  discard block
 block discarded – undo
765 793
 	foreach ($context['settings'] as $i => $setting)
766 794
 	{
767 795
 		// Separators are dummies, so leave them alone.
768
-		if (!is_array($setting))
769
-			continue;
796
+		if (!is_array($setting)) {
797
+					continue;
798
+		}
770 799
 
771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
772
-			$context['settings'][$i]['type'] = 'checkbox';
773
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
774
-			$context['settings'][$i]['type'] = 'number';
775
-		elseif ($setting['type'] == 'string')
776
-			$context['settings'][$i]['type'] = 'text';
800
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
801
+					$context['settings'][$i]['type'] = 'checkbox';
802
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
803
+					$context['settings'][$i]['type'] = 'number';
804
+		} elseif ($setting['type'] == 'string') {
805
+					$context['settings'][$i]['type'] = 'text';
806
+		}
777 807
 
778
-		if (isset($setting['options']))
779
-			$context['settings'][$i]['type'] = 'list';
808
+		if (isset($setting['options'])) {
809
+					$context['settings'][$i]['type'] = 'list';
810
+		}
780 811
 
781 812
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
782 813
 	}
@@ -829,8 +860,9 @@  discard block
 block discarded – undo
829 860
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
830 861
 
831 862
 	// You can't delete the default theme!
832
-	if ($themeID == 1)
833
-		fatal_lang_error('no_access', false);
863
+	if ($themeID == 1) {
864
+			fatal_lang_error('no_access', false);
865
+	}
834 866
 
835 867
 	$theme_info = get_single_theme($themeID);
836 868
 
@@ -838,8 +870,9 @@  discard block
 block discarded – undo
838 870
 	remove_theme($themeID);
839 871
 
840 872
 	// And remove all its files and folders too.
841
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
842
-		remove_dir($theme_info['theme_dir']);
873
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
874
+			remove_dir($theme_info['theme_dir']);
875
+	}
843 876
 
844 877
 	// Go back to the list page.
845 878
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -864,12 +897,14 @@  discard block
 block discarded – undo
864 897
 	$enableThemes = explode(',', $modSettings['enableThemes']);
865 898
 
866 899
 	// Are we disabling it?
867
-	if (isset($_GET['disabled']))
868
-		$enableThemes = array_diff($enableThemes, array($themeID));
900
+	if (isset($_GET['disabled'])) {
901
+			$enableThemes = array_diff($enableThemes, array($themeID));
902
+	}
869 903
 
870 904
 	// Nope? then enable it!
871
-	else
872
-		$enableThemes[] = (string) $themeID;
905
+	else {
906
+			$enableThemes[] = (string) $themeID;
907
+	}
873 908
 
874 909
 	// Update the setting.
875 910
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -904,18 +939,21 @@  discard block
 block discarded – undo
904 939
 
905 940
 	$_SESSION['id_theme'] = 0;
906 941
 
907
-	if (isset($_GET['id']))
908
-		$_GET['th'] = $_GET['id'];
942
+	if (isset($_GET['id'])) {
943
+			$_GET['th'] = $_GET['id'];
944
+	}
909 945
 
910 946
 	// Saving a variant cause JS doesn't work - pretend it did ;)
911 947
 	if (isset($_POST['save']))
912 948
 	{
913 949
 		// Which theme?
914
-		foreach ($_POST['save'] as $k => $v)
915
-			$_GET['th'] = (int) $k;
950
+		foreach ($_POST['save'] as $k => $v) {
951
+					$_GET['th'] = (int) $k;
952
+		}
916 953
 
917
-		if (isset($_POST['vrt'][$k]))
918
-			$_GET['vrt'] = $_POST['vrt'][$k];
954
+		if (isset($_POST['vrt'][$k])) {
955
+					$_GET['vrt'] = $_POST['vrt'][$k];
956
+		}
919 957
 	}
920 958
 
921 959
 	// Have we made a decision, or are we just browsing?
@@ -1004,10 +1042,10 @@  discard block
 block discarded – undo
1004 1042
 				);
1005 1043
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1006 1044
 
1007
-				if ($user_info['id'] == $_REQUEST['u'])
1008
-					$_SESSION['id_variant'] = 0;
1009
-			}
1010
-			elseif ($_GET['th'] == 0)
1045
+				if ($user_info['id'] == $_REQUEST['u']) {
1046
+									$_SESSION['id_variant'] = 0;
1047
+				}
1048
+			} elseif ($_GET['th'] == 0)
1011 1049
 			{
1012 1050
 				// Remove any custom variants.
1013 1051
 				$smcFunc['db_query']('', '
@@ -1088,12 +1126,13 @@  discard block
 block discarded – undo
1088 1126
 		);
1089 1127
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1090 1128
 		{
1091
-			if (!isset($context['available_themes'][$row['id_theme']]))
1092
-				$context['available_themes'][$row['id_theme']] = array(
1129
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1130
+							$context['available_themes'][$row['id_theme']] = array(
1093 1131
 					'id' => $row['id_theme'],
1094 1132
 					'selected' => $context['current_theme'] == $row['id_theme'],
1095 1133
 					'num_users' => 0
1096 1134
 				);
1135
+			}
1097 1136
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1098 1137
 		}
1099 1138
 		$smcFunc['db_free_result']($request);
@@ -1106,9 +1145,9 @@  discard block
 block discarded – undo
1106 1145
 			'num_users' => 0
1107 1146
 		);
1108 1147
 		$guest_theme = 0;
1148
+	} else {
1149
+			$guest_theme = $modSettings['theme_guests'];
1109 1150
 	}
1110
-	else
1111
-		$guest_theme = $modSettings['theme_guests'];
1112 1151
 
1113 1152
 	$request = $smcFunc['db_query']('', '
1114 1153
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1121,15 +1160,17 @@  discard block
 block discarded – undo
1121 1160
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1122 1161
 	{
1123 1162
 		// Figure out which theme it is they are REALLY using.
1124
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1125
-			$row['id_theme'] = $guest_theme;
1126
-		elseif (empty($modSettings['theme_allow']))
1127
-			$row['id_theme'] = $guest_theme;
1163
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1164
+					$row['id_theme'] = $guest_theme;
1165
+		} elseif (empty($modSettings['theme_allow'])) {
1166
+					$row['id_theme'] = $guest_theme;
1167
+		}
1128 1168
 
1129
-		if (isset($context['available_themes'][$row['id_theme']]))
1130
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1131
-		else
1132
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1169
+		if (isset($context['available_themes'][$row['id_theme']])) {
1170
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1171
+		} else {
1172
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1173
+		}
1133 1174
 	}
1134 1175
 	$smcFunc['db_free_result']($request);
1135 1176
 
@@ -1148,8 +1189,9 @@  discard block
 block discarded – undo
1148 1189
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1149 1190
 			)
1150 1191
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			$variant_preferences[$row['id_theme']] = $row['value'];
1192
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1193
+					$variant_preferences[$row['id_theme']] = $row['value'];
1194
+		}
1153 1195
 		$smcFunc['db_free_result']($request);
1154 1196
 	}
1155 1197
 
@@ -1160,17 +1202,18 @@  discard block
 block discarded – undo
1160 1202
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1161 1203
 	{
1162 1204
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1163
-		if ($id_theme == 0)
1164
-			continue;
1205
+		if ($id_theme == 0) {
1206
+					continue;
1207
+		}
1165 1208
 
1166 1209
 		// The thumbnail needs the correct path.
1167 1210
 		$settings['images_url'] = &$theme_data['images_url'];
1168 1211
 
1169
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1170
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1171
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1172
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1173
-		else
1212
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1213
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1214
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1215
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1216
+		} else
1174 1217
 		{
1175 1218
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1176 1219
 			$txt['theme_description'] = '';
@@ -1195,15 +1238,17 @@  discard block
 block discarded – undo
1195 1238
 					loadLanguage('Settings');
1196 1239
 
1197 1240
 					$context['available_themes'][$id_theme]['variants'] = array();
1198
-					foreach ($settings['theme_variants'] as $variant)
1199
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1241
+					foreach ($settings['theme_variants'] as $variant) {
1242
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1200 1243
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1201 1244
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1202 1245
 						);
1246
+					}
1203 1247
 
1204 1248
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1205
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1206
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1249
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1250
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1251
+					}
1207 1252
 
1208 1253
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1209 1254
 					// Allow themes to override the text.
@@ -1219,8 +1264,9 @@  discard block
 block discarded – undo
1219 1264
 	// As long as we're not doing the default theme...
1220 1265
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1221 1266
 	{
1222
-		if ($guest_theme != 0)
1223
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1267
+		if ($guest_theme != 0) {
1268
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1269
+		}
1224 1270
 
1225 1271
 		$context['available_themes'][0]['id'] = 0;
1226 1272
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1269,14 +1315,16 @@  discard block
 block discarded – undo
1269 1315
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1270 1316
 
1271 1317
 		// Got any info from the specific form?
1272
-		if (!isset($_POST['save_' . $action]))
1273
-			fatal_lang_error('theme_install_no_action', false);
1318
+		if (!isset($_POST['save_' . $action])) {
1319
+					fatal_lang_error('theme_install_no_action', false);
1320
+		}
1274 1321
 
1275 1322
 		validateToken('admin-t-' . $action);
1276 1323
 
1277 1324
 		// Hopefully the themes directory is writable, or we might have a problem.
1278
-		if (!is_writable($themedir))
1279
-			fatal_lang_error('theme_install_write_error', 'critical');
1325
+		if (!is_writable($themedir)) {
1326
+					fatal_lang_error('theme_install_write_error', 'critical');
1327
+		}
1280 1328
 
1281 1329
 		// Call the function and handle the result.
1282 1330
 		$result = $subActions[$action]();
@@ -1291,9 +1339,10 @@  discard block
 block discarded – undo
1291 1339
 	}
1292 1340
 
1293 1341
 	// Nope, show a nice error.
1294
-	else
1295
-		fatal_lang_error('theme_install_no_action', false);
1296
-}
1342
+	else {
1343
+			fatal_lang_error('theme_install_no_action', false);
1344
+	}
1345
+	}
1297 1346
 
1298 1347
 /**
1299 1348
  * Installs a theme from a theme package.
@@ -1309,8 +1358,9 @@  discard block
 block discarded – undo
1309 1358
 	$dirtemp = $themedir . '/temp';
1310 1359
 
1311 1360
 	// Make sure the temp dir doesn't already exist
1312
-	if (file_exists($dirtemp))
1313
-		remove_dir($dirtemp);
1361
+	if (file_exists($dirtemp)) {
1362
+			remove_dir($dirtemp);
1363
+	}
1314 1364
 
1315 1365
 	// Create the temp dir.
1316 1366
 	mkdir($dirtemp, 0777);
@@ -1322,17 +1372,20 @@  discard block
 block discarded – undo
1322 1372
 		smf_chmod($dirtemp, '0755');
1323 1373
 
1324 1374
 		// How about now?
1325
-		if (!is_writable($dirtemp))
1326
-			fatal_lang_error('theme_install_write_error', 'critical');
1375
+		if (!is_writable($dirtemp)) {
1376
+					fatal_lang_error('theme_install_write_error', 'critical');
1377
+		}
1327 1378
 	}
1328 1379
 
1329 1380
 	// This happens when the admin session is gone and the user has to login again.
1330
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1331
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1381
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1382
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1383
+	}
1332 1384
 
1333 1385
 	// Another error check layer, something went wrong with the upload.
1334
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1335
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1386
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1387
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1388
+	}
1336 1389
 
1337 1390
 	// Get the theme's name.
1338 1391
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1363,11 +1416,10 @@  discard block
 block discarded – undo
1363 1416
 
1364 1417
 		// return all the info.
1365 1418
 		return $context['to_install'];
1419
+	} else {
1420
+			fatal_lang_error('theme_install_error_title', false);
1421
+	}
1366 1422
 	}
1367
-
1368
-	else
1369
-		fatal_lang_error('theme_install_error_title', false);
1370
-}
1371 1423
 
1372 1424
 /**
1373 1425
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1381,15 +1433,17 @@  discard block
 block discarded – undo
1381 1433
 	global $forum_version;
1382 1434
 
1383 1435
 	// There's gotta be something to work with.
1384
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1385
-		fatal_lang_error('theme_install_error_title', false);
1436
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1437
+			fatal_lang_error('theme_install_error_title', false);
1438
+	}
1386 1439
 
1387 1440
 	// Get a cleaner version.
1388 1441
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1389 1442
 
1390 1443
 	// Is there a theme already named like this?
1391
-	if (file_exists($themedir . '/' . $name))
1392
-		fatal_lang_error('theme_install_already_dir', false);
1444
+	if (file_exists($themedir . '/' . $name)) {
1445
+			fatal_lang_error('theme_install_already_dir', false);
1446
+	}
1393 1447
 
1394 1448
 	// This is a brand new theme so set all possible values.
1395 1449
 	$context['to_install'] = array(
@@ -1409,8 +1463,9 @@  discard block
 block discarded – undo
1409 1463
 
1410 1464
 	// Buy some time.
1411 1465
 	@set_time_limit(600);
1412
-	if (function_exists('apache_reset_timeout'))
1413
-		@apache_reset_timeout();
1466
+	if (function_exists('apache_reset_timeout')) {
1467
+			@apache_reset_timeout();
1468
+	}
1414 1469
 
1415 1470
 	// Create subdirectories for css and javascript files.
1416 1471
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1446,12 +1501,13 @@  discard block
 block discarded – undo
1446 1501
 
1447 1502
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1448 1503
 	{
1449
-		if ($row['variable'] == 'theme_templates')
1450
-			$theme_templates = $row['value'];
1451
-		elseif ($row['variable'] == 'theme_layers')
1452
-			$theme_layers = $row['value'];
1453
-		else
1454
-			continue;
1504
+		if ($row['variable'] == 'theme_templates') {
1505
+					$theme_templates = $row['value'];
1506
+		} elseif ($row['variable'] == 'theme_layers') {
1507
+					$theme_layers = $row['value'];
1508
+		} else {
1509
+					continue;
1510
+		}
1455 1511
 	}
1456 1512
 
1457 1513
 	$smcFunc['db_free_result']($request);
@@ -1510,12 +1566,14 @@  discard block
 block discarded – undo
1510 1566
 	global $themedir, $themeurl, $context;
1511 1567
 
1512 1568
 	// Cannot use the theme dir as a theme dir.
1513
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1514
-		fatal_lang_error('theme_install_invalid_dir', false);
1569
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1570
+			fatal_lang_error('theme_install_invalid_dir', false);
1571
+	}
1515 1572
 
1516 1573
 	// Check is there is "something" on the dir.
1517
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1518
-		fatal_lang_error('theme_install_error', false);
1574
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1575
+			fatal_lang_error('theme_install_error', false);
1576
+	}
1519 1577
 
1520 1578
 	$name = basename($_REQUEST['theme_dir']);
1521 1579
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1559,24 +1617,27 @@  discard block
 block discarded – undo
1559 1617
 	}
1560 1618
 
1561 1619
 	// Any special layers?
1562
-	if (isset($settings['catch_action']['layers']))
1563
-		$context['template_layers'] = $settings['catch_action']['layers'];
1620
+	if (isset($settings['catch_action']['layers'])) {
1621
+			$context['template_layers'] = $settings['catch_action']['layers'];
1622
+	}
1564 1623
 
1565 1624
 	// Any function to call?
1566 1625
 	if (isset($settings['catch_action']['function']))
1567 1626
 	{
1568 1627
 		$hook = $settings['catch_action']['function'];
1569 1628
 
1570
-		if (!isset($settings['catch_action']['filename']))
1571
-			$settings['catch_action']['filename'] = '';
1629
+		if (!isset($settings['catch_action']['filename'])) {
1630
+					$settings['catch_action']['filename'] = '';
1631
+		}
1572 1632
 
1573 1633
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1574 1634
 		call_integration_hook('integrate_wrap_action');
1575 1635
 	}
1576 1636
 	// And finally, the main sub template ;).
1577
-	if (isset($settings['catch_action']['sub_template']))
1578
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1579
-}
1637
+	if (isset($settings['catch_action']['sub_template'])) {
1638
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1639
+	}
1640
+	}
1580 1641
 
1581 1642
 /**
1582 1643
  * Set an option via javascript.
@@ -1595,12 +1656,14 @@  discard block
 block discarded – undo
1595 1656
 	checkSession('get');
1596 1657
 
1597 1658
 	// This good-for-nothing pixel is being used to keep the session alive.
1598
-	if (empty($_GET['var']) || !isset($_GET['val']))
1599
-		redirectexit($settings['images_url'] . '/blank.png');
1659
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1660
+			redirectexit($settings['images_url'] . '/blank.png');
1661
+	}
1600 1662
 
1601 1663
 	// Sorry, guests can't go any further than this.
1602
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1603
-		obExit(false);
1664
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1665
+			obExit(false);
1666
+	}
1604 1667
 
1605 1668
 	$reservedVars = array(
1606 1669
 		'actual_theme_url',
@@ -1623,8 +1686,9 @@  discard block
 block discarded – undo
1623 1686
 	);
1624 1687
 
1625 1688
 	// Can't change reserved vars.
1626
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1627
-		redirectexit($settings['images_url'] . '/blank.png');
1689
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1690
+			redirectexit($settings['images_url'] . '/blank.png');
1691
+	}
1628 1692
 
1629 1693
 	// Use a specific theme?
1630 1694
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1640,8 +1704,9 @@  discard block
 block discarded – undo
1640 1704
 	{
1641 1705
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
1642 1706
 		// New thingy...
1643
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1644
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1707
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1708
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1709
+		}
1645 1710
 
1646 1711
 		// Change the value to be something nice,
1647 1712
 		$_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']);
@@ -1671,8 +1736,9 @@  discard block
 block discarded – undo
1671 1736
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1672 1737
 
1673 1738
 	// @todo Should this be removed?
1674
-	if (isset($_REQUEST['preview']))
1675
-		die('die() with fire');
1739
+	if (isset($_REQUEST['preview'])) {
1740
+			die('die() with fire');
1741
+	}
1676 1742
 
1677 1743
 	isAllowedTo('admin_forum');
1678 1744
 	loadTemplate('Themes');
@@ -1686,11 +1752,11 @@  discard block
 block discarded – undo
1686 1752
 		foreach ($context['themes'] as $key => $theme)
1687 1753
 		{
1688 1754
 			// There has to be a Settings template!
1689
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1690
-				unset($context['themes'][$key]);
1691
-
1692
-			else
1693
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1755
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1756
+							unset($context['themes'][$key]);
1757
+			} else {
1758
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1759
+			}
1694 1760
 		}
1695 1761
 
1696 1762
 		$context['sub_template'] = 'edit_list';
@@ -1705,22 +1771,24 @@  discard block
 block discarded – undo
1705 1771
 	$context['theme_id'] = $currentTheme['id'];
1706 1772
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1707 1773
 
1708
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1709
-		fatal_lang_error('theme_edit_missing', false);
1774
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1775
+			fatal_lang_error('theme_edit_missing', false);
1776
+	}
1710 1777
 
1711 1778
 	if (!isset($_REQUEST['filename']))
1712 1779
 	{
1713 1780
 		if (isset($_GET['directory']))
1714 1781
 		{
1715
-			if (substr($_GET['directory'], 0, 1) == '.')
1716
-				$_GET['directory'] = '';
1717
-			else
1782
+			if (substr($_GET['directory'], 0, 1) == '.') {
1783
+							$_GET['directory'] = '';
1784
+			} else
1718 1785
 			{
1719 1786
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1720 1787
 
1721 1788
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1722
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1723
-					$_GET['directory'] = '';
1789
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1790
+									$_GET['directory'] = '';
1791
+				}
1724 1792
 			}
1725 1793
 		}
1726 1794
 
@@ -1739,44 +1807,47 @@  discard block
 block discarded – undo
1739 1807
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1740 1808
 				'size' => '',
1741 1809
 			));
1810
+		} else {
1811
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1742 1812
 		}
1743
-		else
1744
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1813
 		
1746 1814
 		// Do not list minified_ files
1747 1815
 		foreach($context['theme_files'] as $key=>$file)
1748 1816
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1750
-				unset($context['theme_files'][$key]);
1817
+			if(strpos($file['filename'], 'minified_') !== FALSE) {
1818
+							unset($context['theme_files'][$key]);
1819
+			}
1751 1820
 		}
1752 1821
 
1753 1822
 		$context['sub_template'] = 'edit_browse';
1754 1823
 
1755 1824
 		return;
1756
-	}
1757
-	else
1825
+	} else
1758 1826
 	{
1759
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1760
-			$_REQUEST['filename'] = '';
1761
-		else
1827
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1828
+					$_REQUEST['filename'] = '';
1829
+		} else
1762 1830
 		{
1763 1831
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1764 1832
 
1765 1833
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1766
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1767
-				$_REQUEST['filename'] = '';
1834
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1835
+							$_REQUEST['filename'] = '';
1836
+			}
1768 1837
 		}
1769 1838
 
1770
-		if (empty($_REQUEST['filename']))
1771
-			fatal_lang_error('theme_edit_missing', false);
1839
+		if (empty($_REQUEST['filename'])) {
1840
+					fatal_lang_error('theme_edit_missing', false);
1841
+		}
1772 1842
 	}
1773 1843
 
1774 1844
 	if (isset($_POST['save']))
1775 1845
 	{
1776 1846
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1777 1847
 		{
1778
-			if (is_array($_POST['entire_file']))
1779
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1848
+			if (is_array($_POST['entire_file'])) {
1849
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1850
+			}
1780 1851
 
1781 1852
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1782 1853
 
@@ -1788,10 +1859,11 @@  discard block
 block discarded – undo
1788 1859
 				fclose($fp);
1789 1860
 
1790 1861
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1791
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1792
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1793
-				else
1794
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1862
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1863
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1864
+				} else {
1865
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1866
+				}
1795 1867
 			}
1796 1868
 
1797 1869
 			if (!isset($error_file))
@@ -1812,10 +1884,11 @@  discard block
 block discarded – undo
1812 1884
 			$context['sub_template'] = 'edit_file';
1813 1885
 
1814 1886
 			// Recycle the submitted data.
1815
-			if (is_array($_POST['entire_file']))
1816
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1817
-			else
1818
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1887
+			if (is_array($_POST['entire_file'])) {
1888
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1889
+			} else {
1890
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1891
+			}
1819 1892
 
1820 1893
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1821 1894
 
@@ -1838,17 +1911,17 @@  discard block
 block discarded – undo
1838 1911
 		$context['sub_template'] = 'edit_style';
1839 1912
 
1840 1913
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1841
-	}
1842
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1914
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1843 1915
 	{
1844 1916
 		$context['sub_template'] = 'edit_template';
1845 1917
 
1846
-		if (!isset($error_file))
1847
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1848
-		else
1918
+		if (!isset($error_file)) {
1919
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1920
+		} else
1849 1921
 		{
1850
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1851
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1922
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1923
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1924
+			}
1852 1925
 			$file_data = file($error_file);
1853 1926
 			unlink($error_file);
1854 1927
 		}
@@ -1862,8 +1935,9 @@  discard block
 block discarded – undo
1862 1935
 				// Try to format the functions a little nicer...
1863 1936
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1864 1937
 
1865
-				if (empty($context['file_parts'][$j]['lines']))
1866
-					unset($context['file_parts'][$j]);
1938
+				if (empty($context['file_parts'][$j]['lines'])) {
1939
+									unset($context['file_parts'][$j]);
1940
+				}
1867 1941
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1868 1942
 			}
1869 1943
 
@@ -1872,8 +1946,7 @@  discard block
 block discarded – undo
1872 1946
 		}
1873 1947
 
1874 1948
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1875
-	}
1876
-	else
1949
+	} else
1877 1950
 	{
1878 1951
 		$context['sub_template'] = 'edit_file';
1879 1952
 
@@ -1899,8 +1972,9 @@  discard block
 block discarded – undo
1899 1972
 
1900 1973
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1901 1974
 
1902
-	if (empty($_GET['th']))
1903
-		fatal_lang_error('theme_install_invalid_id');
1975
+	if (empty($_GET['th'])) {
1976
+			fatal_lang_error('theme_install_invalid_id');
1977
+	}
1904 1978
 
1905 1979
 	// Get the theme info.
1906 1980
 	$theme = get_single_theme($_GET['th']);
@@ -1908,25 +1982,24 @@  discard block
 block discarded – undo
1908 1982
 
1909 1983
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1910 1984
 	{
1911
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1912
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1913
-
1914
-		else
1915
-			fatal_lang_error('no_access', false);
1985
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1986
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1987
+		} else {
1988
+					fatal_lang_error('no_access', false);
1989
+		}
1916 1990
 
1917 1991
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1918 1992
 		fwrite($fp, file_get_contents($filename));
1919 1993
 		fclose($fp);
1920 1994
 
1921 1995
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1922
-	}
1923
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1996
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1924 1997
 	{
1925
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1926
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1927
-
1928
-		else
1929
-			fatal_lang_error('no_access', false);
1998
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1999
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
2000
+		} else {
2001
+					fatal_lang_error('no_access', false);
2002
+		}
1930 2003
 
1931 2004
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1932 2005
 		fwrite($fp, file_get_contents($filename));
@@ -1941,16 +2014,18 @@  discard block
 block discarded – undo
1941 2014
 	$dir = dir($settings['default_theme_dir']);
1942 2015
 	while ($entry = $dir->read())
1943 2016
 	{
1944
-		if (substr($entry, -13) == '.template.php')
1945
-			$templates[] = substr($entry, 0, -13);
2017
+		if (substr($entry, -13) == '.template.php') {
2018
+					$templates[] = substr($entry, 0, -13);
2019
+		}
1946 2020
 	}
1947 2021
 	$dir->close();
1948 2022
 
1949 2023
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1950 2024
 	while ($entry = $dir->read())
1951 2025
 	{
1952
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1953
-			$lang_files[] = $matches[1];
2026
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2027
+					$lang_files[] = $matches[1];
2028
+		}
1954 2029
 	}
1955 2030
 	$dir->close();
1956 2031
 
@@ -1958,21 +2033,23 @@  discard block
 block discarded – undo
1958 2033
 	natcasesort($lang_files);
1959 2034
 
1960 2035
 	$context['available_templates'] = array();
1961
-	foreach ($templates as $template)
1962
-		$context['available_templates'][$template] = array(
2036
+	foreach ($templates as $template) {
2037
+			$context['available_templates'][$template] = array(
1963 2038
 			'filename' => $template . '.template.php',
1964 2039
 			'value' => $template,
1965 2040
 			'already_exists' => false,
1966 2041
 			'can_copy' => is_writable($theme['theme_dir']),
1967 2042
 		);
2043
+	}
1968 2044
 	$context['available_language_files'] = array();
1969
-	foreach ($lang_files as $file)
1970
-		$context['available_language_files'][$file] = array(
2045
+	foreach ($lang_files as $file) {
2046
+			$context['available_language_files'][$file] = array(
1971 2047
 			'filename' => $file . '.php',
1972 2048
 			'value' => $file,
1973 2049
 			'already_exists' => false,
1974 2050
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1975 2051
 		);
2052
+	}
1976 2053
 
1977 2054
 	$dir = dir($theme['theme_dir']);
1978 2055
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Sources/Subs-Boards.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	if (!empty($boardUpdateParameters['deny_groups']))
661 661
 	{
662 662
 		$insert = array();
663
-		foreach($boardOptions['deny_groups'] as $value)
663
+		foreach ($boardOptions['deny_groups'] as $value)
664 664
 			$insert[] = array($value, $board_id, 1);
665 665
 
666 666
 		$smcFunc['db_query']('', '
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 				'{db_prefix}board_permissions_view',
675 675
 				array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
676 676
 				$insert,
677
-				array('id_group','id_board','deny')
677
+				array('id_group', 'id_board', 'deny')
678 678
 				);
679 679
 	}
680 680
 
681 681
 	if (!empty($boardUpdateParameters['member_groups']))
682 682
 	{
683 683
 		$insert = array();
684
-		foreach($boardOptions['access_groups'] as $value)
684
+		foreach ($boardOptions['access_groups'] as $value)
685 685
 			$insert[] = array($value, $board_id, 0);
686 686
 		$smcFunc['db_query']('', '
687 687
 			DELETE FROM {db_prefix}board_permissions_view
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 				'{db_prefix}board_permissions_view',
695 695
 				array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
696 696
 				$insert,
697
-				array('id_group','id_board','deny')
697
+				array('id_group', 'id_board', 'deny')
698 698
 				);
699 699
 	}
700 700
 
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 
902 902
 	$insert = array();
903 903
 
904
-	foreach(explode(',', $default_memgrps) as $value)
904
+	foreach (explode(',', $default_memgrps) as $value)
905 905
 			$insert[] = array($value, $board_id, 0);
906 906
 
907 907
 	$smcFunc['db_insert']('',
908 908
 		'{db_prefix}board_permissions_view',
909 909
 		array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
910 910
 		$insert,
911
-		array('id_group','id_board','deny'),
911
+		array('id_group', 'id_board', 'deny'),
912 912
 		1
913 913
 	);
914 914
 
Please login to merge, or discard this patch.
Braces   +256 added lines, -181 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * Mark a board or multiple boards read.
@@ -28,14 +29,16 @@  discard block
 block discarded – undo
28 29
 	global $user_info, $modSettings, $smcFunc;
29 30
 
30 31
 	// Force $boards to be an array.
31
-	if (!is_array($boards))
32
-		$boards = array($boards);
33
-	else
34
-		$boards = array_unique($boards);
32
+	if (!is_array($boards)) {
33
+			$boards = array($boards);
34
+	} else {
35
+			$boards = array_unique($boards);
36
+	}
35 37
 
36 38
 	// No boards, nothing to mark as read.
37
-	if (empty($boards))
38
-		return;
39
+	if (empty($boards)) {
40
+			return;
41
+	}
39 42
 
40 43
 	// Allow the user to mark a board as unread.
41 44
 	if ($unread)
@@ -65,8 +68,9 @@  discard block
 block discarded – undo
65 68
 	else
66 69
 	{
67 70
 		$markRead = array();
68
-		foreach ($boards as $board)
69
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
71
+		foreach ($boards as $board) {
72
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
73
+		}
70 74
 
71 75
 		// Update log_mark_read and log_boards.
72 76
 		$smcFunc['db_insert']('replace',
@@ -99,8 +103,9 @@  discard block
 block discarded – undo
99 103
 	list ($lowest_topic) = $smcFunc['db_fetch_row']($result);
100 104
 	$smcFunc['db_free_result']($result);
101 105
 
102
-	if (empty($lowest_topic))
103
-		return;
106
+	if (empty($lowest_topic)) {
107
+			return;
108
+	}
104 109
 
105 110
 	// @todo SLOW This query seems to eat it sometimes.
106 111
 	$result = $smcFunc['db_query']('', '
@@ -118,12 +123,13 @@  discard block
 block discarded – undo
118 123
 		)
119 124
 	);
120 125
 	$topics = array();
121
-	while ($row = $smcFunc['db_fetch_assoc']($result))
122
-		$topics[] = $row['id_topic'];
126
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
127
+			$topics[] = $row['id_topic'];
128
+	}
123 129
 	$smcFunc['db_free_result']($result);
124 130
 
125
-	if (!empty($topics))
126
-		$smcFunc['db_query']('', '
131
+	if (!empty($topics)) {
132
+			$smcFunc['db_query']('', '
127 133
 			DELETE FROM {db_prefix}log_topics
128 134
 			WHERE id_member = {int:current_member}
129 135
 				AND id_topic IN ({array_int:topic_list})',
@@ -132,7 +138,8 @@  discard block
 block discarded – undo
132 138
 				'topic_list' => $topics,
133 139
 			)
134 140
 		);
135
-}
141
+	}
142
+	}
136 143
 
137 144
 /**
138 145
  * Mark one or more boards as read.
@@ -157,23 +164,26 @@  discard block
 block discarded – undo
157 164
 			)
158 165
 		);
159 166
 		$boards = array();
160
-		while ($row = $smcFunc['db_fetch_assoc']($result))
161
-			$boards[] = $row['id_board'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
168
+					$boards[] = $row['id_board'];
169
+		}
162 170
 		$smcFunc['db_free_result']($result);
163 171
 
164
-		if (!empty($boards))
165
-			markBoardsRead($boards, isset($_REQUEST['unread']));
172
+		if (!empty($boards)) {
173
+					markBoardsRead($boards, isset($_REQUEST['unread']));
174
+		}
166 175
 
167 176
 		$_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID'];
168
-		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false)
169
-			redirectexit('action=unread');
177
+		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) {
178
+					redirectexit('action=unread');
179
+		}
170 180
 
171
-		if (isset($_SESSION['topicseen_cache']))
172
-			$_SESSION['topicseen_cache'] = array();
181
+		if (isset($_SESSION['topicseen_cache'])) {
182
+					$_SESSION['topicseen_cache'] = array();
183
+		}
173 184
 
174 185
 		redirectexit();
175
-	}
176
-	elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
186
+	} elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
177 187
 	{
178 188
 		// Make sure all the topics are integers!
179 189
 		$topics = array_map('intval', explode('-', $_REQUEST['topics']));
@@ -189,13 +199,15 @@  discard block
 block discarded – undo
189 199
 			)
190 200
 		);
191 201
 		$logged_topics = array();
192
-		while ($row = $smcFunc['db_fetch_assoc']($request))
193
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
202
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
203
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
204
+		}
194 205
 		$smcFunc['db_free_result']($request);
195 206
 
196 207
 		$markRead = array();
197
-		foreach ($topics as $id_topic)
198
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
208
+		foreach ($topics as $id_topic) {
209
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
210
+		}
199 211
 
200 212
 		$smcFunc['db_insert']('replace',
201 213
 			'{db_prefix}log_topics',
@@ -204,8 +216,9 @@  discard block
 block discarded – undo
204 216
 			array('id_member', 'id_topic')
205 217
 		);
206 218
 
207
-		if (isset($_SESSION['topicseen_cache']))
208
-			$_SESSION['topicseen_cache'] = array();
219
+		if (isset($_SESSION['topicseen_cache'])) {
220
+					$_SESSION['topicseen_cache'] = array();
221
+		}
209 222
 
210 223
 		redirectexit('action=unreadreplies');
211 224
 	}
@@ -230,11 +243,13 @@  discard block
 block discarded – undo
230 243
 		if (!empty($_GET['t']))
231 244
 		{
232 245
 			// If they read the whole topic, go back to the beginning.
233
-			if ($_GET['t'] >= $topicinfo['id_last_msg'])
234
-				$earlyMsg = 0;
246
+			if ($_GET['t'] >= $topicinfo['id_last_msg']) {
247
+							$earlyMsg = 0;
248
+			}
235 249
 			// If they want to mark the whole thing read, same.
236
-			elseif ($_GET['t'] <= $topicinfo['id_first_msg'])
237
-				$earlyMsg = 0;
250
+			elseif ($_GET['t'] <= $topicinfo['id_first_msg']) {
251
+							$earlyMsg = 0;
252
+			}
238 253
 			// Otherwise, get the latest message before the named one.
239 254
 			else
240 255
 			{
@@ -255,9 +270,9 @@  discard block
 block discarded – undo
255 270
 			}
256 271
 		}
257 272
 		// Marking read from first page?  That's the whole topic.
258
-		elseif ($_REQUEST['start'] == 0)
259
-			$earlyMsg = 0;
260
-		else
273
+		elseif ($_REQUEST['start'] == 0) {
274
+					$earlyMsg = 0;
275
+		} else
261 276
 		{
262 277
 			$result = $smcFunc['db_query']('', '
263 278
 				SELECT id_msg
@@ -285,8 +300,7 @@  discard block
 block discarded – undo
285 300
 		);
286 301
 
287 302
 		redirectexit('board=' . $board . '.0');
288
-	}
289
-	else
303
+	} else
290 304
 	{
291 305
 		$categories = array();
292 306
 		$boards = array();
@@ -294,17 +308,20 @@  discard block
 block discarded – undo
294 308
 		if (isset($_REQUEST['c']))
295 309
 		{
296 310
 			$_REQUEST['c'] = explode(',', $_REQUEST['c']);
297
-			foreach ($_REQUEST['c'] as $c)
298
-				$categories[] = (int) $c;
311
+			foreach ($_REQUEST['c'] as $c) {
312
+							$categories[] = (int) $c;
313
+			}
299 314
 		}
300 315
 		if (isset($_REQUEST['boards']))
301 316
 		{
302 317
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
303
-			foreach ($_REQUEST['boards'] as $b)
304
-				$boards[] = (int) $b;
318
+			foreach ($_REQUEST['boards'] as $b) {
319
+							$boards[] = (int) $b;
320
+			}
321
+		}
322
+		if (!empty($board)) {
323
+					$boards[] = (int) $board;
305 324
 		}
306
-		if (!empty($board))
307
-			$boards[] = (int) $board;
308 325
 
309 326
 		if (isset($_REQUEST['children']) && !empty($boards))
310 327
 		{
@@ -324,9 +341,10 @@  discard block
 block discarded – undo
324 341
 					'board_list' => $boards,
325 342
 				)
326 343
 			);
327
-			while ($row = $smcFunc['db_fetch_assoc']($request))
328
-				if (in_array($row['id_parent'], $boards))
344
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
345
+							if (in_array($row['id_parent'], $boards))
329 346
 					$boards[] = $row['id_board'];
347
+			}
330 348
 			$smcFunc['db_free_result']($request);
331 349
 		}
332 350
 
@@ -343,8 +361,9 @@  discard block
 block discarded – undo
343 361
 			$clauseParameters['board_list'] = $boards;
344 362
 		}
345 363
 
346
-		if (empty($clauses))
347
-			redirectexit();
364
+		if (empty($clauses)) {
365
+					redirectexit();
366
+		}
348 367
 
349 368
 		$request = $smcFunc['db_query']('', '
350 369
 			SELECT b.id_board
@@ -355,19 +374,22 @@  discard block
 block discarded – undo
355 374
 			))
356 375
 		);
357 376
 		$boards = array();
358
-		while ($row = $smcFunc['db_fetch_assoc']($request))
359
-			$boards[] = $row['id_board'];
377
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
378
+					$boards[] = $row['id_board'];
379
+		}
360 380
 		$smcFunc['db_free_result']($request);
361 381
 
362
-		if (empty($boards))
363
-			redirectexit();
382
+		if (empty($boards)) {
383
+					redirectexit();
384
+		}
364 385
 
365 386
 		markBoardsRead($boards, isset($_REQUEST['unread']));
366 387
 
367 388
 		foreach ($boards as $b)
368 389
 		{
369
-			if (isset($_SESSION['topicseen_cache'][$b]))
370
-				$_SESSION['topicseen_cache'][$b] = array();
390
+			if (isset($_SESSION['topicseen_cache'][$b])) {
391
+							$_SESSION['topicseen_cache'][$b] = array();
392
+			}
371 393
 		}
372 394
 
373 395
 		if (!isset($_REQUEST['unread']))
@@ -385,8 +407,9 @@  discard block
 block discarded – undo
385 407
 			if ($smcFunc['db_num_rows']($result) > 0)
386 408
 			{
387 409
 				$logBoardInserts = array();
388
-				while ($row = $smcFunc['db_fetch_assoc']($result))
389
-					$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
410
+				while ($row = $smcFunc['db_fetch_assoc']($result)) {
411
+									$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
412
+				}
390 413
 
391 414
 				$smcFunc['db_insert']('replace',
392 415
 					'{db_prefix}log_boards',
@@ -397,17 +420,18 @@  discard block
 block discarded – undo
397 420
 			}
398 421
 			$smcFunc['db_free_result']($result);
399 422
 
400
-			if (empty($board))
401
-				redirectexit();
402
-			else
403
-				redirectexit('board=' . $board . '.0');
404
-		}
405
-		else
423
+			if (empty($board)) {
424
+							redirectexit();
425
+			} else {
426
+							redirectexit('board=' . $board . '.0');
427
+			}
428
+		} else
406 429
 		{
407
-			if (empty($board_info['parent']))
408
-				redirectexit();
409
-			else
410
-				redirectexit('board=' . $board_info['parent'] . '.0');
430
+			if (empty($board_info['parent'])) {
431
+							redirectexit();
432
+			} else {
433
+							redirectexit('board=' . $board_info['parent'] . '.0');
434
+			}
411 435
 		}
412 436
 	}
413 437
 }
@@ -432,11 +456,13 @@  discard block
 block discarded – undo
432 456
 			'selected_message' => (int) $messageID,
433 457
 		)
434 458
 	);
435
-	if ($smcFunc['db_num_rows']($result) > 0)
436
-		list ($memberID) = $smcFunc['db_fetch_row']($result);
459
+	if ($smcFunc['db_num_rows']($result) > 0) {
460
+			list ($memberID) = $smcFunc['db_fetch_row']($result);
461
+	}
437 462
 	// The message doesn't even exist.
438
-	else
439
-		$memberID = 0;
463
+	else {
464
+			$memberID = 0;
465
+	}
440 466
 	$smcFunc['db_free_result']($result);
441 467
 
442 468
 	return (int) $memberID;
@@ -457,8 +483,9 @@  discard block
 block discarded – undo
457 483
 	getBoardTree();
458 484
 
459 485
 	// Make sure given boards and categories exist.
460
-	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']])))
461
-		fatal_lang_error('no_board');
486
+	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) {
487
+			fatal_lang_error('no_board');
488
+	}
462 489
 
463 490
 	$id = $board_id;
464 491
 	call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions));
@@ -486,8 +513,9 @@  discard block
 block discarded – undo
486 513
 			$child_level = 0;
487 514
 			$id_parent = 0;
488 515
 			$after = 0;
489
-			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy)
490
-				$after = max($after, $boards[$id_board]['order']);
516
+			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) {
517
+							$after = max($after, $boards[$id_board]['order']);
518
+			}
491 519
 		}
492 520
 
493 521
 		// Make the board a child of a given board.
@@ -498,17 +526,19 @@  discard block
 block discarded – undo
498 526
 			$id_parent = $boardOptions['target_board'];
499 527
 
500 528
 			// People can be creative, in many ways...
501
-			if (isChildOf($id_parent, $board_id))
502
-				fatal_lang_error('mboards_parent_own_child_error', false);
503
-			elseif ($id_parent == $board_id)
504
-				fatal_lang_error('mboards_board_own_child_error', false);
529
+			if (isChildOf($id_parent, $board_id)) {
530
+							fatal_lang_error('mboards_parent_own_child_error', false);
531
+			} elseif ($id_parent == $board_id) {
532
+							fatal_lang_error('mboards_board_own_child_error', false);
533
+			}
505 534
 
506 535
 			$after = $boards[$boardOptions['target_board']]['order'];
507 536
 
508 537
 			// Check if there are already children and (if so) get the max board order.
509
-			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child']))
510
-				foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
538
+			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) {
539
+							foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
511 540
 					$after = max($after, $boards[$childBoard_id]['order']);
541
+			}
512 542
 		}
513 543
 
514 544
 		// Place a board before or after another board, on the same child level.
@@ -521,8 +551,9 @@  discard block
 block discarded – undo
521 551
 		}
522 552
 
523 553
 		// Oops...?
524
-		else
525
-			trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
554
+		else {
555
+					trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
556
+		}
526 557
 
527 558
 		// Get a list of children of this board.
528 559
 		$childList = array();
@@ -531,14 +562,16 @@  discard block
 block discarded – undo
531 562
 		// See if there are changes that affect children.
532 563
 		$childUpdates = array();
533 564
 		$levelDiff = $child_level - $boards[$board_id]['level'];
534
-		if ($levelDiff != 0)
535
-			$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
536
-		if ($id_cat != $boards[$board_id]['category'])
537
-			$childUpdates[] = 'id_cat = {int:category}';
565
+		if ($levelDiff != 0) {
566
+					$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
567
+		}
568
+		if ($id_cat != $boards[$board_id]['category']) {
569
+					$childUpdates[] = 'id_cat = {int:category}';
570
+		}
538 571
 
539 572
 		// Fix the children of this board.
540
-		if (!empty($childList) && !empty($childUpdates))
541
-			$smcFunc['db_query']('', '
573
+		if (!empty($childList) && !empty($childUpdates)) {
574
+					$smcFunc['db_query']('', '
542 575
 				UPDATE {db_prefix}boards
543 576
 				SET ' . implode(',
544 577
 					', $childUpdates) . '
@@ -549,6 +582,7 @@  discard block
 block discarded – undo
549 582
 					'level_diff' => $levelDiff,
550 583
 				)
551 584
 			);
585
+		}
552 586
 
553 587
 		// Make some room for this spot.
554 588
 		$smcFunc['db_query']('', '
@@ -644,8 +678,8 @@  discard block
 block discarded – undo
644 678
 	call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters));
645 679
 
646 680
 	// Do the updates (if any).
647
-	if (!empty($boardUpdates))
648
-		$smcFunc['db_query']('', '
681
+	if (!empty($boardUpdates)) {
682
+			$smcFunc['db_query']('', '
649 683
 			UPDATE {db_prefix}boards
650 684
 			SET
651 685
 				' . implode(',
@@ -655,13 +689,15 @@  discard block
 block discarded – undo
655 689
 				'selected_board' => $board_id,
656 690
 			))
657 691
 		);
692
+	}
658 693
 	
659 694
 	// Do permission sync
660 695
 	if (!empty($boardUpdateParameters['deny_groups']))
661 696
 	{
662 697
 		$insert = array();
663
-		foreach($boardOptions['deny_groups'] as $value)
664
-			$insert[] = array($value, $board_id, 1);
698
+		foreach($boardOptions['deny_groups'] as $value) {
699
+					$insert[] = array($value, $board_id, 1);
700
+		}
665 701
 
666 702
 		$smcFunc['db_query']('', '
667 703
 			DELETE FROM {db_prefix}board_permissions_view
@@ -681,8 +717,9 @@  discard block
 block discarded – undo
681 717
 	if (!empty($boardUpdateParameters['member_groups']))
682 718
 	{
683 719
 		$insert = array();
684
-		foreach($boardOptions['access_groups'] as $value)
685
-			$insert[] = array($value, $board_id, 0);
720
+		foreach($boardOptions['access_groups'] as $value) {
721
+					$insert[] = array($value, $board_id, 0);
722
+		}
686 723
 		$smcFunc['db_query']('', '
687 724
 			DELETE FROM {db_prefix}board_permissions_view
688 725
 			WHERE id_board = {int:selected_board} AND deny = 0',
@@ -722,13 +759,15 @@  discard block
 block discarded – undo
722 759
 			{
723 760
 				$moderators[$k] = trim($moderators[$k]);
724 761
 
725
-				if (strlen($moderators[$k]) == 0)
726
-					unset($moderators[$k]);
762
+				if (strlen($moderators[$k]) == 0) {
763
+									unset($moderators[$k]);
764
+				}
727 765
 			}
728 766
 
729 767
 			// Find all the id_member's for the member_name's in the list.
730
-			if (empty($boardOptions['moderators']))
731
-				$boardOptions['moderators'] = array();
768
+			if (empty($boardOptions['moderators'])) {
769
+							$boardOptions['moderators'] = array();
770
+			}
732 771
 			if (!empty($moderators))
733 772
 			{
734 773
 				$request = $smcFunc['db_query']('', '
@@ -741,8 +780,9 @@  discard block
 block discarded – undo
741 780
 						'limit' => count($moderators),
742 781
 					)
743 782
 				);
744
-				while ($row = $smcFunc['db_fetch_assoc']($request))
745
-					$boardOptions['moderators'][] = $row['id_member'];
783
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
784
+									$boardOptions['moderators'][] = $row['id_member'];
785
+				}
746 786
 				$smcFunc['db_free_result']($request);
747 787
 			}
748 788
 		}
@@ -751,8 +791,9 @@  discard block
 block discarded – undo
751 791
 		if (!empty($boardOptions['moderators']))
752 792
 		{
753 793
 			$inserts = array();
754
-			foreach ($boardOptions['moderators'] as $moderator)
755
-				$inserts[] = array($board_id, $moderator);
794
+			foreach ($boardOptions['moderators'] as $moderator) {
795
+							$inserts[] = array($board_id, $moderator);
796
+			}
756 797
 
757 798
 			$smcFunc['db_insert']('insert',
758 799
 				'{db_prefix}moderators',
@@ -782,14 +823,16 @@  discard block
 block discarded – undo
782 823
 			{
783 824
 				$moderator_groups[$k] = trim($moderator_groups[$k]);
784 825
 
785
-				if (strlen($moderator_groups[$k]) == 0)
786
-					unset($moderator_groups[$k]);
826
+				if (strlen($moderator_groups[$k]) == 0) {
827
+									unset($moderator_groups[$k]);
828
+				}
787 829
 			}
788 830
 
789 831
 			/* 	Find all the id_group's for all the group names in the list
790 832
 				But skip any invalid ones (invisible/post groups/Administrator/Moderator) */
791
-			if (empty($boardOptions['moderator_groups']))
792
-				$boardOptions['moderator_groups'] = array();
833
+			if (empty($boardOptions['moderator_groups'])) {
834
+							$boardOptions['moderator_groups'] = array();
835
+			}
793 836
 			if (!empty($moderator_groups))
794 837
 			{
795 838
 				$request = $smcFunc['db_query']('', '
@@ -820,8 +863,9 @@  discard block
 block discarded – undo
820 863
 		if (!empty($boardOptions['moderator_groups']))
821 864
 		{
822 865
 			$inserts = array();
823
-			foreach ($boardOptions['moderator_groups'] as $moderator_group)
824
-				$inserts[] = array($board_id, $moderator_group);
866
+			foreach ($boardOptions['moderator_groups'] as $moderator_group) {
867
+							$inserts[] = array($board_id, $moderator_group);
868
+			}
825 869
 
826 870
 			$smcFunc['db_insert']('insert',
827 871
 				'{db_prefix}moderator_groups',
@@ -835,14 +879,16 @@  discard block
 block discarded – undo
835 879
 		updateSettings(array('settings_updated' => time()));
836 880
 	}
837 881
 
838
-	if (isset($boardOptions['move_to']))
839
-		reorderBoards();
882
+	if (isset($boardOptions['move_to'])) {
883
+			reorderBoards();
884
+	}
840 885
 
841 886
 	clean_cache('data');
842 887
 
843
-	if (empty($boardOptions['dont_log']))
844
-		logAction('edit_board', array('board' => $board_id), 'admin');
845
-}
888
+	if (empty($boardOptions['dont_log'])) {
889
+			logAction('edit_board', array('board' => $board_id), 'admin');
890
+	}
891
+	}
846 892
 
847 893
 /**
848 894
  * Create a new board and set its properties and position.
@@ -858,11 +904,13 @@  discard block
 block discarded – undo
858 904
 	global $boards, $smcFunc;
859 905
 
860 906
 	// Trigger an error if one of the required values is not set.
861
-	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category']))
862
-		trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
907
+	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) {
908
+			trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
909
+	}
863 910
 
864
-	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board']))
865
-		trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
911
+	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) {
912
+			trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
913
+	}
866 914
 
867 915
 	// Set every optional value to its default value.
868 916
 	$boardOptions += array(
@@ -901,8 +949,9 @@  discard block
 block discarded – undo
901 949
 
902 950
 	$insert = array();
903 951
 
904
-	foreach(explode(',', $default_memgrps) as $value)
905
-			$insert[] = array($value, $board_id, 0);
952
+	foreach(explode(',', $default_memgrps) as $value) {
953
+				$insert[] = array($value, $board_id, 0);
954
+	}
906 955
 
907 956
 	$smcFunc['db_insert']('',
908 957
 		'{db_prefix}board_permissions_view',
@@ -912,8 +961,9 @@  discard block
 block discarded – undo
912 961
 		1
913 962
 	);
914 963
 
915
-	if (empty($board_id))
916
-		return 0;
964
+	if (empty($board_id)) {
965
+			return 0;
966
+	}
917 967
 
918 968
 	// Change the board according to the given specifications.
919 969
 	modifyBoard($board_id, $boardOptions);
@@ -976,8 +1026,9 @@  discard block
 block discarded – undo
976 1026
 	global $sourcedir, $boards, $smcFunc;
977 1027
 
978 1028
 	// No boards to delete? Return!
979
-	if (empty($boards_to_remove))
980
-		return;
1029
+	if (empty($boards_to_remove)) {
1030
+			return;
1031
+	}
981 1032
 
982 1033
 	getBoardTree();
983 1034
 
@@ -988,12 +1039,14 @@  discard block
 block discarded – undo
988 1039
 	{
989 1040
 		// Get a list of the child boards that will also be removed.
990 1041
 		$child_boards_to_remove = array();
991
-		foreach ($boards_to_remove as $board_to_remove)
992
-			recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1042
+		foreach ($boards_to_remove as $board_to_remove) {
1043
+					recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1044
+		}
993 1045
 
994 1046
 		// Merge the children with their parents.
995
-		if (!empty($child_boards_to_remove))
996
-			$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1047
+		if (!empty($child_boards_to_remove)) {
1048
+					$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1049
+		}
997 1050
 	}
998 1051
 	// Move the children to a safe home.
999 1052
 	else
@@ -1001,10 +1054,11 @@  discard block
 block discarded – undo
1001 1054
 		foreach ($boards_to_remove as $id_board)
1002 1055
 		{
1003 1056
 			// @todo Separate category?
1004
-			if ($moveChildrenTo === 0)
1005
-				fixChildren($id_board, 0, 0);
1006
-			else
1007
-				fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1057
+			if ($moveChildrenTo === 0) {
1058
+							fixChildren($id_board, 0, 0);
1059
+			} else {
1060
+							fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1061
+			}
1008 1062
 		}
1009 1063
 	}
1010 1064
 
@@ -1018,8 +1072,9 @@  discard block
 block discarded – undo
1018 1072
 		)
1019 1073
 	);
1020 1074
 	$topics = array();
1021
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1022
-		$topics[] = $row['id_topic'];
1075
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1076
+			$topics[] = $row['id_topic'];
1077
+	}
1023 1078
 	$smcFunc['db_free_result']($request);
1024 1079
 
1025 1080
 	require_once($sourcedir . '/RemoveTopic.php');
@@ -1116,8 +1171,9 @@  discard block
 block discarded – undo
1116 1171
 	clean_cache('data');
1117 1172
 
1118 1173
 	// Let's do some serious logging.
1119
-	foreach ($boards_to_remove as $id_board)
1120
-		logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1174
+	foreach ($boards_to_remove as $id_board) {
1175
+			logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1176
+	}
1121 1177
 
1122 1178
 	reorderBoards();
1123 1179
 }
@@ -1136,8 +1192,8 @@  discard block
 block discarded – undo
1136 1192
 	$board_order = 0;
1137 1193
 	foreach ($cat_tree as $catID => $dummy)
1138 1194
 	{
1139
-		foreach ($boardList[$catID] as $boardID)
1140
-			if ($boards[$boardID]['order'] != ++$board_order)
1195
+		foreach ($boardList[$catID] as $boardID) {
1196
+					if ($boards[$boardID]['order'] != ++$board_order)
1141 1197
 				$smcFunc['db_query']('', '
1142 1198
 					UPDATE {db_prefix}boards
1143 1199
 					SET board_order = {int:new_order}
@@ -1147,6 +1203,7 @@  discard block
 block discarded – undo
1147 1203
 						'selected_board' => $boardID,
1148 1204
 					)
1149 1205
 				);
1206
+		}
1150 1207
 	}
1151 1208
 
1152 1209
 	// Empty the board order cache
@@ -1175,8 +1232,9 @@  discard block
 block discarded – undo
1175 1232
 		)
1176 1233
 	);
1177 1234
 	$children = array();
1178
-	while ($row = $smcFunc['db_fetch_assoc']($result))
1179
-		$children[] = $row['id_board'];
1235
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
1236
+			$children[] = $row['id_board'];
1237
+	}
1180 1238
 	$smcFunc['db_free_result']($result);
1181 1239
 
1182 1240
 	// ...and set it to a new parent and child_level.
@@ -1192,9 +1250,10 @@  discard block
 block discarded – undo
1192 1250
 	);
1193 1251
 
1194 1252
 	// Recursively fix the children of the children.
1195
-	foreach ($children as $child)
1196
-		fixChildren($child, $newLevel + 1, $child);
1197
-}
1253
+	foreach ($children as $child) {
1254
+			fixChildren($child, $newLevel + 1, $child);
1255
+	}
1256
+	}
1198 1257
 
1199 1258
 /**
1200 1259
  * Tries to load up the entire board order and category very very quickly
@@ -1211,8 +1270,9 @@  discard block
 block discarded – undo
1211 1270
 		'boards' => array(),
1212 1271
 	);
1213 1272
 
1214
-	if (!empty($tree_order['boards']))
1215
-		return $tree_order;
1273
+	if (!empty($tree_order['boards'])) {
1274
+			return $tree_order;
1275
+	}
1216 1276
 
1217 1277
 	if (($cached = cache_get_data('board_order', 86400)) !== null)
1218 1278
 	{
@@ -1228,8 +1288,9 @@  discard block
 block discarded – undo
1228 1288
 	);
1229 1289
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1230 1290
 	{
1231
-		if (!in_array($row['id_cat'], $tree_order['cats']))
1232
-			$tree_order['cats'][] = $row['id_cat'];
1291
+		if (!in_array($row['id_cat'], $tree_order['cats'])) {
1292
+					$tree_order['cats'][] = $row['id_cat'];
1293
+		}
1233 1294
 		$tree_order['boards'][] = $row['id_board'];
1234 1295
 	}
1235 1296
 	$smcFunc['db_free_result']($request);
@@ -1249,16 +1310,19 @@  discard block
 block discarded – undo
1249 1310
 	$tree = getTreeOrder();
1250 1311
 
1251 1312
 	$ordered = array();
1252
-	foreach ($tree['boards'] as $board)
1253
-		if (!empty($boards[$board]))
1313
+	foreach ($tree['boards'] as $board) {
1314
+			if (!empty($boards[$board]))
1254 1315
 		{
1255 1316
 			$ordered[$board] = $boards[$board];
1317
+	}
1256 1318
 
1257
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards']))
1258
-				sortBoards($ordered[$board]['boards']);
1319
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) {
1320
+							sortBoards($ordered[$board]['boards']);
1321
+			}
1259 1322
 
1260
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['children']))
1261
-				sortBoards($ordered[$board]['children']);
1323
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) {
1324
+							sortBoards($ordered[$board]['children']);
1325
+			}
1262 1326
 		}
1263 1327
 
1264 1328
 	$boards = $ordered;
@@ -1274,12 +1338,14 @@  discard block
 block discarded – undo
1274 1338
 	$tree = getTreeOrder();
1275 1339
 
1276 1340
 	$ordered = array();
1277
-	foreach ($tree['cats'] as $cat)
1278
-		if (!empty($categories[$cat]))
1341
+	foreach ($tree['cats'] as $cat) {
1342
+			if (!empty($categories[$cat]))
1279 1343
 		{
1280 1344
 			$ordered[$cat] = $categories[$cat];
1281
-			if (!empty($ordered[$cat]['boards']))
1282
-				sortBoards($ordered[$cat]['boards']);
1345
+	}
1346
+			if (!empty($ordered[$cat]['boards'])) {
1347
+							sortBoards($ordered[$cat]['boards']);
1348
+			}
1283 1349
 		}
1284 1350
 
1285 1351
 	$categories = $ordered;
@@ -1295,8 +1361,9 @@  discard block
 block discarded – undo
1295 1361
 {
1296 1362
 	global $smcFunc, $scripturl, $txt;
1297 1363
 
1298
-	if (empty($boards))
1299
-		return array();
1364
+	if (empty($boards)) {
1365
+			return array();
1366
+	}
1300 1367
 
1301 1368
 	$request = $smcFunc['db_query']('', '
1302 1369
 		SELECT mem.id_member, mem.real_name, mo.id_board
@@ -1310,8 +1377,9 @@  discard block
 block discarded – undo
1310 1377
 	$moderators = array();
1311 1378
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1312 1379
 	{
1313
-		if (empty($moderators[$row['id_board']]))
1314
-			$moderators[$row['id_board']] = array();
1380
+		if (empty($moderators[$row['id_board']])) {
1381
+					$moderators[$row['id_board']] = array();
1382
+		}
1315 1383
 
1316 1384
 		$moderators[$row['id_board']][] = array(
1317 1385
 			'id' => $row['id_member'],
@@ -1335,8 +1403,9 @@  discard block
 block discarded – undo
1335 1403
 {
1336 1404
 	global $smcFunc, $scripturl, $txt;
1337 1405
 
1338
-	if (empty($boards))
1339
-		return array();
1406
+	if (empty($boards)) {
1407
+			return array();
1408
+	}
1340 1409
 
1341 1410
 	$request = $smcFunc['db_query']('', '
1342 1411
 		SELECT mg.id_group, mg.group_name, bg.id_board
@@ -1350,8 +1419,9 @@  discard block
 block discarded – undo
1350 1419
 	$groups = array();
1351 1420
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1352 1421
 	{
1353
-		if (empty($groups[$row['id_board']]))
1354
-			$groups[$row['id_board']] = array();
1422
+		if (empty($groups[$row['id_board']])) {
1423
+					$groups[$row['id_board']] = array();
1424
+		}
1355 1425
 
1356 1426
 		$groups[$row['id_board']][] = array(
1357 1427
 			'id' => $row['id_group'],
@@ -1426,8 +1496,9 @@  discard block
 block discarded – undo
1426 1496
 
1427 1497
 		if (!empty($row['id_board']))
1428 1498
 		{
1429
-			if ($row['child_level'] != $curLevel)
1430
-				$prevBoard = 0;
1499
+			if ($row['child_level'] != $curLevel) {
1500
+							$prevBoard = 0;
1501
+			}
1431 1502
 
1432 1503
 			$boards[$row['id_board']] = array(
1433 1504
 				'id' => $row['id_board'],
@@ -1459,16 +1530,16 @@  discard block
 block discarded – undo
1459 1530
 					'children' => array()
1460 1531
 				);
1461 1532
 				$boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']];
1462
-			}
1463
-			else
1533
+			} else
1464 1534
 			{
1465 1535
 				// Parent doesn't exist!
1466
-				if (!isset($boards[$row['id_parent']]['tree']))
1467
-					fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1536
+				if (!isset($boards[$row['id_parent']]['tree'])) {
1537
+									fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1538
+				}
1468 1539
 
1469 1540
 				// Wrong childlevel...we can silently fix this...
1470
-				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1)
1471
-					$smcFunc['db_query']('', '
1541
+				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) {
1542
+									$smcFunc['db_query']('', '
1472 1543
 						UPDATE {db_prefix}boards
1473 1544
 						SET child_level = {int:new_child_level}
1474 1545
 						WHERE id_board = {int:selected_board}',
@@ -1477,6 +1548,7 @@  discard block
 block discarded – undo
1477 1548
 							'selected_board' => $row['id_board'],
1478 1549
 						)
1479 1550
 					);
1551
+				}
1480 1552
 
1481 1553
 				$boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array(
1482 1554
 					'node' => &$boards[$row['id_board']],
@@ -1510,8 +1582,9 @@  discard block
 block discarded – undo
1510 1582
  */
1511 1583
 function recursiveBoards(&$_boardList, &$_tree)
1512 1584
 {
1513
-	if (empty($_tree['children']))
1514
-		return;
1585
+	if (empty($_tree['children'])) {
1586
+			return;
1587
+	}
1515 1588
 
1516 1589
 	foreach ($_tree['children'] as $id => $node)
1517 1590
 	{
@@ -1530,11 +1603,13 @@  discard block
 block discarded – undo
1530 1603
 {
1531 1604
 	global $boards;
1532 1605
 
1533
-	if (empty($boards[$child]['parent']))
1534
-		return false;
1606
+	if (empty($boards[$child]['parent'])) {
1607
+			return false;
1608
+	}
1535 1609
 
1536
-	if ($boards[$child]['parent'] == $parent)
1537
-		return true;
1610
+	if ($boards[$child]['parent'] == $parent) {
1611
+			return true;
1612
+	}
1538 1613
 
1539 1614
 	return isChildOf($boards[$child]['parent'], $parent);
1540 1615
 }
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	$smcFunc['db_free_result']($result_boards);
136 136
 
137 137
 	// Run through the categories and boards (or only boards)....
138
-	for (reset($row_boards); key($row_boards)!==null; next($row_boards))
138
+	for (reset($row_boards); key($row_boards) !== null; next($row_boards))
139 139
 	{
140 140
 		$row_board = current($row_boards);
141 141
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 					$row_boards[$row_board['id_parent']]['id_msg'] = $row_board['id_msg'];
304 304
 					$row_boards[$row_board['id_parent']]['subject'] = $row_board['subject'];
305 305
 					$row_boards[$row_board['id_parent']]['poster_time'] = $row_board['poster_time'];
306
-					$row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : '') ;
306
+					$row_boards[$row_board['id_parent']]['short_subject'] = (!empty($row_board['short_subject']) ? $row_board['short_subject'] : '');
307 307
 					$row_boards[$row_board['id_parent']]['poster_name'] = $row_board['poster_name'];
308 308
 					$row_boards[$row_board['id_parent']]['real_name'] = $row_board['real_name'];
309 309
 					$row_boards[$row_board['id_parent']]['id_member'] = $row_board['id_member'];
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
 		// Set the last post in the root board 
375 375
 		if (!$isChild && !empty($row_board['poster_time'])
376
-			&& ( empty($this_category[$row_board['id_board']]['last_post']['timestamp'])
376
+			&& (empty($this_category[$row_board['id_board']]['last_post']['timestamp'])
377 377
 				|| $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])
378 378
 				)
379 379
 			)
Please login to merge, or discard this patch.
Braces   +74 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * Fetches a list of boards and (optional) categories including
@@ -37,19 +38,21 @@  discard block
 block discarded – undo
37 38
 	require_once($sourcedir . '/Subs-Boards.php');
38 39
 
39 40
 	// For performance, track the latest post while going through the boards.
40
-	if (!empty($boardIndexOptions['set_latest_post']))
41
-		$latest_post = array(
41
+	if (!empty($boardIndexOptions['set_latest_post'])) {
42
+			$latest_post = array(
42 43
 			'timestamp' => 0,
43 44
 			'ref' => 0,
44 45
 		);
46
+	}
45 47
 
46 48
 	// This setting is not allowed to be empty
47
-	if (empty($modSettings['boardindex_max_depth']))
48
-		$modSettings['boardindex_max_depth'] = 1;
49
+	if (empty($modSettings['boardindex_max_depth'])) {
50
+			$modSettings['boardindex_max_depth'] = 1;
51
+	}
49 52
 
50 53
 	// Find all boards and categories, as well as related information.  This will be sorted by the natural order of boards and categories, which we control.
51
-	if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']())
52
-		$result_boards = $smcFunc['db_query']('', '
54
+	if ($boardIndexOptions['parent_id'] != 0 && $smcFunc['db_cte_support']()) {
55
+			$result_boards = $smcFunc['db_query']('', '
53 56
 			WITH RECURSIVE 
54 57
 				boards_cte (child_level, id_board, name , description, redirect, num_posts, num_topics, unapproved_posts, unapproved_topics, id_parent, id_msg_updated, id_cat, id_last_msg, board_order)
55 58
 			as
@@ -91,8 +94,8 @@  discard block
 block discarded – undo
91 94
 				'id_parent' => $boardIndexOptions['parent_id'],
92 95
 			)
93 96
 		);
94
-	else
95
-		$result_boards = $smcFunc['db_query']('', '
97
+	} else {
98
+			$result_boards = $smcFunc['db_query']('', '
96 99
 			SELECT' . ($boardIndexOptions['include_categories'] ? '
97 100
 				c.id_cat, c.name AS cat_name, c.description AS cat_desc,' : '') . '
98 101
 				b.id_board, b.name AS board_name, b.description,
@@ -120,18 +123,21 @@  discard block
 block discarded – undo
120 123
 				'blank_string' => '',
121 124
 			)
122 125
 		);
126
+	}
123 127
 
124 128
 	// Start with an empty array.
125
-	if ($boardIndexOptions['include_categories'])
126
-		$categories = array();
127
-	else
128
-		$this_category = array();
129
+	if ($boardIndexOptions['include_categories']) {
130
+			$categories = array();
131
+	} else {
132
+			$this_category = array();
133
+	}
129 134
 	$boards = array();
130 135
 
131 136
 	// Children can affect parents, so we need to gather all the boards first and then process them after.
132 137
 	$row_boards = array();
133
-	while ($row_board = $smcFunc['db_fetch_assoc']($result_boards))
134
-		$row_boards[$row_board['id_board']] = $row_board;
138
+	while ($row_board = $smcFunc['db_fetch_assoc']($result_boards)) {
139
+			$row_boards[$row_board['id_board']] = $row_board;
140
+	}
135 141
 	$smcFunc['db_free_result']($result_boards);
136 142
 
137 143
 	// Run through the categories and boards (or only boards)....
@@ -144,8 +150,9 @@  discard block
 block discarded – undo
144 150
 		$row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0';
145 151
 
146 152
 		// Add parent boards to the $boards list later used to fetch moderators
147
-		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'])
148
-			$boards[] = $row_board['id_board'];
153
+		if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) {
154
+					$boards[] = $row_board['id_board'];
155
+		}
149 156
 
150 157
 		if ($boardIndexOptions['include_categories'])
151 158
 		{
@@ -167,8 +174,9 @@  discard block
 block discarded – undo
167 174
 			}
168 175
 
169 176
 			// If this board has new posts in it (and isn't the recycle bin!) then the category is new.
170
-			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board'])
171
-				$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']);
177
+			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) {
178
+							$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']);
179
+			}
172 180
 
173 181
 			// Avoid showing category unread link where it only has redirection boards.
174 182
 			$categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect'];
@@ -187,8 +195,9 @@  discard block
 block discarded – undo
187 195
 				$isChild = false;
188 196
 
189 197
 				// We might or might not have already added this board, so...
190
-				if (!isset($this_category[$row_board['id_board']]))
191
-					$this_category[$row_board['id_board']] = array();
198
+				if (!isset($this_category[$row_board['id_board']])) {
199
+									$this_category[$row_board['id_board']] = array();
200
+				}
192 201
 
193 202
 				$this_category[$row_board['id_board']] += array(
194 203
 					'new' => empty($row_board['is_read']),
@@ -221,14 +230,12 @@  discard block
 block discarded – undo
221 230
 				{
222 231
 					$this_category[$row_board['id_board']]['board_class'] = 'redirect';
223 232
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board'];
224
-				}
225
-				elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
233
+				} elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
226 234
 				{
227 235
 					// If we're showing to guests, we want to give them the idea that something interesting is going on!
228 236
 					$this_category[$row_board['id_board']]['board_class'] = 'on';
229 237
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts'];
230
-				}
231
-				else
238
+				} else
232 239
 				{
233 240
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts'];
234 241
 				}
@@ -240,12 +247,13 @@  discard block
 block discarded – undo
240 247
 			$isChild = true;
241 248
 
242 249
 			// Ensure the parent has at least the most important info defined
243
-			if (!isset($this_category[$row_board['id_parent']]))
244
-				$this_category[$row_board['id_parent']] = array(
250
+			if (!isset($this_category[$row_board['id_parent']])) {
251
+							$this_category[$row_board['id_parent']] = array(
245 252
 					'children' => array(),
246 253
 					'children_new' => false,
247 254
 					'board_class' => 'off',
248 255
 				);
256
+			}
249 257
 
250 258
 			$this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array(
251 259
 				'id' => $row_board['id_board'],
@@ -289,8 +297,9 @@  discard block
 block discarded – undo
289 297
 			// Propagate some values to the parent board
290 298
 			if (isset($row_boards[$row_board['id_parent']]))
291 299
 			{
292
-				if (empty($row_board['is_read']))
293
-					$row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read'];
300
+				if (empty($row_board['is_read'])) {
301
+									$row_boards[$row_board['id_parent']]['is_read'] = $row_board['is_read'];
302
+				}
294 303
 
295 304
 				if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect'])
296 305
 				{
@@ -341,12 +350,13 @@  discard block
 block discarded – undo
341 350
 			'topic' => $row_board['id_topic']
342 351
 		);
343 352
 
344
-		if (!empty($settings['avatars_on_boardIndex']))
345
-			$this_last_post['member']['avatar'] = set_avatar_data(array(
353
+		if (!empty($settings['avatars_on_boardIndex'])) {
354
+					$this_last_post['member']['avatar'] = set_avatar_data(array(
346 355
 				'avatar' => $row_board['avatar'],
347 356
 				'email' => $row_board['email_address'],
348 357
 				'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '',
349 358
 			));
359
+		}
350 360
 
351 361
 		// Provide the href and link.
352 362
 		if ($row_board['subject'] != '')
@@ -358,8 +368,7 @@  discard block
 block discarded – undo
358 368
 			link, href, subject, start (where they should go for the first unread post.),
359 369
 			and member. (which has id, name, link, href, username in it.) */
360 370
 			$this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']);
361
-		}
362
-		else
371
+		} else
363 372
 		{
364 373
 			$this_last_post['href'] = '';
365 374
 			$this_last_post['link'] = $txt['not_applicable'];
@@ -368,27 +377,31 @@  discard block
 block discarded – undo
368 377
 
369 378
 		// Set the last post in the parent board.
370 379
 		if ($isChild && !empty($row_board['poster_time']) 
371
-				&& $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time'])
372
-			$this_category[$row_board['id_parent']]['last_post'] = $this_last_post;
380
+				&& $row_boards[$row_board['id_parent']]['poster_time'] < $row_board['poster_time']) {
381
+					$this_category[$row_board['id_parent']]['last_post'] = $this_last_post;
382
+		}
373 383
 
374 384
 		// Set the last post in the root board 
375 385
 		if (!$isChild && !empty($row_board['poster_time'])
376 386
 			&& ( empty($this_category[$row_board['id_board']]['last_post']['timestamp'])
377 387
 				|| $this_category[$row_board['id_board']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])
378 388
 				)
379
-			)
380
-			$this_category[$row_board['id_board']]['last_post'] = $this_last_post;
389
+			) {
390
+					$this_category[$row_board['id_board']]['last_post'] = $this_last_post;
391
+		}
381 392
 
382 393
 		// Just in the child...?
383
-		if ($isChild)
384
-			$this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post;
394
+		if ($isChild) {
395
+					$this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post;
396
+		}
385 397
 
386 398
 		// Determine a global most recent topic.
387
-		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard)
388
-			$latest_post = array(
399
+		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) {
400
+					$latest_post = array(
389 401
 				'timestamp' => $row_board['poster_time'],
390 402
 				'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'],
391 403
 			);
404
+		}
392 405
 	}
393 406
 
394 407
 	// Fetch the board's moderators and moderator groups
@@ -404,8 +417,9 @@  discard block
 block discarded – undo
404 417
 				if (!empty($moderators[$board['id']]))
405 418
 				{
406 419
 					$categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']];
407
-					foreach ($moderators[$board['id']] as $moderator)
408
-						$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
420
+					foreach ($moderators[$board['id']] as $moderator) {
421
+											$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
422
+					}
409 423
 				}
410 424
 				if (!empty($groups[$board['id']]))
411 425
 				{
@@ -418,16 +432,16 @@  discard block
 block discarded – undo
418 432
 				}
419 433
 			}
420 434
 		}
421
-	}
422
-	else
435
+	} else
423 436
 	{
424 437
 		foreach ($this_category as $k => $board)
425 438
 		{
426 439
 			if (!empty($moderators[$board['id']]))
427 440
 			{
428 441
 				$this_category[$k]['moderators'] = $moderators[$board['id']];
429
-				foreach ($moderators[$board['id']] as $moderator)
430
-					$this_category[$k]['link_moderators'][] = $moderator['link'];
442
+				foreach ($moderators[$board['id']] as $moderator) {
443
+									$this_category[$k]['link_moderators'][] = $moderator['link'];
444
+				}
431 445
 			}
432 446
 			if (!empty($groups[$board['id']]))
433 447
 			{
@@ -441,20 +455,23 @@  discard block
 block discarded – undo
441 455
 		}
442 456
 	}
443 457
 
444
-	if ($boardIndexOptions['include_categories'])
445
-		sortCategories($categories);
446
-	else
447
-		sortBoards($this_category);
458
+	if ($boardIndexOptions['include_categories']) {
459
+			sortCategories($categories);
460
+	} else {
461
+			sortBoards($this_category);
462
+	}
448 463
 
449 464
 	// By now we should know the most recent post...if we wanna know it that is.
450
-	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref']))
451
-		$context['latest_post'] = $latest_post['ref'];
465
+	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) {
466
+			$context['latest_post'] = $latest_post['ref'];
467
+	}
452 468
 
453 469
 	// I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea.
454
-	if ($boardIndexOptions['include_categories'])
455
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
456
-	else
457
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
470
+	if ($boardIndexOptions['include_categories']) {
471
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
472
+	} else {
473
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
474
+	}
458 475
 
459 476
 	return $boardIndexOptions['include_categories'] ? $categories : $this_category;
460 477
 }
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +54 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,16 +83,18 @@  discard block
 block discarded – undo
83 83
 		foreach ($section['areas'] as $i => $area)
84 84
 		{
85 85
 			// Not supposed to be printed?
86
-			if (empty($area['label']))
87
-				continue;
86
+			if (empty($area['label'])) {
87
+							continue;
88
+			}
88 89
 
89 90
 			echo '
90 91
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>
91 92
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>';
92 93
 
93 94
 			// Is this the current area, or just some area?
94
-			if (!empty($area['selected']) && empty($context['tabs']))
95
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
95
+			if (!empty($area['selected']) && empty($context['tabs'])) {
96
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
97
+			}
96 98
 
97 99
 			// Are there any subsections?
98 100
 			if (!empty($area['subsections']))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 
103 105
 				foreach ($area['subsections'] as $sa => $sub)
104 106
 				{
105
-					if (!empty($sub['disabled']))
106
-						continue;
107
+					if (!empty($sub['disabled'])) {
108
+											continue;
109
+					}
107 110
 
108 111
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
109 112
 
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 							<h3 class="catbg">';
151 154
 
152 155
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
153
-		if (function_exists('template_admin_quick_search'))
154
-			template_admin_quick_search();
156
+		if (function_exists('template_admin_quick_search')) {
157
+					template_admin_quick_search();
158
+		}
155 159
 
156 160
 		// Exactly how many tabs do we have?
157 161
 		if (!empty($context['tabs']))
@@ -166,30 +170,36 @@  discard block
 block discarded – undo
166 170
 				}
167 171
 
168 172
 				// Did this not even exist - or do we not have a label?
169
-				if (!isset($tab_context['tabs'][$id]))
170
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
171
-				elseif (!isset($tab_context['tabs'][$id]['label']))
172
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
173
+				if (!isset($tab_context['tabs'][$id])) {
174
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
175
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
176
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
177
+				}
173 178
 
174 179
 				// Has a custom URL defined in the main admin structure?
175
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
176
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
180
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
181
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
182
+				}
177 183
 
178 184
 				// Any additional paramaters for the url?
179
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
180
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
185
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
186
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
187
+				}
181 188
 
182 189
 				// Has it been deemed selected?
183
-				if (!empty($tab['is_selected']))
184
-					$tab_context['tabs'][$id]['is_selected'] = true;
190
+				if (!empty($tab['is_selected'])) {
191
+									$tab_context['tabs'][$id]['is_selected'] = true;
192
+				}
185 193
 
186 194
 				// Does it have its own help?
187
-				if (!empty($tab['help']))
188
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
195
+				if (!empty($tab['help'])) {
196
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
197
+				}
189 198
 
190 199
 				// Is this the last one?
191
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
192
-					$tab_context['tabs'][$id]['is_last'] = true;
200
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
201
+									$tab_context['tabs'][$id]['is_last'] = true;
202
+				}
193 203
 			}
194 204
 
195 205
 			// Find the selected tab
@@ -206,22 +216,24 @@  discard block
 block discarded – undo
206 216
 		// Show an icon and/or a help item?
207 217
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
208 218
 		{
209
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
210
-				echo '
219
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
220
+							echo '
211 221
 								<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
212
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
213
-				echo '
222
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
223
+							echo '
214 224
 								<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
225
+			}
215 226
 
216
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
217
-				echo '
227
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
228
+							echo '
218 229
 								<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
230
+			}
219 231
 
220 232
 			echo $tab_context['title'];
221
-		}
222
-		else
223
-			echo '
233
+		} else {
234
+					echo '
224 235
 								', $tab_context['title'];
236
+		}
225 237
 
226 238
 		echo '
227 239
 							</h3>', (function_exists('template_admin_quick_search') ? '
@@ -230,11 +242,12 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	// Shall we use the tabs? Yes, it's the only known way!
233
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
234
-		echo '
245
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
246
+			echo '
235 247
 					<p class="information">
236 248
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
237 249
 					</p>';
250
+	}
238 251
 
239 252
 	// Print out all the items in this tab (if any).
240 253
 	if (!empty($context['tabs']))
@@ -246,19 +259,21 @@  discard block
 block discarded – undo
246 259
 
247 260
 		foreach ($tab_context['tabs'] as $sa => $tab)
248 261
 		{
249
-			if (!empty($tab['disabled']))
250
-				continue;
262
+			if (!empty($tab['disabled'])) {
263
+							continue;
264
+			}
251 265
 
252
-			if (!empty($tab['is_selected']))
253
-				echo '
266
+			if (!empty($tab['is_selected'])) {
267
+							echo '
254 268
 							<li>
255 269
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
256 270
 							</li>';
257
-			else
258
-				echo '
271
+			} else {
272
+							echo '
259 273
 							<li>
260 274
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
261 275
 							</li>';
276
+			}
262 277
 		}
263 278
 
264 279
 		// The end of tabs
Please login to merge, or discard this patch.