Completed
Push — release-2.1 ( aa21c4...7040ad )
by Mathias
09:20
created
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, $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;
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/ReCaptcha/ReCaptcha.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,67 +31,67 @@
 block discarded – undo
31 31
  */
32 32
 class ReCaptcha
33 33
 {
34
-    /**
35
-     * Version of this client library.
36
-     * @const string
37
-     */
38
-    const VERSION = 'php_1.1.2';
34
+	/**
35
+	 * Version of this client library.
36
+	 * @const string
37
+	 */
38
+	const VERSION = 'php_1.1.2';
39 39
 
40
-    /**
41
-     * Shared secret for the site.
42
-     * @var string
43
-     */
44
-    private $secret;
40
+	/**
41
+	 * Shared secret for the site.
42
+	 * @var string
43
+	 */
44
+	private $secret;
45 45
 
46
-    /**
47
-     * Method used to communicate  with service. Defaults to POST request.
48
-     * @var RequestMethod
49
-     */
50
-    private $requestMethod;
46
+	/**
47
+	 * Method used to communicate  with service. Defaults to POST request.
48
+	 * @var RequestMethod
49
+	 */
50
+	private $requestMethod;
51 51
 
52
-    /**
53
-     * Create a configured instance to use the reCAPTCHA service.
54
-     *
55
-     * @param string $secret shared secret between site and reCAPTCHA server.
56
-     * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
-     */
58
-    public function __construct($secret, RequestMethod $requestMethod = null)
59
-    {
60
-        if (empty($secret)) {
61
-            throw new \RuntimeException('No secret provided');
62
-        }
52
+	/**
53
+	 * Create a configured instance to use the reCAPTCHA service.
54
+	 *
55
+	 * @param string $secret shared secret between site and reCAPTCHA server.
56
+	 * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
+	 */
58
+	public function __construct($secret, RequestMethod $requestMethod = null)
59
+	{
60
+		if (empty($secret)) {
61
+			throw new \RuntimeException('No secret provided');
62
+		}
63 63
 
64
-        if (!is_string($secret)) {
65
-            throw new \RuntimeException('The provided secret must be a string');
66
-        }
64
+		if (!is_string($secret)) {
65
+			throw new \RuntimeException('The provided secret must be a string');
66
+		}
67 67
 
68
-        $this->secret = $secret;
68
+		$this->secret = $secret;
69 69
 
70
-        if (!is_null($requestMethod)) {
71
-            $this->requestMethod = $requestMethod;
72
-        } else {
73
-            $this->requestMethod = new RequestMethod\Post();
74
-        }
75
-    }
70
+		if (!is_null($requestMethod)) {
71
+			$this->requestMethod = $requestMethod;
72
+		} else {
73
+			$this->requestMethod = new RequestMethod\Post();
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
-     * CAPTCHA test.
80
-     *
81
-     * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
-     * @param string $remoteIp The end user's IP address.
83
-     * @return Response Response from the service.
84
-     */
85
-    public function verify($response, $remoteIp = null)
86
-    {
87
-        // Discard empty solution submissions
88
-        if (empty($response)) {
89
-            $recaptchaResponse = new Response(false, array('missing-input-response'));
90
-            return $recaptchaResponse;
91
-        }
77
+	/**
78
+	 * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
+	 * CAPTCHA test.
80
+	 *
81
+	 * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
+	 * @param string $remoteIp The end user's IP address.
83
+	 * @return Response Response from the service.
84
+	 */
85
+	public function verify($response, $remoteIp = null)
86
+	{
87
+		// Discard empty solution submissions
88
+		if (empty($response)) {
89
+			$recaptchaResponse = new Response(false, array('missing-input-response'));
90
+			return $recaptchaResponse;
91
+		}
92 92
 
93
-        $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
-        $rawResponse = $this->requestMethod->submit($params);
95
-        return Response::fromJson($rawResponse);
96
-    }
93
+		$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
+		$rawResponse = $this->requestMethod->submit($params);
95
+		return Response::fromJson($rawResponse);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Sources/ManageServer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
 		while ($row = $smcFunc['db_fetch_assoc']($request))
252 252
 			$fts_language[$row['cfgname']] = $row['cfgname'];
253 253
 		
254
-		$config_vars = array_merge ($config_vars, array(
254
+		$config_vars = array_merge($config_vars, array(
255 255
 				'',
256 256
 				array('search_language', $txt['search_language'], 'db', 'select', $fts_language, 'pgFulltextSearch')
257 257
 			)
Please login to merge, or discard this patch.
Braces   +265 added lines, -204 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -168,8 +170,9 @@  discard block
 block discarded – undo
168 170
 
169 171
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
170 172
 
171
-	if ($return_config)
172
-		return $config_vars;
173
+	if ($return_config) {
174
+			return $config_vars;
175
+	}
173 176
 
174 177
 	// Setup the template stuff.
175 178
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -186,8 +189,9 @@  discard block
 block discarded – undo
186 189
 			$registerSMStats = registerSMStats();
187 190
 
188 191
 			// Failed to register, disable it again.
189
-			if (empty($registerSMStats))
190
-				$_POST['enable_sm_stats'] = 0;
192
+			if (empty($registerSMStats)) {
193
+							$_POST['enable_sm_stats'] = 0;
194
+			}
191 195
 		}
192 196
 
193 197
 		saveSettings($config_vars);
@@ -248,8 +252,9 @@  discard block
 block discarded – undo
248 252
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
249 253
 		$fts_language = array();
250 254
 
251
-		while ($row = $smcFunc['db_fetch_assoc']($request))
252
-			$fts_language[$row['cfgname']] = $row['cfgname'];
255
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
256
+					$fts_language[$row['cfgname']] = $row['cfgname'];
257
+		}
253 258
 
254 259
 		$config_vars = array_merge ($config_vars, array(
255 260
 				'',
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
 
262 267
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
263 268
 
264
-	if ($return_config)
265
-		return $config_vars;
269
+	if ($return_config) {
270
+			return $config_vars;
271
+	}
266 272
 
267 273
 	// Setup the template stuff.
268 274
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
@@ -337,13 +343,15 @@  discard block
 block discarded – undo
337 343
 		hideGlobalCookies();
338 344
 	});', true);
339 345
 
340
-	if (empty($user_settings['tfa_secret']))
341
-		addInlineJavaScript('');
346
+	if (empty($user_settings['tfa_secret'])) {
347
+			addInlineJavaScript('');
348
+	}
342 349
 
343 350
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
344 351
 
345
-	if ($return_config)
346
-		return $config_vars;
352
+	if ($return_config) {
353
+			return $config_vars;
354
+	}
347 355
 
348 356
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
349 357
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -354,11 +362,13 @@  discard block
 block discarded – undo
354 362
 		call_integration_hook('integrate_save_cookie_settings');
355 363
 
356 364
 		// Local and global do not play nicely together.
357
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
358
-			unset ($_POST['globalCookies']);
365
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
366
+					unset ($_POST['globalCookies']);
367
+		}
359 368
 
360
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
361
-			fatal_lang_error('invalid_cookie_domain', false);
369
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
370
+					fatal_lang_error('invalid_cookie_domain', false);
371
+		}
362 372
 
363 373
 		saveSettings($config_vars);
364 374
 
@@ -441,8 +451,9 @@  discard block
 block discarded – undo
441 451
 
442 452
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
443 453
 
444
-	if ($return_config)
445
-		return $config_vars;
454
+	if ($return_config) {
455
+			return $config_vars;
456
+	}
446 457
 
447 458
 	// Saving?
448 459
 	if (isset($_GET['save']))
@@ -481,8 +492,7 @@  discard block
 block discarded – undo
481 492
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
482 493
 		$cache_level = array($txt['cache_off']);
483 494
 		$detected['none'] = $txt['cache_off'];
484
-	}
485
-	else
495
+	} else
486 496
 	{
487 497
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
488 498
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -519,8 +529,9 @@  discard block
 block discarded – undo
519 529
 			}
520 530
 		}
521 531
 	}
522
-	if ($return_config)
523
-		return $config_vars;
532
+	if ($return_config) {
533
+			return $config_vars;
534
+	}
524 535
 
525 536
 	// Saving again?
526 537
 	if (isset($_GET['save']))
@@ -548,8 +559,9 @@  discard block
 block discarded – undo
548 559
 	$context['save_disabled'] = $context['settings_not_writable'];
549 560
 
550 561
 	// Decide what message to show.
551
-	if (!$context['save_disabled'])
552
-		$context['settings_message'] = $txt['caching_information'];
562
+	if (!$context['save_disabled']) {
563
+			$context['settings_message'] = $txt['caching_information'];
564
+	}
553 565
 
554 566
 	// Prepare the template.
555 567
 	prepareServerSettingsContext($config_vars);
@@ -572,24 +584,25 @@  discard block
 block discarded – undo
572 584
 	if (stripos(PHP_OS, 'win') === 0)
573 585
 	{
574 586
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
575
-		if (isset($_GET['save']))
576
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
577
-	}
578
-	elseif (stripos(PHP_OS, 'darwin') === 0)
587
+		if (isset($_GET['save'])) {
588
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
589
+		}
590
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
579 591
 	{
580 592
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
581
-		if (isset($_GET['save']))
582
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
583
-	}
584
-	else
593
+		if (isset($_GET['save'])) {
594
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
595
+		}
596
+	} else
585 597
 	{
586 598
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
587
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
588
-			$modSettings['load_average'] = (float) $matches[1];
589
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
590
-			$modSettings['load_average'] = (float) $matches[1];
591
-		else
592
-			unset($modSettings['load_average']);
599
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
600
+					$modSettings['load_average'] = (float) $matches[1];
601
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
602
+					$modSettings['load_average'] = (float) $matches[1];
603
+		} else {
604
+					unset($modSettings['load_average']);
605
+		}
593 606
 
594 607
 		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
595 608
 		{
@@ -625,8 +638,9 @@  discard block
 block discarded – undo
625 638
 
626 639
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
627 640
 
628
-	if ($return_config)
629
-		return $config_vars;
641
+	if ($return_config) {
642
+			return $config_vars;
643
+	}
630 644
 
631 645
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
632 646
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -637,24 +651,27 @@  discard block
 block discarded – undo
637 651
 		// Stupidity is not allowed.
638 652
 		foreach ($_POST as $key => $value)
639 653
 		{
640
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
641
-				continue;
642
-			else
643
-				$_POST[$key] = (float) $value;
644
-
645
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
646
-				$_POST['loadavg_auto_opt'] = 1.0;
647
-			elseif ($key == 'loadavg_forum' && $value < 10)
648
-				$_POST['loadavg_forum'] = 10.0;
649
-			elseif ($value < 2)
650
-				$_POST[$key] = 2.0;
654
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
655
+							continue;
656
+			} else {
657
+							$_POST[$key] = (float) $value;
658
+			}
659
+
660
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
661
+							$_POST['loadavg_auto_opt'] = 1.0;
662
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
663
+							$_POST['loadavg_forum'] = 10.0;
664
+			} elseif ($value < 2) {
665
+							$_POST[$key] = 2.0;
666
+			}
651 667
 		}
652 668
 
653 669
 		call_integration_hook('integrate_save_loadavg_settings');
654 670
 
655 671
 		saveDBSettings($config_vars);
656
-		if (!isset($_SESSION['adm-save']))
657
-			$_SESSION['adm-save'] = true;
672
+		if (!isset($_SESSION['adm-save'])) {
673
+					$_SESSION['adm-save'] = true;
674
+		}
658 675
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
659 676
 	}
660 677
 
@@ -690,10 +707,11 @@  discard block
 block discarded – undo
690 707
 
691 708
 	if (isset($_SESSION['adm-save']))
692 709
 	{
693
-		if ($_SESSION['adm-save'] === true)
694
-			$context['saved_successful'] = true;
695
-		else
696
-			$context['saved_failed'] = $_SESSION['adm-save'];
710
+		if ($_SESSION['adm-save'] === true) {
711
+					$context['saved_successful'] = true;
712
+		} else {
713
+					$context['saved_failed'] = $_SESSION['adm-save'];
714
+		}
697 715
 
698 716
 		unset($_SESSION['adm-save']);
699 717
 	}
@@ -701,9 +719,9 @@  discard block
 block discarded – undo
701 719
 	$context['config_vars'] = array();
702 720
 	foreach ($config_vars as $identifier => $config_var)
