Completed
Pull Request — release-2.1 (#4089)
by Sebastiaan
08:14
created
Sources/ManageNews.php 1 patch
Braces   +141 added lines, -104 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The news dispatcher; doesn't do anything, just delegates.
@@ -67,8 +68,9 @@  discard block
 block discarded – undo
67 68
 	);
68 69
 
69 70
 	// Force the right area...
70
-	if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
71
-		$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
71
+	if (substr($_REQUEST['sa'], 0, 7) == 'mailing') {
72
+			$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
73
+	}
72 74
 
73 75
 	call_helper($subActions[$_REQUEST['sa']][0]);
74 76
 }
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		$temp_news = explode("\n", $modSettings['news']);
100 102
 
101 103
 		// Remove the items that were selected.
102
-		foreach ($temp_news as $i => $news)
103
-			if (in_array($i, $_POST['remove']))
104
+		foreach ($temp_news as $i => $news) {
105
+					if (in_array($i, $_POST['remove']))
104 106
 				unset($temp_news[$i]);
107
+		}
105 108
 
106 109
 		// Update the database.
107 110
 		updateSettings(array('news' => implode("\n", $temp_news)));
@@ -117,9 +120,9 @@  discard block
 block discarded – undo
117 120
 
118 121
 		foreach ($_POST['news'] as $i => $news)
119 122
 		{
120
-			if (trim($news) == '')
121
-				unset($_POST['news'][$i]);
122
-			else
123
+			if (trim($news) == '') {
124
+							unset($_POST['news'][$i]);
125
+			} else
123 126
 			{
124 127
 				$_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES);
125 128
 				preparsecode($_POST['news'][$i]);
@@ -154,11 +157,12 @@  discard block
 block discarded – undo
154 157
 				'data' => array(
155 158
 					'function' => function($news)
156 159
 					{
157
-						if (is_numeric($news['id']))
158
-							return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
160
+						if (is_numeric($news['id'])) {
161
+													return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
159 162
 							<div class="floatleft" id="preview_' . $news['id'] . '"></div>';
160
-						else
161
-							return $news['unparsed'];
163
+						} else {
164
+													return $news['unparsed'];
165
+						}
162 166
 					},
163 167
 					'style' => 'width: 50%;',
164 168
 				),
@@ -183,10 +187,11 @@  discard block
 block discarded – undo
183 187
 				'data' => array(
184 188
 					'function' => function($news)
185 189
 					{
186
-						if (is_numeric($news['id']))
187
-							return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">';
188
-						else
189
-							return '';
190
+						if (is_numeric($news['id'])) {
191
+													return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">';
192
+						} else {
193
+													return '';
194
+						}
190 195
 					},
191 196
 					'class' => 'centercol',
192 197
 				),
@@ -280,12 +285,13 @@  discard block
 block discarded – undo
280 285
 
281 286
 	$admin_current_news = array();
282 287
 	// Ready the current news.
283
-	foreach (explode("\n", $modSettings['news']) as $id => $line)
284
-		$admin_current_news[$id] = array(
288
+	foreach (explode("\n", $modSettings['news']) as $id => $line) {
289
+			$admin_current_news[$id] = array(
285 290
 			'id' => $id,
286 291
 			'unparsed' => un_preparsecode($line),
287 292
 			'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext">&lt;$1form&gt;</em>', parse_bbc($line)),
288 293
 		);
294
+	}
289 295
 
290 296
 	$admin_current_news['last'] = array(
291 297
 		'id' => 'last',
@@ -352,10 +358,11 @@  discard block
 block discarded – undo
352 358
 			'member_count' => 0,
353 359
 		);
354 360
 
355
-		if ($row['min_posts'] == -1)
356
-			$normalGroups[$row['id_group']] = $row['id_group'];
357
-		else
358
-			$postGroups[$row['id_group']] = $row['id_group'];
361
+		if ($row['min_posts'] == -1) {
362
+					$normalGroups[$row['id_group']] = $row['id_group'];
363
+		} else {
364
+					$postGroups[$row['id_group']] = $row['id_group'];
365
+		}
359 366
 	}
360 367
 	$smcFunc['db_free_result']($request);
361 368
 
@@ -371,8 +378,9 @@  discard block
 block discarded – undo
371 378
 				'post_group_list' => $postGroups,
372 379
 			)
373 380
 		);
374
-		while ($row = $smcFunc['db_fetch_assoc']($query))
375
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
381
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
382
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
383
+		}
376 384
 		$smcFunc['db_free_result']($query);
377 385
 	}
378 386
 
@@ -388,8 +396,9 @@  discard block
 block discarded – undo
388 396
 				'normal_group_list' => $normalGroups,
389 397
 			)
390 398
 		);
391
-		while ($row = $smcFunc['db_fetch_assoc']($query))
392
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
399
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
400
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
401
+		}
393 402
 		$smcFunc['db_free_result']($query);
394 403
 
395 404
 		// Also do those who have it as an additional membergroup - this ones more yucky...
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
 				'blank_string' => '',
407 416
 			)
408 417
 		);
409
-		while ($row = $smcFunc['db_fetch_assoc']($query))
410
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
419
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
420
+		}
411 421
 		$smcFunc['db_free_result']($query);
412 422
 	}
413 423
 
@@ -458,10 +468,11 @@  discard block
 block discarded – undo
458 468
 	{
459 469
 		$context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : '';
460 470
 
461
-		if (empty($context[$key]) && empty($_REQUEST['xml']))
462
-			$context['post_error']['messages'][] = $txt['error_no_' . $post];
463
-		elseif (!empty($_REQUEST['xml']))
464
-			continue;
471
+		if (empty($context[$key]) && empty($_REQUEST['xml'])) {
472
+					$context['post_error']['messages'][] = $txt['error_no_' . $post];
473
+		} elseif (!empty($_REQUEST['xml'])) {
474
+					continue;
475
+		}
465 476
 
466 477
 		preparsecode($context[$key]);
467 478
 		if ($html)
@@ -540,10 +551,12 @@  discard block
 block discarded – undo
540 551
 
541 552
 	// Start by finding any members!
542 553
 	$toClean = array();
543
-	if (!empty($_POST['members']))
544
-		$toClean[] = 'members';
545
-	if (!empty($_POST['exclude_members']))
546
-		$toClean[] = 'exclude_members';
554
+	if (!empty($_POST['members'])) {
555
+			$toClean[] = 'members';
556
+	}
557
+	if (!empty($_POST['exclude_members'])) {
558
+			$toClean[] = 'exclude_members';
559
+	}
547 560
 	if (!empty($toClean))
548 561
 	{
549 562
 		require_once($sourcedir . '/Subs-Auth.php');
@@ -555,11 +568,13 @@  discard block
 block discarded – undo
555 568
 			preg_match_all('~"([^"]+)"~', $_POST[$type], $matches);
556 569
 			$_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type]))));
557 570
 
558
-			foreach ($_POST[$type] as $index => $member)
559
-				if (strlen(trim($member)) > 0)
571
+			foreach ($_POST[$type] as $index => $member) {
572
+							if (strlen(trim($member)) > 0)
560 573
 					$_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member)));
561
-				else
562
-					unset($_POST[$type][$index]);
574
+			}
575
+				else {
576
+									unset($_POST[$type][$index]);
577
+				}
563 578
 
564 579
 			// Find the members
565 580
 			$_POST[$type] = implode(',', array_keys(findMembers($_POST[$type])));
@@ -569,16 +584,18 @@  discard block
 block discarded – undo
569 584
 	if (isset($_POST['member_list']) && is_array($_POST['member_list']))
570 585
 	{
571 586
 		$members = array();
572
-		foreach ($_POST['member_list'] as $member_id)
573
-			$members[] = (int) $member_id;
587
+		foreach ($_POST['member_list'] as $member_id) {
588
+					$members[] = (int) $member_id;
589
+		}
574 590
 		$_POST['members'] = implode(',', $members);
575 591
 	}
576 592
 
577 593
 	if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list']))
578 594
 	{
579 595
 		$members = array();
580
-		foreach ($_POST['exclude_member_list'] as $member_id)
581
-			$members[] = (int) $member_id;
596
+		foreach ($_POST['exclude_member_list'] as $member_id) {
597
+					$members[] = (int) $member_id;
598
+		}
582 599
 		$_POST['exclude_members'] = implode(',', $members);
583 600
 	}
584 601
 
@@ -602,8 +619,9 @@  discard block
 block discarded – undo
602 619
 			'current_time' => time(),
603 620
 		)
604 621
 	);
605
-	while ($row = $smcFunc['db_fetch_assoc']($request))
606
-		$context['recipients']['exclude_members'][] = $row['id_member'];
622
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
623
+			$context['recipients']['exclude_members'][] = $row['id_member'];
624
+	}
607 625
 	$smcFunc['db_free_result']($request);
608 626
 
609 627
 	$request = $smcFunc['db_query']('', '
@@ -638,8 +656,9 @@  discard block
 block discarded – undo
638 656
 			WHERE email_address IN(' . implode(', ', $condition_array) . ')',
639 657
 			$condition_array_params
640 658
 		);
641
-		while ($row = $smcFunc['db_fetch_assoc']($request))
642
-			$context['recipients']['exclude_members'][] = $row['id_member'];
659
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
660
+					$context['recipients']['exclude_members'][] = $row['id_member'];
661
+		}
643 662
 		$smcFunc['db_free_result']($request);
644 663
 	}
645 664
 
@@ -657,10 +676,11 @@  discard block
 block discarded – undo
657 676
 		);
658 677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
659 678
 		{
660
-			if (in_array(3, $context['recipients']))
661
-				$context['recipients']['exclude_members'][] = $row['identifier'];
662
-			else
663
-				$context['recipients']['members'][] = $row['identifier'];
679
+			if (in_array(3, $context['recipients'])) {
680
+							$context['recipients']['exclude_members'][] = $row['identifier'];
681
+			} else {
682
+							$context['recipients']['members'][] = $row['identifier'];
683
+			}
664 684
 		}
665 685
 		$smcFunc['db_free_result']($request);
666 686
 	}
@@ -707,8 +727,9 @@  discard block
 block discarded – undo
707 727
 	$num_at_once = 1000;
708 728
 
709 729
 	// If by PM's I suggest we half the above number.
710
-	if (!empty($_POST['send_pm']))
711
-		$num_at_once /= 2;
730
+	if (!empty($_POST['send_pm'])) {
731
+			$num_at_once /= 2;
732
+	}
712 733
 
713 734
 	checkSession();
714 735
 
@@ -731,8 +752,7 @@  discard block
 block discarded – undo
731 752
 		);
732 753
 		list ($context['total_members']) = $smcFunc['db_fetch_row']($request);
733 754
 		$smcFunc['db_free_result']($request);
734
-	}
735
-	else
755
+	} else
736 756
 	{
737 757
 		$context['total_members'] = (int) $_REQUEST['total_members'];
738 758
 	}
@@ -750,32 +770,35 @@  discard block
 block discarded – undo
750 770
 	if (!empty($_POST['exclude_members']))
751 771
 	{
752 772
 		$members = explode(',', $_POST['exclude_members']);
753
-		foreach ($members as $member)
754
-			if ($member >= $context['start'])
773
+		foreach ($members as $member) {
774
+					if ($member >= $context['start'])
755 775
 				$context['recipients']['exclude_members'][] = (int) $member;
776
+		}
756 777
 	}
757 778
 
758 779
 	// What about members we *must* do?
759 780
 	if (!empty($_POST['members']))
760 781
 	{
761 782
 		$members = explode(',', $_POST['members']);
762
-		foreach ($members as $member)
763
-			if ($member >= $context['start'])
783
+		foreach ($members as $member) {
784
+					if ($member >= $context['start'])
764 785
 				$context['recipients']['members'][] = (int) $member;
786
+		}
765 787
 	}
766 788
 	// Cleaning groups is simple - although deal with both checkbox and commas.
767 789
 	if (isset($_POST['groups']))
768 790
 	{
769 791
 		if (is_array($_POST['groups']))
770 792
 		{
771
-			foreach ($_POST['groups'] as $group => $dummy)
772
-				$context['recipients']['groups'][] = (int) $group;
773
-		}
774
-		else
793
+			foreach ($_POST['groups'] as $group => $dummy) {
794
+							$context['recipients']['groups'][] = (int) $group;
795
+			}
796
+		} else
775 797
 		{
776 798
 			$groups = explode(',', $_POST['groups']);
777
-			foreach ($groups as $group)
778
-				$context['recipients']['groups'][] = (int) $group;
799
+			foreach ($groups as $group) {
800
+							$context['recipients']['groups'][] = (int) $group;
801
+			}
779 802
 		}
780 803
 	}
781 804
 	// Same for excluded groups
@@ -783,14 +806,15 @@  discard block
 block discarded – undo
783 806
 	{
784 807
 		if (is_array($_POST['exclude_groups']))
785 808
 		{
786
-			foreach ($_POST['exclude_groups'] as $group => $dummy)
787
-				$context['recipients']['exclude_groups'][] = (int) $group;
788
-		}
789
-		else
809
+			foreach ($_POST['exclude_groups'] as $group => $dummy) {
810
+							$context['recipients']['exclude_groups'][] = (int) $group;
811
+			}
812
+		} else
790 813
 		{
791 814
 			$groups = explode(',', $_POST['exclude_groups']);
792
-			foreach ($groups as $group)
793
-				$context['recipients']['exclude_groups'][] = (int) $group;
815
+			foreach ($groups as $group) {
816
+							$context['recipients']['exclude_groups'][] = (int) $group;
817
+			}
794 818
 		}
795 819
 	}
796 820
 	// Finally - emails!
@@ -800,14 +824,16 @@  discard block
 block discarded – undo
800 824
 		foreach ($addressed as $curmem)
801 825
 		{
802 826
 			$curmem = trim($curmem);
803
-			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL))
804
-				$context['recipients']['emails'][$curmem] = $curmem;
827
+			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) {
828
+							$context['recipients']['emails'][$curmem] = $curmem;
829
+			}
805 830
 		}
806 831
 	}
807 832
 
808 833
 	// If we're only cleaning drop out here.
809
-	if ($clean_only)
810
-		return;
834
+	if ($clean_only) {
835
+			return;
836
+	}
811 837
 
812 838
 	require_once($sourcedir . '/Subs-Post.php');
813 839
 
@@ -823,16 +849,18 @@  discard block
 block discarded – undo
823 849
 	if (!$context['send_pm'] && !empty($_POST['send_html']))
824 850
 	{
825 851
 		// Prepare the message for HTML.
826
-		if (!empty($_POST['parse_html']))
827
-			$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
852
+		if (!empty($_POST['parse_html'])) {
853
+					$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
854
+		}
828 855
 
829 856
 		// This is here to prevent spam filters from tagging this as spam.
830 857
 		if (preg_match('~\<html~i', $_POST['message']) == 0)
831 858
 		{
832
-			if (preg_match('~\<body~i', $_POST['message']) == 0)
833
-				$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
834
-			else
835
-				$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
859
+			if (preg_match('~\<body~i', $_POST['message']) == 0) {
860
+							$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
861
+			} else {
862
+							$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
863
+			}
836 864
 		}
837 865
 	}