703 721
 	{
704
-		if (!is_array($config_var) || !isset($config_var[1]))
705
-			$context['config_vars'][] = $config_var;
706
-		else
722
+		if (!is_array($config_var) || !isset($config_var[1])) {
723
+					$context['config_vars'][] = $config_var;
724
+		} else
707 725
 		{
708 726
 			$varname = $config_var[0];
709 727
 			global $$varname;
@@ -738,16 +756,19 @@  discard block
 block discarded – undo
738 756
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
739 757
 			{
740 758
 				// Default to a min of 0 if one isn't set
741
-				if (isset($config_var['min']))
742
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
743
-				else
744
-					$context['config_vars'][$config_var[0]]['min'] = 0;
759
+				if (isset($config_var['min'])) {
760
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
761
+				} else {
762
+									$context['config_vars'][$config_var[0]]['min'] = 0;
763
+				}
745 764
 
746
-				if (isset($config_var['max']))
747
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
765
+				if (isset($config_var['max'])) {
766
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
767
+				}
748 768
 
749
-				if (isset($config_var['step']))
750
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
769
+				if (isset($config_var['step'])) {
770
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
771
+				}
751 772
 			}
752 773
 
753 774
 			// If this is a select box handle any data.
@@ -755,12 +776,13 @@  discard block
 block discarded – undo
755 776
 			{
756 777
 				// If it's associative
757 778
 				$config_values = array_values($config_var[4]);
758
-				if (isset($config_values[0]) && is_array($config_values[0]))
759
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
760
-				else
779
+				if (isset($config_values[0]) && is_array($config_values[0])) {
780
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
781
+				} else
761 782
 				{
762
-					foreach ($config_var[4] as $key => $item)
763
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
783
+					foreach ($config_var[4] as $key => $item) {
784
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
785
+					}
764 786
 				}
765 787
 			}
766 788
 		}
@@ -785,10 +807,11 @@  discard block
 block discarded – undo
785 807
 
786 808
 	if (isset($_SESSION['adm-save']))
787 809
 	{
788
-		if ($_SESSION['adm-save'] === true)
789
-			$context['saved_successful'] = true;
790
-		else
791
-			$context['saved_failed'] = $_SESSION['adm-save'];
810
+		if ($_SESSION['adm-save'] === true) {
811
+					$context['saved_successful'] = true;
812
+		} else {
813
+					$context['saved_failed'] = $_SESSION['adm-save'];
814
+		}
792 815
 
793 816
 		unset($_SESSION['adm-save']);
794 817
 	}
@@ -800,26 +823,30 @@  discard block
 block discarded – undo
800 823
 	foreach ($config_vars as $config_var)
801 824
 	{
802 825
 		// HR?
803
-		if (!is_array($config_var))
804
-			$context['config_vars'][] = $config_var;
805
-		else
826
+		if (!is_array($config_var)) {
827
+					$context['config_vars'][] = $config_var;
828
+		} else
806 829
 		{
807 830
 			// If it has no name it doesn't have any purpose!
808
-			if (empty($config_var[1]))
809
-				continue;
831
+			if (empty($config_var[1])) {
832
+							continue;
833
+			}
810 834
 
811 835
 			// Special case for inline permissions
812
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
813
-				$inlinePermissions[] = $config_var[1];
814
-			elseif ($config_var[0] == 'permissions')
815
-				continue;
836
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
837
+							$inlinePermissions[] = $config_var[1];
838
+			} elseif ($config_var[0] == 'permissions') {
839
+							continue;
840
+			}
816 841
 
817
-			if ($config_var[0] == 'boards')
818
-				$board_list = true;
842
+			if ($config_var[0] == 'boards') {
843
+							$board_list = true;
844
+			}
819 845
 
820 846
 			// Are we showing the BBC selection box?
821
-			if ($config_var[0] == 'bbc')
822
-				$bbcChoice[] = $config_var[1];
847
+			if ($config_var[0] == 'bbc') {
848
+							$bbcChoice[] = $config_var[1];
849
+			}
823 850
 
824 851
 			// We need to do some parsing of the value before we pass it in.
825 852
 			if (isset($modSettings[$config_var[1]]))
@@ -838,8 +865,7 @@  discard block
 block discarded – undo
838 865
 					default:
839 866
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
840 867
 				}
841
-			}
842
-			else
868
+			} else
843 869
 			{
844 870
 				// Darn, it's empty. What type is expected?
845 871
 				switch ($config_var[0])
@@ -879,16 +905,19 @@  discard block
 block discarded – undo
879 905
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
880 906
 			{
881 907
 				// Default to a min of 0 if one isn't set
882
-				if (isset($config_var['min']))
883
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
884
-				else
885
-					$context['config_vars'][$config_var[1]]['min'] = 0;
908
+				if (isset($config_var['min'])) {
909
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
910
+				} else {
911
+									$context['config_vars'][$config_var[1]]['min'] = 0;
912
+				}
886 913
 
887
-				if (isset($config_var['max']))
888
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
914
+				if (isset($config_var['max'])) {
915
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
916
+				}
889 917
 
890
-				if (isset($config_var['step']))
891
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
918
+				if (isset($config_var['step'])) {
919
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
920
+				}
892 921
 			}
893 922
 
894 923
 			// If this is a select box handle any data.
@@ -902,12 +931,13 @@  discard block
 block discarded – undo
902 931
 				}
903 932
 
904 933
 				// If it's associative
905
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
906
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
907
-				else
934
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
935
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
936
+				} else
908 937
 				{
909
-					foreach ($config_var[2] as $key => $item)
910
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
938
+					foreach ($config_var[2] as $key => $item) {
939
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
940
+					}
911 941
 				}
912 942
 			}
913 943
 
@@ -916,17 +946,19 @@  discard block
 block discarded – undo
916 946
 			{
917 947
 				if (!is_numeric($k))
918 948
 				{
919
-					if (substr($k, 0, 2) == 'on')
920
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
921
-					else
922
-						$context['config_vars'][$config_var[1]][$k] = $v;
949
+					if (substr($k, 0, 2) == 'on') {
950
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
951
+					} else {
952
+											$context['config_vars'][$config_var[1]][$k] = $v;
953
+					}
923 954
 				}
924 955
 
925 956
 				// See if there are any other labels that might fit?
926
-				if (isset($txt['setting_' . $config_var[1]]))
927
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
928
-				elseif (isset($txt['groups_' . $config_var[1]]))
929
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
957
+				if (isset($txt['setting_' . $config_var[1]])) {
958
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
959
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
960
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
961
+				}
930 962
 			}
931 963
 
932 964
 			// Set the subtext in case it's part of the label.
@@ -959,8 +991,9 @@  discard block
 block discarded – undo
959 991
 		// What are the options, eh?
960 992
 		$temp = parse_bbc(false);
961 993
 		$bbcTags = array();
962
-		foreach ($temp as $tag)
963
-			$bbcTags[] = $tag['tag'];
994
+		foreach ($temp as $tag) {
995
+					$bbcTags[] = $tag['tag'];
996
+		}
964 997
 
965 998
 		$bbcTags = array_unique($bbcTags);
966 999
 		$totalTags = count($bbcTags);
@@ -975,8 +1008,9 @@  discard block
 block discarded – undo
975 1008
 		$col = 0; $i = 0;
976 1009
 		foreach ($bbcTags as $tag)
977 1010
 		{
978
-			if ($i % $tagsPerColumn == 0 && $i != 0)
979
-				$col++;
1011
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1012
+							$col++;
1013
+			}
980 1014
 
981 1015
 			$context['bbc_columns'][$col][] = array(
982 1016
 				'tag' => $tag,
@@ -1019,18 +1053,21 @@  discard block
 block discarded – undo
1019 1053
 	validateToken('admin-ssc');
1020 1054
 
1021 1055
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1022
-	if (isset($_POST['cookiename']))
1023
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1056
+	if (isset($_POST['cookiename'])) {
1057
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1058
+	}
1024 1059
 
1025 1060
 	// Fix the forum's URL if necessary.
1026 1061
 	if (isset($_POST['boardurl']))
1027 1062
 	{
1028
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1029
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1030
-		elseif (substr($_POST['boardurl'], -1) == '/')
1031
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1032
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1033
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1063
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1064
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1065
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1066
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1067
+		}
1068
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1069
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1070
+		}
1034 1071
 	}
1035 1072
 
1036 1073
 	// Any passwords?
@@ -1065,21 +1102,21 @@  discard block
 block discarded – undo
1065 1102
 	// Figure out which config vars we're saving here...
1066 1103
 	foreach ($config_vars as $var)
1067 1104
 	{
1068
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1069
-			continue;
1105
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1106
+					continue;
1107
+		}
1070 1108
 
1071 1109
 		$config_var = $var[0];
1072 1110
 
1073 1111
 		if (in_array($config_var, $config_passwords))
1074 1112
 		{
1075
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1076
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1077
-		}
1078
-		elseif (in_array($config_var, $config_strs))
1113
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1114
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1115
+			}
1116
+		} elseif (in_array($config_var, $config_strs))
1079 1117
 		{
1080 1118
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1081
-		}
1082
-		elseif (in_array($config_var, $config_ints))
1119
+		} elseif (in_array($config_var, $config_ints))
1083 1120
 		{
1084 1121
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1085 1122
 
@@ -1088,17 +1125,17 @@  discard block
 block discarded – undo
1088 1125
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1089 1126
 
1090 1127
 			// Is there a max value for this as well?
1091
-			if (isset($var['max']))
1092
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1093
-		}
1094
-		elseif (in_array($config_var, $config_bools))
1128
+			if (isset($var['max'])) {
1129
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1130
+			}
1131
+		} elseif (in_array($config_var, $config_bools))
1095 1132
 		{
1096
-			if (!empty($_POST[$config_var]))
1097
-				$new_settings[$config_var] = '1';
1098
-			else
1099
-				$new_settings[$config_var] = '0';
1100
-		}
1101
-		else
1133
+			if (!empty($_POST[$config_var])) {
1134
+							$new_settings[$config_var] = '1';
1135
+			} else {
1136
+							$new_settings[$config_var] = '0';
1137
+			}
1138
+		} else
1102 1139
 		{
1103 1140
 			// This shouldn't happen, but it might...
1104 1141
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1114,30 +1151,35 @@  discard block
 block discarded – undo
1114 1151
 	foreach ($config_vars as $config_var)
1115 1152
 	{
1116 1153
 		// We just saved the file-based settings, so skip their definitions.
1117
-		if (!is_array($config_var) || $config_var[2] == 'file')
1118
-			continue;
1154
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1155
+					continue;
1156
+		}
1119 1157
 
1120 1158
 		$new_setting = array($config_var[3], $config_var[0]);
1121 1159
 
1122 1160
 		// Select options need carried over, too.
1123
-		if (isset($config_var[4]))
1124
-			$new_setting[] = $config_var[4];
1161
+		if (isset($config_var[4])) {
1162
+					$new_setting[] = $config_var[4];
1163
+		}
1125 1164
 
1126 1165
 		// Include min and max if necessary
1127
-		if (isset($config_var['min']))
1128
-			$new_setting['min'] = $config_var['min'];
1166
+		if (isset($config_var['min'])) {
1167
+					$new_setting['min'] = $config_var['min'];
1168
+		}
1129 1169
 
1130
-		if (isset($config_var['max']))
1131
-			$new_setting['max'] = $config_var['max'];
1170
+		if (isset($config_var['max'])) {
1171
+					$new_setting['max'] = $config_var['max'];
1172
+		}
1132 1173
 
1133 1174
 		// Rewrite the definition a bit.
1134 1175
 		$new_settings[] = $new_setting;
1135 1176
 	}
1136 1177
 
1137 1178
 	// Save the new database-based settings, if any.
1138
-	if (!empty($new_settings))
1139
-		saveDBSettings($new_settings);
1140
-}
1179
+	if (!empty($new_settings)) {
1180
+			saveDBSettings($new_settings);
1181
+	}
1182
+	}
1141 1183
 
1142 1184
 /**
1143 1185
  * Helper function for saving database settings.
@@ -1155,22 +1197,25 @@  discard block
 block discarded – undo
1155 1197
 	$inlinePermissions = array();
1156 1198
 	foreach ($config_vars as $var)
1157 1199
 	{
1158
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1159
-			continue;
1200
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1201
+					continue;
1202
+		}
1160 1203
 
1161 1204
 		// Checkboxes!
1162
-		elseif ($var[0] == 'check')
1163
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1205
+		elseif ($var[0] == 'check') {
1206
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1207
+		}
1164 1208
 		// Select boxes!
1165
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1166
-			$setArray[$var[1]] = $_POST[$var[1]];
1167
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1209
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1210
+					$setArray[$var[1]] = $_POST[$var[1]];
1211
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1168 1212
 		{
1169 1213
 			// For security purposes we validate this line by line.
1170 1214
 			$lOptions = array();
1171
-			foreach ($_POST[$var[1]] as $invar)
1172
-				if (in_array($invar, array_keys($var[2])))
1215
+			foreach ($_POST[$var[1]] as $invar) {
1216
+							if (in_array($invar, array_keys($var[2])))
1173 1217
 					$lOptions[] = $invar;
1218
+			}
1174 1219
 
1175 1220
 			$setArray[$var[1]] = json_encode($lOptions);
1176 1221
 		}
@@ -1184,18 +1229,20 @@  discard block
 block discarded – undo
1184 1229
 				$request = $smcFunc['db_query']('', '
1185 1230
 					SELECT id_board
1186 1231
 					FROM {db_prefix}boards');
1187
-				while ($row = $smcFunc['db_fetch_row']($request))
1188
-					$board_list[$row[0]] = true;
1232
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1233
+									$board_list[$row[0]] = true;
1234
+				}
1189 1235
 
1190 1236
 				$smcFunc['db_free_result']($request);
1191 1237
 			}
1192 1238
 
1193 1239
 			$lOptions = array();
1194 1240
 
1195
-			if (!empty($_POST[$var[1]]))
1196
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1241
+			if (!empty($_POST[$var[1]])) {
1242
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1197 1243
 					if (isset($board_list[$invar]))
1198 1244
 						$lOptions[] = $invar;
1245
+			}
1199 1246
 
1200 1247
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1201 1248
 		}
@@ -1209,8 +1256,9 @@  discard block
 block discarded – undo
1209 1256
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1210 1257
 
1211 1258
 			// Do we have a max value for this as well?
1212
-			if (isset($var['max']))
1213
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1259
+			if (isset($var['max'])) {
1260
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1261
+			}
1214 1262
 		}
1215 1263
 		// Floating point!
1216 1264
 		elseif ($var[0] == 'float')
@@ -1222,40 +1270,47 @@  discard block
 block discarded – undo
1222 1270
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1223 1271
 
1224 1272
 			// Do we have a max value for this as well?
1225
-			if (isset($var['max']))
1226
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1273
+			if (isset($var['max'])) {
1274
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1275
+			}
1227 1276
 		}
1228 1277
 		// Text!
1229
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1230
-			$setArray[$var[1]] = $_POST[$var[1]];
1278
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1279
+					$setArray[$var[1]] = $_POST[$var[1]];
1280
+		}
1231 1281
 		// Passwords!
1232 1282
 		elseif ($var[0] == 'password')
1233 1283
 		{
1234
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1235
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1284
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1285
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1286
+			}
1236 1287
 		}
1237 1288
 		// BBC.
1238 1289
 		elseif ($var[0] == 'bbc')
1239 1290
 		{
1240 1291
 
1241 1292
 			$bbcTags = array();
1242
-			foreach (parse_bbc(false) as $tag)
1243
-				$bbcTags[] = $tag['tag'];
1293
+			foreach (parse_bbc(false) as $tag) {
1294
+							$bbcTags[] = $tag['tag'];
1295
+			}
1244 1296
 
1245
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1246
-				$_POST[$var[1] . '_enabledTags'] = array();
1247
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1248
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1297
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1298
+							$_POST[$var[1] . '_enabledTags'] = array();
1299
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1300
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1301
+			}
1249 1302
 
1250 1303
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1251 1304
 		}
1252 1305
 		// Permissions?
1253
-		elseif ($var[0] == 'permissions')
1254
-			$inlinePermissions[] = $var[1];
1306
+		elseif ($var[0] == 'permissions') {
1307
+					$inlinePermissions[] = $var[1];
1308
+		}
1255 1309
 	}
1256 1310
 
1257
-	if (!empty($setArray))
1258
-		updateSettings($setArray);
1311
+	if (!empty($setArray)) {
1312
+			updateSettings($setArray);
1313
+	}
1259 1314
 
1260 1315
 	// If we have inline permissions we need to save them.
1261 1316
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1292,18 +1347,21 @@  discard block
 block discarded – undo
1292 1347
 	// put all of it into an array
1293 1348
 	foreach ($info_lines as $line)
1294 1349
 	{
1295
-		if (preg_match('~(' . $remove . ')~', $line))
1296
-			continue;
1350
+		if (preg_match('~(' . $remove . ')~', $line)) {
1351
+					continue;
1352
+		}
1297 1353
 
1298 1354
 		// new category?
1299
-		if (strpos($line, '<h2>') !== false)
1300
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1355
+		if (strpos($line, '<h2>') !== false) {
1356
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1357
+		}
1301 1358
 
1302 1359
 		// load it as setting => value or the old setting local master
1303
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1304
-			$pinfo[$category][$val[1]] = $val[2];
1305
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1306
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1360
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1361
+					$pinfo[$category][$val[1]] = $val[2];
1362
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1363
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1364
+		}
1307 1365
 	}
1308 1366
 
1309 1367
 	// load it in to context and display it
@@ -1338,8 +1396,9 @@  discard block
 block discarded – undo
1338 1396
 				$testAPI = new $cache_class_name();
1339 1397
 
1340 1398
 				// No Support?  NEXT!
1341
-				if (!$testAPI->isSupported(true))
1342
-					continue;
1399
+				if (!$testAPI->isSupported(true)) {
1400
+									continue;
1401
+				}
1343 1402
 
1344 1403
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1345 1404
 			}
@@ -1364,8 +1423,9 @@  discard block
 block discarded – undo
1364 1423
 	global $modSettings, $boardurl, $smcFunc;
1365 1424
 
1366 1425
 	// Already have a key?  Can't register again.
1367
-	if (!empty($modSettings['sm_stats_key']))
1368
-		return true;
1426
+	if (!empty($modSettings['sm_stats_key'])) {
1427
+			return true;
1428
+	}
1369 1429
 
1370 1430
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1371 1431
 	if ($fp)
@@ -1376,8 +1436,9 @@  discard block
 block discarded – undo
1376 1436
 		fwrite($fp, $out);
1377 1437
 
1378 1438
 		$return_data = '';
1379
-		while (!feof($fp))
1380
-			$return_data .= fgets($fp, 128);
1439
+		while (!feof($fp)) {
1440
+					$return_data .= fgets($fp, 128);
1441
+		}
1381 1442
 
1382 1443
 		fclose($fp);
1383 1444
 
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	$version = $smcFunc['db_get_version']();
39 39
 	// if we got a Beta Version
40 40
 	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
42 42
 	// or RC
43 43
 	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
44
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
45 45
 
46
-	if (version_compare($version,'9.5.0','>='))
46
+	if (version_compare($version, '9.5.0', '>='))
47 47
 		$smcFunc['db_support_ignore'] = true;
48 48
 }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function smf_db_search_support($search_type)
57 57
 {
58
-	$supported_types = array('custom','fulltext');
58
+	$supported_types = array('custom', 'fulltext');
59 59
 
60 60
 	return in_array($search_type, $supported_types);
61 61
 }
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 110
 	{
111 111
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112
-		if ($smcFunc['db_support_ignore']){
112
+		if ($smcFunc['db_support_ignore']) {
113 113
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
115 115
 		}
116 116
 		else
117 117
 		{
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$language_ftx = $modSettings['search_language'];
169 169
 	else
170 170
 	{
171
-		$request = $smcFunc['db_query']('','
171
+		$request = $smcFunc['db_query']('', '
172 172
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
173 173
 			array(
174 174
 			'default_language' => 'default_text_search_config'
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,29 +24,33 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 			'db_search_language' => 'smf_db_search_language',
33 34
 		);
35
+	}
34 36
 
35 37
 	db_extend();
36 38
 
37 39
 	//pg 9.5 got ignore support
38 40
 	$version = $smcFunc['db_get_version']();
39 41
 	// if we got a Beta Version
40
-	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
42
+	if (stripos($version, 'beta') !== false) {
43
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
44
+	}
42 45
 	// or RC
43
-	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
46
+	if (stripos($version, 'rc') !== false) {
47
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
48
+	}
45 49
 
46
-	if (version_compare($version,'9.5.0','>='))
47
-		$smcFunc['db_support_ignore'] = true;
48
-}
50
+	if (version_compare($version,'9.5.0','>=')) {
51
+			$smcFunc['db_support_ignore'] = true;
52
+	}
53
+	}
49 54
 
50 55
 /**
51 56
  * This function will tell you whether this database type supports this search type.
@@ -104,16 +109,16 @@  discard block
 block discarded – undo
104 109
 		),
105 110
 	);
106 111
 
107
-	if (isset($replacements[$identifier]))
108
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
112
+	if (isset($replacements[$identifier])) {
113
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
114
+	}
109 115
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 116
 	{
111 117
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112 118
 		if ($smcFunc['db_support_ignore']){
113 119
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114 120
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
115
-		}
116
-		else
121
+		} else
117 122
 		{
118 123
 			// Don't error on multi-insert.
119 124
 			$db_values['db_error_skip'] = true;
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
 	}
122 127
 
123 128
 	//fix double quotes
124
-	if ($identifier == 'insert_into_log_messages_fulltext')
125
-		$db_values = str_replace('"', "'", $db_values);
129
+	if ($identifier == 'insert_into_log_messages_fulltext') {
130
+			$db_values = str_replace('"', "'", $db_values);
131
+	}
126 132
 
127 133
 	$return = $smcFunc['db_query']('', $db_string,
128 134
 		$db_values, $connection
@@ -164,9 +170,9 @@  discard block
 block discarded – undo
164 170
 
165 171
 	$language_ftx = 'english';
166 172
 
167
-	if (!empty($modSettings['search_language']))
168
-		$language_ftx = $modSettings['search_language'];
169
-	else
173
+	if (!empty($modSettings['search_language'])) {
174
+			$language_ftx = $modSettings['search_language'];
175
+	} else
170 176
 	{
171 177
 		$request = $smcFunc['db_query']('','
172 178
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
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
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 
257 257
 		case 'datetime':
258 258
 			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)
259
-				return 'str_to_date('.
260
-					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]).
259
+				return 'str_to_date(' .
260
+					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]) .
261 261
 					',\'%Y-%m-%d %h:%i:%s\')';
262 262
 			else
263 263
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		$connection
825 825
 	);
826 826
 
827
-	if(!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
827
+	if (!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
828 828
 	{
829 829
 		if ($returnmode == 1)
830 830
 			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			$return_var = array();
834 834
 			$count = count($insertRows);
835 835
 			$start = smf_db_insert_id($table, $keys[0]);
836
-			for ($i = 0; $i < $count; $i++ )
836
+			for ($i = 0; $i < $count; $i++)
837 837
 				$return_var[] = $start + $i;
838 838
 		}
839 839
 		return $return_var;
Please login to merge, or discard this patch.
Braces   +251 added lines, -185 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc;
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,24 +74,27 @@  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
 	$smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'',
94 100
 		array(),
@@ -164,34 +170,42 @@  discard block
 block discarded – undo
164 170
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
165 171
 
166 172
 	list ($values, $connection) = $db_callback;
167
-	if (!is_object($connection))
168
-		display_db_error();
173
+	if (!is_object($connection)) {
174
+			display_db_error();
175
+	}
169 176
 
170
-	if ($matches[1] === 'db_prefix')
171
-		return $db_prefix;
177
+	if ($matches[1] === 'db_prefix') {
178
+			return $db_prefix;
179
+	}
172 180
 
173
-	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false)
174
-		return $user_info[$matches[1]];
181
+	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) {
182
+			return $user_info[$matches[1]];
183
+	}
175 184
 
176
-	if ($matches[1] === 'empty')
177
-		return '\'\'';
185
+	if ($matches[1] === 'empty') {
186
+			return '\'\'';
187
+	}
178 188
 
179
-	if (!isset($matches[2]))
180
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
189
+	if (!isset($matches[2])) {
190
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
191
+	}
181 192
 
182
-	if ($matches[1] === 'literal')
183
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
193
+	if ($matches[1] === 'literal') {
194
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
195
+	}
184 196
 
185
-	if (!isset($values[$matches[2]]))
186
-		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__);
197
+	if (!isset($values[$matches[2]])) {
198
+			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__);
199
+	}
187 200
 
188 201
 	$replacement = $values[$matches[2]];
189 202
 
190 203
 	switch ($matches[1])
191 204
 	{
192 205
 		case 'int':
193
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
194
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
206
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
207
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
208
+			}
195 209
 			return (string) (int) $replacement;
196 210
 		break;
197 211
 
@@ -203,65 +217,73 @@  discard block
 block discarded – undo
203 217
 		case 'array_int':
204 218
 			if (is_array($replacement))
205 219
 			{
206
-				if (empty($replacement))
207
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
220
+				if (empty($replacement)) {
221
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
222
+				}
208 223
 
209 224
 				foreach ($replacement as $key => $value)
210 225
 				{
211
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
212
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
226
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
227
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
228
+					}
213 229
 
214 230
 					$replacement[$key] = (string) (int) $value;
215 231
 				}
216 232
 
217 233
 				return implode(', ', $replacement);
234
+			} else {
235
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
218 236
 			}
219
-			else
220
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
221 237
 
222 238
 		break;
223 239
 
224 240
 		case 'array_string':
225 241
 			if (is_array($replacement))
226 242
 			{
227
-				if (empty($replacement))
228
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
243
+				if (empty($replacement)) {
244
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
245
+				}
229 246
 
230
-				foreach ($replacement as $key => $value)
231
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
247
+				foreach ($replacement as $key => $value) {
248
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
249
+				}
232 250
 
233 251
 				return implode(', ', $replacement);
252
+			} else {
253
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
234 254
 			}
235
-			else
236
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
237 255
 		break;
238 256
 
239 257
 		case 'date':
240
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
241
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
242
-			else
243
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
258
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
259
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
260
+			} else {
261
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
262
+			}
244 263
 		break;
245 264
 
246 265
 		case 'time':
247
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
248
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
249
-			else
250
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
266
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
267
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
268
+			} else {
269
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+			}
251 271
 		break;
252 272
 
253 273
 		case 'datetime':
254
-			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)
255
-				return 'str_to_date('.
274
+			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) {
275
+							return 'str_to_date('.
256 276
 					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]).
257 277
 					',\'%Y-%m-%d %h:%i:%s\')';
258
-			else
259
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
278
+			} else {
279
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
280
+			}
260 281
 		break;
261 282
 
262 283
 		case 'float':
263
-			if (!is_numeric($replacement))
264
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
284
+			if (!is_numeric($replacement)) {
285
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
286
+			}
265 287
 			return (string) (float) $replacement;
266 288
 		break;
267 289
 
@@ -275,32 +297,37 @@  discard block
 block discarded – undo
275 297
 		break;
276 298
 
277 299
 		case 'inet':
278
-			if ($replacement == 'null' || $replacement == '')
279
-				return 'null';
280
-			if (!isValidIP($replacement))
281
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
300
+			if ($replacement == 'null' || $replacement == '') {
301
+							return 'null';
302
+			}
303
+			if (!isValidIP($replacement)) {
304
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
305
+			}
282 306
 			//we don't use the native support of mysql > 5.6.2
283 307
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
284 308
 
285 309
 		case 'array_inet':
286 310
 			if (is_array($replacement))
287 311
 			{
288
-				if (empty($replacement))
289
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
312
+				if (empty($replacement)) {
313
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
314
+				}
290 315
 
291 316
 				foreach ($replacement as $key => $value)
292 317
 				{
293
-					if ($replacement == 'null' || $replacement == '')
294
-						$replacement[$key] = 'null';
295
-					if (!isValidIP($value))
296
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
318
+					if ($replacement == 'null' || $replacement == '') {
319
+											$replacement[$key] = 'null';
320
+					}
321
+					if (!isValidIP($value)) {
322
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
323
+					}
297 324
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
298 325
 				}
299 326
 
300 327
 				return implode(', ', $replacement);
328
+			} else {
329
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
301 330
 			}
302
-			else
303
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
304 331
 		break;
305 332
 
306 333
 		default:
@@ -376,22 +403,25 @@  discard block
 block discarded – undo
376 403
 		// Are we in SSI mode?  If so try that username and password first
377 404
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
378 405
 		{
379
-			if (empty($db_persist))
380
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
381
-			else
382
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
406
+			if (empty($db_persist)) {
407
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
408
+			} else {
409
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
410
+			}
383 411
 		}
384 412
 		// Fall back to the regular username and password if need be
385 413
 		if (!$db_connection)
386 414
 		{
387
-			if (empty($db_persist))
388
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
389
-			else
390
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
415
+			if (empty($db_persist)) {
416
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
417
+			} else {
418
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
419
+			}
391 420
 		}
392 421
 
393
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
394
-			$db_connection = false;
422
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
423
+					$db_connection = false;
424
+		}
395 425
 
396 426
 		$connection = $db_connection;
397 427
 	}
@@ -399,18 +429,20 @@  discard block
 block discarded – undo
399 429
 	// One more query....
400 430
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
401 431
 
402
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
403
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
432
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
433
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
434
+	}
404 435
 
405 436
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
406 437
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
407 438
 	{
408 439
 		// Add before LIMIT
409
-		if ($pos = strpos($db_string, 'LIMIT '))
410
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
411
-		else
412
-			// Append it.
440
+		if ($pos = strpos($db_string, 'LIMIT ')) {
441
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
442
+		} else {
443
+					// Append it.
413 444
 			$db_string .= "\n\t\t\tORDER BY null";
445
+		}
414 446
 	}
415 447
 
416 448
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -432,8 +464,9 @@  discard block
 block discarded – undo
432 464
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
433 465
 
434 466
 		// Initialize $db_cache if not already initialized.
435
-		if (!isset($db_cache))
436
-			$db_cache = array();
467
+		if (!isset($db_cache)) {
468
+					$db_cache = array();
469
+		}
437 470
 
438 471
 		if (!empty($_SESSION['debug_redirect']))
439 472
 		{
@@ -459,17 +492,18 @@  discard block
 block discarded – undo
459 492
 		while (true)
460 493
 		{
461 494
 			$pos = strpos($db_string, '\'', $pos + 1);
462
-			if ($pos === false)
463
-				break;
495
+			if ($pos === false) {
496
+							break;
497
+			}
464 498
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
465 499
 
466 500
 			while (true)
467 501
 			{
468 502
 				$pos1 = strpos($db_string, '\'', $pos + 1);
469 503
 				$pos2 = strpos($db_string, '\\', $pos + 1);
470
-				if ($pos1 === false)
471
-					break;
472
-				elseif ($pos2 === false || $pos2 > $pos1)
504
+				if ($pos1 === false) {
505
+									break;
506
+				} elseif ($pos2 === false || $pos2 > $pos1)
473 507
 				{
474 508
 					$pos = $pos1;
475 509
 					break;
@@ -485,29 +519,35 @@  discard block
 block discarded – undo
485 519
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
486 520
 
487 521
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
488
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
489
-			$fail = true;
522
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
523
+					$fail = true;
524
+		}
490 525
 		// Trying to change passwords, slow us down, or something?
491
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
492
-			$fail = true;
493
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
494
-			$fail = true;
526
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
527
+					$fail = true;
528
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
529
+					$fail = true;
530
+		}
495 531
 
496
-		if (!empty($fail) && function_exists('log_error'))
497
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
532
+		if (!empty($fail) && function_exists('log_error')) {
533
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
534
+		}
498 535
 	}
499 536
 
500
-	if (empty($db_unbuffered))
501
-		$ret = @mysqli_query($connection, $db_string);
502
-	else
503
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
537
+	if (empty($db_unbuffered)) {
538
+			$ret = @mysqli_query($connection, $db_string);
539
+	} else {
540
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
541
+	}
504 542
 
505
-	if ($ret === false && empty($db_values['db_error_skip']))
506
-		$ret = smf_db_error($db_string, $connection);
543
+	if ($ret === false && empty($db_values['db_error_skip'])) {
544
+			$ret = smf_db_error($db_string, $connection);
545
+	}
507 546
 
508 547
 	// Debugging.
509
-	if (isset($db_show_debug) && $db_show_debug === true)
510
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
548
+	if (isset($db_show_debug) && $db_show_debug === true) {
549
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
550
+	}
511 551
 
512 552
 	return $ret;
513 553
 }
@@ -554,12 +594,13 @@  discard block
 block discarded – undo
554 594
 	// Decide which connection to use
555 595
 	$connection = $connection === null ? $db_connection : $connection;
556 596
 
557
-	if ($type == 'begin')
558
-		return @mysqli_query($connection, 'BEGIN');
559
-	elseif ($type == 'rollback')
560
-		return @mysqli_query($connection, 'ROLLBACK');
561
-	elseif ($type == 'commit')
562
-		return @mysqli_query($connection, 'COMMIT');
597
+	if ($type == 'begin') {
598
+			return @mysqli_query($connection, 'BEGIN');
599
+	} elseif ($type == 'rollback') {
600
+			return @mysqli_query($connection, 'ROLLBACK');
601
+	} elseif ($type == 'commit') {
602
+			return @mysqli_query($connection, 'COMMIT');
603
+	}
563 604
 
564 605
 	return false;
565 606
 }
@@ -599,8 +640,9 @@  discard block
 block discarded – undo
599 640
 	//    2013: Lost connection to server during query.
600 641
 
601 642
 	// Log the error.
602
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
603
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
643
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
644
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
645
+	}
604 646
 
605 647
 	// Database error auto fixing ;).
606 648
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -609,8 +651,9 @@  discard block
 block discarded – undo
609 651
 		$old_cache = @$modSettings['cache_enable'];
610 652
 		$modSettings['cache_enable'] = '1';
611 653
 
612
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
613
-			$db_last_error = max(@$db_last_error, $temp);
654
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
655
+					$db_last_error = max(@$db_last_error, $temp);
656
+		}
614 657
 
615 658
 		if (@$db_last_error < time() - 3600 * 24 * 3)
616 659
 		{
@@ -626,8 +669,9 @@  discard block
 block discarded – undo
626 669
 					foreach ($tables as $table)
627 670
 					{
628 671
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
629
-						if (trim($table) != '')
630
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
672
+						if (trim($table) != '') {
673
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
674
+						}
631 675
 					}
632 676
 				}
633 677
 
@@ -636,8 +680,9 @@  discard block
 block discarded – undo
636 680
 			// Table crashed.  Let's try to fix it.
637 681
 			elseif ($query_errno == 1016)
638 682
 			{
639
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
640
-					$fix_tables = array('`' . $match[1] . '`');
683
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
684
+									$fix_tables = array('`' . $match[1] . '`');
685
+				}
641 686
 			}
642 687
 			// Indexes crashed.  Should be easy to fix!
643 688
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -656,13 +701,15 @@  discard block
 block discarded – undo
656 701
 
657 702
 			// Make a note of the REPAIR...
658 703
 			cache_put_data('db_last_error', time(), 600);
659
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
660
-				updateSettingsFile(array('db_last_error' => time()));
704
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
705
+							updateSettingsFile(array('db_last_error' => time()));
706
+			}
661 707
 
662 708
 			// Attempt to find and repair the broken table.
663
-			foreach ($fix_tables as $table)
664
-				$smcFunc['db_query']('', "
709
+			foreach ($fix_tables as $table) {
710
+							$smcFunc['db_query']('', "
665 711
 					REPAIR TABLE $table", false, false);
712
+			}
666 713
 
667 714
 			// And send off an email!
668 715
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -671,11 +718,12 @@  discard block
 block discarded – undo
671 718
 
672 719
 			// Try the query again...?
673 720
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
674
-			if ($ret !== false)
675
-				return $ret;
721
+			if ($ret !== false) {
722
+							return $ret;
723
+			}
724
+		} else {
725
+					$modSettings['cache_enable'] = $old_cache;
676 726
 		}
677
-		else
678
-			$modSettings['cache_enable'] = $old_cache;
679 727
 
680 728
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
681 729
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -685,22 +733,25 @@  discard block
 block discarded – undo
685 733
 				// Are we in SSI mode?  If so try that username and password first
686 734
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
687 735
 				{
688
-					if (empty($db_persist))
689
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
690
-					else
691
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
736
+					if (empty($db_persist)) {
737
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
738
+					} else {
739
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
740
+					}
692 741
 				}
693 742
 				// Fall back to the regular username and password if need be
694 743
 				if (!$db_connection)
695 744
 				{
696
-					if (empty($db_persist))
697
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
698
-					else
699
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
745
+					if (empty($db_persist)) {
746
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
747
+					} else {
748
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
749
+					}
700 750
 				}
701 751
 
702
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
703
-					$db_connection = false;
752
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
753
+									$db_connection = false;
754
+				}
704 755
 			}
705 756
 
706 757
 			if ($db_connection)
@@ -711,24 +762,27 @@  discard block
 block discarded – undo
711 762
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
712 763
 
713 764
 					$new_errno = mysqli_errno($db_connection);
714
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
715
-						break;
765
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
766
+											break;
767
+					}
716 768
 				}
717 769
 
718 770
 				// If it failed again, shucks to be you... we're not trying it over and over.
719
-				if ($ret !== false)
720
-					return $ret;
771
+				if ($ret !== false) {
772
+									return $ret;
773
+				}
721 774
 			}
722 775
 		}
723 776
 		// Are they out of space, perhaps?
724 777
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
725 778
 		{
726
-			if (!isset($txt))
727
-				$query_error .= ' - check database storage space.';
728
-			else
779
+			if (!isset($txt)) {
780
+							$query_error .= ' - check database storage space.';
781
+			} else
729 782
 			{
730
-				if (!isset($txt['mysql_error_space']))
731
-					loadLanguage('Errors');
783
+				if (!isset($txt['mysql_error_space'])) {
784
+									loadLanguage('Errors');
785
+				}
732 786
 
733 787
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
734 788
 			}
@@ -736,15 +790,17 @@  discard block
 block discarded – undo
736 790
 	}
737 791
 
738 792
 	// Nothing's defined yet... just die with it.
739
-	if (empty($context) || empty($txt))
740
-		die($query_error);
793
+	if (empty($context) || empty($txt)) {
794
+			die($query_error);
795
+	}
741 796
 
742 797
 	// Show an error message, if possible.
743 798
 	$context['error_title'] = $txt['database_error'];
744
-	if (allowedTo('admin_forum'))
745
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
746
-	else
747
-		$context['error_message'] = $txt['try_again'];
799
+	if (allowedTo('admin_forum')) {
800
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
801
+	} else {
802
+			$context['error_message'] = $txt['try_again'];
803
+	}
748 804
 
749 805
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
750 806
 	{
@@ -774,25 +830,28 @@  discard block
 block discarded – undo
774 830
 	$connection = $connection === null ? $db_connection : $connection;
775 831
 
776 832
 	// With nothing to insert, simply return.
777
-	if (empty($data))
778
-		return;
833
+	if (empty($data)) {
834
+			return;
835
+	}
779 836
 
780 837
 	// Replace the prefix holder with the actual prefix.
781 838
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
782 839
 
783 840
 	// Inserting data as a single row can be done as a single array.
784
-	if (!is_array($data[array_rand($data)]))
785
-		$data = array($data);
841
+	if (!is_array($data[array_rand($data)])) {
842
+			$data = array($data);
843
+	}
786 844
 
787 845
 	// Create the mold for a single row insert.
788 846
 	$insertData = '(';
789 847
 	foreach ($columns as $columnName => $type)
790 848
 	{
791 849
 		// Are we restricting the length?
792
-		if (strpos($type, 'string-') !== false)
793
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
794
-		else
795
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
850
+		if (strpos($type, 'string-') !== false) {
851
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
852
+		} else {
853
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
854
+		}
796 855
 	}
797 856
 	$insertData = substr($insertData, 0, -2) . ')';
798 857
 
@@ -801,8 +860,9 @@  discard block
 block discarded – undo
801 860
 
802 861
 	// Here's where the variables are injected to the query.
803 862
 	$insertRows = array();
804
-	foreach ($data as $dataRow)
805
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
863
+	foreach ($data as $dataRow) {
864
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
865
+	}
806 866
 
807 867
 	// Determine the method of insertion.
808 868
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -822,15 +882,16 @@  discard block
 block discarded – undo
822 882
 
823 883
 	if(!empty($keys) && (count($keys) > 0) && ($method === '' || $method === 'insert') && $returnmode > 0)
824 884
 	{
825
-		if ($returnmode == 1)
826
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
827
-		else if ($returnmode == 2)
885
+		if ($returnmode == 1) {
886
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
887
+		} else if ($returnmode == 2)
828 888
 		{
829 889
 			$return_var = array();
830 890
 			$count = count($insertRows);
831 891
 			$start = smf_db_insert_id($table, $keys[0]);
832
-			for ($i = 0; $i < $count; $i++ )
833
-				$return_var[] = $start + $i;
892
+			for ($i = 0; $i < $count; $i++ ) {
893
+							$return_var[] = $start + $i;
894
+			}
834 895
 		}
835 896
 		return $return_var;
836 897
 	}
@@ -848,8 +909,9 @@  discard block
 block discarded – undo
848 909
  */