838 866
 
@@ -886,15 +914,17 @@  discard block
 block discarded – undo
886 914
 	foreach ($context['recipients']['emails'] as $k => $email)
887 915
 	{
888 916
 		// Done as many as we can?
889
-		if ($i >= $num_at_once)
890
-			break;
917
+		if ($i >= $num_at_once) {
918
+					break;
919
+		}
891 920
 
892 921
 		// Don't sent it twice!
893 922
 		unset($context['recipients']['emails'][$k]);
894 923
 
895 924
 		// Dammit - can't PM emails!
896
-		if ($context['send_pm'])
897
-			continue;
925
+		if ($context['send_pm']) {
926
+					continue;
927
+		}
898 928
 
899 929
 		$to_member = array(
900 930
 			$email,
@@ -928,8 +958,9 @@  discard block
 block discarded – undo
928 958
 					$queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}';
929 959
 				}
930 960
 			}
931
-			if (!empty($queryBuild))
932
-			$sendQuery .= implode(' OR ', $queryBuild);
961
+			if (!empty($queryBuild)) {
962
+						$sendQuery .= implode(' OR ', $queryBuild);
963
+			}
933 964
 		}
934 965
 		if (!empty($context['recipients']['members']))
935 966
 		{
@@ -948,8 +979,9 @@  discard block
 block discarded – undo
948 979
 		}
949 980
 
950 981
 		// Anything to exclude?
951
-		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups']))
952
-			$sendQuery .= ' AND mem.id_group != {int:regular_group}';
982
+		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) {
983
+					$sendQuery .= ' AND mem.id_group != {int:regular_group}';
984
+		}
953 985
 		if (!empty($context['recipients']['exclude_members']))
954 986
 		{
955 987
 			$sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})';
@@ -985,21 +1017,24 @@  discard block
 block discarded – undo
985 1017
 		foreach ($rows as $row)
986 1018
 		{
987 1019
 			// Force them to have it?
988
-			if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements']))
989
-				continue;
1020
+			if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) {
1021
+							continue;
1022
+			}
990 1023
 
991 1024
 			// What groups are we looking at here?
992
-			if (empty($row['additional_groups']))
993
-				$groups = array($row['id_group'], $row['id_post_group']);
994
-			else
995
-				$groups = array_merge(
1025
+			if (empty($row['additional_groups'])) {
1026
+							$groups = array($row['id_group'], $row['id_post_group']);
1027
+			} else {
1028
+							$groups = array_merge(
996 1029
 					array($row['id_group'], $row['id_post_group']),
997 1030
 					explode(',', $row['additional_groups'])
998 1031
 				);
1032
+			}
999 1033
 
1000 1034
 			// Excluded groups?
1001
-			if (array_intersect($groups, $context['recipients']['exclude_groups']))
1002
-				continue;
1035
+			if (array_intersect($groups, $context['recipients']['exclude_groups'])) {
1036
+							continue;
1037
+			}
1003 1038
 
1004 1039
 			// We might need this
1005 1040
 			$cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name'];
@@ -1022,10 +1057,11 @@  discard block
 block discarded – undo
1022 1057
 				), $_POST['subject']);
1023 1058
 
1024 1059
 			// Send the actual email - or a PM!
1025
-			if (!$context['send_pm'])
1026
-				sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1027
-			else
1028
-				sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1060
+			if (!$context['send_pm']) {
1061
+							sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1062
+			} else {
1063
+							sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1064
+			}
1029 1065
 		}
1030 1066
 	}
1031 1067
 
@@ -1075,8 +1111,9 @@  discard block
 block discarded – undo
1075 1111
 
1076 1112
 	call_integration_hook('integrate_modify_news_settings', array(&$config_vars));
1077 1113
 
1078
-	if ($return_config)
1079
-		return $config_vars;
1114
+	if ($return_config) {
1115
+			return $config_vars;
1116
+	}
1080 1117
 
1081 1118
 	$context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
1082 1119
 	$context['sub_template'] = 'show_settings';
Please login to merge, or discard this patch.
Sources/tasks/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
avatars/Oxygen/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
avatars/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Themes.php 1 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 3
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})');
@@ -578,13 +590,13 @@  discard block
 block discarded – undo
578 590
 			)
579 591
 		);
580 592
 		$context['theme_options'] = array();
581
-		while ($row = $smcFunc['db_fetch_assoc']($request))
582
-			$context['theme_options'][$row['variable']] = $row['value'];
593
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
594
+					$context['theme_options'][$row['variable']] = $row['value'];
595
+		}
583 596
 		$smcFunc['db_free_result']($request);
584 597
 
585 598
 		$context['theme_options_reset'] = false;
586
-	}
587
-	else
599
+	} else
588 600
 	{
589 601
 		$context['theme_options'] = array();
590 602
 		$context['theme_options_reset'] = true;
@@ -593,30 +605,32 @@  discard block
 block discarded – undo
593 605
 	foreach ($context['options'] as $i => $setting)
594 606
 	{
595 607
 		// Just skip separators
596
-		if (!is_array($setting))
597
-			continue;
608
+		if (!is_array($setting)) {
609
+					continue;
610
+		}
598 611
 
599 612
 		// Is this disabled?
600 613
 		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
601 614
 		{
602 615
 			unset($context['options'][$i]);
603 616
 			continue;
604
-		}
605
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
617
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
606 618
 		{
607 619
 			unset($context['options'][$i]);
608 620
 			continue;
609 621
 		}
610 622
 
611
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
612
-			$context['options'][$i]['type'] = 'checkbox';
613
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
614
-			$context['options'][$i]['type'] = 'number';
615
-		elseif ($setting['type'] == 'string')
616
-			$context['options'][$i]['type'] = 'text';
623
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
624
+					$context['options'][$i]['type'] = 'checkbox';
625
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
626
+					$context['options'][$i]['type'] = 'number';
627
+		} elseif ($setting['type'] == 'string') {
628
+					$context['options'][$i]['type'] = 'text';
629
+		}
617 630
 
618
-		if (isset($setting['options']))
619
-			$context['options'][$i]['type'] = 'list';
631
+		if (isset($setting['options'])) {
632
+					$context['options'][$i]['type'] = 'list';
633
+		}
620 634
 
621 635
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
622 636
 	}
@@ -641,8 +655,9 @@  discard block
 block discarded – undo
641 655
 {
642 656
 	global $txt, $context, $settings, $modSettings, $smcFunc;
643 657
 
644
-	if (empty($_GET['th']) && empty($_GET['id']))
645
-		return ThemeAdmin();
658
+	if (empty($_GET['th']) && empty($_GET['id'])) {
659
+			return ThemeAdmin();
660
+	}
646 661
 
647 662
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
648 663
 
@@ -653,8 +668,9 @@  discard block
 block discarded – undo
653 668
 	isAllowedTo('admin_forum');
654 669
 
655 670
 	// Validate inputs/user.
656
-	if (empty($_GET['th']))
657
-		fatal_lang_error('no_theme', false);
671
+	if (empty($_GET['th'])) {
672
+			fatal_lang_error('no_theme', false);
673
+	}
658 674
 
659 675
 	// Fetch the smiley sets...
660 676
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -662,8 +678,9 @@  discard block
 block discarded – undo
662 678
 	$context['smiley_sets'] = array(
663 679
 		'' => $txt['smileys_no_default']
664 680
 	);
665
-	foreach ($sets as $i => $set)
666
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
681
+	foreach ($sets as $i => $set) {
682
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
683
+	}
667 684
 
668 685
 	$old_id = $settings['theme_id'];
669 686
 	$old_settings = $settings;
@@ -688,8 +705,9 @@  discard block
 block discarded – undo
688 705
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
689 706
 	{
690 707
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
691
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
692
-				eval('global $settings;' . $matches[0]);
708
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
709
+						eval('global $settings;' . $matches[0]);
710
+		}
693 711
 	}
694 712
 
695 713
 	// Submitting!
@@ -698,37 +716,45 @@  discard block
 block discarded – undo
698 716
 		checkSession();
699 717
 		validateToken('admin-sts');
700 718
 
701
-		if (empty($_POST['options']))
702
-			$_POST['options'] = array();
703
-		if (empty($_POST['default_options']))
704
-			$_POST['default_options'] = array();
719
+		if (empty($_POST['options'])) {
720
+					$_POST['options'] = array();
721
+		}
722
+		if (empty($_POST['default_options'])) {
723
+					$_POST['default_options'] = array();
724
+		}
705 725
 
706 726
 		// Make sure items are cast correctly.
707 727
 		foreach ($context['theme_settings'] as $item)
708 728
 		{
709 729
 			// Disregard this item if this is just a separator.
710
-			if (!is_array($item))
711
-				continue;
730
+			if (!is_array($item)) {
731
+							continue;
732
+			}
712 733
 
713 734
 			foreach (array('options', 'default_options') as $option)
714 735
 			{
715
-				if (!isset($_POST[$option][$item['id']]))
716
-					continue;
736
+				if (!isset($_POST[$option][$item['id']])) {
737
+									continue;
738
+				}
717 739
 				// Checkbox.
718
-				elseif (empty($item['type']))
719
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
740
+				elseif (empty($item['type'])) {
741
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				}
720 743
 				// Number
721
-				elseif ($item['type'] == 'number')
722
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
744
+				elseif ($item['type'] == 'number') {
745
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				}
723 747
 			}
724 748
 		}
725 749
 
726 750
 		// Set up the sql query.
727 751
 		$inserts = array();
728
-		foreach ($_POST['options'] as $opt => $val)
729
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
730
-		foreach ($_POST['default_options'] as $opt => $val)
731
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
752
+		foreach ($_POST['options'] as $opt => $val) {
753
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
754
+		}
755
+		foreach ($_POST['default_options'] as $opt => $val) {
756
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
757
+		}
732 758
 		// If we're actually inserting something..
733 759
 		if (!empty($inserts))
734 760
 		{
@@ -754,8 +780,9 @@  discard block
 block discarded – undo
754 780
 
755 781
 	foreach ($settings as $setting => $dummy)
756 782
 	{
757
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
758
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
783
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
784
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		}
759 786
 	}
760 787
 
761 788
 	$context['settings'] = $context['theme_settings'];
@@ -764,18 +791,21 @@  discard block
 block discarded – undo
764 791
 	foreach ($context['settings'] as $i => $setting)
765 792
 	{
766 793
 		// Separators are dummies, so leave them alone.
767
-		if (!is_array($setting))
768
-			continue;
794
+		if (!is_array($setting)) {
795
+					continue;
796
+		}
769 797
 
770
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
771
-			$context['settings'][$i]['type'] = 'checkbox';
772
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
773
-			$context['settings'][$i]['type'] = 'number';
774
-		elseif ($setting['type'] == 'string')
775
-			$context['settings'][$i]['type'] = 'text';
798
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
799
+					$context['settings'][$i]['type'] = 'checkbox';
800
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
801
+					$context['settings'][$i]['type'] = 'number';
802
+		} elseif ($setting['type'] == 'string') {
803
+					$context['settings'][$i]['type'] = 'text';
804
+		}
776 805
 
777
-		if (isset($setting['options']))
778
-			$context['settings'][$i]['type'] = 'list';
806
+		if (isset($setting['options'])) {
807
+					$context['settings'][$i]['type'] = 'list';
808
+		}
779 809
 
780 810
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
781 811
 	}
@@ -828,8 +858,9 @@  discard block
 block discarded – undo
828 858
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
829 859
 
830 860
 	// You can't delete the default theme!
831
-	if ($themeID == 1)
832
-		fatal_lang_error('no_access', false);
861
+	if ($themeID == 1) {
862
+			fatal_lang_error('no_access', false);
863
+	}
833 864
 
834 865
 	$theme_info = get_single_theme($themeID);
835 866
 
@@ -837,8 +868,9 @@  discard block
 block discarded – undo
837 868
 	remove_theme($themeID);
838 869
 
839 870
 	// And remove all its files and folders too.
840
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
841
-		remove_dir($theme_info['theme_dir']);
871
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
872
+			remove_dir($theme_info['theme_dir']);
873
+	}
842 874
 
843 875
 	// Go back to the list page.
844 876
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -863,12 +895,14 @@  discard block
 block discarded – undo
863 895
 	$enableThemes = explode(',', $modSettings['enableThemes']);
864 896
 
865 897
 	// Are we disabling it?
866
-	if (isset($_GET['disabled']))
867
-		$enableThemes = array_diff($enableThemes, array($themeID));
898
+	if (isset($_GET['disabled'])) {
899
+			$enableThemes = array_diff($enableThemes, array($themeID));
900
+	}
868 901
 
869 902
 	// Nope? then enable it!
870
-	else
871
-		$enableThemes[] = (string) $themeID;
903
+	else {
904
+			$enableThemes[] = (string) $themeID;
905
+	}
872 906
 
873 907
 	// Update the setting.
874 908
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -903,18 +937,21 @@  discard block
 block discarded – undo
903 937
 
904 938
 	$_SESSION['id_theme'] = 0;
905 939
 
906
-	if (isset($_GET['id']))
907
-		$_GET['th'] = $_GET['id'];
940
+	if (isset($_GET['id'])) {
941
+			$_GET['th'] = $_GET['id'];
942
+	}
908 943
 
909 944
 	// Saving a variant cause JS doesn't work - pretend it did ;)
910 945
 	if (isset($_POST['save']))
911 946
 	{
912 947
 		// Which theme?
913
-		foreach ($_POST['save'] as $k => $v)
914
-			$_GET['th'] = (int) $k;
948
+		foreach ($_POST['save'] as $k => $v) {
949
+					$_GET['th'] = (int) $k;
950
+		}
915 951
 
916
-		if (isset($_POST['vrt'][$k]))
917
-			$_GET['vrt'] = $_POST['vrt'][$k];
952
+		if (isset($_POST['vrt'][$k])) {
953
+					$_GET['vrt'] = $_POST['vrt'][$k];
954
+		}
918 955
 	}
919 956
 
920 957
 	// Have we made a decision, or are we just browsing?
@@ -992,8 +1029,9 @@  discard block
 block discarded – undo
992 1029
 		else
993 1030
 		{
994 1031
 			// The forum's default theme is always 0 and we
995
-			if (isset($_GET['th']) && $_GET['th'] == 0)
996
-					$_GET['th'] = $modSettings['theme_guests'];
1032
+			if (isset($_GET['th']) && $_GET['th'] == 0) {
1033
+								$_GET['th'] = $modSettings['theme_guests'];
1034
+			}
997 1035
 
998 1036
 			updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th']));
999 1037
 
@@ -1007,8 +1045,9 @@  discard block
 block discarded – undo
1007 1045
 				);
1008 1046
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1009 1047
 
1010
-				if ($user_info['id'] == $_REQUEST['u'])
1011
-					$_SESSION['id_variant'] = 0;
1048
+				if ($user_info['id'] == $_REQUEST['u']) {
1049
+									$_SESSION['id_variant'] = 0;
1050
+				}
1012 1051
 			}
1013 1052
 
1014 1053
 			redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme');
@@ -1077,12 +1116,13 @@  discard block
 block discarded – undo
1077 1116
 		);