849 910
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
850 911
 {
851
-	if (empty($log_message))
852
-		$log_message = $error_message;
912
+	if (empty($log_message)) {
913
+			$log_message = $error_message;
914
+	}
853 915
 
854 916
 	foreach (debug_backtrace() as $step)
855 917
 	{
@@ -868,12 +930,14 @@  discard block
 block discarded – undo
868 930
 	}
869 931
 
870 932
 	// A special case - we want the file and line numbers for debugging.
871
-	if ($error_type == 'return')
872
-		return array($file, $line);
933
+	if ($error_type == 'return') {
934
+			return array($file, $line);
935
+	}
873 936
 
874 937
 	// Is always a critical error.
875
-	if (function_exists('log_error'))
876
-		log_error($log_message, 'critical', $file, $line);
938
+	if (function_exists('log_error')) {
939
+			log_error($log_message, 'critical', $file, $line);
940
+	}
877 941
 
878 942
 	if (function_exists('fatal_error'))
879 943
 	{
@@ -881,12 +945,12 @@  discard block
 block discarded – undo
881 945
 
882 946
 		// Cannot continue...
883 947
 		exit;
948
+	} elseif ($error_type) {
949
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
950
+	} else {
951
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
952
+	}
884 953
 	}
885
-	elseif ($error_type)
886
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
887
-	else
888
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
889
-}
890 954
 
891 955
 /**
892 956
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -903,10 +967,11 @@  discard block
 block discarded – undo
903 967
 		'\\' => '\\\\',
904 968
 	);
905 969
 
906
-	if ($translate_human_wildcards)
907
-		$replacements += array(
970
+	if ($translate_human_wildcards) {
971
+			$replacements += array(
908 972
 			'*' => '%',
909 973
 		);
974
+	}
910 975
 
911 976
 	return strtr($string, $replacements);
912 977
 }
@@ -920,8 +985,9 @@  discard block
 block discarded – undo
920 985
  */
921 986
 function smf_is_resource($result)
922 987
 {
923
-	if ($result instanceof mysqli_result)
924
-		return true;
988
+	if ($result instanceof mysqli_result) {
989
+			return true;
990
+	}
925 991
 
926 992
 	return false;
927 993
 }
Please login to merge, or discard this patch.
Sources/Display.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		call_integration_hook('integrate_poll_buttons');
825 825
 	}
826 826
 	
827
-	if(!empty($_REQUEST['page_id']))
827
+	if (!empty($_REQUEST['page_id']))
828 828
 		$start_char = substr($_REQUEST['page_id'], 0, 1);
829 829
 	else
830 830
 		$start_char = null;
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 			SELECT id_msg, id_member, approved
887 887
 			FROM {db_prefix}messages
888 888
 			WHERE id_topic = {int:current_topic} 
889
-			AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : '
889
+			AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : '
890 890
 			AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . '
891 891
 			ORDER BY id_msg ' . ($ascending ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : '
892 892
 			LIMIT {int:limit}'),
Please login to merge, or discard this patch.
Braces   +349 added lines, -263 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * The central part of the board - topic display.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	global $messages_request, $language, $smcFunc;
35 36
 
36 37
 	// What are you gonna display if these are empty?!
37
-	if (empty($topic))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($topic)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// Load the proper template.
41 43
 	loadTemplate('Display');
@@ -52,15 +54,17 @@  discard block
 block discarded – undo
52 54
 	$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
53 55
 
54 56
 	// Let's do some work on what to search index.
55
-	if (count($_GET) > 2)
56
-		foreach ($_GET as $k => $v)
57
+	if (count($_GET) > 2) {
58
+			foreach ($_GET as $k => $v)
57 59
 		{
58 60
 			if (!in_array($k, array('topic', 'board', 'start', session_name())))
59 61
 				$context['robot_no_index'] = true;
62
+	}
60 63
 		}
61 64
 
62
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
63
-		$context['robot_no_index'] = true;
65
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
66
+			$context['robot_no_index'] = true;
67
+	}
64 68
 
65 69
 	// Find the previous or next topic.  Make a fuss if there are no more.
66 70
 	if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
 			$topic_parameters
173 177
 	);
174 178
 
175
-	if ($smcFunc['db_num_rows']($request) == 0)
176
-		fatal_lang_error('not_a_topic', false, 404);
179
+	if ($smcFunc['db_num_rows']($request) == 0) {
180
+			fatal_lang_error('not_a_topic', false, 404);
181
+	}
177 182
 	$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request);
178 183
 	$smcFunc['db_free_result']($request);
179 184
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0;
211 216
 
212 217
 	// Add up unapproved replies to get real number of replies...
213
-	if ($modSettings['postmod_active'] && $approve_posts)
214
-		$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
218
+	if ($modSettings['postmod_active'] && $approve_posts) {
219
+			$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
220
+	}
215 221
 
216 222
 	// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing.
217 223
 	if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts)
@@ -231,11 +237,11 @@  discard block
 block discarded – undo
231 237
 		$smcFunc['db_free_result']($request);
232 238
 
233 239
 		$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0);
240
+	} elseif ($user_info['is_guest']) {
241
+			$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
242
+	} else {
243
+			$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
234 244
 	}
235
-	elseif ($user_info['is_guest'])
236
-		$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
237
-	else
238
-		$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
239 245
 
240 246
 	// The start isn't a number; it's information about what to do, where to go.
241 247
 	if (!is_numeric($_REQUEST['start']))
@@ -248,8 +254,7 @@  discard block
 block discarded – undo
248 254
 			{
249 255
 				$context['start_from'] = $context['total_visible_posts'] - 1;
250 256
 				$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0;
251
-			}
252
-			else
257
+			} else
253 258
 			{
254 259
 				// Find the earliest unread message in the topic. (the use of topics here is just for both tables.)
255 260
 				$request = $smcFunc['db_query']('', '
@@ -277,9 +282,9 @@  discard block
 block discarded – undo
277 282
 		if (substr($_REQUEST['start'], 0, 4) == 'from')
278 283
 		{
279 284
 			$timestamp = (int) substr($_REQUEST['start'], 4);
280
-			if ($timestamp === 0)
281
-				$_REQUEST['start'] = 0;
282
-			else
285
+			if ($timestamp === 0) {
286
+							$_REQUEST['start'] = 0;
287
+			} else
283 288
 			{
284 289
 				// Find the number of messages posted before said time...
285 290
 				$request = $smcFunc['db_query']('', '
@@ -307,11 +312,11 @@  discard block
 block discarded – undo
307 312
 		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
308 313
 		{
309 314
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
310
-			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg'])
311
-				$context['start_from'] = $context['total_visible_posts'] - 1;
312
-			elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg'])
313
-				$context['start_from'] = 0;
314
-			else
315
+			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) {
316
+							$context['start_from'] = $context['total_visible_posts'] - 1;
317
+			} elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) {
318
+							$context['start_from'] = 0;
319
+			} else
315 320
 			{
316 321
 				// Find the start value for that message......
317 322
 				$request = $smcFunc['db_query']('', '
@@ -394,21 +399,25 @@  discard block
 block discarded – undo
394 399
 		);
395 400
 		while ($row = $smcFunc['db_fetch_assoc']($request))
396 401
 		{
397
-			if (empty($row['id_member']))
398
-				continue;
402
+			if (empty($row['id_member'])) {
403
+							continue;
404
+			}
399 405
 
400
-			if (!empty($row['online_color']))
401
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
402
-			else
403
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
406
+			if (!empty($row['online_color'])) {
407
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
408
+			} else {
409
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
410
+			}
404 411
 
405 412
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
406
-			if ($is_buddy)
407
-				$link = '<strong>' . $link . '</strong>';
413
+			if ($is_buddy) {
414
+							$link = '<strong>' . $link . '</strong>';
415
+			}
408 416
 
409 417
 			// Add them both to the list and to the more detailed list.
410
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
411
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
418
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
419
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
420
+			}
412 421
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
413 422
 				'id' => $row['id_member'],
414 423
 				'username' => $row['member_name'],
@@ -420,8 +429,9 @@  discard block
 block discarded – undo
420 429
 				'hidden' => empty($row['show_online']),
421 430
 			);
422 431
 
423
-			if (empty($row['show_online']))
424
-				$context['view_num_hidden']++;
432
+			if (empty($row['show_online'])) {
433
+							$context['view_num_hidden']++;
434
+			}
425 435
 		}
426 436
 
427 437
 		// The number of guests is equal to the rows minus the ones we actually used ;).
@@ -435,11 +445,13 @@  discard block
 block discarded – undo
435 445
 
436 446
 	// If all is set, but not allowed... just unset it.
437 447
 	$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
438
-	if (isset($_REQUEST['all']) && !$can_show_all)
439
-		unset($_REQUEST['all']);
448
+	if (isset($_REQUEST['all']) && !$can_show_all) {
449
+			unset($_REQUEST['all']);
450
+	}
440 451
 	// Otherwise, it must be allowed... so pretend start was -1.
441
-	elseif (isset($_REQUEST['all']))
442
-		$_REQUEST['start'] = -1;
452
+	elseif (isset($_REQUEST['all'])) {
453
+			$_REQUEST['start'] = -1;
454
+	}
443 455
 
444 456
 	// Construct allowing for the .START method...
445 457
 	$context['start'] = $_REQUEST['start'];
@@ -475,14 +487,16 @@  discard block
 block discarded – undo
475 487
 	if (!empty($board_info['moderators']))
476 488
 	{
477 489
 		// Add a link for each moderator...
478
-		foreach ($board_info['moderators'] as $mod)
479
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
490
+		foreach ($board_info['moderators'] as $mod) {
491
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
492
+		}
480 493
 	}
481 494
 	if (!empty($board_info['moderator_groups']))
482 495
 	{
483 496
 		// Add a link for each moderator group as well...
484
-		foreach ($board_info['moderator_groups'] as $mod_group)
485
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
497
+		foreach ($board_info['moderator_groups'] as $mod_group) {
498
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
499
+		}
486 500
 	}
487 501
 
488 502
 	if (!empty($context['link_moderators']))
@@ -513,9 +527,9 @@  discard block
 block discarded – undo
513 527
 	// For quick reply we need a response prefix in the default forum language.
514 528
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600)))
515 529
 	{
516
-		if ($language === $user_info['language'])
517
-			$context['response_prefix'] = $txt['response_prefix'];
518
-		else
530
+		if ($language === $user_info['language']) {
531
+					$context['response_prefix'] = $txt['response_prefix'];
532
+		} else
519 533
 		{
520 534
 			loadLanguage('index', $language, false);
521 535
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -547,8 +561,9 @@  discard block
 block discarded – undo
547 561
 			list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
548 562
 
549 563
 			// Sanity check
550
-			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
551
-				continue;
564
+			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
565
+							continue;
566
+			}
552 567
 
553 568
 			$linked_calendar_event = array(
554 569
 				'id' => $row['id_event'],
@@ -597,8 +612,9 @@  discard block
 block discarded – undo
597 612
 		}
598 613
 		$smcFunc['db_free_result']($request);
599 614
 
600
-		if (!empty($context['linked_calendar_events']))
601
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
615
+		if (!empty($context['linked_calendar_events'])) {
616
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
617
+		}
602 618
 	}
603 619
 
604 620
 	// Create the poll info if it exists.
@@ -661,8 +677,9 @@  discard block
 block discarded – undo
661 677
 		$smcFunc['db_free_result']($request);
662 678
 		
663 679
 		// Got we multi choice?
664
-		if ($pollinfo['max_votes'] > 1)
665
-			$realtotal = $pollinfo['total'];
680
+		if ($pollinfo['max_votes'] > 1) {
681
+					$realtotal = $pollinfo['total'];
682
+		}
666 683
 
667 684
 		// If this is a guest we need to do our best to work out if they have voted, and what they voted for.
668 685
 		if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote'))
@@ -675,20 +692,21 @@  discard block
 block discarded – undo
675 692
 				foreach ($guestinfo as $i => $guestvoted)
676 693
 				{
677 694
 					$guestvoted = explode(',', $guestvoted);
678
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
679
-						break;
695
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
696
+											break;
697
+					}
680 698
 				}
681 699
 				// Has the poll been reset since guest voted?
682 700
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
683 701
 				{
684 702
 					// Remove the poll info from the cookie to allow guest to vote again
685 703
 					unset($guestinfo[$i]);
686
-					if (!empty($guestinfo))
687
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
688
-					else
689
-						unset($_COOKIE['guest_poll_vote']);
690
-				}
691
-				else
704
+					if (!empty($guestinfo)) {
705
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
706
+					} else {
707
+											unset($_COOKIE['guest_poll_vote']);
708
+					}
709
+				} else
692 710
 				{
693 711
 					// What did they vote for?
694 712
 					unset($guestvoted[0], $guestvoted[1]);
@@ -802,35 +820,43 @@  discard block
 block discarded – undo
802 820
 		// Build the poll moderation button array.
803 821
 		$context['poll_buttons'] = array();
804 822
 
805
-		if ($context['allow_return_vote'])
806
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
823
+		if ($context['allow_return_vote']) {
824
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
825
+		}
807 826
 
808
-		if ($context['show_view_results_button'])
809
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
827
+		if ($context['show_view_results_button']) {
828
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
829
+		}
810 830
 
811
-		if ($context['allow_change_vote'])
812
-			$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
831
+		if ($context['allow_change_vote']) {
832
+					$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
833
+		}
813 834
 
814
-		if ($context['allow_lock_poll'])
815
-			$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
835
+		if ($context['allow_lock_poll']) {
836
+					$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
837
+		}
816 838
 
817
-		if ($context['allow_edit_poll'])
818
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
839
+		if ($context['allow_edit_poll']) {
840
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
841
+		}
819 842
 
820
-		if ($context['can_remove_poll'])
821
-			$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
843
+		if ($context['can_remove_poll']) {
844
+					$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
845
+		}
822 846
 
823 847
 		// Allow mods to add additional buttons here
824 848
 		call_integration_hook('integrate_poll_buttons');
825 849
 	}
826 850
 	
827
-	if(!empty($_REQUEST['page_id']))
828
-		$start_char = substr($_REQUEST['page_id'], 0, 1);
829
-	else
830
-		$start_char = null;
851
+	if(!empty($_REQUEST['page_id'])) {
852
+			$start_char = substr($_REQUEST['page_id'], 0, 1);
853
+	} else {
854
+			$start_char = null;
855
+	}
831 856
 
832
-	if ($start_char === 'M' || $start_char === 'L')
833
-		$page_id = substr($_REQUEST['page_id'], 1);
857
+	if ($start_char === 'M' || $start_char === 'L') {
858
+			$page_id = substr($_REQUEST['page_id'], 1);
859
+	}
834 860
 
835 861
 	$limit = $context['messages_per_page'];
836 862
  
@@ -866,8 +892,7 @@  discard block
 block discarded – undo
866 892
 				'max' => $limit,
867 893
 			)
868 894
 		);
869
-	}
870
-	else //next or before page
895
+	} else //next or before page
871 896
 	{
872 897
 		$firstIndex = 0;
873 898
 		
@@ -875,8 +900,7 @@  discard block
 block discarded – undo
875 900
 		{
876 901
 			$ascending = true;
877 902
 			$page_operator = '>';
878
-		}
879
-		else
903
+		} else
880 904
 		{
881 905
 			$ascending = false;
882 906
 			$page_operator = '<';
@@ -906,14 +930,16 @@  discard block
 block discarded – undo
906 930
 	$all_posters = array();
907 931
 	while ($row = $smcFunc['db_fetch_assoc']($request))
908 932
 	{
909
-		if (!empty($row['id_member']))
910
-			$all_posters[$row['id_msg']] = $row['id_member'];
933
+		if (!empty($row['id_member'])) {
934
+					$all_posters[$row['id_msg']] = $row['id_member'];
935
+		}
911 936
 		$messages[] = $row['id_msg'];
912 937
 	}
913 938
 	
914 939
 	// Before Page bring in the right order
915
-	if (!empty($start_char) && $start_char === 'L')
916
-		krsort($messages);
940
+	if (!empty($start_char) && $start_char === 'L') {
941
+			krsort($messages);
942
+	}
917 943
 	
918 944
 	// Construct the page index, allowing for the .START method...
919 945
 	$page_options = array(
@@ -935,8 +961,9 @@  discard block
 block discarded – undo
935 961
 			$_REQUEST['start'] = 0;
936 962
 		}
937 963
 		// They aren't using it, but the *option* is there, at least.
938
-		else
939
-			$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
964
+		else {
965
+					$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
966
+		}
940 967
 	}
941 968
 	
942 969
 	$smcFunc['db_free_result']($request);
@@ -948,8 +975,9 @@  discard block
 block discarded – undo
948 975
 	if (!$user_info['is_guest'] && !empty($messages))
949 976
 	{
950 977
 		$mark_at_msg = max($messages);
951
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
952
-			$mark_at_msg = $modSettings['maxMsgID'];
978
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
979
+					$mark_at_msg = $modSettings['maxMsgID'];
980
+		}
953 981
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
954 982
 		{
955 983
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -981,8 +1009,9 @@  discard block
 block discarded – undo
981 1009
 		while ($row = $smcFunc['db_fetch_assoc']($request))
982 1010
 		{
983 1011
 			// Find if this topic is marked for notification...
984
-			if (!empty($row['id_topic']))
985
-				$context['is_marked_notify'] = true;
1012
+			if (!empty($row['id_topic'])) {
1013
+							$context['is_marked_notify'] = true;
1014
+			}
986 1015
 
987 1016
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
988 1017
 			if (!empty($row['sent']) && $do_once)
@@ -1004,8 +1033,9 @@  discard block
 block discarded – undo
1004 1033
 		}
1005 1034
 
1006 1035
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
1007
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
1008
-			$_SESSION['topicseen_cache'][$board]--;
1036
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
1037
+					$_SESSION['topicseen_cache'][$board]--;
1038
+		}
1009 1039
 		// Mark board as seen if this is the only new topic.
1010 1040
 		elseif (isset($_REQUEST['topicseen']))
1011 1041
 		{
@@ -1029,14 +1059,16 @@  discard block
 block discarded – undo
1029 1059
 			$smcFunc['db_free_result']($request);
1030 1060
 
1031 1061
 			// If there're no real new topics in this board, mark the board as seen.
1032
-			if (empty($numNewTopics))
1033
-				$_REQUEST['boardseen'] = true;
1034
-			else
1035
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1062
+			if (empty($numNewTopics)) {
1063
+							$_REQUEST['boardseen'] = true;
1064
+			} else {
1065
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1066
+			}
1036 1067
 		}
1037 1068
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
1038
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
1039
-			$_SESSION['topicseen_cache'][$board]--;
1069
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
1070
+					$_SESSION['topicseen_cache'][$board]--;
1071
+		}
1040 1072
 
1041 1073
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
1042 1074
 		if (isset($_REQUEST['boardseen']))
@@ -1093,23 +1125,26 @@  discard block
 block discarded – undo
1093 1125
 			$temp = array();
1094 1126
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1095 1127
 			{
1096
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1097
-					continue;
1128
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1129
+									continue;
1130
+				}
1098 1131
 
1099 1132
 				$temp[$row['id_attach']] = $row;
1100 1133
 				$temp[$row['id_attach']]['topic'] = $topic;
1101 1134
 				$temp[$row['id_attach']]['board'] = $board;
1102 1135
 
1103
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1104
-					$context['loaded_attachments'][$row['id_msg']] = array();
1136
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1137
+									$context['loaded_attachments'][$row['id_msg']] = array();
1138
+				}
1105 1139
 			}
1106 1140
 			$smcFunc['db_free_result']($request);
1107 1141
 
1108 1142
 			// This is better than sorting it with the query...
1109 1143
 			ksort($temp);
1110 1144
 
1111
-			foreach ($temp as $row)
1112
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1145
+			foreach ($temp as $row) {
1146
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1147
+			}
1113 1148
 		}
1114 1149
 
1115 1150
 		$msg_parameters = array(
@@ -1136,21 +1171,23 @@  discard block
 block discarded – undo
1136 1171
 		);