1078 1117
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1079 1118
 		{
1080
-			if (!isset($context['available_themes'][$row['id_theme']]))
1081
-				$context['available_themes'][$row['id_theme']] = array(
1119
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1120
+							$context['available_themes'][$row['id_theme']] = array(
1082 1121
 					'id' => $row['id_theme'],
1083 1122
 					'selected' => $context['current_theme'] == $row['id_theme'],
1084 1123
 					'num_users' => 0
1085 1124
 				);
1125
+			}
1086 1126
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1087 1127
 		}
1088 1128
 		$smcFunc['db_free_result']($request);
@@ -1095,9 +1135,9 @@  discard block
 block discarded – undo
1095 1135
 			'num_users' => 0
1096 1136
 		);
1097 1137
 		$guest_theme = 0;
1138
+	} else {
1139
+			$guest_theme = $modSettings['theme_guests'];
1098 1140
 	}
1099
-	else
1100
-		$guest_theme = $modSettings['theme_guests'];
1101 1141
 
1102 1142
 	$request = $smcFunc['db_query']('', '
1103 1143
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1110,15 +1150,17 @@  discard block
 block discarded – undo
1110 1150
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1111 1151
 	{
1112 1152
 		// Figure out which theme it is they are REALLY using.
1113
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1114
-			$row['id_theme'] = $guest_theme;
1115
-		elseif (empty($modSettings['theme_allow']))
1116
-			$row['id_theme'] = $guest_theme;
1153
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1154
+					$row['id_theme'] = $guest_theme;
1155
+		} elseif (empty($modSettings['theme_allow'])) {
1156
+					$row['id_theme'] = $guest_theme;
1157
+		}
1117 1158
 
1118
-		if (isset($context['available_themes'][$row['id_theme']]))
1119
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1120
-		else
1121
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1159
+		if (isset($context['available_themes'][$row['id_theme']])) {
1160
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1161
+		} else {
1162
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1163
+		}
1122 1164
 	}
1123 1165
 	$smcFunc['db_free_result']($request);
1124 1166
 
@@ -1137,8 +1179,9 @@  discard block
 block discarded – undo
1137 1179
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1138 1180
 			)
1139 1181
 		);
1140
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1141
-			$variant_preferences[$row['id_theme']] = $row['value'];
1182
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1183
+					$variant_preferences[$row['id_theme']] = $row['value'];
1184
+		}
1142 1185
 		$smcFunc['db_free_result']($request);
1143 1186
 	}
1144 1187
 
@@ -1149,17 +1192,18 @@  discard block
 block discarded – undo
1149 1192
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1150 1193
 	{
1151 1194
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1152
-		if ($id_theme == 0)
1153
-			continue;
1195
+		if ($id_theme == 0) {
1196
+					continue;
1197
+		}
1154 1198
 
1155 1199
 		// The thumbnail needs the correct path.
1156 1200
 		$settings['images_url'] = &$theme_data['images_url'];
1157 1201
 
1158
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1159
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1160
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1161
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1162
-		else
1202
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1203
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1204
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1205
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1206
+		} else
1163 1207
 		{
1164 1208
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1165 1209
 			$txt['theme_description'] = '';
@@ -1184,15 +1228,17 @@  discard block
 block discarded – undo
1184 1228
 					loadLanguage('Settings');
1185 1229
 
1186 1230
 					$context['available_themes'][$id_theme]['variants'] = array();
1187
-					foreach ($settings['theme_variants'] as $variant)
1188
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1231
+					foreach ($settings['theme_variants'] as $variant) {
1232
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1189 1233
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1190 1234
 							'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'),
1191 1235
 						);
1236
+					}
1192 1237
 
1193 1238
 					$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]));
1194
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1195
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1239
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1240
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1241
+					}
1196 1242
 
1197 1243
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1198 1244
 					// Allow themes to override the text.
@@ -1208,8 +1254,9 @@  discard block
 block discarded – undo
1208 1254
 	// As long as we're not doing the default theme...
1209 1255
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1210 1256
 	{
1211
-		if ($guest_theme != 0)
1212
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1257
+		if ($guest_theme != 0) {
1258
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1259
+		}
1213 1260
 
1214 1261
 		$context['available_themes'][0]['id'] = 0;
1215 1262
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1258,14 +1305,16 @@  discard block
 block discarded – undo
1258 1305
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1259 1306
 
1260 1307
 		// Got any info from the specific form?
1261
-		if (!isset($_POST['save_' . $action]))
1262
-			fatal_lang_error('theme_install_no_action', false);
1308
+		if (!isset($_POST['save_' . $action])) {
1309
+					fatal_lang_error('theme_install_no_action', false);
1310
+		}
1263 1311
 
1264 1312
 		validateToken('admin-t-' . $action);
1265 1313
 
1266 1314
 		// Hopefully the themes directory is writable, or we might have a problem.
1267
-		if (!is_writable($themedir))
1268
-			fatal_lang_error('theme_install_write_error', 'critical');
1315
+		if (!is_writable($themedir)) {
1316
+					fatal_lang_error('theme_install_write_error', 'critical');
1317
+		}
1269 1318
 
1270 1319
 		// Call the function and handle the result.
1271 1320
 		$result = $subActions[$action]();
@@ -1280,9 +1329,10 @@  discard block
 block discarded – undo
1280 1329
 	}
1281 1330
 
1282 1331
 	// Nope, show a nice error.
1283
-	else
1284
-		fatal_lang_error('theme_install_no_action', false);
1285
-}
1332
+	else {
1333
+			fatal_lang_error('theme_install_no_action', false);
1334
+	}
1335
+	}
1286 1336
 