1137 1172
 
1138 1173
 		// And the likes
1139
-		if (!empty($modSettings['enable_likes']))
1140
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1174
+		if (!empty($modSettings['enable_likes'])) {
1175
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1176
+		}
1141 1177
 
1142 1178
 		// Go to the last message if the given time is beyond the time of the last message.
1143
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1144
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1179
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1180
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1181
+		}
1145 1182
 
1146 1183
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1147 1184
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1148
-		if (empty($options['view_newest_first']))
1149
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1150
-		else
1151
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1152
-	}
1153
-	else
1185
+		if (empty($options['view_newest_first'])) {
1186
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1187
+		} else {
1188
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1189
+		}
1190
+	} else
1154 1191
 	{
1155 1192
 		$messages_request = false;
1156 1193
 		$context['first_message'] = 0;
@@ -1186,8 +1223,9 @@  discard block
 block discarded – undo
1186 1223
 		'can_see_likes' => 'likes_view',
1187 1224
 		'can_like' => 'likes_like',
1188 1225
 	);
1189
-	foreach ($common_permissions as $contextual => $perm)
1190
-		$context[$contextual] = allowedTo($perm);
1226
+	foreach ($common_permissions as $contextual => $perm) {
1227
+			$context[$contextual] = allowedTo($perm);
1228
+	}
1191 1229
 
1192 1230
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1193 1231
 	$anyown_permissions = array(
@@ -1200,8 +1238,9 @@  discard block
 block discarded – undo
1200 1238
 		'can_reply_unapproved' => 'post_unapproved_replies',
1201 1239
 		'can_view_warning' => 'profile_warning',
1202 1240
 	);
1203
-	foreach ($anyown_permissions as $contextual => $perm)
1204
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1241
+	foreach ($anyown_permissions as $contextual => $perm) {
1242
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1243
+	}
1205 1244
 
1206 1245
 	if (!$user_info['is_admin'] && !$modSettings['topic_move_any'])
1207 1246
 	{
@@ -1247,8 +1286,9 @@  discard block
 block discarded – undo
1247 1286
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1248 1287
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1249 1288
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1250
-	if (!empty($context['drafts_save']))
1251
-		loadLanguage('Drafts');
1289
+	if (!empty($context['drafts_save'])) {
1290
+			loadLanguage('Drafts');
1291
+	}
1252 1292
 
1253 1293
 	// When was the last time this topic was replied to?  Should we warn them about it?
1254 1294
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1309,26 +1349,31 @@  discard block
 block discarded – undo
1309 1349
 	// Message icons - customized icons are off?
1310 1350
 	$context['icons'] = getMessageIcons($board);
1311 1351
 
1312
-	if (!empty($context['icons']))
1313
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1352
+	if (!empty($context['icons'])) {
1353
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1354
+	}
1314 1355
 
1315 1356
 	// Build the normal button array.
1316 1357
 	$context['normal_buttons'] = array();
1317 1358
 
1318
-	if ($context['can_reply'])
1319
-		$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1359
+	if ($context['can_reply']) {
1360
+			$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1361
+	}
1320 1362
 
1321
-	if ($context['can_add_poll'])
1322
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1363
+	if ($context['can_add_poll']) {
1364
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1365
+	}
1323 1366
 
1324
-	if ($context['can_mark_unread'])
1325
-		$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1367
+	if ($context['can_mark_unread']) {
1368
+			$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1369
+	}
1326 1370
 
1327
-	if ($context['can_print'])
1328
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1371
+	if ($context['can_print']) {
1372
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1373
+	}
1329 1374
 
1330
-	if ($context['can_set_notify'])
1331
-		$context['normal_buttons']['notify'] = array(
1375
+	if ($context['can_set_notify']) {
1376
+			$context['normal_buttons']['notify'] = array(
1332 1377
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1333 1378
 			'sub_buttons' => array(
1334 1379
 				array(
@@ -1350,38 +1395,47 @@  discard block
 block discarded – undo
1350 1395
 				),
1351 1396
 			),
1352 1397
 		);
1398
+	}
1353 1399
 
1354 1400
 	// Build the mod button array
1355 1401
 	$context['mod_buttons'] = array();
1356 1402
 
1357
-	if ($context['can_move'])
1358
-		$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1403
+	if ($context['can_move']) {
1404
+			$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1405
+	}
1359 1406
 
1360
-	if ($context['can_delete'])
1361
-		$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1407
+	if ($context['can_delete']) {
1408
+			$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1409
+	}
1362 1410
 
1363
-	if ($context['can_lock'])
1364
-		$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1411
+	if ($context['can_lock']) {
1412
+			$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1413
+	}
1365 1414
 
1366
-	if ($context['can_sticky'])
1367
-		$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1415
+	if ($context['can_sticky']) {
1416
+			$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1417
+	}
1368 1418
 
1369
-	if ($context['can_merge'])
1370
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1419
+	if ($context['can_merge']) {
1420
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1421
+	}
1371 1422
 
1372
-	if ($context['calendar_post'])
1373
-		$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1423
+	if ($context['calendar_post']) {
1424
+			$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1425
+	}
1374 1426
 
1375 1427
 	// Restore topic. eh?  No monkey business.
1376
-	if ($context['can_restore_topic'])
1377
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1428
+	if ($context['can_restore_topic']) {
1429
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1430
+	}
1378 1431
 
1379 1432
 	// Show a message in case a recently posted message became unapproved.
1380 1433
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1381 1434
 
1382 1435
 	// Don't want to show this forever...
1383
-	if ($context['becomesUnapproved'])
1384
-		unset($_SESSION['becomesUnapproved']);
1436
+	if ($context['becomesUnapproved']) {
1437
+			unset($_SESSION['becomesUnapproved']);
1438
+	}
1385 1439
 
1386 1440
 	// Allow adding new mod buttons easily.
1387 1441
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1390,12 +1444,14 @@  discard block
 block discarded – undo
1390 1444
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1391 1445
 
1392 1446
 	// Load the drafts js file
1393
-	if ($context['drafts_autosave'])
1394
-		loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1447
+	if ($context['drafts_autosave']) {
1448
+			loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1449
+	}
1395 1450
 
1396 1451
 	// Spellcheck
1397
-	if ($context['show_spellchecking'])
1398
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1452
+	if ($context['show_spellchecking']) {
1453
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1454
+	}
1399 1455
 
1400 1456
 	// topic.js
1401 1457
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -1429,16 +1485,19 @@  discard block
 block discarded – undo
1429 1485
 	static $counter = null;
1430 1486
 
1431 1487
 	// If the query returned false, bail.
1432
-	if ($messages_request == false)
1433
-		return false;
1488
+	if ($messages_request == false) {
1489
+			return false;
1490
+	}
1434 1491
 
1435 1492
 	// Remember which message this is.  (ie. reply #83)
1436
-	if ($counter === null || $reset)
1437
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1493
+	if ($counter === null || $reset) {
1494
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1495
+	}
1438 1496
 
1439 1497
 	// Start from the beginning...
1440
-	if ($reset)
1441
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1498
+	if ($reset) {
1499
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1500
+	}
1442 1501
 
1443 1502
 	// Attempt to get the next message.
1444 1503
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1452,19 +1511,21 @@  discard block
 block discarded – undo
1452 1511
 	if (empty($context['icon_sources']))
1453 1512
 	{
1454 1513
 		$context['icon_sources'] = array();
1455
-		foreach ($context['stable_icons'] as $icon)
1456
-			$context['icon_sources'][$icon] = 'images_url';
1514
+		foreach ($context['stable_icons'] as $icon) {
1515
+					$context['icon_sources'][$icon] = 'images_url';
1516
+		}
1457 1517
 	}
1458 1518
 
1459 1519
 	// Message Icon Management... check the images exist.
1460 1520
 	if (empty($modSettings['messageIconChecks_disable']))
1461 1521
 	{
1462 1522
 		// If the current icon isn't known, then we need to do something...
1463
-		if (!isset($context['icon_sources'][$message['icon']]))
1464
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1523
+		if (!isset($context['icon_sources'][$message['icon']])) {
1524
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1525
+		}
1526
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1527
+			$context['icon_sources'][$message['icon']] = 'images_url';
1465 1528
 	}
1466
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1467
-		$context['icon_sources'][$message['icon']] = 'images_url';
1468 1529
 
1469 1530
 	// If you're a lazy bum, you probably didn't give a subject...
1470 1531
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1489,8 +1550,7 @@  discard block
 block discarded – undo
1489 1550
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1490 1551
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1491 1552
 		$memberContext[$message['id_member']]['is_guest'] = true;
1492
-	}
1493
-	else
1553
+	} else
1494 1554
 	{
1495 1555
 		// Define this here to make things a bit more readable
1496 1556
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1513,8 +1573,9 @@  discard block
 block discarded – undo
1513 1573
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1514 1574
 
1515 1575
 	// If it's in the recycle bin we need to override whatever icon we did have.
1516
-	if (!empty($board_info['recycle']))
1517
-		$message['icon'] = 'recycled';
1576
+	if (!empty($board_info['recycle'])) {
1577
+			$message['icon'] = 'recycled';
1578
+	}
1518 1579
 
1519 1580
 	require_once($sourcedir . '/Subs-Attachments.php');
1520 1581
 
@@ -1558,32 +1619,36 @@  discard block
 block discarded – undo
1558 1619
 	}
1559 1620
 
1560 1621
 	// Are likes enable?
1561
-	if (!empty($modSettings['enable_likes']))
1562
-		$output['likes'] = array(
1622
+	if (!empty($modSettings['enable_likes'])) {
1623
+			$output['likes'] = array(
1563 1624
 			'count' => $message['likes'],
1564 1625
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1565 1626
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1566 1627
 		);
1628
+	}
1567 1629
 
1568 1630
 	// Is this user the message author?
1569 1631
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1570
-	if (!empty($output['modified']['name']))
1571
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1632
+	if (!empty($output['modified']['name'])) {
1633
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1634
+	}
1572 1635
 
1573 1636
 	// Did they give a reason for editing?
1574
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1575
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1637
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1638
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1639
+	}
1576 1640
 
1577 1641
 	// Any custom profile fields?
1578
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1579
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1642
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1643
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1580 1644
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1645
+	}
1581 1646
 
1582
-	if (empty($options['view_newest_first']))
1583
-		$counter++;
1584
-
1585
-	else
1586
-		$counter--;
1647
+	if (empty($options['view_newest_first'])) {
1648
+			$counter++;
1649
+	} else {
1650
+			$counter--;
1651
+	}
1587 1652
 
1588 1653
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1589 1654
 
@@ -1609,21 +1674,23 @@  discard block
 block discarded – undo
1609 1674
 	$context['no_last_modified'] = true;
1610 1675
 
1611 1676
 	// Prevent a preview image from being displayed twice.
1612
-	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview'))
1613
-		return;
1677
+	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) {
1678
+			return;
1679
+	}
1614 1680
 
1615 1681
 	// Make sure some attachment was requested!
1616
-	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id']))
1617
-		fatal_lang_error('no_access', false);
1682
+	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
1683
+			fatal_lang_error('no_access', false);
1684
+	}
1618 1685
 
1619 1686
 	$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
1620 1687
 
1621 1688
 	// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
1622 1689
 	$attachRequest = null;
1623 1690
 	call_integration_hook('integrate_download_request', array(&$attachRequest));
1624
-	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
1625
-		$request = $attachRequest;
1626
-	else
1691
+	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
1692
+			$request = $attachRequest;
1693
+	} else
1627 1694
 	{
1628 1695
 		// This checks only the current board for $board/$topic's permissions.
1629 1696
 		isAllowedTo('view_attachments');
@@ -1644,19 +1711,21 @@  discard block
 block discarded – undo
1644 1711
 		);
1645 1712
 	}
1646 1713
 
1647
-	if ($smcFunc['db_num_rows']($request) == 0)
1648
-		fatal_lang_error('no_access', false);
1714
+	if ($smcFunc['db_num_rows']($request) == 0) {
1715
+			fatal_lang_error('no_access', false);
1716
+	}
1649 1717
 
1650 1718
 	list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
1651 1719
 	$smcFunc['db_free_result']($request);
1652 1720
 
1653 1721
 	// If it isn't yet approved, do they have permission to view it?
1654
-	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3))
1655
-		isAllowedTo('approve_posts');
1722
+	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
1723
+			isAllowedTo('approve_posts');
1724
+	}
1656 1725
 
1657 1726
 	// Update the download counter (unless it's a thumbnail).
1658
-	if ($attachment_type != 3)
1659
-		$smcFunc['db_query']('attach_download_increase', '
1727
+	if ($attachment_type != 3) {
1728
+			$smcFunc['db_query']('attach_download_increase', '
1660 1729
 			UPDATE LOW_PRIORITY {db_prefix}attachments
1661 1730
 			SET downloads = downloads + 1
1662 1731
 			WHERE id_attach = {int:id_attach}',
@@ -1664,15 +1733,15 @@  discard block
 block discarded – undo
1664 1733
 				'id_attach' => $id_attach,
1665 1734
 			)
1666 1735
 		);
1736
+	}
1667 1737
 
1668 1738
 	$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
1669 1739
 
1670 1740
 	// This is done to clear any output that was made before now.
1671 1741
 	ob_end_clean();
1672
-	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java')))
1673
-		@ob_start('ob_gzhandler');
1674
-
1675
-	else
1742
+	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) {
1743
+			@ob_start('ob_gzhandler');
1744
+	} else
1676 1745
 	{
1677 1746
 		ob_start();
1678 1747
 		header('Content-Encoding: none');
@@ -1715,8 +1784,9 @@  discard block
 block discarded – undo
1715 1784
 	// Send the attachment headers.
1716 1785
 	header('Pragma: ');
1717 1786
 
1718
-	if (!isBrowser('gecko'))
1719
-		header('Content-Transfer-Encoding: binary');
1787
+	if (!isBrowser('gecko')) {
1788
+			header('Content-Transfer-Encoding: binary');
1789
+	}
1720 1790
 
1721 1791
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
1722 1792
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
@@ -1725,18 +1795,19 @@  discard block
 block discarded – undo
1725 1795
 	header('ETag: ' . $eTag);
1726 1796
 
1727 1797
 	// Make sure the mime type warrants an inline display.
1728
-	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0)
1729
-		unset($_REQUEST['image']);
1798
+	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
1799
+			unset($_REQUEST['image']);
1800
+	}
1730 1801
 
1731 1802
 	// Does this have a mime type?
1732
-	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
1733
-		header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1734
-
1735
-	else
1803
+	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
1804
+			header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1805
+	} else
1736 1806
 	{
1737 1807
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
1738
-		if (isset($_REQUEST['image']))
1739
-			unset($_REQUEST['image']);
1808
+		if (isset($_REQUEST['image'])) {
1809
+					unset($_REQUEST['image']);
1810
+		}
1740 1811
 	}