1287 1337
 /**
1288 1338
  * Installs a theme from a theme package.
@@ -1298,8 +1348,9 @@  discard block
 block discarded – undo
1298 1348
 	$dirtemp = $themedir . '/temp';
1299 1349
 
1300 1350
 	// Make sure the temp dir doesn't already exist
1301
-	if (file_exists($dirtemp))
1302
-		remove_dir($dirtemp);
1351
+	if (file_exists($dirtemp)) {
1352
+			remove_dir($dirtemp);
1353
+	}
1303 1354
 
1304 1355
 	// Create the temp dir.
1305 1356
 	mkdir($dirtemp, 0777);
@@ -1311,17 +1362,20 @@  discard block
 block discarded – undo
1311 1362
 		smf_chmod($dirtemp, '0755');
1312 1363
 
1313 1364
 		// How about now?
1314
-		if (!is_writable($dirtemp))
1315
-			fatal_lang_error('theme_install_write_error', 'critical');
1365
+		if (!is_writable($dirtemp)) {
1366
+					fatal_lang_error('theme_install_write_error', 'critical');
1367
+		}
1316 1368
 	}
1317 1369
 
1318 1370
 	// This happens when the admin session is gone and the user has to login again.
1319
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1320
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1371
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1372
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1373
+	}
1321 1374
 
1322 1375
 	// Another error check layer, something went wrong with the upload.
1323
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1324
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1376
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1377
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1378
+	}
1325 1379
 
1326 1380
 	// Get the theme's name.
1327 1381
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1352,11 +1406,10 @@  discard block
 block discarded – undo
1352 1406
 
1353 1407
 		// return all the info.
1354 1408
 		return $context['to_install'];
1409
+	} else {
1410
+			fatal_lang_error('theme_install_error_title', false);
1411
+	}
1355 1412
 	}
1356
-
1357
-	else
1358
-		fatal_lang_error('theme_install_error_title', false);
1359
-}
1360 1413
 
1361 1414
 /**
1362 1415
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1370,15 +1423,17 @@  discard block
 block discarded – undo
1370 1423
 	global $forum_version;
1371 1424
 
1372 1425
 	// There's gotta be something to work with.
1373
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1374
-		fatal_lang_error('theme_install_error_title', false);
1426
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1427
+			fatal_lang_error('theme_install_error_title', false);
1428
+	}
1375 1429
 
1376 1430
 	// Get a cleaner version.
1377 1431
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1378 1432
 
1379 1433
 	// Is there a theme already named like this?
1380
-	if (file_exists($themedir . '/' . $name))
1381
-		fatal_lang_error('theme_install_already_dir', false);
1434
+	if (file_exists($themedir . '/' . $name)) {
1435
+			fatal_lang_error('theme_install_already_dir', false);
1436
+	}
1382 1437
 
1383 1438
 	// This is a brand new theme so set all possible values.
1384 1439
 	$context['to_install'] = array(
@@ -1398,8 +1453,9 @@  discard block
 block discarded – undo
1398 1453
 
1399 1454
 	// Buy some time.
1400 1455
 	@set_time_limit(600);
1401
-	if (function_exists('apache_reset_timeout'))
1402
-		@apache_reset_timeout();
1456
+	if (function_exists('apache_reset_timeout')) {
1457
+			@apache_reset_timeout();
1458
+	}
1403 1459
 
1404 1460
 	// Create subdirectories for css and javascript files.
1405 1461
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1435,12 +1491,13 @@  discard block
 block discarded – undo
1435 1491
 
1436 1492
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1437 1493
 	{
1438
-		if ($row['variable'] == 'theme_templates')
1439
-			$theme_templates = $row['value'];
1440
-		elseif ($row['variable'] == 'theme_layers')
1441
-			$theme_layers = $row['value'];
1442
-		else
1443
-			continue;
1494
+		if ($row['variable'] == 'theme_templates') {
1495
+					$theme_templates = $row['value'];
1496
+		} elseif ($row['variable'] == 'theme_layers') {
1497
+					$theme_layers = $row['value'];
1498
+		} else {
1499
+					continue;
1500
+		}
1444 1501
 	}
1445 1502
 
1446 1503
 	$smcFunc['db_free_result']($request);
@@ -1499,12 +1556,14 @@  discard block
 block discarded – undo
1499 1556
 	global $themedir, $themeurl, $context;
1500 1557
 
1501 1558
 	// Cannot use the theme dir as a theme dir.
1502
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1503
-		fatal_lang_error('theme_install_invalid_dir', false);
1559
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1560
+			fatal_lang_error('theme_install_invalid_dir', false);
1561
+	}
1504 1562
 
1505 1563
 	// Check is there is "something" on the dir.
1506
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1507
-		fatal_lang_error('theme_install_error', false);
1564
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1565
+			fatal_lang_error('theme_install_error', false);
1566
+	}
1508 1567
 
1509 1568
 	$name = basename($_REQUEST['theme_dir']);
1510 1569
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1548,24 +1607,27 @@  discard block
 block discarded – undo
1548 1607
 	}
1549 1608
 
1550 1609
 	// Any special layers?
1551
-	if (isset($settings['catch_action']['layers']))
1552
-		$context['template_layers'] = $settings['catch_action']['layers'];
1610
+	if (isset($settings['catch_action']['layers'])) {
1611
+			$context['template_layers'] = $settings['catch_action']['layers'];
1612
+	}
1553 1613
 
1554 1614
 	// Any function to call?
1555 1615
 	if (isset($settings['catch_action']['function']))
1556 1616
 	{
1557 1617
 		$hook = $settings['catch_action']['function'];
1558 1618
 
1559
-		if (!isset($settings['catch_action']['filename']))
1560
-			$settings['catch_action']['filename'] = '';
1619
+		if (!isset($settings['catch_action']['filename'])) {
1620
+					$settings['catch_action']['filename'] = '';
1621
+		}
1561 1622
 
1562 1623
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1563 1624
 		call_integration_hook('integrate_wrap_action');
1564 1625
 	}
1565 1626
 	// And finally, the main sub template ;).
1566
-	if (isset($settings['catch_action']['sub_template']))
1567
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1568
-}
1627
+	if (isset($settings['catch_action']['sub_template'])) {
1628
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1629
+	}
1630
+	}
1569 1631
 
1570 1632
 /**
1571 1633
  * Set an option via javascript.
@@ -1584,12 +1646,14 @@  discard block
 block discarded – undo
1584 1646
 	checkSession('get');
1585 1647
 
1586 1648
 	// This good-for-nothing pixel is being used to keep the session alive.
1587
-	if (empty($_GET['var']) || !isset($_GET['val']))
1588
-		redirectexit($settings['images_url'] . '/blank.png');
1649
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1650
+			redirectexit($settings['images_url'] . '/blank.png');
1651
+	}
1589 1652
 
1590 1653
 	// Sorry, guests can't go any further than this.
1591
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1592
-		obExit(false);
1654
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1655
+			obExit(false);
1656
+	}
1593 1657
 
1594 1658
 	$reservedVars = array(
1595 1659
 		'actual_theme_url',
@@ -1612,8 +1676,9 @@  discard block
 block discarded – undo
1612 1676
 	);
1613 1677
 
1614 1678
 	// Can't change reserved vars.
1615
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1616
-		redirectexit($settings['images_url'] . '/blank.png');
1679
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1680
+			redirectexit($settings['images_url'] . '/blank.png');
1681
+	}
1617 1682
 
1618 1683
 	// Use a specific theme?
1619 1684
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1629,8 +1694,9 @@  discard block
 block discarded – undo
1629 1694
 	{
1630 1695
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array();
1631 1696
 		// New thingy...
1632
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1633
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1697
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1698
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1699
+		}
1634 1700
 
1635 1701
 		// Change the value to be something nice,
1636 1702
 		$_GET['val'] = json_encode($options['admin_preferences']);
@@ -1660,8 +1726,9 @@  discard block
 block discarded – undo
1660 1726
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1661 1727
 
1662 1728
 	// @todo Should this be removed?
1663
-	if (isset($_REQUEST['preview']))
1664
-		die('die() with fire');
1729
+	if (isset($_REQUEST['preview'])) {
1730
+			die('die() with fire');
1731
+	}
1665 1732
 
1666 1733
 	isAllowedTo('admin_forum');
1667 1734
 	loadTemplate('Themes');
@@ -1675,11 +1742,11 @@  discard block
 block discarded – undo
1675 1742
 		foreach ($context['themes'] as $key => $theme)
1676 1743
 		{
1677 1744
 			// There has to be a Settings template!
1678
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1679
-				unset($context['themes'][$key]);
1680
-
1681
-			else
1682
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1745
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1746
+							unset($context['themes'][$key]);
1747
+			} else {
1748
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1749
+			}
1683 1750
 		}
1684 1751
 
1685 1752
 		$context['sub_template'] = 'edit_list';
@@ -1694,22 +1761,24 @@  discard block
 block discarded – undo
1694 1761
 	$context['theme_id'] = $currentTheme['id'];
1695 1762
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1696 1763
 
1697
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1698
-		fatal_lang_error('theme_edit_missing', false);
1764
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1765
+			fatal_lang_error('theme_edit_missing', false);
1766
+	}
1699 1767
 
1700 1768
 	if (!isset($_REQUEST['filename']))
1701 1769
 	{
1702 1770
 		if (isset($_GET['directory']))
1703 1771
 		{
1704
-			if (substr($_GET['directory'], 0, 1) == '.')
1705
-				$_GET['directory'] = '';
1706
-			else
1772
+			if (substr($_GET['directory'], 0, 1) == '.') {
1773
+							$_GET['directory'] = '';
1774
+			} else
1707 1775
 			{
1708 1776
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1709 1777
 
1710 1778
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1711
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1712
-					$_GET['directory'] = '';
1779
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1780
+									$_GET['directory'] = '';
1781
+				}
1713 1782
 			}
1714 1783
 		}
1715 1784
 
@@ -1728,37 +1797,39 @@  discard block
 block discarded – undo
1728 1797
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1729 1798
 				'size' => '',
1730 1799
 			));
1800
+		} else {
1801
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1731 1802
 		}
1732
-		else
1733
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1734 1803
 
1735 1804
 		$context['sub_template'] = 'edit_browse';
1736 1805
 
1737 1806
 		return;
1738
-	}
1739
-	else
1807
+	} else
1740 1808
 	{
1741
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1742
-			$_REQUEST['filename'] = '';
1743
-		else
1809
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1810
+					$_REQUEST['filename'] = '';
1811
+		} else
1744 1812
 		{
1745 1813
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1746 1814
 
1747 1815
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1748
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1749
-				$_REQUEST['filename'] = '';
1816
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1817
+							$_REQUEST['filename'] = '';
1818
+			}
1750 1819
 		}
1751 1820
 
1752
-		if (empty($_REQUEST['filename']))
1753
-			fatal_lang_error('theme_edit_missing', false);
1821
+		if (empty($_REQUEST['filename'])) {
1822
+					fatal_lang_error('theme_edit_missing', false);
1823
+		}
1754 1824
 	}
1755 1825
 
1756 1826
 	if (isset($_POST['save']))
1757 1827
 	{
1758 1828
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1759 1829
 		{
1760
-			if (is_array($_POST['entire_file']))
1761
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1830
+			if (is_array($_POST['entire_file'])) {
1831
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1832
+			}
1762 1833
 
1763 1834
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1764 1835
 
@@ -1770,10 +1841,11 @@  discard block
 block discarded – undo
1770 1841
 				fclose($fp);
1771 1842
 
1772 1843
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1773
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1774
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1775
-				else
1776
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1844
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1845
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1846
+				} else {
1847
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1848
+				}
1777 1849
 			}
1778 1850
 
1779 1851
 			if (!isset($error_file))
@@ -1794,10 +1866,11 @@  discard block
 block discarded – undo
1794 1866
 			$context['sub_template'] = 'edit_file';
1795 1867
 
1796 1868
 			// Recycle the submitted data.
1797
-			if (is_array($_POST['entire_file']))
1798
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1799
-			else
1800
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1869
+			if (is_array($_POST['entire_file'])) {
1870
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1871
+			} else {
1872
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1873
+			}
1801 1874
 
1802 1875
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1803 1876
 
@@ -1820,17 +1893,17 @@  discard block
 block discarded – undo
1820 1893
 		$context['sub_template'] = 'edit_style';
1821 1894
 
1822 1895
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1823
-	}
1824
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1896
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1825 1897
 	{
1826 1898
 		$context['sub_template'] = 'edit_template';
1827 1899
 
1828
-		if (!isset($error_file))
1829
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1830
-		else
1900
+		if (!isset($error_file)) {
1901
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1902
+		} else
1831 1903
 		{
1832
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1833
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1904
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1905
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1906
+			}
1834 1907
 			$file_data = file($error_file);
1835 1908
 			unlink($error_file);
1836 1909
 		}
@@ -1844,8 +1917,9 @@  discard block
 block discarded – undo
1844 1917
 				// Try to format the functions a little nicer...
1845 1918
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1846 1919
 
1847
-				if (empty($context['file_parts'][$j]['lines']))
1848
-					unset($context['file_parts'][$j]);
1920
+				if (empty($context['file_parts'][$j]['lines'])) {
1921
+									unset($context['file_parts'][$j]);
1922
+				}
1849 1923
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1850 1924
 			}
1851 1925
 
@@ -1854,8 +1928,7 @@  discard block
 block discarded – undo
1854 1928
 		}
1855 1929
 
1856 1930
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1857
-	}
1858
-	else
1931
+	} else
1859 1932
 	{
1860 1933
 		$context['sub_template'] = 'edit_file';
1861 1934
 
@@ -1881,8 +1954,9 @@  discard block
 block discarded – undo
1881 1954
 
1882 1955
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1883 1956
 
1884
-	if (empty($_GET['th']))
1885
-		fatal_lang_error('theme_install_invalid_id');
1957
+	if (empty($_GET['th'])) {
1958
+			fatal_lang_error('theme_install_invalid_id');
1959
+	}
1886 1960
 
1887 1961
 	// Get the theme info.
1888 1962
 	$theme = get_single_theme($_GET['th']);
@@ -1890,25 +1964,24 @@  discard block
 block discarded – undo
1890 1964
 
1891 1965
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1892 1966
 	{
1893
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1894
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1895
-
1896
-		else
1897
-			fatal_lang_error('no_access', false);
1967
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1968
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1969
+		} else {
1970
+					fatal_lang_error('no_access', false);
1971
+		}
1898 1972
 
1899 1973
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1900 1974
 		fwrite($fp, file_get_contents($filename));
1901 1975
 		fclose($fp);
1902 1976
 
1903 1977
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1904
-	}
1905
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1978
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1906 1979
 	{
1907
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1908
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1909
-
1910
-		else
1911
-			fatal_lang_error('no_access', false);
1980
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1981
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1982
+		} else {
1983
+					fatal_lang_error('no_access', false);
1984
+		}
1912 1985
 
1913 1986
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1914 1987
 		fwrite($fp, file_get_contents($filename));
@@ -1923,16 +1996,18 @@  discard block
 block discarded – undo
1923 1996
 	$dir = dir($settings['default_theme_dir']);
1924 1997
 	while ($entry = $dir->read())
1925 1998
 	{
1926
-		if (substr($entry, -13) == '.template.php')
1927
-			$templates[] = substr($entry, 0, -13);
1999
+		if (substr($entry, -13) == '.template.php') {
2000
+					$templates[] = substr($entry, 0, -13);
2001
+		}
1928 2002
 	}
1929 2003
 	$dir->close();
1930 2004
 
1931 2005
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1932 2006
 	while ($entry = $dir->read())
1933 2007
 	{
1934
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1935
-			$lang_files[] = $matches[1];
2008
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2009
+					$lang_files[] = $matches[1];
2010
+		}
1936 2011
 	}
1937 2012
 	$dir->close();
1938 2013
 
@@ -1940,21 +2015,23 @@  discard block
 block discarded – undo
1940 2015
 	natcasesort($lang_files);
1941 2016
 
1942 2017
 	$context['available_templates'] = array();
1943
-	foreach ($templates as $template)
1944
-		$context['available_templates'][$template] = array(
2018
+	foreach ($templates as $template) {
2019
+			$context['available_templates'][$template] = array(
1945 2020
 			'filename' => $template . '.template.php',
1946 2021
 			'value' => $template,
1947 2022
 			'already_exists' => false,
1948 2023
 			'can_copy' => is_writable($theme['theme_dir']),
1949 2024
 		);
2025
+	}
1950 2026
 	$context['available_language_files'] = array();
1951
-	foreach ($lang_files as $file)
1952
-		$context['available_language_files'][$file] = array(
2027
+	foreach ($lang_files as $file) {
2028
+			$context['available_language_files'][$file] = array(
1953 2029
 			'filename' => $file . '.php',
1954 2030
 			'value' => $file,
1955 2031
 			'already_exists' => false,
1956 2032
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1957 2033
 		);
2034
+	}
1958 2035
 
1959 2036
 	$dir = dir($theme['theme_dir']);
1960 2037
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Themes/default/Themes.template.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -645,12 +645,12 @@
 block discarded – undo
645 645
 					</dd>';
646 646
 		}
647 647
 		// A Textarea?
648
-        	elseif ($setting['type'] == 'textarea')
648
+			elseif ($setting['type'] == 'textarea')
649 649
 		{
650 650
 			echo '
651 651
 					<dd>
652 652
 						<textarea rows="4" style="width: 95%;" cols="40" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">', $setting['value'], '</textarea>';
653
-                echo '
653
+				echo '
654 654
                 			</dd>';
655 655
 		}
656 656
 		// A regular input box, then?
Please login to merge, or discard this patch.
Braces   +103 added lines, -80 removed lines patch added patch discarded remove patch
@@ -54,9 +54,10 @@  discard block
 block discarded – undo
54 54
 					<dd>
55 55
 						<div id="known_themes_list">';
56 56
 
57
-	foreach ($context['themes'] as $theme)
58
-		echo '
57
+	foreach ($context['themes'] as $theme) {
58
+			echo '
59 59
 							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', ' class="input_check"> ', $theme['name'], '</label><br>';
60
+	}
60 61
 
61 62
 		echo '
62 63
 						</div>
@@ -73,9 +74,10 @@  discard block
 block discarded – undo
73 74
 						<select name="options[theme_guests]" id="theme_guests">';
74 75
 
75 76
 	// Put an option for each theme in the select box.
76
-	foreach ($context['themes'] as $theme)
77
-		echo '
77
+	foreach ($context['themes'] as $theme) {
78
+			echo '
78 79
 							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
80
+	}
79 81
 
80 82
 	echo '
81 83
 						</select>
@@ -90,9 +92,10 @@  discard block
 block discarded – undo
90 92
 							<option value="0">', $txt['theme_forum_default'], '</option>';
91 93
 
92 94
 	// Same thing, this time for changing the theme of everyone.
93
-	foreach ($context['themes'] as $theme)
94
-		echo '
95
+	foreach ($context['themes'] as $theme) {
96
+			echo '
95 97
 							<option value="', $theme['id'], '">', $theme['name'], '</option>';
98
+	}
96 99
 
97 100
 	echo '
98 101
 						</select>
@@ -189,11 +192,12 @@  discard block
 block discarded – undo
189 192
 	global $context, $scripturl, $txt;
190 193
 
191 194
 	// Show a nice confirmation message.
192
-	if (isset($_GET['done']))
193
-		echo '
195
+	if (isset($_GET['done'])) {
196
+			echo '
194 197
 	<div class="infobox">
195 198
 		', $txt['theme_confirmed_' . $_GET['done']], '
196 199
 	</div>';
200
+	}
197 201
 
198 202
 	echo '
199 203
 	<div id="admincenter">';
@@ -356,11 +360,12 @@  discard block
 block discarded – undo
356 360
 		if (empty($setting) || !is_array($setting))
357 361
 		{
358 362
 			// Insert a separator (unless this is the first item in the list)
359
-			if ($i !== $first_option_key)
360
-				echo '
363
+			if ($i !== $first_option_key) {
364
+							echo '
361 365
 				</dl>
362 366
 				<hr>
363 367
 				<dl class="settings">';
368
+			}
364 369
 
365 370
 			// Should we give a name to this section?
366 371
 			if (is_string($setting) && !empty($setting))
@@ -368,9 +373,9 @@  discard block
 block discarded – undo
368 373
 				$titled_section = true;
369 374
 				echo '
370 375
 					<dt><b>' . $setting . '</b></dt><dd></dd>';
376
+			} else {
377
+							$titled_section = false;
371 378
 			}
372
-			else
373
-				$titled_section = false;
374 379
 
375 380
 			continue;
376 381
 		}
@@ -379,19 +384,21 @@  discard block
 block discarded – undo
379 384
 					<dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>';
380 385
 
381 386
 		// Show the change option box ?
382
-		if ($context['theme_options_reset'])
383
-			echo '
387
+		if ($context['theme_options_reset']) {
388
+					echo '
384 389
 						<span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
385 390
 							<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
386 391
 							<option value="1">', $txt['themeadmin_reset_options_change'], '</option>
387 392
 							<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
388 393
 						</select>&nbsp;</span>';
394
+		}
389 395
 
390 396
 		echo '
391 397
 						<label for="options_', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>';
392
-		if (isset($setting['description']))
393
-			echo '
398
+		if (isset($setting['description'])) {
399
+					echo '
394 400
 						<br><span class="smalltext">', $setting['description'], '</span>';
401
+		}
395 402
 		echo '
396 403
 					</dt>';
397 404
 
@@ -433,13 +440,11 @@  discard block
 block discarded – undo
433 440
 
434 441
 				echo '
435 442
 						<input type="number"', $min . $max . $step;
436
-			}
437
-			else if (isset($setting['type']) && $setting['type'] == 'url')
443
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
438 444
 			{
439 445
 				echo'
440 446
 						<input type="url"';
441
-			}
442
-			else
447
+			} else
443 448
 			{
444 449
 				echo '
445 450
 						<input type="text"';
@@ -483,8 +488,8 @@  discard block
 block discarded – undo
483 488
 			<br>';
484 489
 
485 490
 	// @todo Why can't I edit the default theme popup.
486
-	if ($context['theme_settings']['theme_id'] != 1)
487
-		echo '
491
+	if ($context['theme_settings']['theme_id'] != 1) {
492
+			echo '
488 493
 			<div class="cat_bar">
489 494
 				<h3 class="catbg config_hd">
490 495
 					', $txt['theme_edit'], '
@@ -500,6 +505,7 @@  discard block
 block discarded – undo
500 505
 					</li>
501 506
 				</ul>
502 507
 			</div>';
508
+	}
503 509
 
504 510
 	echo '
505 511
 			<div class="cat_bar">
@@ -553,9 +559,10 @@  discard block
 block discarded – undo
553 559
 					<dd>
554 560
 						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
555 561
 
556
-		foreach ($context['theme_variants'] as $key => $variant)
557
-			echo '
562
+		foreach ($context['theme_variants'] as $key => $variant) {
563
+					echo '
558 564
 							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
565
+		}
559 566
 
560 567
 		echo '
561 568
 						</select>
@@ -590,11 +597,12 @@  discard block
 block discarded – undo
590 597
 		if (empty($setting) || !is_array($setting))
591 598
 		{
592 599
 			// We don't need a separator before the first list element
593
-			if ($i !== $first_setting_key)
594
-				echo '
600
+			if ($i !== $first_setting_key) {
601
+							echo '
595 602
 				</dl>
596 603
 				<hr>
597 604
 				<dl class="settings">';
605
+			}
598 606
 
599 607
 			// Add a fake heading?
600 608
 			if (is_string($setting) && !empty($setting))
@@ -602,9 +610,9 @@  discard block
 block discarded – undo
602 610
 				$titled_section = true;
603 611
 				echo '
604 612
 					<dt><b>' . $setting . '</b></dt><dd></dd>';
613
+			} else {
614
+							$titled_section = false;
605 615
 			}
606
-			else
607
-				$titled_section = false;
608 616
 
609 617
 			continue;
610 618
 		}
@@ -613,9 +621,10 @@  discard block
 block discarded – undo
613 621
 					<dt>
614 622
 						<label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>:';
615 623
 
616
-		if (isset($setting['description']))
617
-			echo '<br>
624
+		if (isset($setting['description'])) {
625
+					echo '<br>
618 626
 						<span class="smalltext">', $setting['description'], '</span>';
627
+		}
619 628
 
620 629
 		echo '
621 630
 					</dt>';
@@ -636,9 +645,10 @@  discard block
 block discarded – undo
636 645
 					<dd>
637 646
 						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
638 647
 
639
-			foreach ($setting['options'] as $value => $label)
640
-				echo '
648
+			foreach ($setting['options'] as $value => $label) {
649
+							echo '
641 650
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
651
+			}
642 652
 
643 653
 			echo '
644 654
 						</select>
@@ -667,13 +677,11 @@  discard block
 block discarded – undo
667 677
 
668 678
 				echo '
669 679
 						<input type="number"', $min . $max . $step;
670
-			}
671
-			else if (isset($setting['type']) && $setting['type'] == 'url')
680
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
672 681
 			{
673 682
 				echo'
674 683
 						<input type="url"';
675
-			}
676
-			else
684
+			} else
677 685
 			{
678 686
 				echo '
679 687
 						<input type="text"';
@@ -826,21 +834,23 @@  discard block
 block discarded – undo
826 834
 		<div class="windowbg">';
827 835
 
828 836
 	// Oops! there was an error :(
829
-	if (!empty($context['error_message']))
830
-		echo '
837
+	if (!empty($context['error_message'])) {
838
+			echo '
831 839
 			<p>
832 840
 				', $context['error_message'], '
833 841
 			</p>';
842
+	}
834 843
 
835 844
 	// Not much to show except a link back...
836
-	else
837
-		echo '
845
+	else {
846
+			echo '
838 847
 			<p>
839 848
 				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
840 849
 			</p>
841 850
 			<p>
842 851
 				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
843 852
 			</p>';
853
+	}
844 854
 
845 855
 	echo '
846 856
 		</div>
@@ -907,10 +917,11 @@  discard block
 block discarded – undo
907 917
 					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
908 918
 					<span class="floatright">';
909 919
 
910
-		if ($template['can_copy'])
911
-			echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
912
-		else
913
-			echo $txt['themeadmin_edit_no_copy'];
920
+		if ($template['can_copy']) {
921
+					echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
922
+		} else {
923
+					echo $txt['themeadmin_edit_no_copy'];
924
+		}
914 925
 
915 926
 		echo '
916 927
 					</span>
@@ -933,11 +944,12 @@  discard block
 block discarded – undo
933 944
 	echo '
934 945
 	<div id="admincenter">';
935 946
 
936
-	if (!empty($context['browse_title']))
937
-		echo '
947
+	if (!empty($context['browse_title'])) {
948
+			echo '
938 949
 		<div class="cat_bar">
939 950
 			<h3 class="catbg">', $context['browse_title'], '</h3>
940 951
 		</div>';
952
+	}
941 953
 
942 954
 	echo '
943 955
 		<table class="table_grid tborder">
@@ -957,14 +969,13 @@  discard block
 block discarded – undo
957 969
 			<tr class="windowbg">
958 970
 				<td>';
959 971
 
960
-		if ($file['is_editable'])
961
-			echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
962
-
963
-		elseif ($file['is_directory'])
964
-			echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
965
-
966
-		else
967
-			echo $file['filename'];
972
+		if ($file['is_editable']) {
973
+					echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
974
+		} elseif ($file['is_directory']) {
975
+					echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
976
+		} else {
977
+					echo $file['filename'];
978
+		}
968 979
 
969 980
 		echo '
970 981
 				</td>
@@ -986,11 +997,12 @@  discard block
 block discarded – undo
986 997
 {
987 998
 	global $context, $settings, $scripturl, $txt;
988 999
 
989
-	if ($context['session_error'])
990
-		echo '
1000
+	if ($context['session_error']) {
1001
+			echo '
991 1002
 	<div class="errorbox">
992 1003
 		', $txt['error_session_timeout'], '
993 1004
 	</div>';
1005
+	}
994 1006
 
995 1007
 	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
996 1008
 	echo '
@@ -1053,17 +1065,18 @@  discard block
 block discarded – undo
1053 1065
 					try
1054 1066
 					{
1055 1067
 					';
1056
-	if (isBrowser('is_ie'))
1057
-		echo '
1068
+	if (isBrowser('is_ie')) {
1069
+			echo '
1058 1070
 						var sheets = frames["css_preview_box"].document.styleSheets;
1059 1071
 						for (var j = 0; j < sheets.length; j++)
1060 1072
 						{
1061 1073
 							if (sheets[j].id == "css_preview_box")
1062 1074
 								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1063 1075
 						}';
1064
-	else
1065
-		echo '
1076
+	} else {
1077
+			echo '
1066 1078
 						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1079
+	}
1067 1080
 	echo '
1068 1081
 					}
1069 1082
 					catch (e)
@@ -1115,9 +1128,10 @@  discard block
 block discarded – undo
1115 1128
 			</div>
1116 1129
 			<div class="windowbg">';
1117 1130
 
1118
-	if (!$context['allow_save'])
1119
-		echo '
1131
+	if (!$context['allow_save']) {
1132
+			echo '
1120 1133
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1134
+	}
1121 1135
 
1122 1136
 	echo '
1123 1137
 				<textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br>
@@ -1130,9 +1144,10 @@  discard block
 block discarded – undo
1130 1144
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1131 1145
 
1132 1146
 	// Hopefully it exists.
1133
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1134
-		echo '
1147
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1148
+			echo '
1135 1149
 			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1150
+	}
1136 1151
 
1137 1152
 	echo '
1138 1153
 		</form>
@@ -1146,18 +1161,20 @@  discard block
 block discarded – undo
1146 1161
 {
1147 1162
 	global $context, $scripturl, $txt;
1148 1163
 
1149
-	if ($context['session_error'])
1150
-		echo '
1164
+	if ($context['session_error']) {
1165
+			echo '
1151 1166
 	<div class="errorbox">
1152 1167
 		', $txt['error_session_timeout'], '
1153 1168
 	</div>';
1169
+	}
1154 1170
 
1155
-	if (isset($context['parse_error']))
1156
-		echo '
1171
+	if (isset($context['parse_error'])) {
1172
+			echo '
1157 1173
 	<div class="errorbox">
1158 1174
 		', $txt['themeadmin_edit_error'], '
1159 1175
 			<div><pre>', $context['parse_error'], '</pre></div>
1160 1176
 	</div>';
1177
+	}
1161 1178
 
1162 1179
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1163 1180
 	echo '
@@ -1168,16 +1185,18 @@  discard block
 block discarded – undo
1168 1185
 			</div>
1169 1186
 			<div class="windowbg">';
1170 1187
 
1171
-	if (!$context['allow_save'])
1172
-		echo '
1188
+	if (!$context['allow_save']) {
1189
+			echo '
1173 1190
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1191
+	}
1174 1192
 
1175
-	foreach ($context['file_parts'] as $part)
1176
-		echo '
1193
+	foreach ($context['file_parts'] as $part) {
1194
+			echo '
1177 1195
 				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1178 1196
 				<div class="centertext">
1179 1197
 					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1180 1198
 				</div>';
1199
+	}
1181 1200
 
1182 1201
 	echo '
1183 1202
 				<div class="padding righttext">
@@ -1186,9 +1205,10 @@  discard block
 block discarded – undo
1186 1205
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1187 1206
 
1188 1207
 	// Hopefully it exists.
1189
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1190
-		echo '
1208
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1209
+			echo '
1191 1210
 					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1211
+	}
1192 1212
 
1193 1213
 	echo '
1194 1214
 				</div>
@@ -1204,18 +1224,20 @@  discard block
 block discarded – undo
1204 1224
 {
1205 1225
 	global $context, $scripturl, $txt;
1206 1226
 
1207
-	if ($context['session_error'])
1208
-		echo '
1227
+	if ($context['session_error']) {
1228
+			echo '
1209 1229
 	<div class="errorbox">
1210 1230
 		', $txt['error_session_timeout'], '
1211 1231
 	</div>';
1232
+	}
1212 1233
 
1213 1234
 	//Is this file writeable?
1214
-	if (!$context['allow_save'])
1215
-		echo '
1235
+	if (!$context['allow_save']) {
1236
+			echo '
1216 1237
 	<div class="errorbox">
1217 1238
 		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1218 1239
 	</div>';
1240
+	}
1219 1241
 
1220 1242
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1221 1243
 	echo '
@@ -1231,9 +1253,10 @@  discard block
 block discarded – undo
1231 1253
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1232 1254
 
1233 1255
 	// Hopefully it exists.
1234
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1235
-		echo '
1256
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1257
+			echo '
1236 1258
 				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1259
+	}
1237 1260
 
1238 1261
 	echo '
1239 1262
 			</div>
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 1 patch
Braces   +173 added lines, -125 removed lines patch added patch discarded remove patch
@@ -64,9 +64,10 @@  discard block
 block discarded – undo
64 64
 										<strong>', $txt['administrators'], ':</strong>
65 65
 										', implode(', ', $context['administrators']);
66 66
 	// If we have lots of admins... don't show them all.
67
-	if (!empty($context['more_admins_link']))
68
-		echo '
67
+	if (!empty($context['more_admins_link'])) {
68
+			echo '
69 69
 							(', $context['more_admins_link'], ')';
70
+	}
70 71
 
71 72
 	echo '
72 73
 									</div>
@@ -83,16 +84,18 @@  discard block
 block discarded – undo
83 84
 		foreach ($area['areas'] as $item_id => $item)
84 85
 		{
85 86
 			// No point showing the 'home' page here, we're already on it!
86
-			if ($area_id == 'forum' && $item_id == 'index')
87
-				continue;
87
+			if ($area_id == 'forum' && $item_id == 'index') {
88
+							continue;
89
+			}
88 90
 
89 91
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
90
-			if (!empty($item['icon_file']))
91
-				echo '
92
+			if (!empty($item['icon_file'])) {
93
+							echo '
92 94
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
93
-			else
94
-				echo '
95
+			} else {
96
+							echo '
95 97
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
98
+			}
96 99
 		}
97 100
 
98 101
 		echo '
@@ -103,10 +106,11 @@  discard block
 block discarded – undo
103 106
 					</div>';
104 107
 
105 108
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
106
-	if (empty($modSettings['disable_smf_js']))
107
-		echo '
109
+	if (empty($modSettings['disable_smf_js'])) {
110
+			echo '
108 111
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
109 112
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
113
+	}
110 114
 
111 115
 	// This sets the announcements and current versions themselves ;).
112 116
 	echo '
@@ -185,9 +189,10 @@  discard block
 block discarded – undo
185 189
 								<em>', $version['version'], '</em>';
186 190
 
187 191
 		// more details for this item, show them a link
188
-		if ($context['can_admin'] && isset($version['more']))
189
-			echo
192
+		if ($context['can_admin'] && isset($version['more'])) {
193
+					echo
190 194
 								' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
195
+		}
191 196
 		echo '
192 197
 								<br>';
193 198
 	}
@@ -218,20 +223,22 @@  discard block
 block discarded – undo
218 223
 
219 224
 	foreach ($context['credits'] as $section)
220 225
 	{
221
-		if (isset($section['pretext']))
222
-			echo '
226
+		if (isset($section['pretext'])) {
227
+					echo '
223 228
 								<p>', $section['pretext'], '</p><hr>';
229
+		}
224 230
 
225 231
 		echo '
226 232
 								<dl>';
227 233
 
228 234
 		foreach ($section['groups'] as $group)
229 235
 		{
230
-			if (isset($group['title']))
231
-				echo '
236
+			if (isset($group['title'])) {
237
+							echo '
232 238
 									<dt>
233 239
 										<strong>', $group['title'], ':</strong>
234 240
 									</dt>';
241
+			}
235 242
 
236 243
 			echo '
237 244
 									<dd>', implode(', ', $group['members']), '</dd>';
@@ -240,10 +247,11 @@  discard block
 block discarded – undo
240 247
 		echo '
241 248
 								</dl>';
242 249
 
243
-		if (isset($section['posttext']))
244
-			echo '
250
+		if (isset($section['posttext'])) {
251
+					echo '
245 252
 								<hr>
246 253
 								<p>', $section['posttext'], '</p>';
254
+		}
247 255
 	}
248 256
 
249 257
 	echo '
@@ -259,9 +267,10 @@  discard block
 block discarded – undo
259 267
 							smfSupportVersions.forum = "', $context['forum_version'], '";';
260 268
 
261 269
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
262
-	foreach ($context['current_versions'] as $variable => $version)
263
-		echo '
270
+	foreach ($context['current_versions'] as $variable => $version) {
271
+			echo '
264 272
 							smfSupportVersions.', $variable, ' = "', $version['version'], '";';
273
+	}
265 274
 
266 275
 	// Now we just have to include the script and wait ;).
267 276
 	echo '
@@ -358,8 +367,8 @@  discard block
 block discarded – undo
358 367
 							<tbody>';
359 368
 
360 369
 	// Loop through every source file displaying its version - using javascript.
361
-	foreach ($context['file_versions'] as $filename => $version)
362
-		echo '
370
+	foreach ($context['file_versions'] as $filename => $version) {
371
+			echo '
363 372
 								<tr class="windowbg">
364 373
 									<td class="half_table">
365 374
 										', $filename, '
@@ -371,6 +380,7 @@  discard block
 block discarded – undo
371 380
 										<em id="currentSources', $filename, '">??</em>
372 381
 									</td>
373 382
 								</tr>';
383
+	}
374 384
 
375 385
 	// Default template files.
376 386
 	echo '
@@ -396,8 +406,8 @@  discard block
 block discarded – undo
396 406
 							<table id="Default" class="table_grid">
397 407
 								<tbody>';
398 408
 
399
-	foreach ($context['default_template_versions'] as $filename => $version)
400
-		echo '
409
+	foreach ($context['default_template_versions'] as $filename => $version) {
410
+			echo '
401 411
 									<tr class="windowbg">
402 412
 										<td class="half_table">
403 413
 											', $filename, '
@@ -409,6 +419,7 @@  discard block
 block discarded – undo
409 419
 											<em id="currentDefault', $filename, '">??</em>
410 420
 										</td>
411 421
 									</tr>';
422
+	}
412 423
 
413 424
 	// Now the language files...
414 425
 	echo '
@@ -436,8 +447,8 @@  discard block
 block discarded – undo
436 447
 
437 448
 	foreach ($context['default_language_versions'] as $language => $files)
438 449
 	{
439
-		foreach ($files as $filename => $version)
440
-			echo '
450
+		foreach ($files as $filename => $version) {
451
+					echo '
441 452
 									<tr class="windowbg">
442 453
 										<td class="half_table">
443 454
 											', $filename, '.<em>', $language, '</em>.php
@@ -449,6 +460,7 @@  discard block
 block discarded – undo
449 460
 											<em id="current', $filename, '.', $language, '">??</em>
450 461
 										</td>
451 462
 									</tr>';
463
+		}
452 464
 	}
453 465
 
454 466
 	echo '
@@ -478,8 +490,8 @@  discard block
 block discarded – undo
478 490
 							<table id="Templates" class="table_grid">
479 491
 								<tbody>';
480 492
 
481
-		foreach ($context['template_versions'] as $filename => $version)
482
-			echo '
493
+		foreach ($context['template_versions'] as $filename => $version) {
494
+					echo '
483 495
 									<tr class="windowbg">
484 496
 										<td class="half_table">
485 497
 											', $filename, '
@@ -491,6 +503,7 @@  discard block
 block discarded – undo
491 503
 											<em id="currentTemplates', $filename, '">??</em>
492 504
 										</td>
493 505
 									</tr>';
506
+		}
494 507
 
495 508
 		echo '
496 509
 								</tbody>
@@ -520,8 +533,8 @@  discard block
 block discarded – undo
520 533
 							<table id="Tasks" class="table_grid">
521 534
 								<tbody>';
522 535
 
523
-		foreach ($context['tasks_versions'] as $filename => $version)
524
-			echo '
536
+		foreach ($context['tasks_versions'] as $filename => $version) {
537
+					echo '
525 538
 									<tr class="windowbg">
526 539
 										<td class="half_table">
527 540
 											', $filename, '
@@ -533,6 +546,7 @@  discard block
 block discarded – undo
533 546
 											<em id="currentTasks', $filename, '">??</em>
534 547
 										</td>
535 548
 									</tr>';
549
+		}
536 550
 
537 551
 		echo '
538 552
 								</tbody>
@@ -574,9 +588,10 @@  discard block
 block discarded – undo
574 588
 {
575 589
 	global $context, $scripturl, $txt, $modSettings;
576 590
 
577
-	if (!empty($context['saved_successful']))
578
-		echo '
591
+	if (!empty($context['saved_successful'])) {
592
+			echo '
579 593
 					<div class="infobox">', $txt['settings_saved'], '</div>';
594
+	}
580 595
 
581 596
 	// First section is for adding/removing words from the censored list.
582 597
 	echo '
@@ -591,11 +606,12 @@  discard block
 block discarded – undo
591 606
 								<p>', $txt['admin_censored_where'], '</p>';
592 607
 
593 608
 	// Show text boxes for censoring [bad   ] => [good  ].
594
-	foreach ($context['censored_words'] as $vulgar => $proper)
595
-		echo '
609
+	foreach ($context['censored_words'] as $vulgar => $proper) {
610
+			echo '
596 611
 								<div class="block">
597 612
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
598 613
 								</div>';
614
+	}
599 615
 
600 616
 	// Now provide a way to censor more words.
601 617
 	echo '
@@ -669,19 +685,21 @@  discard block
 block discarded – undo
669 685
 						<div class="windowbg2 noup">
670 686
 							', $txt['not_done_reason'];
671 687
 
672
-	if (!empty($context['continue_percent']))
673
-		echo '
688
+	if (!empty($context['continue_percent'])) {
689
+			echo '
674 690
 							<div class="progress_bar">
675 691
 								<div class="full_bar">', $context['continue_percent'], '%</div>
676 692
 								<div class="green_percent" style="width: ', $context['continue_percent'], '%;">&nbsp;</div>
677 693
 							</div>';
694
+	}
678 695
 
679
-	if (!empty($context['substep_enabled']))
680
-		echo '
696
+	if (!empty($context['substep_enabled'])) {
697
+			echo '
681 698
 							<div class="progress_bar">
682 699
 								<div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div>
683 700
 								<div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;">&nbsp;</div>
684 701
 							</div>';
702
+	}
685 703
 
686 704
 	echo '
687 705
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
@@ -716,35 +734,40 @@  discard block
 block discarded – undo
716 734
 {
717 735
 	global $context, $txt, $settings, $scripturl;
718 736
 
719
-	if (!empty($context['saved_successful']))
720
-		echo '
737
+	if (!empty($context['saved_successful'])) {
738
+			echo '
721 739
 					<div class="infobox">', $txt['settings_saved'], '</div>';
722
-	elseif (!empty($context['saved_failed']))
723
-		echo '
740
+	} elseif (!empty($context['saved_failed'])) {
741
+			echo '
724 742
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
743
+	}
725 744
 
726
-	if (!empty($context['settings_pre_javascript']))
727
-		echo '
745
+	if (!empty($context['settings_pre_javascript'])) {
746
+			echo '
728 747
 					<script>', $context['settings_pre_javascript'], '</script>';
748
+	}
729 749
 
730
-	if (!empty($context['settings_insert_above']))
731
-		echo $context['settings_insert_above'];
750
+	if (!empty($context['settings_insert_above'])) {
751
+			echo $context['settings_insert_above'];
752
+	}
732 753
 
733 754
 	echo '
734 755
 					<div id="admincenter">
735 756
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
736 757
 
737 758
 	// Is there a custom title?
738
-	if (isset($context['settings_title']))
739
-		echo '
759
+	if (isset($context['settings_title'])) {
760
+			echo '
740 761
 							<div class="cat_bar">
741 762
 								<h3 class="catbg">', $context['settings_title'], '</h3>
742 763
 							</div>';
764
+	}
743 765
 
744 766
 	// Have we got a message to display?
745
-	if (!empty($context['settings_message']))
746
-		echo '
767
+	if (!empty($context['settings_message'])) {
768
+			echo '
747 769
 							<div class="information">', $context['settings_message'], '</div>';
770
+	}
748 771
 
749 772
 	// Now actually loop through all the variables.
750 773
 	$is_open = false;
@@ -797,8 +820,9 @@  discard block
 block discarded – undo
797 820
 		// Hang about? Are you pulling my leg - a callback?!
798 821
 		if (is_array($config_var) && $config_var['type'] == 'callback')
799 822
 		{
800
-			if (function_exists('template_callback_' . $config_var['name']))
801
-				call_user_func('template_callback_' . $config_var['name']);
823
+			if (function_exists('template_callback_' . $config_var['name'])) {
824
+							call_user_func('template_callback_' . $config_var['name']);
825
+			}
802 826
 
803 827
 			continue;
804 828
 		}
@@ -828,9 +852,10 @@  discard block
 block discarded – undo
828 852
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
829 853
 
830 854
 				// Show the [?] button.
831
-				if ($config_var['help'])
832
-					echo '
855
+				if ($config_var['help']) {
856
+									echo '
833 857
 							<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
858
+				}
834 859
 
835 860
 				echo '
836 861
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -839,22 +864,25 @@  discard block
 block discarded – undo
839 864
 										$config_var['preinput'];
840 865
 
841 866
 				// Show a check box.
842
-				if ($config_var['type'] == 'check')
843
-					echo '
867
+				if ($config_var['type'] == 'check') {
868
+									echo '
844 869
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">';
870
+				}
845 871
 				// Escape (via htmlspecialchars.) the text box.
846
-				elseif ($config_var['type'] == 'password')
847
-					echo '
872
+				elseif ($config_var['type'] == 'password') {
873
+									echo '
848 874
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br>
849 875
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">';
876
+				}
850 877
 				// Show a selection box.
851 878
 				elseif ($config_var['type'] == 'select')
852 879
 				{
853 880
 					echo '
854 881
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
855
-					foreach ($config_var['data'] as $option)
856
-						echo '
882
+					foreach ($config_var['data'] as $option) {
883
+											echo '
857 884
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
885
+					}
858 886
 					echo '
859 887
 										</select>';
860 888
 				}
@@ -868,15 +896,17 @@  discard block
 block discarded – undo
868 896
 												<legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>';
869 897
 					foreach ($context['board_list'] as $id_cat => $cat)
870 898
 					{
871
-						if (!$first)
872
-							echo '
899
+						if (!$first) {
900
+													echo '
873 901
 											<hr>';
902
+						}
874 903
 						echo '
875 904
 											<strong>', $cat['name'], '</strong>
876 905
 											<ul>';
877
-						foreach ($cat['boards'] as $id_board => $brd)
878
-							echo '
906
+						foreach ($cat['boards'] as $id_board => $brd) {
907
+													echo '
879 908
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
909
+						}
880 910
 
881 911
 						echo '
882 912
 											</ul>';
@@ -886,12 +916,14 @@  discard block
 block discarded – undo
886 916
 											</fieldset>';
887 917
 				}
888 918
 				// Text area?
889
-				elseif ($config_var['type'] == 'large_text')
890
-					echo '
919
+				elseif ($config_var['type'] == 'large_text') {
920
+									echo '
891 921
 											<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
922
+				}
892 923
 				// Permission group?
893
-				elseif ($config_var['type'] == 'permissions')
894
-					theme_inline_permissions($config_var['name']);
924
+				elseif ($config_var['type'] == 'permissions') {
925
+									theme_inline_permissions($config_var['name']);
926
+				}
895 927
 				// BBC selection?
896 928
 				elseif ($config_var['type'] == 'bbc')
897 929
 				{
@@ -902,20 +934,22 @@  discard block
 block discarded – undo
902 934
 
903 935
 					foreach ($context['bbc_columns'] as $bbcColumn)
904 936
 					{
905
-						foreach ($bbcColumn as $bbcTag)
906
-							echo '
937
+						foreach ($bbcColumn as $bbcTag) {
938
+													echo '
907 939
 														<li class="list_bbc floatleft">
908 940
 															<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
909 941
 														</li>';
942
+						}
910 943
 					}
911 944
 					echo '							</ul>
912 945
 												<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
913 946
 											</fieldset>';
914 947
 				}
915 948
 				// A simple message?
916
-				elseif ($config_var['type'] == 'var_message')
917
-					echo '
949
+				elseif ($config_var['type'] == 'var_message') {
950
+									echo '
918 951
 											<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>';
952
+				}
919 953
 				// Assume it must be a text box
920 954
 				else
921 955
 				{
@@ -940,63 +974,70 @@  discard block
 block discarded – undo
940 974
 											' . $config_var['postinput'] : '',
941 975
 										'</dd>';
942 976
 			}
943
-		}
944
-
945
-		else
977
+		} else
946 978
 		{
947 979
 			// Just show a separator.
948
-			if ($config_var == '')
949
-				echo '
980
+			if ($config_var == '') {
981
+							echo '
950 982
 								</dl>
951 983
 								<hr>
952 984
 								<dl class="settings">';
953
-			else
954
-				echo '
985
+			} else {
986
+							echo '
955 987
 									<dd>
956 988
 										<strong>' . $config_var . '</strong>
957 989
 									</dd>';
990
+			}
958 991
 		}
959 992
 	}
960 993
 
961
-	if ($is_open)
962
-		echo '
994
+	if ($is_open) {
995
+			echo '
963 996
 								</dl>';
997
+	}
964 998
 
965
-	if (empty($context['settings_save_dont_show']))
966
-		echo '
999
+	if (empty($context['settings_save_dont_show'])) {
1000
+			echo '
967 1001
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">';
1002
+	}
968 1003
 
969
-	if ($is_open)
970
-		echo '
1004
+	if ($is_open) {
1005
+			echo '
971 1006
 							</div>';
1007
+	}
972 1008
 
973 1009
 
974 1010
 	// At least one token has to be used!
975
-	if (isset($context['admin-ssc_token']))
976
-		echo '
1011
+	if (isset($context['admin-ssc_token'])) {
1012
+			echo '
977 1013
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1014
+	}
978 1015
 
979
-	if (isset($context['admin-dbsc_token']))
980
-		echo '
1016
+	if (isset($context['admin-dbsc_token'])) {
1017
+			echo '
981 1018
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1019
+	}
982 1020
 
983
-	if (isset($context['admin-mp_token']))
984
-		echo '
1021
+	if (isset($context['admin-mp_token'])) {
1022
+			echo '
985 1023
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1024
+	}
986 1025
 
987 1026
 	echo '
988 1027
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
989 1028
 						</form>
990 1029
 					</div>';
991 1030
 
992
-	if (!empty($context['settings_post_javascript']))
993
-		echo '
1031
+	if (!empty($context['settings_post_javascript'])) {
1032
+			echo '
994 1033
 					<script>
995 1034
 					', $context['settings_post_javascript'], '
996 1035
 					</script>';
1036
+	}
997 1037
 
998
-	if (!empty($context['settings_insert_below']))
999
-		echo $context['settings_insert_below'];
1038
+	if (!empty($context['settings_insert_below'])) {
1039
+			echo $context['settings_insert_below'];
1040
+	}
1000 1041
 
1001 1042
 	// We may have added a board listing. If we did, we need to make it work.
1002 1043
 	addInlineJavascript('
@@ -1019,9 +1060,10 @@  discard block
 block discarded – undo
1019 1060
 {
1020 1061
 	global $context, $txt;
1021 1062
 
1022
-	if (!empty($context['saved_successful']))
1023
-		echo '
1063
+	if (!empty($context['saved_successful'])) {
1064
+			echo '
1024 1065
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1066
+	}
1025 1067
 
1026 1068
 	// Standard fields.
1027 1069
 	template_show_list('standard_profile_fields');
@@ -1053,11 +1095,12 @@  discard block
 block discarded – undo
1053 1095
 	if (isset($_GET['msg']))
1054 1096
 	{
1055 1097
 		loadLanguage('Errors');
1056
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1057
-			echo '
1098
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1099
+					echo '
1058 1100
 					<div class="errorbox">',
1059 1101
 						$txt['custom_option_' . $_GET['msg']], '
1060 1102
 					</div>';
1103
+		}
1061 1104
 	}
1062 1105
 
1063 1106
 	echo '
@@ -1123,9 +1166,10 @@  discard block
 block discarded – undo
1123 1166
 										<dd>
1124 1167
 											<select name="placement" id="placement">';
1125 1168
 
1126
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1127
-		echo '
1169
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1170
+			echo '
1128 1171
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1172
+	}
1129 1173
 
1130 1174
 	echo '
1131 1175
 											</select>
@@ -1148,9 +1192,10 @@  discard block
 block discarded – undo
1148 1192
 										</dt>
1149 1193
 										<dd>
1150 1194
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1151
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1152
-		echo '
1195
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1196
+			echo '
1153 1197
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1198
+	}
1154 1199
 
1155 1200
 	echo '
1156 1201
 											</select>
@@ -1251,9 +1296,10 @@  discard block
 block discarded – undo
1251 1296
 								</fieldset>
1252 1297
 									<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">';
1253 1298
 
1254
-	if ($context['fid'])
1255
-		echo '
1299
+	if ($context['fid']) {
1300
+			echo '
1256 1301
 									<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">';
1302
+	}
1257 1303
 
1258 1304
 	echo '
1259 1305
 							</div>
@@ -1296,8 +1342,7 @@  discard block
 block discarded – undo
1296 1342
 	{
1297 1343
 		echo '
1298 1344
 						<p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>';
1299
-	}
1300
-	else
1345
+	} else
1301 1346
 	{
1302 1347
 		echo '
1303 1348
 						<ol class="search_results">';
@@ -1323,9 +1368,10 @@  discard block
 block discarded – undo
1323 1368
 							<li>
1324 1369
 								<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1325 1370
 
1326
-				if ($result['help'])
1327
-					echo '
1371
+				if ($result['help']) {
1372
+									echo '
1328 1373
 								<p class="double_height">', $result['help'], '</p>';
1374
+				}
1329 1375
 
1330 1376
 				echo '
1331 1377
 							</li>';
@@ -1365,18 +1411,20 @@  discard block
 block discarded – undo
1365 1411
 									<strong>', $txt['setup_verification_answer'], '</strong>
1366 1412
 								</dd>';
1367 1413
 
1368
-		if (!empty($context['qa_by_lang'][$lang_id]))
1369
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1414
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1415
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1370 1416
 			{
1371 1417
 				$question = $context['question_answers'][$q_id];
1418
+		}
1372 1419
 				echo '
1373 1420
 								<dt>
1374 1421
 									<input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question">
1375 1422
 								</dt>
1376 1423
 								<dd>';
1377
-				foreach ($question['answers'] as $answer)
1378
-					echo '
1424
+				foreach ($question['answers'] as $answer) {
1425
+									echo '
1379 1426
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">';
1427
+				}
1380 1428
 
1381 1429
 				echo '
1382 1430
 									<div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1415,11 +1463,12 @@  discard block
 block discarded – undo
1415 1463
 							', $txt['errors_found'], ':
1416 1464
 							<ul>';
1417 1465
 
1418
-			foreach ($context['repair_errors'] as $error)
1419
-				echo '
1466
+			foreach ($context['repair_errors'] as $error) {
1467
+							echo '
1420 1468
 								<li>
1421 1469
 									', $error, '
1422 1470
 								</li>';
1471
+			}
1423 1472
 
1424 1473
 			echo '
1425 1474
 							</ul>
@@ -1429,16 +1478,15 @@  discard block
 block discarded – undo
1429 1478
 							<p class="padding">
1430 1479
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1431 1480
 							</p>';
1432
-		}
1433
-		else
1434
-			echo '
1481
+		} else {
1482
+					echo '
1435 1483
 							<p>', $txt['maintain_no_errors'], '</p>
1436 1484
 							<p class="padding">
1437 1485
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1438 1486
 							</p>';
1487
+		}
1439 1488
 
1440
-	}
1441
-	else
1489
+	} else
1442 1490
 	{
1443 1491
 		if (!empty($context['redirect_to_recount']))
1444 1492
 		{
@@ -1450,8 +1498,7 @@  discard block
 block discarded – undo
1450 1498
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1451 1499
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1452 1500
 							</form>';
1453
-		}
1454
-		else
1501
+		} else
1455 1502
 		{
1456 1503
 			echo '
1457 1504
 							<p>', $txt['errors_fixed'], '</p>
@@ -1603,8 +1650,8 @@  discard block
 block discarded – undo
1603 1650
 function template_admin_quick_search()
1604 1651
 {
1605 1652
 	global $context, $txt, $scripturl;
1606
-	if ($context['user']['is_admin'])
1607
-		echo '
1653
+	if ($context['user']['is_admin']) {
1654
+			echo '
1608 1655
 								<span class="floatright admin_search">
1609 1656
 									<span class="generic_icons filter centericon"></span>
1610 1657
 									<input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text">
@@ -1615,6 +1662,7 @@  discard block
 block discarded – undo
1615 1662
 									</select>
1616 1663
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit">
1617 1664
 								</span>';
1618
-}
1665
+	}
1666
+	}
1619 1667
 
1620 1668
 ?>
1621 1669
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-MembersOnline.php 1 patch
Braces   +27 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Retrieve a list and several other statistics of the users currently online.
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	}
46 47
 
47 48
 	// Not allowed sort method? Bang! Error!
48
-	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options))
49
-		trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
49
+	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) {
50
+			trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
51
+	}
50 52
 
51 53
 	// Initialize the array that'll be returned later on.
52 54
 	$membersOnlineStats = array(
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
 	// Get any spiders if enabled.
64 66
 	$spiders = array();
65 67
 	$spider_finds = array();
66
-	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
67
-		$spiders = smf_json_decode($modSettings['spider_name_cache'], true);
68
+	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
69
+			$spiders = smf_json_decode($modSettings['spider_name_cache'], true);
70
+	}
68 71
 
69 72
 	// Load the users online right now.
70 73
 	$request = $smcFunc['db_query']('', '
@@ -92,9 +95,7 @@  discard block
 block discarded – undo
92 95
 			$membersOnlineStats['num_guests']++;
93 96
 
94 97
 			continue;
95
-		}
96
-
97
-		elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98
+		} elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98 99
 		{
99 100
 			// Just increase the stats and don't add this hidden user to any list.
100 101
 			$membersOnlineStats['num_users_hidden']++;
@@ -102,10 +103,11 @@  discard block
 block discarded – undo
102 103
 		}
103 104
 
104 105
 		// Some basic color coding...
105
-		if (!empty($row['online_color']))
106
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
107
-		else
108
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
106
+		if (!empty($row['online_color'])) {
107
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
108
+		} else {
109
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
110
+		}
109 111
 
110 112
 		// Buddies get counted and highlighted.
111 113
 		$is_buddy = in_array($row['id_member'], $user_info['buddies']);
@@ -132,12 +134,13 @@  discard block
 block discarded – undo
132 134
 		$membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
133 135
 
134 136
 		// Store all distinct (primary) membergroups that are shown.
135
-		if (!isset($membersOnlineStats['online_groups'][$row['id_group']]))
136
-			$membersOnlineStats['online_groups'][$row['id_group']] = array(
137
+		if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) {
138
+					$membersOnlineStats['online_groups'][$row['id_group']] = array(
137 139
 				'id' => $row['id_group'],
138 140
 				'name' => $row['group_name'],
139 141
 				'color' => $row['online_color']
140 142
 			);
143
+		}
141 144
 	}
142 145
 	$smcFunc['db_free_result']($request);
143 146
 
@@ -198,11 +201,12 @@  discard block
 block discarded – undo
198 201
 	$settingsToUpdate = array();
199 202
 
200 203
 	// More members on now than ever were?  Update it!
201
-	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline'])
202
-		$settingsToUpdate = array(
204
+	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) {
205
+			$settingsToUpdate = array(
203 206
 			'mostOnline' => $total_users_online,
204 207
 			'mostDate' => time()
205 208
 		);
209
+	}
206 210
 
207 211
 	$date = strftime('%Y-%m-%d', forum_time(false));
208 212
 
@@ -234,8 +238,9 @@  discard block
 block discarded – undo
234 238
 		{
235 239
 			list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request);
236 240
 
237
-			if ($total_users_online > $modSettings['mostOnlineToday'])
238
-				trackStats(array('most_on' => $total_users_online));
241
+			if ($total_users_online > $modSettings['mostOnlineToday']) {
242
+							trackStats(array('most_on' => $total_users_online));
243
+			}
239 244
 
240 245
 			$total_users_online = max($total_users_online, $modSettings['mostOnlineToday']);
241 246
 		}
@@ -252,8 +257,9 @@  discard block
 block discarded – undo
252 257
 		$settingsToUpdate['mostOnlineToday'] = $total_users_online;
253 258
 	}
254 259
 
255
-	if (!empty($settingsToUpdate))
256
-		updateSettings($settingsToUpdate);
257
-}
260
+	if (!empty($settingsToUpdate)) {
261
+			updateSettings($settingsToUpdate);
262
+	}
263
+	}
258 264
 
259 265
 ?>
260 266
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Db-mysql.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 		
256 256
 		case 'datetime':
257 257
 			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
258
-				return 'str_to_date('.
259
-					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
258
+				return 'str_to_date(' .
259
+					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) .
260 260
 					',\'%Y-%m-%d %h:%i:%s\')';
261 261
 			else
262 262
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		$connection
824 824
 	);
825 825
 	
826
-	if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
826
+	if (!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
827 827
 	{
828 828
 		if ($returnmode == 1)
829 829
 			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 			$return_var = array();
833 833
 			$count = count($insertRows);
834 834
 			$start = smf_db_insert_id($table, $keys[0]);
835
-			for ($i = 0; $i < $count; $i++ )
835
+			for ($i = 0; $i < $count; $i++)
836 836
 				$return_var[] = $start + $i;
837 837
 		}
838 838
 		return $return_var;
Please login to merge, or discard this patch.
Braces   +257 added lines, -189 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc, $mysql_set_mode;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']))
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc'])) {
38
+			$smcFunc += array(
38 39
 			'db_query'                  => 'smf_db_query',
39 40
 			'db_quote'                  => 'smf_db_quote',
40 41
 			'db_fetch_assoc'            => 'mysqli_fetch_assoc',
@@ -60,9 +61,11 @@  discard block
 block discarded – undo
60 61
 			'db_mb4'                    => false,
61 62
 			'db_ping'                   => 'mysqli_ping',
62 63
 		);
64
+	}
63 65
 
64
-	if (!empty($db_options['persist']))
65
-		$db_server = 'p:' . $db_server;
66
+	if (!empty($db_options['persist'])) {
67
+			$db_server = 'p:' . $db_server;
68
+	}
66 69
 
67 70
 	$connection = mysqli_init();
68 71
 	
@@ -71,31 +74,35 @@  discard block
 block discarded – undo
71 74
 	$success = false;
72 75
 	
73 76
 	if ($connection) {
74
-		if (!empty($db_options['port']))
75
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
76
-		else
77
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
77
+		if (!empty($db_options['port'])) {
78
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
79
+		} else {
80
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
81
+		}
78 82
 	}
79 83
 
80 84
 	// Something's wrong, show an error if its fatal (which we assume it is)
81 85
 	if ($success === false)
82 86
 	{
83
-		if (!empty($db_options['non_fatal']))
84
-			return null;
85
-		else
86
-			display_db_error();
87
+		if (!empty($db_options['non_fatal'])) {
88
+					return null;
89
+		} else {
90
+					display_db_error();
91
+		}
87 92
 	}
88 93
 
89 94
 	// Select the database, unless told not to
90
-	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal']))
91
-		display_db_error();
95
+	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) {
96
+			display_db_error();
97
+	}
92 98
 
93 99
 	// This makes it possible to have SMF automatically change the sql_mode and autocommit if needed.
94
-	if (isset($mysql_set_mode) && $mysql_set_mode === true)
95
-		$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
100
+	if (isset($mysql_set_mode) && $mysql_set_mode === true) {
101
+			$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
96 102
 		array(),
97 103
 		false
98 104
 	);
105
+	}
99 106
 
100 107
 	return $connection;
101 108
 }
@@ -166,37 +173,46 @@  discard block
 block discarded – undo
166 173
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
167 174
 
168 175
 	list ($values, $connection) = $db_callback;
169
-	if (!is_object($connection))
170
-		display_db_error();
176
+	if (!is_object($connection)) {
177
+			display_db_error();
178
+	}
171 179
 
172
-	if ($matches[1] === 'db_prefix')
173
-		return $db_prefix;
180
+	if ($matches[1] === 'db_prefix') {
181
+			return $db_prefix;
182
+	}
174 183
 
175
-	if ($matches[1] === 'query_see_board')
176
-		return $user_info['query_see_board'];
184
+	if ($matches[1] === 'query_see_board') {
185
+			return $user_info['query_see_board'];
186
+	}
177 187
 
178
-	if ($matches[1] === 'query_wanna_see_board')
179
-		return $user_info['query_wanna_see_board'];
188
+	if ($matches[1] === 'query_wanna_see_board') {
189
+			return $user_info['query_wanna_see_board'];
190
+	}
180 191
 
181
-	if ($matches[1] === 'empty')
182
-		return '\'\'';
192
+	if ($matches[1] === 'empty') {
193
+			return '\'\'';
194
+	}
183 195
 
184
-	if (!isset($matches[2]))
185
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
196
+	if (!isset($matches[2])) {
197
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
198
+	}
186 199
 
187
-	if ($matches[1] === 'literal')
188
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
200
+	if ($matches[1] === 'literal') {
201
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
202
+	}
189 203
 
190
-	if (!isset($values[$matches[2]]))
191
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
204
+	if (!isset($values[$matches[2]])) {
205
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
206
+	}
192 207
 
193 208
 	$replacement = $values[$matches[2]];
194 209
 
195 210
 	switch ($matches[1])
196 211
 	{
197 212
 		case 'int':
198
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
199
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
213
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
214
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
215
+			}
200 216
 			return (string) (int) $replacement;
201 217
 		break;
202 218
 
@@ -208,65 +224,73 @@  discard block
 block discarded – undo
208 224
 		case 'array_int':
209 225
 			if (is_array($replacement))
210 226
 			{
211
-				if (empty($replacement))
212
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
227
+				if (empty($replacement)) {
228
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
229
+				}
213 230
 
214 231
 				foreach ($replacement as $key => $value)
215 232
 				{
216
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
217
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
233
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
234
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
235
+					}
218 236
 
219 237
 					$replacement[$key] = (string) (int) $value;
220 238
 				}
221 239
 
222 240
 				return implode(', ', $replacement);
241
+			} else {
242
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
223 243
 			}
224
-			else
225
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
226 244
 
227 245
 		break;
228 246
 
229 247
 		case 'array_string':
230 248
 			if (is_array($replacement))
231 249
 			{
232
-				if (empty($replacement))
233
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
250
+				if (empty($replacement)) {
251
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
252
+				}
234 253
 
235
-				foreach ($replacement as $key => $value)
236
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
254
+				foreach ($replacement as $key => $value) {
255
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
256
+				}
237 257
 
238 258
 				return implode(', ', $replacement);
259
+			} else {
260
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
239 261
 			}
240
-			else
241
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
242 262
 		break;
243 263
 
244 264
 		case 'date':
245
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
246
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
247
-			else
248
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
265
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
266
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
267
+			} else {
268
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
269
+			}
249 270
 		break;
250 271
 
251 272
 		case 'time':
252
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
253
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
254
-			else
255
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
273
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
274
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
275
+			} else {
276
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
277
+			}
256 278
 		break;
257 279
 		
258 280
 		case 'datetime':
259
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
260
-				return 'str_to_date('.
281
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
282
+							return 'str_to_date('.
261 283
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
262 284
 					',\'%Y-%m-%d %h:%i:%s\')';
263
-			else
264
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
285
+			} else {
286
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
287
+			}
265 288
 		break;
266 289
 
267 290
 		case 'float':
268
-			if (!is_numeric($replacement))
269
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
291
+			if (!is_numeric($replacement)) {
292
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
293
+			}
270 294
 			return (string) (float) $replacement;
271 295
 		break;
272 296
 
@@ -280,32 +304,37 @@  discard block
 block discarded – undo
280 304
 		break;
281 305
 
282 306
 		case 'inet':
283
-			if ($replacement == 'null' || $replacement == '')
284
-				return 'null';
285
-			if (!isValidIP($replacement))
286
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
307
+			if ($replacement == 'null' || $replacement == '') {
308
+							return 'null';
309
+			}
310
+			if (!isValidIP($replacement)) {
311
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
312
+			}
287 313
 			//we don't use the native support of mysql > 5.6.2
288 314
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
289 315
 
290 316
 		case 'array_inet':
291 317
 			if (is_array($replacement))
292 318
 			{
293
-				if (empty($replacement))
294
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
319
+				if (empty($replacement)) {
320
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
321
+				}
295 322
 
296 323
 				foreach ($replacement as $key => $value)
297 324
 				{
298
-					if ($replacement == 'null' || $replacement == '')
299
-						$replacement[$key] = 'null';
300
-					if (!isValidIP($value))
301
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
325
+					if ($replacement == 'null' || $replacement == '') {
326
+											$replacement[$key] = 'null';
327
+					}
328
+					if (!isValidIP($value)) {
329
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
330
+					}
302 331
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
303 332
 				}
304 333
 
305 334
 				return implode(', ', $replacement);
335
+			} else {
336
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
306 337
 			}
307
-			else
308
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
309 338
 		break;
310 339
 
311 340
 		default:
@@ -381,22 +410,25 @@  discard block
 block discarded – undo
381 410
 		// Are we in SSI mode?  If so try that username and password first
382 411
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
383 412
 		{
384
-			if (empty($db_persist))
385
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
386
-			else
387
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
413
+			if (empty($db_persist)) {
414
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
415
+			} else {
416
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
417
+			}
388 418
 		}
389 419
 		// Fall back to the regular username and password if need be
390 420
 		if (!$db_connection)
391 421
 		{
392
-			if (empty($db_persist))
393
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
394
-			else
395
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
422
+			if (empty($db_persist)) {
423
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
424
+			} else {
425
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
426
+			}
396 427
 		}
397 428
 
398
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
399
-			$db_connection = false;
429
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
430
+					$db_connection = false;
431
+		}
400 432
 
401 433
 		$connection = $db_connection;
402 434
 	}
@@ -404,18 +436,20 @@  discard block
 block discarded – undo
404 436
 	// One more query....
405 437
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
406 438
 
407
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
408
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
439
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
440
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
441
+	}
409 442
 
410 443
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
411 444
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
412 445
 	{
413 446
 		// Add before LIMIT
414
-		if ($pos = strpos($db_string, 'LIMIT '))
415
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
416
-		else
417
-			// Append it.
447
+		if ($pos = strpos($db_string, 'LIMIT ')) {
448
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
449
+		} else {
450
+					// Append it.
418 451
 			$db_string .= "\n\t\t\tORDER BY null";
452
+		}
419 453
 	}
420 454
 
421 455
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -437,8 +471,9 @@  discard block
 block discarded – undo
437 471
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
438 472
 
439 473
 		// Initialize $db_cache if not already initialized.
440
-		if (!isset($db_cache))
441
-			$db_cache = array();
474
+		if (!isset($db_cache)) {
475
+					$db_cache = array();
476
+		}
442 477
 
443 478
 		if (!empty($_SESSION['debug_redirect']))
444 479
 		{
@@ -464,17 +499,18 @@  discard block
 block discarded – undo
464 499
 		while (true)
465 500
 		{
466 501
 			$pos = strpos($db_string, '\'', $pos + 1);
467
-			if ($pos === false)
468
-				break;
502
+			if ($pos === false) {
503
+							break;
504
+			}
469 505
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
470 506
 
471 507
 			while (true)
472 508
 			{
473 509
 				$pos1 = strpos($db_string, '\'', $pos + 1);
474 510
 				$pos2 = strpos($db_string, '\\', $pos + 1);
475
-				if ($pos1 === false)
476
-					break;
477
-				elseif ($pos2 === false || $pos2 > $pos1)
511
+				if ($pos1 === false) {
512
+									break;
513
+				} elseif ($pos2 === false || $pos2 > $pos1)
478 514
 				{
479 515
 					$pos = $pos1;
480 516
 					break;
@@ -490,29 +526,35 @@  discard block
 block discarded – undo
490 526
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
491 527
 
492 528
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
493
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
494
-			$fail = true;
529
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
530
+					$fail = true;
531
+		}
495 532
 		// Trying to change passwords, slow us down, or something?
496
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
497
-			$fail = true;
498
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
499
-			$fail = true;
533
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
534
+					$fail = true;
535
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
536
+					$fail = true;
537
+		}
500 538
 
501
-		if (!empty($fail) && function_exists('log_error'))
502
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
539
+		if (!empty($fail) && function_exists('log_error')) {
540
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
541
+		}
503 542
 	}
504 543
 
505
-	if (empty($db_unbuffered))
506
-		$ret = @mysqli_query($connection, $db_string);
507
-	else
508
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
544
+	if (empty($db_unbuffered)) {
545
+			$ret = @mysqli_query($connection, $db_string);
546
+	} else {
547
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
548
+	}
509 549
 
510
-	if ($ret === false && empty($db_values['db_error_skip']))
511
-		$ret = smf_db_error($db_string, $connection);
550
+	if ($ret === false && empty($db_values['db_error_skip'])) {
551
+			$ret = smf_db_error($db_string, $connection);
552
+	}
512 553
 
513 554
 	// Debugging.
514
-	if (isset($db_show_debug) && $db_show_debug === true)
515
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
555
+	if (isset($db_show_debug) && $db_show_debug === true) {
556
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
557
+	}
516 558
 
517 559
 	return $ret;
518 560
 }
@@ -559,12 +601,13 @@  discard block
 block discarded – undo
559 601
 	// Decide which connection to use
560 602
 	$connection = $connection === null ? $db_connection : $connection;
561 603
 
562
-	if ($type == 'begin')
563
-		return @mysqli_query($connection, 'BEGIN');
564
-	elseif ($type == 'rollback')
565
-		return @mysqli_query($connection, 'ROLLBACK');
566
-	elseif ($type == 'commit')
567
-		return @mysqli_query($connection, 'COMMIT');
604
+	if ($type == 'begin') {
605
+			return @mysqli_query($connection, 'BEGIN');
606
+	} elseif ($type == 'rollback') {
607
+			return @mysqli_query($connection, 'ROLLBACK');
608
+	} elseif ($type == 'commit') {
609
+			return @mysqli_query($connection, 'COMMIT');
610
+	}
568 611
 
569 612
 	return false;
570 613
 }
@@ -604,8 +647,9 @@  discard block
 block discarded – undo
604 647
 	//    2013: Lost connection to server during query.
605 648
 
606 649
 	// Log the error.
607
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
608
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
650
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
651
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
652
+	}
609 653
 
610 654
 	// Database error auto fixing ;).
611 655
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -614,8 +658,9 @@  discard block
 block discarded – undo
614 658
 		$old_cache = @$modSettings['cache_enable'];
615 659
 		$modSettings['cache_enable'] = '1';
616 660
 
617
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
618
-			$db_last_error = max(@$db_last_error, $temp);
661
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
662
+					$db_last_error = max(@$db_last_error, $temp);
663
+		}
619 664
 
620 665
 		if (@$db_last_error < time() - 3600 * 24 * 3)
621 666
 		{
@@ -631,8 +676,9 @@  discard block
 block discarded – undo
631 676
 					foreach ($tables as $table)
632 677
 					{
633 678
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
634
-						if (trim($table) != '')
635
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
679
+						if (trim($table) != '') {
680
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
681
+						}
636 682
 					}
637 683
 				}
638 684
 
@@ -641,8 +687,9 @@  discard block
 block discarded – undo
641 687
 			// Table crashed.  Let's try to fix it.
642 688
 			elseif ($query_errno == 1016)
643 689
 			{
644
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
645
-					$fix_tables = array('`' . $match[1] . '`');
690
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
691
+									$fix_tables = array('`' . $match[1] . '`');
692
+				}
646 693
 			}
647 694
 			// Indexes crashed.  Should be easy to fix!
648 695
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -661,13 +708,15 @@  discard block
 block discarded – undo
661 708
 
662 709
 			// Make a note of the REPAIR...
663 710
 			cache_put_data('db_last_error', time(), 600);
664
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
665
-				updateSettingsFile(array('db_last_error' => time()));
711
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
712
+							updateSettingsFile(array('db_last_error' => time()));
713
+			}
666 714
 
667 715
 			// Attempt to find and repair the broken table.
668
-			foreach ($fix_tables as $table)
669
-				$smcFunc['db_query']('', "
716
+			foreach ($fix_tables as $table) {
717
+							$smcFunc['db_query']('', "
670 718
 					REPAIR TABLE $table", false, false);
719
+			}
671 720
 
672 721
 			// And send off an email!
673 722
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -676,11 +725,12 @@  discard block
 block discarded – undo
676 725
 
677 726
 			// Try the query again...?
678 727
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
679
-			if ($ret !== false)
680
-				return $ret;
728
+			if ($ret !== false) {
729
+							return $ret;
730
+			}
731
+		} else {
732
+					$modSettings['cache_enable'] = $old_cache;
681 733
 		}
682
-		else
683
-			$modSettings['cache_enable'] = $old_cache;
684 734
 
685 735
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
686 736
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -690,22 +740,25 @@  discard block
 block discarded – undo
690 740
 				// Are we in SSI mode?  If so try that username and password first
691 741
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
692 742
 				{
693
-					if (empty($db_persist))
694
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
695
-					else
696
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
743
+					if (empty($db_persist)) {
744
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
745
+					} else {
746
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
747
+					}
697 748
 				}
698 749
 				// Fall back to the regular username and password if need be
699 750
 				if (!$db_connection)
700 751
 				{
701
-					if (empty($db_persist))
702
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
703
-					else
704
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
752
+					if (empty($db_persist)) {
753
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
754
+					} else {
755
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
756
+					}
705 757
 				}
706 758
 
707
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
708
-					$db_connection = false;
759
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
760
+									$db_connection = false;
761
+				}
709 762
 			}
710 763
 
711 764
 			if ($db_connection)
@@ -716,24 +769,27 @@  discard block
 block discarded – undo
716 769
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
717 770
 
718 771
 					$new_errno = mysqli_errno($db_connection);
719
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
720
-						break;
772
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
773
+											break;
774
+					}
721 775
 				}
722 776
 
723 777
 				// If it failed again, shucks to be you... we're not trying it over and over.
724
-				if ($ret !== false)
725
-					return $ret;
778
+				if ($ret !== false) {
779
+									return $ret;
780
+				}
726 781
 			}
727 782
 		}
728 783
 		// Are they out of space, perhaps?
729 784
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
730 785
 		{
731
-			if (!isset($txt))
732
-				$query_error .= ' - check database storage space.';
733
-			else
786
+			if (!isset($txt)) {
787
+							$query_error .= ' - check database storage space.';
788
+			} else
734 789
 			{
735
-				if (!isset($txt['mysql_error_space']))
736
-					loadLanguage('Errors');
790
+				if (!isset($txt['mysql_error_space'])) {
791
+									loadLanguage('Errors');
792
+				}
737 793
 
738 794
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
739 795
 			}
@@ -741,15 +797,17 @@  discard block
 block discarded – undo
741 797
 	}
742 798
 
743 799
 	// Nothing's defined yet... just die with it.
744
-	if (empty($context) || empty($txt))
745
-		die($query_error);
800
+	if (empty($context) || empty($txt)) {
801
+			die($query_error);
802
+	}
746 803
 
747 804
 	// Show an error message, if possible.
748 805
 	$context['error_title'] = $txt['database_error'];
749
-	if (allowedTo('admin_forum'))
750
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
751
-	else
752
-		$context['error_message'] = $txt['try_again'];
806
+	if (allowedTo('admin_forum')) {
807
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
808
+	} else {
809
+			$context['error_message'] = $txt['try_again'];
810
+	}
753 811
 
754 812
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
755 813
 	{
@@ -779,25 +837,28 @@  discard block
 block discarded – undo
779 837
 	$connection = $connection === null ? $db_connection : $connection;
780 838
 
781 839
 	// With nothing to insert, simply return.
782
-	if (empty($data))
783
-		return;
840
+	if (empty($data)) {
841
+			return;
842
+	}
784 843
 
785 844
 	// Replace the prefix holder with the actual prefix.
786 845
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
787 846
 
788 847
 	// Inserting data as a single row can be done as a single array.
789
-	if (!is_array($data[array_rand($data)]))
790
-		$data = array($data);
848
+	if (!is_array($data[array_rand($data)])) {
849
+			$data = array($data);
850
+	}
791 851
 
792 852
 	// Create the mold for a single row insert.
793 853
 	$insertData = '(';
794 854
 	foreach ($columns as $columnName => $type)
795 855
 	{
796 856
 		// Are we restricting the length?
797
-		if (strpos($type, 'string-') !== false)
798
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
799
-		else
800
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
857
+		if (strpos($type, 'string-') !== false) {
858
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
859
+		} else {
860
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
861
+		}
801 862
 	}
802 863
 	$insertData = substr($insertData, 0, -2) . ')';
803 864
 
@@ -806,8 +867,9 @@  discard block
 block discarded – undo
806 867
 
807 868
 	// Here's where the variables are injected to the query.
808 869
 	$insertRows = array();
809
-	foreach ($data as $dataRow)
810
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
870
+	foreach ($data as $dataRow) {
871
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
872
+	}
811 873
 
812 874
 	// Determine the method of insertion.
813 875
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -827,15 +889,16 @@  discard block
 block discarded – undo
827 889
 	
828 890
 	if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
829 891
 	{
830
-		if ($returnmode == 1)
831
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
832
-		else if ($returnmode == 2)
892
+		if ($returnmode == 1) {
893
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
894
+		} else if ($returnmode == 2)
833 895
 		{
834 896
 			$return_var = array();
835 897
 			$count = count($insertRows);
836 898
 			$start = smf_db_insert_id($table, $keys[0]);
837
-			for ($i = 0; $i < $count; $i++ )
838
-				$return_var[] = $start + $i;
899
+			for ($i = 0; $i < $count; $i++ ) {
900
+							$return_var[] = $start + $i;
901
+			}
839 902
 		}
840 903
 		return $return_var;
841 904
 	}
@@ -853,8 +916,9 @@  discard block
 block discarded – undo
853 916
  */
854 917
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
855 918
 {
856
-	if (empty($log_message))
857
-		$log_message = $error_message;
919
+	if (empty($log_message)) {
920
+			$log_message = $error_message;
921
+	}
858 922
 
859 923
 	foreach (debug_backtrace() as $step)
860 924
 	{
@@ -873,12 +937,14 @@  discard block
 block discarded – undo
873 937
 	}
874 938
 
875 939
 	// A special case - we want the file and line numbers for debugging.
876
-	if ($error_type == 'return')
877
-		return array($file, $line);
940
+	if ($error_type == 'return') {
941
+			return array($file, $line);
942
+	}
878 943
 
879 944
 	// Is always a critical error.
880
-	if (function_exists('log_error'))
881
-		log_error($log_message, 'critical', $file, $line);
945
+	if (function_exists('log_error')) {
946
+			log_error($log_message, 'critical', $file, $line);
947
+	}
882 948
 
883 949
 	if (function_exists('fatal_error'))
884 950
 	{
@@ -886,12 +952,12 @@  discard block
 block discarded – undo
886 952
 
887 953
 		// Cannot continue...
888 954
 		exit;
955
+	} elseif ($error_type) {
956
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
957
+	} else {
958
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
959
+	}
889 960
 	}
890
-	elseif ($error_type)
891
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
892
-	else
893
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
894
-}
895 961
 
896 962
 /**
897 963
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -908,10 +974,11 @@  discard block
 block discarded – undo
908 974
 		'\\' => '\\\\',
909 975
 	);
910 976
 
911
-	if ($translate_human_wildcards)
912
-		$replacements += array(
977
+	if ($translate_human_wildcards) {
978
+			$replacements += array(
913 979
 			'*' => '%',
914 980
 		);
981
+	}
915 982
 
916 983
 	return strtr($string, $replacements);
917 984
 }
@@ -925,8 +992,9 @@  discard block
 block discarded – undo
925 992
  */
926 993
 function smf_is_resource($result)
927 994
 {
928
-	if ($result instanceof mysqli_result)
929
-		return true;
995
+	if ($result instanceof mysqli_result) {
996
+			return true;
997
+	}
930 998
 
931 999
 	return false;
932 1000
 }
Please login to merge, or discard this patch.