1741 1812
 
1742 1813
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -1744,23 +1815,22 @@  discard block
 block discarded – undo
1744 1815
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
1745 1816
 
1746 1817
 	// Different browsers like different standards...
1747
-	if (isBrowser('firefox'))
1748
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1749
-
1750
-	elseif (isBrowser('opera'))
1751
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1752
-
1753
-	elseif (isBrowser('ie'))
1754
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1755
-
1756
-	else
1757
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1818
+	if (isBrowser('firefox')) {
1819
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1820
+	} elseif (isBrowser('opera')) {
1821
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1822
+	} elseif (isBrowser('ie')) {
1823
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1824
+	} else {
1825
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1826
+	}
1758 1827
 
1759 1828
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
1760
-	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
1761
-		header('Cache-Control: no-cache');
1762
-	else
1763
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1829
+	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
1830
+			header('Cache-Control: no-cache');
1831
+	} else {
1832
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1833
+	}
1764 1834
 
1765 1835
 	header('Content-Length: ' . filesize($filename));
1766 1836
 
@@ -1770,20 +1840,23 @@  discard block
 block discarded – undo
1770 1840
 	// Recode line endings for text files, if enabled.
1771 1841
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1772 1842
 	{
1773
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1774
-			$callback = function($buffer)
1843
+		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
1844
+					$callback = function($buffer)
1775 1845
 			{
1776 1846
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1847
+		}
1777 1848
 			};
1778
-		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1779
-			$callback = function($buffer)
1849
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
1850
+					$callback = function($buffer)
1780 1851
 			{
1781 1852
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1853
+		}
1782 1854
 			};
1783
-		else
1784
-			$callback = function($buffer)
1855
+		else {
1856
+					$callback = function($buffer)
1785 1857
 			{
1786 1858
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1859
+		}
1787 1860
 			};
1788 1861
 	}
1789 1862
 
@@ -1791,23 +1864,26 @@  discard block
 block discarded – undo
1791 1864
 	if (filesize($filename) > 4194304)
1792 1865
 	{
1793 1866
 		// Forcibly end any output buffering going on.
1794
-		while (@ob_get_level() > 0)
1795
-			@ob_end_clean();
1867
+		while (@ob_get_level() > 0) {
1868
+					@ob_end_clean();
1869
+		}
1796 1870
 
1797 1871
 		$fp = fopen($filename, 'rb');
1798 1872
 		while (!feof($fp))
1799 1873
 		{
1800
-			if (isset($callback))
1801
-				echo $callback(fread($fp, 8192));
1802
-			else
1803
-				echo fread($fp, 8192);
1874
+			if (isset($callback)) {
1875
+							echo $callback(fread($fp, 8192));
1876
+			} else {
1877
+							echo fread($fp, 8192);
1878
+			}
1804 1879
 			flush();
1805 1880
 		}
1806 1881
 		fclose($fp);
1807 1882
 	}
1808 1883
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
1809
-	elseif (isset($callback) || @readfile($filename) === null)
1810
-		echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1884
+	elseif (isset($callback) || @readfile($filename) === null) {
1885
+			echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1886
+	}
1811 1887
 
1812 1888
 	obExit(false);
1813 1889
 }
@@ -1820,8 +1896,9 @@  discard block
 block discarded – undo
1820 1896
  */
1821 1897
 function approved_attach_sort($a, $b)
1822 1898
 {
1823
-	if ($a['is_approved'] == $b['is_approved'])
1824
-		return 0;
1899
+	if ($a['is_approved'] == $b['is_approved']) {
1900
+			return 0;
1901
+	}
1825 1902
 
1826 1903
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1827 1904
 }
@@ -1838,16 +1915,19 @@  discard block
 block discarded – undo
1838 1915
 
1839 1916
 	require_once($sourcedir . '/RemoveTopic.php');
1840 1917
 
1841
-	if (empty($_REQUEST['msgs']))
1842
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1918
+	if (empty($_REQUEST['msgs'])) {
1919
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1920
+	}
1843 1921
 
1844 1922
 	$messages = array();
1845
-	foreach ($_REQUEST['msgs'] as $dummy)
1846
-		$messages[] = (int) $dummy;
1923
+	foreach ($_REQUEST['msgs'] as $dummy) {
1924
+			$messages[] = (int) $dummy;
1925
+	}
1847 1926
 
1848 1927
 	// We are restoring messages. We handle this in another place.
1849
-	if (isset($_REQUEST['restore_selected']))
1850
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1928
+	if (isset($_REQUEST['restore_selected'])) {
1929
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1930
+	}
1851 1931
 	if (isset($_REQUEST['split_selection']))
1852 1932
 	{
1853 1933
 		$request = $smcFunc['db_query']('', '
@@ -1866,8 +1946,9 @@  discard block
 block discarded – undo
1866 1946
 	}
1867 1947
 
1868 1948
 	// Allowed to delete any message?
1869
-	if (allowedTo('delete_any'))
1870
-		$allowed_all = true;
1949
+	if (allowedTo('delete_any')) {
1950
+			$allowed_all = true;
1951
+	}
1871 1952
 	// Allowed to delete replies to their messages?
1872 1953
 	elseif (allowedTo('delete_replies'))
1873 1954
 	{
@@ -1884,13 +1965,14 @@  discard block
 block discarded – undo
1884 1965
 		$smcFunc['db_free_result']($request);
1885 1966
 
1886 1967
 		$allowed_all = $starter == $user_info['id'];
1968
+	} else {
1969
+			$allowed_all = false;
1887 1970
 	}
1888
-	else
1889
-		$allowed_all = false;
1890 1971
 
1891 1972
 	// Make sure they're allowed to delete their own messages, if not any.
1892
-	if (!$allowed_all)
1893
-		isAllowedTo('delete_own');
1973
+	if (!$allowed_all) {
1974
+			isAllowedTo('delete_own');
1975
+	}
1894 1976
 
1895 1977
 	// Allowed to remove which messages?
1896 1978
 	$request = $smcFunc['db_query']('', '
@@ -1910,8 +1992,9 @@  discard block
 block discarded – undo
1910 1992
 	$messages = array();
1911 1993
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1912 1994
 	{
1913
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1914
-			continue;
1995
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1996
+					continue;
1997
+		}
1915 1998
 
1916 1999
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1917 2000
 	}
@@ -1934,17 +2017,20 @@  discard block
 block discarded – undo
1934 2017
 	foreach ($messages as $message => $info)
1935 2018
 	{
1936 2019
 		// Just skip the first message - if it's not the last.
1937
-		if ($message == $first_message && $message != $last_message)
1938
-			continue;
2020
+		if ($message == $first_message && $message != $last_message) {
2021
+					continue;
2022
+		}
1939 2023
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1940
-		elseif ($message == $first_message)
1941
-			$topicGone = true;
2024
+		elseif ($message == $first_message) {
2025
+					$topicGone = true;
2026
+		}
1942 2027
 
1943 2028
 		removeMessage($message);
1944 2029
 
1945 2030
 		// Log this moderation action ;).
1946
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1947
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
2031
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
2032
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
2033
+		}
1948 2034
 	}
1949 2035
 
1950 2036
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Sources/Subs-Compat.php 1 patch
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
  * @version 2.1 Beta 4
17 17
  */
18 18
 
19
-if (!defined('SMF'))
19
+if (!defined('SMF')) {
20 20
 	die('No direct access...');
21
+}
21 22
 
22 23
 
23 24
 /**
@@ -28,14 +29,16 @@  discard block
 block discarded – undo
28 29
 function sha1_smf($str)
29 30
 {
30 31
 	// If we have mhash loaded in, use it instead!
31
-	if (function_exists('mhash') && defined('MHASH_SHA1'))
32
-		return bin2hex(mhash(MHASH_SHA1, $str));
32
+	if (function_exists('mhash') && defined('MHASH_SHA1')) {
33
+			return bin2hex(mhash(MHASH_SHA1, $str));
34
+	}
33 35
 
34 36
 	$nblk = (strlen($str) + 8 >> 6) + 1;
35 37
 	$blks = array_pad(array(), $nblk * 16, 0);
36 38
 
37
-	for ($i = 0; $i < strlen($str); $i++)
38
-		$blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8);
39
+	for ($i = 0; $i < strlen($str); $i++) {
40
+			$blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8);
41
+	}
39 42
 
40 43
 	$blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
41 44
 
@@ -70,10 +73,11 @@  discard block
 block discarded – undo
70 73
 
71 74
 		for ($j = 0; $j < 80; $j++)
72 75
 		{
73
-			if ($j < 16)
74
-				$w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0;
75
-			else
76
-				$w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
76
+			if ($j < 16) {
77
+							$w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0;
78
+			} else {
79
+							$w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
80
+			}
77 81
 
78 82
 			$t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j);
79 83
 			$e = $d;
@@ -103,12 +107,15 @@  discard block
 block discarded – undo
103 107
  */
104 108
 function sha1_ft($t, $b, $c, $d)
105 109
 {
106
-	if ($t < 20)
107
-		return ($b & $c) | ((~$b) & $d);
108
-	if ($t < 40)
109
-		return $b ^ $c ^ $d;
110
-	if ($t < 60)
111
-		return ($b & $c) | ($b & $d) | ($c & $d);
110
+	if ($t < 20) {
111
+			return ($b & $c) | ((~$b) & $d);
112
+	}
113
+	if ($t < 40) {
114
+			return $b ^ $c ^ $d;
115
+	}
116
+	if ($t < 60) {
117
+			return ($b & $c) | ($b & $d) | ($c & $d);
118
+	}
112 119
 
113 120
 	return $b ^ $c ^ $d;
114 121
 }
@@ -132,10 +139,11 @@  discard block
 block discarded – undo
132 139
 function sha1_rol($num, $cnt)
133 140
 {
134 141
 	// Unfortunately, PHP uses unsigned 32-bit longs only.  So we have to kludge it a bit.
135
-	if ($num & 0x80000000)
136
-		$a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt);
137
-	else
138
-		$a = $num >> (32 - $cnt);
142
+	if ($num & 0x80000000) {
143
+			$a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt);
144
+	} else {
145
+			$a = $num >> (32 - $cnt);
146
+	}
139 147
 
140 148
 	return ($num << $cnt) | $a;
141 149
 }
Please login to merge, or discard this patch.
Sources/MoveTopic.php 1 patch
Braces   +101 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function allows to move a topic, making sure to ask the moderator
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 {
33 34
 	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir;
34 35
 
35
-	if (empty($topic))
36
-		fatal_lang_error('no_access', false);
36
+	if (empty($topic)) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	$request = $smcFunc['db_query']('', '
39 41
 		SELECT t.id_member_started, ms.subject, t.approved
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 	$smcFunc['db_free_result']($request);
50 52
 
51 53
 	// Can they see it - if not approved?
52
-	if ($modSettings['postmod_active'] && !$context['is_approved'])
53
-		isAllowedTo('approve_posts');
54
+	if ($modSettings['postmod_active'] && !$context['is_approved']) {
55
+			isAllowedTo('approve_posts');
56
+	}
54 57
 
55 58
 	// Permission check!
56 59
 	// @todo
@@ -59,9 +62,9 @@  discard block
 block discarded – undo
59 62
 		if ($id_member_started == $user_info['id'])
60 63
 		{
61 64
 			isAllowedTo('move_own');
65
+		} else {
66
+					isAllowedTo('move_any');
62 67
 		}
63
-		else
64
-			isAllowedTo('move_any');
65 68
 	}
66 69
 
67 70
 	$context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any'];
@@ -83,11 +86,13 @@  discard block
 block discarded – undo
83 86
 		'not_redirection' => true,
84 87
 	);
85 88
 
86
-	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board)
87
-		$options['selected_board'] = $_SESSION['move_to_topic'];
89
+	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) {
90
+			$options['selected_board'] = $_SESSION['move_to_topic'];
91
+	}
88 92
 
89
-	if (!$context['move_any'])
90
-		$options['included_boards'] = $boards;
93
+	if (!$context['move_any']) {
94
+			$options['included_boards'] = $boards;
95
+	}
91 96
 
92 97
 	require_once($sourcedir . '/Subs-MessageIndex.php');
93 98
 	$context['categories'] = getBoardList($options);
@@ -138,12 +143,14 @@  discard block
 block discarded – undo
138 143
 	global $txt, $topic, $scripturl, $sourcedir, $context;
139 144
 	global $board, $language, $user_info, $smcFunc;
140 145
 
141
-	if (empty($topic))
142
-		fatal_lang_error('no_access', false);
146
+	if (empty($topic)) {
147
+			fatal_lang_error('no_access', false);
148
+	}
143 149
 
144 150
 	// You can't choose to have a redirection topic and use an empty reason.
145
-	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == ''))
146
-		fatal_lang_error('movetopic_no_reason', false);
151
+	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) {
152
+			fatal_lang_error('movetopic_no_reason', false);
153
+	}
147 154
 
148 155
 	moveTopicConcurrence();
149 156
 
@@ -163,16 +170,18 @@  discard block
 block discarded – undo
163 170
 	$smcFunc['db_free_result']($request);
164 171
 
165 172
 	// Can they see it?
166
-	if (!$context['is_approved'])
167
-		isAllowedTo('approve_posts');
173
+	if (!$context['is_approved']) {
174
+			isAllowedTo('approve_posts');
175
+	}
168 176
 
169 177
 	// Can they move topics on this board?
170 178
 	if (!allowedTo('move_any'))
171 179
 	{
172
-		if ($id_member_started == $user_info['id'])
173
-			isAllowedTo('move_own');
174
-		else
175
-			isAllowedTo('move_any');
180
+		if ($id_member_started == $user_info['id']) {
181
+					isAllowedTo('move_own');
182
+		} else {
183
+					isAllowedTo('move_any');
184
+		}
176 185
 	}
177 186
 
178 187
 	checkSession();
@@ -197,8 +206,9 @@  discard block
 block discarded – undo
197 206
 			'blank_redirect' => '',
198 207
 		)
199 208
 	);
200
-	if ($smcFunc['db_num_rows']($request) == 0)
201
-		fatal_lang_error('no_board');
209
+	if ($smcFunc['db_num_rows']($request) == 0) {
210
+			fatal_lang_error('no_board');
211
+	}
202 212
 	list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request);
203 213
 	$smcFunc['db_free_result']($request);
204 214
 
@@ -210,8 +220,9 @@  discard block
 block discarded – undo
210 220
 	{
211 221
 		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
212 222
 		// Keep checking the length.
213
-		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
214
-			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
223
+		if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
224
+					$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
225
+		}
215 226
 
216 227
 		// If it's still valid move onwards and upwards.
217 228
 		if ($_POST['custom_subject'] != '')
@@ -221,9 +232,9 @@  discard block
 block discarded – undo
221 232
 				// Get a response prefix, but in the forum's default language.
222 233
 				if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
223 234
 				{
224
-					if ($language === $user_info['language'])
225
-						$context['response_prefix'] = $txt['response_prefix'];
226
-					else
235
+					if ($language === $user_info['language']) {
236
+											$context['response_prefix'] = $txt['response_prefix'];
237
+					} else
227 238
 					{
228 239
 						loadLanguage('index', $language, false);
229 240
 						$context['response_prefix'] = $txt['response_prefix'];
@@ -263,8 +274,9 @@  discard block
 block discarded – undo
263 274
 	if (isset($_POST['postRedirect']))
264 275
 	{
265 276
 		// Should be in the boardwide language.
266
-		if ($user_info['language'] != $language)
267
-			loadLanguage('index', $language);
277
+		if ($user_info['language'] != $language) {
278
+					loadLanguage('index', $language);
279
+		}
268 280
 
269 281
 		$_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
270 282
 		preparsecode($_POST['reason']);
@@ -328,8 +340,9 @@  discard block
 block discarded – undo
328 340
 		$posters = array();
329 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
330 342
 		{
331
-			if (!isset($posters[$row['id_member']]))
332
-				$posters[$row['id_member']] = 0;
343
+			if (!isset($posters[$row['id_member']])) {
344
+							$posters[$row['id_member']] = 0;
345
+			}
333 346
 
334 347
 			$posters[$row['id_member']]++;
335 348
 		}
@@ -338,11 +351,13 @@  discard block
 block discarded – undo
338 351
 		foreach ($posters as $id_member => $posts)
339 352
 		{
340 353
 			// The board we're moving from counted posts, but not to.
341
-			if (empty($pcounter_from))
342
-				updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
354
+			if (empty($pcounter_from)) {
355
+							updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
356
+			}
343 357
 			// The reverse: from didn't, to did.
344
-			else
345
-				updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
358
+			else {
359
+							updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
360
+			}
346 361
 		}
347 362
 	}
348 363
 
@@ -350,17 +365,19 @@  discard block
 block discarded – undo
350 365
 	moveTopics($topic, $_POST['toboard']);
351 366
 
352 367
 	// Log that they moved this topic.
353
-	if (!allowedTo('move_own') || $id_member_started != $user_info['id'])
354
-		logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
368
+	if (!allowedTo('move_own') || $id_member_started != $user_info['id']) {
369
+			logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
370
+	}
355 371
 	// Notify people that this topic has been moved?
356 372
 	sendNotifications($topic, 'move');
357 373
 
358 374
 	// Why not go back to the original board in case they want to keep moving?
359
-	if (!isset($_REQUEST['goback']))
360
-		redirectexit('board=' . $board . '.0');
361
-	else
362
-		redirectexit('topic=' . $topic . '.0');
363
-}
375
+	if (!isset($_REQUEST['goback'])) {
376
+			redirectexit('board=' . $board . '.0');
377
+	} else {
378
+			redirectexit('topic=' . $topic . '.0');
379
+	}
380
+	}
364 381
 
365 382
 /**
366 383
  * Moves one or more topics to a specific board. (doesn't check permissions.)
@@ -376,18 +393,21 @@  discard block
 block discarded – undo
376 393
 	global $sourcedir, $user_info, $modSettings, $smcFunc;
377 394
 
378 395
 	// Empty array?
379
-	if (empty($topics))
380
-		return;
396
+	if (empty($topics)) {
397
+			return;
398
+	}
381 399
 
382 400
 	// Only a single topic.
383
-	if (is_numeric($topics))
384
-		$topics = array($topics);
401
+	if (is_numeric($topics)) {
402
+			$topics = array($topics);
403
+	}
385 404
 
386 405
 	$fromBoards = array();
387 406
 
388 407
 	// Destination board empty or equal to 0?
389
-	if (empty($toBoard))
390
-		return;
408
+	if (empty($toBoard)) {
409
+			return;
410
+	}
391 411
 
392 412
 	// Are we moving to the recycle board?
393 413
 	$isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard;
@@ -395,8 +415,9 @@  discard block
 block discarded – undo
395 415
 	// Callback for search APIs to do their thing
396 416
 	require_once($sourcedir . '/Search.php');
397 417
 	$searchAPI = findSearchAPI();
398
-	if ($searchAPI->supportsMethod('topicsMoved'))
399
-		$searchAPI->topicsMoved($topics, $toBoard);
418
+	if ($searchAPI->supportsMethod('topicsMoved')) {
419
+			$searchAPI->topicsMoved($topics, $toBoard);
420
+	}
400 421
 
401 422
 	// Determine the source boards...
402 423
 	$request = $smcFunc['db_query']('', '
@@ -410,8 +431,9 @@  discard block
 block discarded – undo
410 431
 		)
411 432
 	);
412 433
 	// Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards.
413
-	if ($smcFunc['db_num_rows']($request) == 0)
414
-		return;
434
+	if ($smcFunc['db_num_rows']($request) == 0) {
435
+			return;
436
+	}
415 437
 	while ($row = $smcFunc['db_fetch_assoc']($request))
416 438
 	{
417 439
 		if (!isset($fromBoards[$row['id_board']]['num_posts']))
@@ -429,10 +451,11 @@  discard block
 block discarded – undo
429 451
 		$fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
430 452
 
431 453
 		// Add the topics to the right type.
432
-		if ($row['approved'])
433
-			$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
434
-		else
435
-			$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
454
+		if ($row['approved']) {
455
+					$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
456
+		} else {
457
+					$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
458
+		}
436 459
 	}
437 460
 	$smcFunc['db_free_result']($request);
438 461
 
@@ -558,13 +581,14 @@  discard block
 block discarded – undo
558 581
 			)
559 582
 		);
560 583
 		$approval_msgs = array();
561
-		while ($row = $smcFunc['db_fetch_assoc']($request))
562
-			$approval_msgs[] = $row['id_msg'];
584
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
585
+					$approval_msgs[] = $row['id_msg'];
586
+		}
563 587
 		$smcFunc['db_free_result']($request);
564 588
 
565 589
 		// Empty the approval queue for these, as we're going to approve them next.
566
-		if (!empty($approval_msgs))
567
-			$smcFunc['db_query']('', '
590
+		if (!empty($approval_msgs)) {
591
+					$smcFunc['db_query']('', '
568 592
 				DELETE FROM {db_prefix}approval_queue
569 593
 				WHERE id_msg IN ({array_int:message_list})
570 594
 					AND id_attach = {int:id_attach}',
@@ -573,6 +597,7 @@  discard block
 block discarded – undo
573 597
 					'id_attach' => 0,
574 598
 				)
575 599
 			);
600
+		}
576 601
 
577 602
 		// Get all the current max and mins.
578 603
 		$request = $smcFunc['db_query']('', '
@@ -606,8 +631,8 @@  discard block
 block discarded – undo
606 631
 		while ($row = $smcFunc['db_fetch_assoc']($request))
607 632
 		{
608 633
 			// If not, update.
609
-			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max'])
610
-				$smcFunc['db_query']('', '
634
+			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) {
635
+							$smcFunc['db_query']('', '
611 636
 					UPDATE {db_prefix}topics
612 637
 					SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg}
613 638
 					WHERE id_topic = {int:selected_topic}',
@@ -617,6 +642,7 @@  discard block
 block discarded – undo
617 642
 						'selected_topic' => $row['id_topic'],
618 643
 					)
619 644
 				);
645
+			}
620 646
 		}
621 647
 		$smcFunc['db_free_result']($request);
622 648
 	}
@@ -675,9 +701,10 @@  discard block
 block discarded – undo
675 701
 	}
676 702
 
677 703
 	// Update the cache?
678
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
679
-		foreach ($topics as $topic_id)
704
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) {
705
+			foreach ($topics as $topic_id)
680 706
 			cache_put_data('topic_board-' . $topic_id, null, 120);
707
+	}
681 708
 
682 709
 	require_once($sourcedir . '/Subs-Post.php');
683 710
 
@@ -701,15 +728,17 @@  discard block
 block discarded – undo
701 728
 {
702 729
 	global $board, $topic, $smcFunc, $scripturl;
703 730
 
704
-	if (isset($_GET['current_board']))
705
-		$move_from = (int) $_GET['current_board'];
731
+	if (isset($_GET['current_board'])) {
732
+			$move_from = (int) $_GET['current_board'];
733
+	}
706 734
 
707
-	if (empty($move_from) || empty($board) || empty($topic))
708
-		return true;
735
+	if (empty($move_from) || empty($board) || empty($topic)) {
736
+			return true;
737
+	}
709 738
 
710
-	if ($move_from == $board)
711
-		return true;
712
-	else
739
+	if ($move_from == $board) {
740
+			return true;
741
+	} else
713 742
 	{
714 743
 		$request = $smcFunc['db_query']('', '
715 744
 			SELECT m.subject, b.name
Please login to merge, or discard this patch.
Sources/ManageErrors.php 1 patch
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * View the forum's error log.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 
36 38
 	// Check for the administrative permission to do this.
37 39
 	isAllowedTo('admin_forum');
@@ -85,8 +87,8 @@  discard block
 block discarded – undo
85 87
 	);
86 88
 
87 89
 	// Set up the filtering...
88
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
89
-		$filter = array(
90
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
91
+			$filter = array(
90 92
 			'variable' => $_GET['filter'],
91 93
 			'value' => array(
92 94
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -94,10 +96,12 @@  discard block
 block discarded – undo
94 96
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
95 97
 			'entity' => $filters[$_GET['filter']]['txt']
96 98
 		);
99
+	}
97 100
 
98 101
 	// Deleting, are we?
99
-	if (isset($_POST['delall']) || isset($_POST['delete']))
100
-		deleteErrors();
102
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
103
+			deleteErrors();
104
+	}
101 105
 
102 106
 	// Just how many errors are there?
103 107
 	$result = $smcFunc['db_query']('', '
@@ -112,12 +116,14 @@  discard block
 block discarded – undo
112 116
 	$smcFunc['db_free_result']($result);
113 117
 
114 118
 	// If this filter is empty...
115
-	if ($num_errors == 0 && isset($filter))
116
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
119
+	if ($num_errors == 0 && isset($filter)) {
120
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
121
+	}
117 122
 
118 123
 	// Clean up start.
119
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
120
-		$_GET['start'] = 0;
124
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
125
+			$_GET['start'] = 0;
126
+	}
121 127
 
122 128
 	// Do we want to reverse error listing?
123 129
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -127,9 +133,9 @@  discard block
 block discarded – undo
127 133
 	$context['start'] = $_GET['start'];
128 134
 
129 135
 	// Update the error count
130
-	if (!isset($filter))
131
-		$context['num_errors'] = $num_errors;
132
-	else
136
+	if (!isset($filter)) {
137
+			$context['num_errors'] = $num_errors;
138
+	} else
133 139
 	{
134 140
 		// We want all errors, not just the number of filtered messages...
135 141
 		$query = $smcFunc['db_query']('', '
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
162 168
 	{
163 169
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164
-		if ($search_message == $filter['value']['sql'])
165
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
170
+		if ($search_message == $filter['value']['sql']) {
171
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
172
+		}
166 173
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
167 174
 
168 175
 		$context['errors'][$row['id_error']] = array(
@@ -221,8 +228,9 @@  discard block
 block discarded – undo
221 228
 				'members' => count($members),
222 229
 			)
223 230
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($request))
225
-			$members[$row['id_member']] = $row;
231
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
232
+					$members[$row['id_member']] = $row;
233
+		}
226 234
 		$smcFunc['db_free_result']($request);
227 235
 
228 236
 		// This is a guest...
@@ -254,20 +262,18 @@  discard block
 block discarded – undo
254 262
 			$id = $filter['value']['sql'];
255 263
 			loadMemberData($id, false, 'minimal');
256 264
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
257
-		}
258
-		elseif ($filter['variable'] == 'url')
259
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
260
-		elseif ($filter['variable'] == 'message')
265
+		} elseif ($filter['variable'] == 'url') {
266
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
267
+		} elseif ($filter['variable'] == 'message')
261 268
 		{
262 269
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
263 270
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
264
-		}
265
-		elseif ($filter['variable'] == 'error_type')
271
+		} elseif ($filter['variable'] == 'error_type')
266 272
 		{
267 273
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
274
+		} else {
275
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
268 276
 		}
269
-		else
270
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
271 277
 	}
272 278
 
273 279
 	$context['error_types'] = array();
@@ -308,10 +314,11 @@  discard block
 block discarded – undo
308 314
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
309 315
 
310 316
 	// Finally, work out what is the last tab!
311
-	if (isset($context['error_types'][$sum]))
312
-		$context['error_types'][$sum]['is_last'] = true;
313
-	else
314
-		$context['error_types']['all']['is_last'] = true;
317
+	if (isset($context['error_types'][$sum])) {
318
+			$context['error_types'][$sum]['is_last'] = true;
319
+	} else {
320
+			$context['error_types']['all']['is_last'] = true;
321
+	}
315 322
 
316 323
 	// And this is pretty basic ;).
317 324
 	$context['page_title'] = $txt['errlog'];
@@ -337,21 +344,23 @@  discard block
 block discarded – undo
337 344
 	validateToken('admin-el');
338 345
 
339 346
 	// Delete all or just some?
340
-	if (isset($_POST['delall']) && !isset($filter))
341
-		$smcFunc['db_query']('truncate_table', '
347
+	if (isset($_POST['delall']) && !isset($filter)) {
348
+			$smcFunc['db_query']('truncate_table', '
342 349
 			TRUNCATE {db_prefix}log_errors',
343 350
 			array(
344 351
 			)
345 352
 		);
353
+	}
346 354
 	// Deleting all with a filter?
347
-	elseif (isset($_POST['delall']) && isset($filter))
348
-		$smcFunc['db_query']('', '
355
+	elseif (isset($_POST['delall']) && isset($filter)) {
356
+			$smcFunc['db_query']('', '
349 357
 			DELETE FROM {db_prefix}log_errors
350 358
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
351 359
 			array(
352 360
 				'filter' => $filter['value']['sql'],
353 361
 			)
354 362
 		);
363
+	}
355 364
 	// Just specific errors?
356 365
 	elseif (!empty($_POST['delete']))
357 366
 	{
@@ -397,15 +406,17 @@  discard block
 block discarded – undo
397 406
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
398 407
 
399 408
 	// Make sure the file we are looking for is one they are allowed to look at
400
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
401
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
409
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
410
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
411
+	}
402 412
 
403 413
 	// get the min and max lines
404 414
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
405 415
 	$max = $line + 21; // One additional line to make everything work out correctly
406 416
 
407
-	if ($max <= 0 || $min >= $max)
408
-		fatal_lang_error('error_bad_line');
417
+	if ($max <= 0 || $min >= $max) {
418
+			fatal_lang_error('error_bad_line');
419
+	}
409 420
 
410 421
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
411 422
 
Please login to merge, or discard this patch.