Completed
Push — release-2.1 ( aa21c4...7040ad )
by Mathias
09:20
created
Themes/default/Packages.template.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1096,7 +1096,7 @@
 block discarded – undo
1096 1096
 /**
1097 1097
  * CHMOD control form
1098 1098
  *
1099
- * @return bool False if nothing to do.
1099
+ * @return false|null False if nothing to do.
1100 1100
  */
1101 1101
 function template_control_chmod()
1102 1102
 {
Please login to merge, or discard this patch.
Braces   +144 added lines, -104 removed lines patch added patch discarded remove patch
@@ -31,12 +31,13 @@  discard block
 block discarded – undo
31 31
 		</div>
32 32
 		<div class="information">';
33 33
 
34
-	if ($context['is_installed'])
35
-		echo '
34
+	if ($context['is_installed']) {
35
+			echo '
36 36
 			<strong>', $txt['package_installed_warning1'], '</strong><br>
37 37
 			<br>
38 38
 			', $txt['package_installed_warning2'], '<br>
39 39
 			<br>';
40
+	}
40 41
 
41 42
 	echo $txt['package_installed_warning3'], '
42 43
 		</div><br>';
@@ -63,8 +64,9 @@  discard block
 block discarded – undo
63 64
 				', $context['package_readme'], '
64 65
 				<span class="floatright">', $txt['package_available_readme_language'], '
65 66
 					<select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
66
-						foreach ($context['readmes'] as $a => $b)
67
-							echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
67
+						foreach ($context['readmes'] as $a => $b) {
68
+													echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
69
+						}
68 70
 			echo '
69 71
 					</select>
70 72
 				</span>
@@ -83,8 +85,9 @@  discard block
 block discarded – undo
83 85
 				', $context['package_license'], '
84 86
 				<span class="floatright">', $txt['package_available_license_language'], '
85 87
 					<select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
86
-						foreach ($context['licenses'] as $a => $b)
87
-							echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
88
+						foreach ($context['licenses'] as $a => $b) {
89
+													echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
90
+						}
88 91
 			echo '
89 92
 					</select>
90 93
 				</span>
@@ -110,9 +113,10 @@  discard block
 block discarded – undo
110 113
 					', $txt['package_db_uninstall_actions'], ':
111 114
 					<ul>';
112 115
 
113
-		foreach ($context['database_changes'] as $change)
114
-			echo '
116
+		foreach ($context['database_changes'] as $change) {
117
+					echo '
115 118
 						<li>', $change, '</li>';
119
+		}
116 120
 		echo '
117 121
 					</ul>
118 122
 				</div>
@@ -122,14 +126,14 @@  discard block
 block discarded – undo
122 126
 	echo '
123 127
 			<div class="information">';
124 128
 
125
-	if (empty($context['actions']) && empty($context['database_changes']))
126
-		echo '
129
+	if (empty($context['actions']) && empty($context['database_changes'])) {
130
+			echo '
127 131
 				<br>
128 132
 				<div class="errorbox">
129 133
 					', $txt['corrupt_compatible'], '
130 134
 				</div>
131 135
 			</div>';
132
-	else
136
+	} else
133 137
 	{
134 138
 		echo '
135 139
 					', $txt['perform_actions'], '
@@ -229,9 +233,10 @@  discard block
 block discarded – undo
229 233
 					<tr class="title_bar">
230 234
 						<td></td>
231 235
 						<td>';
232
-				if (!empty($context['themes_locked']))
233
-					echo '
236
+				if (!empty($context['themes_locked'])) {
237
+									echo '
234 238
 							<input type="hidden" name="custom_theme[]" value="', $id, '">';
239
+				}
235 240
 				echo '
236 241
 							<input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" class="input_check" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '>
237 242
 						</td>
@@ -372,14 +377,15 @@  discard block
 block discarded – undo
372 377
 	</script>';
373 378
 
374 379
 	// And a bit more for database changes.
375
-	if (!empty($context['database_changes']))
376
-		echo '
380
+	if (!empty($context['database_changes'])) {
381
+			echo '
377 382
 	<script>
378 383
 		var database_changes_area = document.getElementById(\'db_changes_div\');
379 384
 		var db_vis = false;
380 385
 		database_changes_area.style.display = "none";
381 386
 	</script>';
382
-}
387
+	}
388
+	}
383 389
 
384 390
 /**
385 391
  * Extract package contents
@@ -411,12 +417,12 @@  discard block
 block discarded – undo
411 417
 				<h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
412 418
 			</div>
413 419
 			<div class="information">', $txt['package_installed_extract'], '</div>';
414
-	}
415
-	else
416
-		echo '
420
+	} else {
421
+			echo '
417 422
 			<div class="cat_bar">
418 423
 				<h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
419 424
 			</div>';
425
+	}
420 426
 
421 427
 	echo '
422 428
 		<div class="windowbg">';
@@ -427,25 +433,25 @@  discard block
 block discarded – undo
427 433
 		echo '
428 434
 			', $context['redirect_text'], '<br><br>
429 435
 			<a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
430
-	}
431
-	elseif ($context['uninstalling'])
432
-		echo '
436
+	} elseif ($context['uninstalling']) {
437
+			echo '
433 438
 			', $txt['package_uninstall_done'];
434
-	elseif ($context['install_finished'])
439
+	} elseif ($context['install_finished'])
435 440
 	{
436
-		if ($context['extract_type'] == 'avatar')
437
-			echo '
441
+		if ($context['extract_type'] == 'avatar') {
442
+					echo '
438 443
 				', $txt['avatars_extracted'];
439
-		elseif ($context['extract_type'] == 'language')
440
-			echo '
444
+		} elseif ($context['extract_type'] == 'language') {
445
+					echo '
441 446
 				', $txt['language_extracted'];
442
-		else
443
-			echo '
447
+		} else {
448
+					echo '
444 449
 				', $txt['package_installed_done'];
445
-	}
446
-	else
447
-		echo '
450
+		}
451
+	} else {
452
+			echo '
448 453
 			', $txt['corrupt_compatible'];
454
+	}
449 455
 
450 456
 	echo '
451 457
 		</div>';
@@ -479,9 +485,10 @@  discard block
 block discarded – undo
479 485
 		<div class="windowbg">
480 486
 			<ol>';
481 487
 
482
-	foreach ($context['files'] as $fileinfo)
483
-		echo '
488
+	foreach ($context['files'] as $fileinfo) {
489
+			echo '
484 490
 				<li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
491
+	}
485 492
 
486 493
 	echo '
487 494
 			</ol>
@@ -545,9 +552,10 @@  discard block
 block discarded – undo
545 552
 			</script>
546 553
 			<div id="yourVersion" style="display:none">', $context['forum_version'], '</div>';
547 554
 
548
-	if (empty($modSettings['disable_smf_js']))
549
-		echo '
555
+	if (empty($modSettings['disable_smf_js'])) {
556
+			echo '
550 557
 			<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
558
+	}
551 559
 
552 560
 	// This sets the announcements and current versions themselves ;).
553 561
 	echo '
@@ -586,12 +594,13 @@  discard block
 block discarded – undo
586 594
 		}
587 595
 	}
588 596
 
589
-	if (!$mods_available)
590
-		echo '
597
+	if (!$mods_available) {
598
+			echo '
591 599
 		<div class="noticebox">', $txt['no_packages'], '</div>';
592
-	else
593
-		echo '
600
+	} else {
601
+			echo '
594 602
 		<br>';
603
+	}
595 604
 
596 605
 	// the advanced (emulation) box, collapsed by default
597 606
 	echo '
@@ -680,11 +689,12 @@  discard block
 block discarded – undo
680 689
 {
681 690
 	global $context, $txt, $scripturl;
682 691
 
683
-	if (!empty($context['package_ftp']['error']))
684
-			echo '
692
+	if (!empty($context['package_ftp']['error'])) {
693
+				echo '
685 694
 					<div class="errorbox">
686 695
 						<pre>', $context['package_ftp']['error'], '</pre>
687 696
 					</div>';
697
+	}
688 698
 
689 699
 	echo '
690 700
 	<div id="admin_form_wrapper">
@@ -765,13 +775,14 @@  discard block
 block discarded – undo
765 775
 				<fieldset>
766 776
 					<legend>' . $txt['package_servers'] . '</legend>
767 777
 					<ul class="package_servers">';
768
-	foreach ($context['servers'] as $server)
769
-		echo '
778
+	foreach ($context['servers'] as $server) {
779
+			echo '
770 780
 						<li class="flow_auto">
771 781
 							<span class="floatleft">' . $server['name'] . '</span>
772 782
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
773 783
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
774 784
 						</li>';
785
+	}
775 786
 	echo '
776 787
 					</ul>
777 788
 				</fieldset>
@@ -858,11 +869,12 @@  discard block
 block discarded – undo
858 869
 		<div class="windowbg2">';
859 870
 
860 871
 	// No packages, as yet.
861
-	if (empty($context['package_list']))
862
-		echo '
872
+	if (empty($context['package_list'])) {
873
+			echo '
863 874
 			<ul>
864 875
 				<li>', $txt['no_packages'], '</li>
865 876
 			</ul>';
877
+	}
866 878
 	// List out the packages...
867 879
 	else
868 880
 	{
@@ -874,11 +886,12 @@  discard block
 block discarded – undo
874 886
 				<li>
875 887
 					<strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
876 888
 
877
-			if (!empty($packageSection['text']))
878
-				echo '
889
+			if (!empty($packageSection['text'])) {
890
+							echo '
879 891
 					<div class="sub_bar">
880 892
 						<h3 class="subbg">', $packageSection['text'], '</h3>
881 893
 					</div>';
894
+			}
882 895
 
883 896
 			echo '
884 897
 					<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
@@ -888,13 +901,15 @@  discard block
 block discarded – undo
888 901
 				echo '
889 902
 						<li>';
890 903
 				// Textual message. Could be empty just for a blank line...
891
-				if ($package['is_text'])
892
-					echo '
904
+				if ($package['is_text']) {
905
+									echo '
893 906
 							', empty($package['name']) ? '&nbsp;' : $package['name'];
907
+				}
894 908
 				// This is supposed to be a rule..
895
-				elseif ($package['is_line'])
896
-					echo '
909
+				elseif ($package['is_line']) {
910
+									echo '
897 911
 						<hr>';
912
+				}
898 913
 				// A remote link.
899 914
 				elseif ($package['is_remote'])
900 915
 				{
@@ -916,21 +931,25 @@  discard block
 block discarded – undo
916 931
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
917 932
 
918 933
 					// Show the mod type?
919
-					if ($package['type'] != '')
920
-						echo '
934
+					if ($package['type'] != '') {
935
+											echo '
921 936
 							<li class="package_section">', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>';
937
+					}
922 938
 					// Show the version number?
923
-					if ($package['version'] != '')
924
-						echo '
939
+					if ($package['version'] != '') {
940
+											echo '
925 941
 							<li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
942
+					}
926 943
 					// How 'bout the author?
927
-					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
928
-						echo '
944
+					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
945
+											echo '
929 946
 							<li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
947
+					}
930 948
 					// The homepage....
931
-					if ($package['author']['website']['link'] != '')
932
-						echo '
949
+					if ($package['author']['website']['link'] != '') {
950
+											echo '
933 951
 							<li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
952
+					}
934 953
 
935 954
 					// Desciption: bleh bleh!
936 955
 					// Location of file: http://someplace/.
@@ -983,8 +1002,8 @@  discard block
 block discarded – undo
983 1002
 
984 1003
 				foreach ($ps['items'] as $id => $package)
985 1004
 				{
986
-					if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
987
-						echo '
1005
+					if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) {
1006
+											echo '
988 1007
 				var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
989 1008
 					bToggleEnabled: true,
990 1009
 					bCurrentlyCollapsed: true,
@@ -999,6 +1018,7 @@  discard block
 block discarded – undo
999 1018
 						}
1000 1019
 					]
1001 1020
 				});';
1021
+					}
1002 1022
 				}
1003 1023
 			}
1004 1024
 			echo '
@@ -1039,9 +1059,10 @@  discard block
 block discarded – undo
1039 1059
 {
1040 1060
 	global $context, $txt, $scripturl;
1041 1061
 
1042
-	if (!empty($context['saved_successful']))
1043
-		echo '
1062
+	if (!empty($context['saved_successful'])) {
1063
+			echo '
1044 1064
 	<div class="infobox">', $txt['settings_saved'], '</div>';
1065
+	}
1045 1066
 
1046 1067
 	echo '
1047 1068
 	<div id="admincenter">
@@ -1103,8 +1124,9 @@  discard block
 block discarded – undo
1103 1124
 	global $context, $txt;
1104 1125
 
1105 1126
 	// Nothing to do? Brilliant!
1106
-	if (empty($context['package_ftp']))
1107
-		return false;
1127
+	if (empty($context['package_ftp'])) {
1128
+			return false;
1129
+	}
1108 1130
 
1109 1131
 	if (empty($context['package_ftp']['form_elements_only']))
1110 1132
 	{
@@ -1113,19 +1135,21 @@  discard block
 block discarded – undo
1113 1135
 				<div id="need_writable_list" class="smalltext">
1114 1136
 					', $txt['package_ftp_why_file_list'], '
1115 1137
 					<ul style="display: inline;">';
1116
-		if (!empty($context['notwritable_files']))
1117
-			foreach ($context['notwritable_files'] as $file)
1138
+		if (!empty($context['notwritable_files'])) {
1139
+					foreach ($context['notwritable_files'] as $file)
1118 1140
 				echo '
1119 1141
 						<li>', $file, '</li>';
1142
+		}
1120 1143
 
1121 1144
 		echo '
1122 1145
 					</ul>';
1123 1146
 
1124
-		if (!$context['server']['is_windows'])
1125
-			echo '
1147
+		if (!$context['server']['is_windows']) {
1148
+					echo '
1126 1149
 				<hr>
1127 1150
 				', $txt['package_chmod_linux'], '<br />
1128 1151
 				<tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>';
1152
+		}
1129 1153
 
1130 1154
 		echo '
1131 1155
 				</div>';
@@ -1136,9 +1160,10 @@  discard block
 block discarded – undo
1136 1160
 					<tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt>
1137 1161
 				</div></div>';
1138 1162
 
1139
-	if (!empty($context['package_ftp']['destination']))
1140
-		echo '
1163
+	if (!empty($context['package_ftp']['destination'])) {
1164
+			echo '
1141 1165
 				<form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
1166
+	}
1142 1167
 
1143 1168
 	echo '
1144 1169
 					<fieldset>
@@ -1171,25 +1196,28 @@  discard block
 block discarded – undo
1171 1196
 					</dl>
1172 1197
 					</fieldset>';
1173 1198
 
1174
-	if (empty($context['package_ftp']['form_elements_only']))
1175
-		echo '
1199
+	if (empty($context['package_ftp']['form_elements_only'])) {
1200
+			echo '
1176 1201
 
1177 1202
 					<div class="righttext" style="margin: 1ex;">
1178 1203
 						<span id="test_ftp_placeholder_full"></span>
1179 1204
 						<input type="submit" value="', $txt['package_proceed'], '" class="button_submit">
1180 1205
 					</div>';
1206
+	}
1181 1207
 
1182
-	if (!empty($context['package_ftp']['destination']))
1183
-		echo '
1208
+	if (!empty($context['package_ftp']['destination'])) {
1209
+			echo '
1184 1210
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1185 1211
 				</form>';
1212
+	}
1186 1213
 
1187 1214
 	// Hide the details of the list.
1188
-	if (empty($context['package_ftp']['form_elements_only']))
1189
-		echo '
1215
+	if (empty($context['package_ftp']['form_elements_only'])) {
1216
+			echo '
1190 1217
 		<script>
1191 1218
 			document.getElementById(\'need_writable_list\').style.display = \'none\';
1192 1219
 		</script>';
1220
+	}
1193 1221
 
1194 1222
 	// Quick generate the test button.
1195 1223
 	echo '
@@ -1545,9 +1573,10 @@  discard block
 block discarded – undo
1545 1573
 				<tr class="windowbg">
1546 1574
 					<td width="30%"><strong>';
1547 1575
 
1548
-				if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1549
-					echo '
1576
+				if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1577
+									echo '
1550 1578
 						<span class="generic_icons folder"></span>';
1579
+				}
1551 1580
 
1552 1581
 				echo '
1553 1582
 						', $name, '
@@ -1564,8 +1593,9 @@  discard block
 block discarded – undo
1564 1593
 				</tr>
1565 1594
 			';
1566 1595
 
1567
-		if (!empty($dir['contents']))
1568
-			template_permission_show_contents($name, $dir['contents'], 1);
1596
+		if (!empty($dir['contents'])) {
1597
+					template_permission_show_contents($name, $dir['contents'], 1);
1598
+		}
1569 1599
 	}
1570 1600
 
1571 1601
 	echo '
@@ -1601,13 +1631,14 @@  discard block
 block discarded – undo
1601 1631
 			</fieldset>';
1602 1632
 
1603 1633
 	// Likely to need FTP?
1604
-	if (empty($context['ftp_connected']))
1605
-		echo '
1634
+	if (empty($context['ftp_connected'])) {
1635
+			echo '
1606 1636
 			<p>
1607 1637
 				', $txt['package_file_perms_ftp_details'], ':
1608 1638
 			</p>
1609 1639
 			', template_control_chmod(), '
1610 1640
 			<div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>';
1641
+	}
1611 1642
 
1612 1643
 	echo '
1613 1644
 			<span id="test_ftp_placeholder_full"></span>
@@ -1616,9 +1647,10 @@  discard block
 block discarded – undo
1616 1647
 		</div>';
1617 1648
 
1618 1649
 	// Any looks fors we've already done?
1619
-	foreach ($context['look_for'] as $path)
1620
-		echo '
1650
+	foreach ($context['look_for'] as $path) {
1651
+			echo '
1621 1652
 			<input type="hidden" name="back_look[]" value="', $path, '">';
1653
+	}
1622 1654
 	echo '
1623 1655
 	</form><br>';
1624 1656
 }
@@ -1657,9 +1689,10 @@  discard block
 block discarded – undo
1657 1689
 				<td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
1658 1690
 					', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : '';
1659 1691
 
1660
-			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1661
-				echo '
1692
+			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1693
+							echo '
1662 1694
 						<span class="generic_icons folder"></span>';
1695
+			}
1663 1696
 
1664 1697
 			echo '
1665 1698
 					', $name, '
@@ -1685,14 +1718,15 @@  discard block
 block discarded – undo
1685 1718
 	}
1686 1719
 
1687 1720
 	// We have more files to show?
1688
-	if ($has_more)
1689
-		echo '
1721
+	if ($has_more) {
1722
+			echo '
1690 1723
 	<tr class="windowbg" id="content_', $js_ident, '_more">
1691 1724
 		<td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
1692 1725
 			&#171; <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> &#187;
1693 1726
 		</td>
1694 1727
 		<td colspan="6"></td>
1695 1728
 	</tr>';
1729
+	}
1696 1730
 
1697 1731
 	if ($drawn_div)
1698 1732
 	{
@@ -1700,15 +1734,17 @@  discard block
 block discarded – undo
1700 1734
 		$isFound = false;
1701 1735
 		foreach ($context['look_for'] as $tree)
1702 1736
 		{
1703
-			if (substr($tree, 0, strlen($ident)) == $ident)
1704
-				$isFound = true;
1737
+			if (substr($tree, 0, strlen($ident)) == $ident) {
1738
+							$isFound = true;
1739
+			}
1705 1740
 		}
1706 1741
 
1707
-		if ($level > 1 && !$isFound)
1708
-			echo '
1742
+		if ($level > 1 && !$isFound) {
1743
+					echo '
1709 1744
 		<script>
1710 1745
 			expandFolder(\'', $js_ident, '\', \'\');
1711 1746
 		</script>';
1747
+		}
1712 1748
 	}
1713 1749
 }
1714 1750
 
@@ -1728,11 +1764,12 @@  discard block
 block discarded – undo
1728 1764
 				<h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
1729 1765
 			</div>';
1730 1766
 
1731
-	if (!empty($context['skip_ftp']))
1732
-		echo '
1767
+	if (!empty($context['skip_ftp'])) {
1768
+			echo '
1733 1769
 			<div class="errorbox">
1734 1770
 				', $txt['package_file_perms_skipping_ftp'], '
1735 1771
 			</div>';
1772
+	}
1736 1773
 
1737 1774
 	// How many have we done?
1738 1775
 	$remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
@@ -1770,28 +1807,31 @@  discard block
 block discarded – undo
1770 1807
 				<br>';
1771 1808
 
1772 1809
 	// Put out the right hidden data.
1773
-	if ($context['method'] == 'individual')
1774
-		echo '
1810
+	if ($context['method'] == 'individual') {
1811
+			echo '
1775 1812
 				<input type="hidden" name="custom_value" value="', $context['custom_value'], '">
1776 1813
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1777 1814
 				<input type="hidden" name="toProcess" value="', base64_encode(json_encode($context['to_process'])), '">';
1778
-	else
1779
-		echo '
1815
+	} else {
1816
+			echo '
1780 1817
 				<input type="hidden" name="predefined" value="', $context['predefined_type'], '">
1781 1818
 				<input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
1782 1819
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1783 1820
 				<input type="hidden" name="dirList" value="', base64_encode(json_encode($context['directory_list'])), '">
1784 1821
 				<input type="hidden" name="specialFiles" value="', base64_encode(json_encode($context['special_files'])), '">';
1822
+	}
1785 1823
 
1786 1824
 	// Are we not using FTP for whatever reason.
1787
-	if (!empty($context['skip_ftp']))
1788
-		echo '
1825
+	if (!empty($context['skip_ftp'])) {
1826
+			echo '
1789 1827
 				<input type="hidden" name="skip_ftp" value="1">';
1828
+	}
1790 1829
 
1791 1830
 	// Retain state.
1792
-	foreach ($context['back_look_data'] as $path)
1793
-		echo '
1831
+	foreach ($context['back_look_data'] as $path) {
1832
+			echo '
1794 1833
 				<input type="hidden" name="back_look[]" value="', $path, '">';
1834
+	}
1795 1835
 
1796 1836
 	echo '
1797 1837
 				<input type="hidden" name="method" value="', $context['method'], '">
Please login to merge, or discard this patch.
Sources/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Attachments.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		// Just send a generic message.
77 77
 		else
78 78
 			$this->setResponse(array(
79
-				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
79
+				'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error',
80 80
 				'type' => 'error',
81 81
 				'data' => false,
82 82
 			));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			// Gotta urlencode the filename.
405 405
 			if ($this->_attachResults)
406 406
 				foreach ($this->_attachResults as $k => $v)
407
-					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
407
+					$this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']);
408 408
 
409 409
 			$this->_response = array(
410 410
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			ob_start();
432 432
 
433 433
 		// Set the header.
434
-		header('Content-Type: application/json; charset='. $context['character_set'] .'');
434
+		header('Content-Type: application/json; charset=' . $context['character_set'] . '');
435 435
 
436 436
 		echo json_encode($this->_response ? $this->_response : array());
437 437
 
Please login to merge, or discard this patch.
Braces   +102 added lines, -75 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
 class Attachments
20 21
 {
@@ -70,16 +71,18 @@  discard block
 block discarded – undo
70 71
 
71 72
 		$this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false;
72 73
 
73
-		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions))
74
-			$this->{$this->_sa}();
74
+		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) {
75
+					$this->{$this->_sa}();
76
+		}
75 77
 
76 78
 		// Just send a generic message.
77
-		else
78
-			$this->setResponse(array(
79
+		else {
80
+					$this->setResponse(array(
79 81
 				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
80 82
 				'type' => 'error',
81 83
 				'data' => false,
82 84
 			));
85
+		}
83 86
 
84 87
 		// Back to the future, oh, to the browser!
85 88
 		$this->sendResponse();
@@ -95,12 +98,13 @@  discard block
 block discarded – undo
95 98
 		$attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0;
96 99
 
97 100
 		// Need something to work with.
98
-		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID])))
99
-			return $this->setResponse(array(
101
+		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) {
102
+					return $this->setResponse(array(
100 103
 				'text' => 'attached_file_deleted_error',
101 104
 				'type' => 'error',
102 105
 				'data' => false,
103 106
 			));
107
+		}
104 108
 
105 109
 		// Lets pass some params and see what happens :P
106 110
 		$affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true);
@@ -119,19 +123,21 @@  discard block
 block discarded – undo
119 123
 	public function add()
120 124
 	{
121 125
 		// You gotta be able to post attachments.
122
-		if (!$this->_canPostAttachment)
123
-			return $this->setResponse(array(
126
+		if (!$this->_canPostAttachment) {
127
+					return $this->setResponse(array(
124 128
 				'text' => 'attached_file_cannot',
125 129
 				'type' => 'error',
126 130
 				'data' => false,
127 131
 			));
132
+		}
128 133
 
129 134
 		// Process them at once!
130 135
 		$this->processAttachments();
131 136
 
132 137
 		// The attachments was created and moved the the right folder, time to update the DB.
133
-		if (!empty($_SESSION['temp_attachments']))
134
-			$this->createAtttach();
138
+		if (!empty($_SESSION['temp_attachments'])) {
139
+					$this->createAtttach();
140
+		}
135 141
 
136 142
 		// Set the response.
137 143
 		$this->setResponse();
@@ -144,8 +150,9 @@  discard block
 block discarded – undo
144 150
 	{
145 151
 		global $context, $modSettings, $smcFunc, $user_info, $txt;
146 152
 
147
-		if (!isset($_FILES['attachment']['name']))
148
-			$_FILES['attachment']['tmp_name'] = array();
153
+		if (!isset($_FILES['attachment']['name'])) {
154
+					$_FILES['attachment']['tmp_name'] = array();
155
+		}
149 156
 
150 157
 		// If there are attachments, calculate the total size and how many.
151 158
 		$context['attachments']['total_size'] = 0;
@@ -155,25 +162,30 @@  discard block
 block discarded – undo
155 162
 		if (isset($_REQUEST['msg']))
156 163
 		{
157 164
 			$context['attachments']['quantity'] = count($context['current_attachments']);
158
-			foreach ($context['current_attachments'] as $attachment)
159
-				$context['attachments']['total_size'] += $attachment['size'];
165
+			foreach ($context['current_attachments'] as $attachment) {
166
+							$context['attachments']['total_size'] += $attachment['size'];
167
+			}
160 168
 		}
161 169
 
162 170
 		// A bit of house keeping first.
163
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
164
-			unset($_SESSION['temp_attachments']);
171
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
172
+					unset($_SESSION['temp_attachments']);
173
+		}
165 174
 
166 175
 		// Our infamous SESSION var, we are gonna have soo much fun with it!
167
-		if (!isset($_SESSION['temp_attachments']))
168
-			$_SESSION['temp_attachments'] = array();
176
+		if (!isset($_SESSION['temp_attachments'])) {
177
+					$_SESSION['temp_attachments'] = array();
178
+		}
169 179
 
170 180
 		// Make sure we're uploading to the right place.
171
-		if (!empty($modSettings['automanage_attachments']))
172
-			automanage_attachments_check_directory();
181
+		if (!empty($modSettings['automanage_attachments'])) {
182
+					automanage_attachments_check_directory();
183
+		}
173 184
 
174 185
 		// Is the attachments folder actually there?
175
-		if (!empty($context['dir_creation_error']))
176
-			$this->_generalErrors[] = $context['dir_creation_error'];
186
+		if (!empty($context['dir_creation_error'])) {
187
+					$this->_generalErrors[] = $context['dir_creation_error'];
188
+		}
177 189
 
178 190
 		// The current attach folder ha some issues...
179 191
 		elseif (!is_dir($this->_attchDir))
@@ -198,13 +210,12 @@  discard block
 block discarded – undo
198 210
 			);
199 211
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
200 212
 			$smcFunc['db_free_result']($request);
201
-		}
202
-
203
-		else
204
-			$context['attachments'] = array(
213
+		} else {
214
+					$context['attachments'] = array(
205 215
 				'quantity' => 0,
206 216
 				'total_size' => 0,
207 217
 			);
218
+		}
208 219
 
209 220
 		// Check for other general errors here.
210 221
 
@@ -212,9 +223,10 @@  discard block
 block discarded – undo
212 223
 		if (!empty($this->_generalErrors))
213 224
 		{
214 225
 			// And delete the files 'cos they ain't going nowhere.
215
-			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
216
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
226
+			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
227
+							if (file_exists($_FILES['attachment']['tmp_name'][$n]))
217 228
 					unlink($_FILES['attachment']['tmp_name'][$n]);
229
+			}
218 230
 
219 231
 			$_FILES['attachment']['tmp_name'] = array();
220 232
 
@@ -225,26 +237,29 @@  discard block
 block discarded – undo
225 237
 		// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
226 238
 		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
227 239
 		{
228
-			if ($_FILES['attachment']['name'][$n] == '')
229
-				continue;
240
+			if ($_FILES['attachment']['name'][$n] == '') {
241
+							continue;
242
+			}
230 243
 
231 244
 			// First, let's first check for PHP upload errors.
232 245
 			$errors = array();
233 246
 			if (!empty($_FILES['attachment']['error'][$n]))
234 247
 			{
235
-				if ($_FILES['attachment']['error'][$n] == 2)
236
-					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
237
-
238
-				else
239
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
248
+				if ($_FILES['attachment']['error'][$n] == 2) {
249
+									$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
250
+				} else {
251
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
252
+				}
240 253
 
241 254
 				// Log this one, because...
242
-				if ($_FILES['attachment']['error'][$n] == 6)
243
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
255
+				if ($_FILES['attachment']['error'][$n] == 6) {
256
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
257
+				}
244 258
 
245 259
 				// Weird, no errors were cached, still fill out a generic one.
246
-				if (empty($errors))
247
-					$errors[] = 'attach_php_error';
260
+				if (empty($errors)) {
261
+									$errors[] = 'attach_php_error';
262
+				}
248 263
 			}
249 264
 
250 265
 			// Try to move and rename the file before doing any more checks on it.
@@ -256,8 +271,9 @@  discard block
 block discarded – undo
256 271
 			{
257 272
 				// The reported MIME type of the attachment might not be reliable.
258 273
 				// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
259
-				if (function_exists('mime_content_type'))
260
-					$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
274
+				if (function_exists('mime_content_type')) {
275
+									$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
276
+				}
261 277
 
262 278
 				$_SESSION['temp_attachments'][$attachID] = array(
263 279
 					'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -269,16 +285,18 @@  discard block
 block discarded – undo
269 285
 				);
270 286
 
271 287
 				// Move the file to the attachments folder with a temp name for now.
272
-				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
273
-					smf_chmod($destName, 0644);
288
+				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
289
+									smf_chmod($destName, 0644);
290
+				}
274 291
 
275 292
 				// This is madness!!
276 293
 				else
277 294
 				{
278 295
 					// File couldn't be moved.
279 296
 					$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
280
-					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
281
-						unlink($_FILES['attachment']['tmp_name'][$n]);
297
+					if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
298
+											unlink($_FILES['attachment']['tmp_name'][$n]);
299
+					}
282 300
 				}
283 301
 			}
284 302
 
@@ -291,13 +309,15 @@  discard block
 block discarded – undo
291 309
 					'errors' => $errors,
292 310
 				);
293 311
 
294
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
295
-					unlink($_FILES['attachment']['tmp_name'][$n]);
312
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
313
+									unlink($_FILES['attachment']['tmp_name'][$n]);
314
+				}
296 315
 			}
297 316
 
298 317
 			// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
299
-			if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
300
-				attachmentChecks($attachID);
318
+			if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
319
+							attachmentChecks($attachID);
320
+			}
301 321
 		}
302 322
 
303 323
 		// Mod authors, finally a hook to hang an alternate attachment upload system upon
@@ -344,14 +364,15 @@  discard block
 block discarded – undo
344 364
 
345 365
 					$_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID'];
346 366
 
347
-					if (!empty($attachmentOptions['thumb']))
348
-						$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
367
+					if (!empty($attachmentOptions['thumb'])) {
368
+											$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
369
+					}
349 370
 
350
-					if ($this->_msg)
351
-						assignAttachments($_SESSION['already_attached'], $this->_msg);
371
+					if ($this->_msg) {
372
+											assignAttachments($_SESSION['already_attached'], $this->_msg);
373
+					}
352 374
 				}
353
-			}
354
-			else
375
+			} else
355 376
 			{
356 377
 				// Sort out the errors for display and delete any associated files.
357 378
 				$log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file');
@@ -363,14 +384,16 @@  discard block
 block discarded – undo
363 384
 					if (!is_array($error))
364 385
 					{
365 386
 						$attachmentOptions['errors'][] = $txt[$error];
366
-						if (in_array($error, $log_these))
367
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
387
+						if (in_array($error, $log_these)) {
388
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
389
+						}
390
+					} else {
391
+											$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
368 392
 					}
369
-					else
370
-						$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
371 393
 				}
372
-				if (file_exists($attachment['tmp_name']))
373
-					unlink($attachment['tmp_name']);
394
+				if (file_exists($attachment['tmp_name'])) {
395
+									unlink($attachment['tmp_name']);
396
+				}
374 397
 			}
375 398
 
376 399
 			// Regardless of errors, pass the results.
@@ -378,8 +401,9 @@  discard block
 block discarded – undo
378 401
 		}
379 402
 
380 403
 		// Temp save this on the db.
381
-		if (!empty($_SESSION['already_attached']))
382
-			$this->_attachSuccess = $_SESSION['already_attached'];
404
+		if (!empty($_SESSION['already_attached'])) {
405
+					$this->_attachSuccess = $_SESSION['already_attached'];
406
+		}
383 407
 
384 408
 		unset($_SESSION['temp_attachments']);
385 409
 	}
@@ -399,14 +423,16 @@  discard block
 block discarded – undo
399 423
 		if ($this->_sa == 'add')
400 424
 		{
401 425
 			// Is there any generic errors? made some sense out of them!
402
-			if ($this->_generalErrors)
403
-				foreach ($this->_generalErrors as $k => $v)
426
+			if ($this->_generalErrors) {
427
+							foreach ($this->_generalErrors as $k => $v)
404 428
 					$this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]);
429
+			}
405 430
 
406 431
 			// Gotta urlencode the filename.
407
-			if ($this->_attachResults)
408
-				foreach ($this->_attachResults as $k => $v)
432
+			if ($this->_attachResults) {
433
+							foreach ($this->_attachResults as $k => $v)
409 434
 					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
435
+			}
410 436
 
411 437
 			$this->_response = array(
412 438
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -415,9 +441,10 @@  discard block
 block discarded – undo
415 441
 		}
416 442
 
417 443
 		// Rest of us mere mortals gets no special treatment...
418
-		elseif (!empty($data))
419
-			if (!empty($data['text']) && !empty($txt[$data['text']]))
444
+		elseif (!empty($data)) {
445
+					if (!empty($data['text']) && !empty($txt[$data['text']]))
420 446
 				$this->_response['text'] = $txt[$data['text']];
447
+		}
421 448
 	}
422 449
 
423 450
 	protected function sendResponse()
@@ -426,11 +453,11 @@  discard block
 block discarded – undo
426 453
 
427 454
 		ob_end_clean();
428 455
 
429
-		if (!empty($modSettings['CompressedOutput']))
430
-			@ob_start('ob_gzhandler');
431
-
432
-		else
433
-			ob_start();
456
+		if (!empty($modSettings['CompressedOutput'])) {
457
+					@ob_start('ob_gzhandler');
458
+		} else {
459
+					ob_start();
460
+		}
434 461
 
435 462
 		// Set the header.
436 463
 		header('Content-Type: application/json; charset='. $context['character_set'] .'');
Please login to merge, or discard this patch.
Sources/ManagePosts.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,6 @@
 block discarded – undo
273 273
  * Modify any setting related to topics.
274 274
  * Requires the admin_forum permission.
275 275
  * Accessed from ?action=admin;area=postsettings;sa=topics.
276
-
277 276
  * @param bool $return_config Whether or not to return the config_vars array (used for admin search)
278 277
  * @return void|array Returns nothing or returns $config_vars if $return_config is true
279 278
  * @uses Admin template, edit_topic_settings sub-template.
Please login to merge, or discard this patch.
Braces   +39 added lines, -29 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
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -221,8 +225,9 @@  discard block
 block discarded – undo
221 225
 
222 226
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
223 227
 
224
-	if ($return_config)
225
-		return $config_vars;
228
+	if ($return_config) {
229
+			return $config_vars;
230
+	}
226 231
 
227 232
 	// We'll want this for our easy save.
228 233
 	require_once($sourcedir . '/ManageServer.php');
@@ -242,17 +247,20 @@  discard block
 block discarded – undo
242 247
 			db_extend('packages');
243 248
 
244 249
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
245
-			foreach ($colData as $column)
246
-				if ($column['name'] == 'body')
250
+			foreach ($colData as $column) {
251
+							if ($column['name'] == 'body')
247 252
 					$body_type = $column['type'];
253
+			}
248 254
 
249
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
250
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
255
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
256
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
257
+			}
251 258
 		}
252 259
 
253 260
 		// If we're changing the post preview length let's check its valid
254
-		if (!empty($_POST['preview_characters']))
255
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
261
+		if (!empty($_POST['preview_characters'])) {
262
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
263
+		}
256 264
 
257 265
 		call_integration_hook('integrate_save_post_settings');
258 266
 
@@ -313,8 +321,9 @@  discard block
 block discarded – undo
313 321
 
314 322
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
315 323
 
316
-	if ($return_config)
317
-		return $config_vars;
324
+	if ($return_config) {
325
+			return $config_vars;
326
+	}
318 327
 
319 328
 	// Get the settings template ready.
320 329
 	require_once($sourcedir . '/ManageServer.php');
@@ -367,8 +376,9 @@  discard block
 block discarded – undo
367 376
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
368 377
 	);
369 378
 
370
-	if ($return_config)
371
-		return $config_vars;
379
+	if ($return_config) {
380
+			return $config_vars;
381
+	}
372 382
 
373 383
 	// Get the settings template ready.
374 384
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/Who.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 						'Shitiz &quot;Dragooon&quot; Garg',
590 590
 						'Karl &quot;RegularExpression&quot; Benson',
591 591
 						'Matthew &quot;Labradoodle-360&quot; Kerle',
592
-						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf': 'Grudge',
592
+						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf' : 'Grudge',
593 593
 						'Michael &quot;Thantos&quot; Miller',
594 594
 						'Norv',
595 595
 						'Peter "Arantor" Spicer',
@@ -813,13 +813,13 @@  discard block
 block discarded – undo
813 813
 			$credit_info = smf_json_decode($row['credits'], true);
814 814
 
815 815
 			$copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' &copy; ' . $smcFunc['htmlspecialchars']($credit_info['copyright']);
816
-			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
816
+			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
817 817
 			$version = $txt['credits_version'] . ' ' . $row['version'];
818 818
 			$title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version;
819 819
 
820 820
 			// build this one out and stash it away
821 821
 			$mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
822
-			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license  : '') . (!empty($copyright) ? ' | ' . $copyright  : '');
822
+			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : '');
823 823
 		}
824 824
 		cache_put_data('mods_credits', $mods, 86400);
825 825
 	}
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -673,7 +673,7 @@
 block discarded – undo
673 673
 						'Nikola &quot;Dzonny&quot; Novakovi&cacute;',
674 674
 						// Localizers
675 675
 						'Dr. Deejay',
676
-                        			'd3vcho',
676
+									'd3vcho',
677 677
 						// Former Localizers
678 678
 						'Relyana',
679 679
 					),
Please login to merge, or discard this patch.
Braces   +126 added lines, -95 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
  * Who's online, and what are they doing?
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
 	isAllowedTo('who_view');
36 37
 
37 38
 	// You can't do anything if this is off.
38
-	if (empty($modSettings['who_enabled']))
39
-		fatal_lang_error('who_off', false);
39
+	if (empty($modSettings['who_enabled'])) {
40
+			fatal_lang_error('who_off', false);
41
+	}
40 42
 
41 43
 	// Load the 'Who' template.
42 44
 	loadTemplate('Who');
@@ -71,9 +73,9 @@  discard block
 block discarded – undo
71 73
 		$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
72 74
 		$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
73 75
 		$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
76
+	} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
77
+			unset($_SESSION['who_online_filter']);
74 78
 	}
75
-	elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
76
-		unset($_SESSION['who_online_filter']);
77 79
 
78 80
 	// Does the user prefer a different sort direction?
79 81
 	if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
@@ -97,20 +99,24 @@  discard block
 block discarded – undo
97 99
 	$context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
98 100
 
99 101
 	$conditions = array();
100
-	if (!allowedTo('moderate_forum'))
101
-		$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
102
+	if (!allowedTo('moderate_forum')) {
103
+			$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
104
+	}
102 105
 
103 106
 	// Fallback to top filter?
104
-	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
105
-		$_REQUEST['show'] = $_REQUEST['show_top'];
107
+	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
108
+			$_REQUEST['show'] = $_REQUEST['show_top'];
109
+	}
106 110
 	// Does the user wish to apply a filter?
107
-	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
108
-		$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
111
+	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
112
+			$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
113
+	}
109 114
 	// Perhaps we saved a filter earlier in the session?
110
-	elseif (isset($_SESSION['who_online_filter']))
111
-		$context['show_by'] = $_SESSION['who_online_filter'];
112
-	else
113
-		$context['show_by'] = 'members';
115
+	elseif (isset($_SESSION['who_online_filter'])) {
116
+			$context['show_by'] = $_SESSION['who_online_filter'];
117
+	} else {
118
+			$context['show_by'] = 'members';
119
+	}
114 120
 
115 121
 	$conditions[] = $show_methods[$context['show_by']];
116 122
 
@@ -156,8 +162,9 @@  discard block
 block discarded – undo
156 162
 	while ($row = $smcFunc['db_fetch_assoc']($request))
157 163
 	{
158 164
 		$actions = smf_json_decode($row['url'], true);
159
-		if ($actions === false)
160
-			continue;
165
+		if ($actions === false) {
166
+					continue;
167
+		}
161 168
 
162 169
 		// Send the information to the template.
163 170
 		$context['members'][$row['session']] = array(
@@ -195,8 +202,8 @@  discard block
 block discarded – undo
195 202
 	$spiderContext = array();
196 203
 	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
197 204
 	{
198
-		foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name)
199
-			$spiderContext[$id] = array(
205
+		foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) {
206
+					$spiderContext[$id] = array(
200 207
 				'id' => 0,
201 208
 				'name' => $name,
202 209
 				'group' => $txt['spiders'],
@@ -205,6 +212,7 @@  discard block
 block discarded – undo
205 212
 				'email' => $name,
206 213
 				'is_guest' => true
207 214
 			);
215
+		}
208 216
 	}
209 217
 
210 218
 	$url_data = determineActions($url_data);
@@ -219,16 +227,18 @@  discard block
 block discarded – undo
219 227
 	// Put it in the context variables.
220 228
 	foreach ($context['members'] as $i => $member)
221 229
 	{
222
-		if ($member['id'] != 0)
223
-			$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
230
+		if ($member['id'] != 0) {
231
+					$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
232
+		}
224 233
 
225 234
 		// Keep the IP that came from the database.
226 235
 		$memberContext[$member['id']]['ip'] = $member['ip'];
227 236
 		$context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
228
-		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
229
-			$context['members'][$i] += $spiderContext[$member['id_spider']];
230
-		else
231
-			$context['members'][$i] += $memberContext[$member['id']];
237
+		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) {
238
+					$context['members'][$i] += $spiderContext[$member['id_spider']];
239
+		} else {
240
+					$context['members'][$i] += $memberContext[$member['id']];
241
+		}
232 242
 	}
233 243
 
234 244
 	// Some people can't send personal messages...
@@ -263,8 +273,9 @@  discard block
 block discarded – undo
263 273
 {
264 274
 	global $txt, $user_info, $modSettings, $smcFunc;
265 275
 
266
-	if (!allowedTo('who_view'))
267
-		return array();
276
+	if (!allowedTo('who_view')) {
277
+			return array();
278
+	}
268 279
 	loadLanguage('Who');
269 280
 
270 281
 	// Actions that require a specific permission level.
@@ -292,10 +303,11 @@  discard block
 block discarded – undo
292 303
 	);
293 304
 	call_integration_hook('who_allowed', array(&$allowedActions));
294 305
 
295
-	if (!is_array($urls))
296
-		$url_list = array(array($urls, $user_info['id']));
297
-	else
298
-		$url_list = $urls;
306
+	if (!is_array($urls)) {
307
+			$url_list = array(array($urls, $user_info['id']));
308
+	} else {
309
+			$url_list = $urls;
310
+	}
299 311
 
300 312
 	// These are done to later query these in large chunks. (instead of one by one.)
301 313
 	$topic_ids = array();
@@ -307,12 +319,14 @@  discard block
 block discarded – undo
307 319
 	{
308 320
 		// Get the request parameters..
309 321
 		$actions = smf_json_decode($url[0], true);
310
-		if ($actions === false)
311
-			continue;
322
+		if ($actions === false) {
323
+					continue;
324
+		}
312 325
 
313 326
 		// If it's the admin or moderation center, and there is an area set, use that instead.
314
-		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
315
-			$actions['action'] = $actions['area'];
327
+		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) {
328
+					$actions['action'] = $actions['area'];
329
+		}
316 330
 
317 331
 		// Check if there was no action or the action is display.
318 332
 		if (!isset($actions['action']) || $actions['action'] == 'display')
@@ -332,12 +346,14 @@  discard block
 block discarded – undo
332 346
 				$board_ids[$actions['board']][$k] = $txt['who_board'];
333 347
 			}
334 348
 			// It's the board index!!  It must be!
335
-			else
336
-				$data[$k] = $txt['who_index'];
349
+			else {
350
+							$data[$k] = $txt['who_index'];
351
+			}
337 352
 		}
338 353
 		// Probably an error or some goon?
339
-		elseif ($actions['action'] == '')
340
-			$data[$k] = $txt['who_index'];
354
+		elseif ($actions['action'] == '') {
355
+					$data[$k] = $txt['who_index'];
356
+		}
341 357
 		// Some other normal action...?
342 358
 		else
343 359
 		{
@@ -345,23 +361,25 @@  discard block
 block discarded – undo
345 361
 			if ($actions['action'] == 'profile')
346 362
 			{
347 363
 				// Whose?  Their own?
348
-				if (empty($actions['u']))
349
-					$actions['u'] = $url[1];
364
+				if (empty($actions['u'])) {
365
+									$actions['u'] = $url[1];
366
+				}
350 367
 
351 368
 				$data[$k] = $txt['who_hidden'];
352 369
 				$profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile'];
353
-			}
354
-			elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
370
+			} elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
355 371
 			{
356 372
 				$data[$k] = $txt['who_hidden'];
357 373
 				$board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
358 374
 			}
359 375
 			// A subaction anyone can view... if the language string is there, show it.
360
-			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
361
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
376
+			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) {
377
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
378
+			}
362 379
 			// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
363
-			elseif (isset($txt['whoall_' . $actions['action']]))
364
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
380
+			elseif (isset($txt['whoall_' . $actions['action']])) {
381
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
382
+			}
365 383
 			// Viewable if and only if they can see the board...
366 384
 			elseif (isset($txt['whotopic_' . $actions['action']]))
367 385
 			{
@@ -370,8 +388,7 @@  discard block
 block discarded – undo
370 388
 
371 389
 				$data[$k] = $txt['who_hidden'];
372 390
 				$topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
373
-			}
374
-			elseif (isset($txt['whopost_' . $actions['action']]))
391
+			} elseif (isset($txt['whopost_' . $actions['action']]))
375 392
 			{
376 393
 				// Find out what message they are accessing.
377 394
 				$msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
@@ -394,41 +411,46 @@  discard block
 block discarded – undo
394 411
 				$data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
395 412
 				$smcFunc['db_free_result']($result);
396 413
 
397
-				if (empty($id_topic))
398
-					$data[$k] = $txt['who_hidden'];
414
+				if (empty($id_topic)) {
415
+									$data[$k] = $txt['who_hidden'];
416
+				}
399 417
 			}
400 418
 			// Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
401
-			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
402
-				$data[$k] = $txt['whoadmin_' . $actions['action']];
419
+			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) {
420
+							$data[$k] = $txt['whoadmin_' . $actions['action']];
421
+			}
403 422
 			// Viewable by permission level.
404 423
 			elseif (isset($allowedActions[$actions['action']]))
405 424
 			{
406
-				if (allowedTo($allowedActions[$actions['action']]))
407
-					$data[$k] = $txt['whoallow_' . $actions['action']];
408
-				elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
409
-					$data[$k] = $txt['who_moderate'];
410
-				elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
411
-					$data[$k] = $txt['who_admin'];
412
-				else
413
-					$data[$k] = $txt['who_hidden'];
425
+				if (allowedTo($allowedActions[$actions['action']])) {
426
+									$data[$k] = $txt['whoallow_' . $actions['action']];
427
+				} elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) {
428
+									$data[$k] = $txt['who_moderate'];
429
+				} elseif (in_array('admin_forum', $allowedActions[$actions['action']])) {
430
+									$data[$k] = $txt['who_admin'];
431
+				} else {
432
+									$data[$k] = $txt['who_hidden'];
433
+				}
434
+			} elseif (!empty($actions['action'])) {
435
+							$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
436
+			} else {
437
+							$data[$k] = $txt['who_unknown'];
414 438
 			}
415
-			elseif (!empty($actions['action']))
416
-				$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
417
-			else
418
-				$data[$k] = $txt['who_unknown'];
419 439
 		}
420 440
 
421 441
 		if (isset($actions['error']))
422 442
 		{
423
-			if (isset($txt[$actions['error']]))
424
-				$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
425
-			elseif ($actions['error'] == 'guest_login')
426
-				$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
427
-			else
428
-				$error_message = str_replace('"', '&quot;', $actions['error']);
429
-
430
-			if (!empty($error_message))
431
-				$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
443
+			if (isset($txt[$actions['error']])) {
444
+							$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
445
+			} elseif ($actions['error'] == 'guest_login') {
446
+							$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
447
+			} else {
448
+							$error_message = str_replace('"', '&quot;', $actions['error']);
449
+			}
450
+
451
+			if (!empty($error_message)) {
452
+							$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
453
+			}
432 454
 		}
433 455
 
434 456
 		// Maybe the action is integrated into another system?
@@ -439,12 +461,15 @@  discard block
 block discarded – undo
439 461
 				if (!empty($integrate_action))
440 462
 				{
441 463
 					$data[$k] = $integrate_action;
442
-					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k]))
443
-						$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
444
-					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k]))
445
-						$board_ids[(int) $actions['board']][$k] = $integrate_action;
446
-					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k]))
447
-						$profile_ids[(int) $actions['u']][$k] = $integrate_action;
464
+					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) {
465
+											$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
466
+					}
467
+					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) {
468
+											$board_ids[(int) $actions['board']][$k] = $integrate_action;
469
+					}
470
+					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) {
471
+											$profile_ids[(int) $actions['u']][$k] = $integrate_action;
472
+					}
448 473
 					break;
449 474
 				}
450 475
 			}
@@ -472,8 +497,9 @@  discard block
 block discarded – undo
472 497
 		while ($row = $smcFunc['db_fetch_assoc']($result))
473 498
 		{
474 499
 			// Show the topic's subject for each of the actions.
475
-			foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
476
-				$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
500
+			foreach ($topic_ids[$row['id_topic']] as $k => $session_text) {
501
+							$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
502
+			}
477 503
 		}
478 504
 		$smcFunc['db_free_result']($result);
479 505
 	}
@@ -495,8 +521,9 @@  discard block
 block discarded – undo
495 521
 		while ($row = $smcFunc['db_fetch_assoc']($result))
496 522
 		{
497 523
 			// Put the board name into the string for each member...
498
-			foreach ($board_ids[$row['id_board']] as $k => $session_text)
499
-				$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
524
+			foreach ($board_ids[$row['id_board']] as $k => $session_text) {
525
+							$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
526
+			}
500 527
 		}
501 528
 		$smcFunc['db_free_result']($result);
502 529
 	}
@@ -518,23 +545,26 @@  discard block
 block discarded – undo
518 545
 		while ($row = $smcFunc['db_fetch_assoc']($result))
519 546
 		{
520 547
 			// If they aren't allowed to view this person's profile, skip it.
521
-			if (!$allow_view_any && ($user_info['id'] != $row['id_member']))
522
-				continue;
548
+			if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) {
549
+							continue;
550
+			}
523 551
 
524 552
 			// Set their action on each - session/text to sprintf.
525
-			foreach ($profile_ids[$row['id_member']] as $k => $session_text)
526
-				$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
553
+			foreach ($profile_ids[$row['id_member']] as $k => $session_text) {
554
+							$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
555
+			}
527 556
 		}
528 557
 		$smcFunc['db_free_result']($result);
529 558
 	}
530 559
 
531 560
 	call_integration_hook('whos_online_after', array(&$urls, &$data));
532 561
 
533
-	if (!is_array($urls))
534
-		return isset($data[0]) ? $data[0] : false;
535
-	else
536
-		return $data;
537
-}
562
+	if (!is_array($urls)) {
563
+			return isset($data[0]) ? $data[0] : false;
564
+	} else {
565
+			return $data;
566
+	}
567
+	}
538 568
 
539 569
 /**
540 570
  * It prepares credit and copyright information for the credits page or the admin page
@@ -710,8 +740,8 @@  discard block
 block discarded – undo
710 740
 	);
711 741
 
712 742
 	// Give the translators some credit for their hard work.
713
-	if (!empty($txt['translation_credits']))
714
-		$context['credits'][] = array(
743
+	if (!empty($txt['translation_credits'])) {
744
+			$context['credits'][] = array(
715 745
 			'title' => $txt['credits_groups_translation'],
716 746
 			'groups' => array(
717 747
 				array(
@@ -720,6 +750,7 @@  discard block
 block discarded – undo
720 750
 				),
721 751
 			),
722 752
 		);
753
+	}
723 754
 
724 755
 	$context['credits'][] = array(
725 756
 		'title' => $txt['credits_special'],
Please login to merge, or discard this patch.
Sources/Recent.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	else
238 238
 	{
239 239
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240
-					AND b.id_board != {int:recycle_board}' : ''). '
240
+					AND b.id_board != {int:recycle_board}' : '') . '
241 241
 					AND m.id_msg >= {int:max_id_msg}';
242 242
 		$query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6);
243 243
 		$query_parameters['recycle_board'] = $modSettings['recycle_board'];
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 			);
1125 1125
 		else
1126 1126
 			$request = $smcFunc['db_query']('', '
1127
-				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1127
+				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . '
1128 1128
 				FROM {db_prefix}topics AS t
1129 1129
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
1130 1130
 					INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : '
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 	if ($is_topics)
1392 1392
 	{
1393 1393
 		$context['recent_buttons'] = array(
1394
-			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1394
+			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1395
 		);
1396 1396
 
1397 1397
 		if ($context['showCheckboxes'])
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1408
 	{
1409 1409
 		$context['recent_buttons'] = array(
1410
-			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1410
+			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1411
 		);
1412 1412
 
1413 1413
 		if ($context['showCheckboxes'])
Please login to merge, or discard this patch.
Braces   +208 added lines, -170 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
  * Get the latest post made on the system
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 			'is_approved' => 1,
45 46
 		)
46 47
 	);
47
-	if ($smcFunc['db_num_rows']($request) == 0)
48
-		return array();
48
+	if ($smcFunc['db_num_rows']($request) == 0) {
49
+			return array();
50
+	}
49 51
 	$row = $smcFunc['db_fetch_assoc']($request);
50 52
 	$smcFunc['db_free_result']($request);
51 53
 
@@ -54,8 +56,9 @@  discard block
 block discarded – undo
54 56
 	censorText($row['body']);
55 57
 
56 58
 	$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => '&#10;')));
57
-	if ($smcFunc['strlen']($row['body']) > 128)
58
-		$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
59
+	if ($smcFunc['strlen']($row['body']) > 128) {
60
+			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
61
+	}
59 62
 
60 63
 	// Send the data.
61 64
 	return array(
@@ -83,15 +86,17 @@  discard block
 block discarded – undo
83 86
 
84 87
 	$context['is_redirect'] = false;
85 88
 
86
-	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95)
87
-		$_REQUEST['start'] = 95;
89
+	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) {
90
+			$_REQUEST['start'] = 95;
91
+	}
88 92
 
89 93
 	$query_parameters = array();
90 94
 	if (!empty($_REQUEST['c']) && empty($board))
91 95
 	{
92 96
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
93
-		foreach ($_REQUEST['c'] as $i => $c)
94
-			$_REQUEST['c'][$i] = (int) $c;
97
+		foreach ($_REQUEST['c'] as $i => $c) {
98
+					$_REQUEST['c'][$i] = (int) $c;
99
+		}
95 100
 
96 101
 		if (count($_REQUEST['c']) == 1)
97 102
 		{
@@ -107,8 +112,9 @@  discard block
 block discarded – undo
107 112
 			list ($name) = $smcFunc['db_fetch_row']($request);
108 113
 			$smcFunc['db_free_result']($request);
109 114
 
110
-			if (empty($name))
111
-				fatal_lang_error('no_access', false);
115
+			if (empty($name)) {
116
+							fatal_lang_error('no_access', false);
117
+			}
112 118
 
113 119
 			$context['linktree'][] = array(
114 120
 				'url' => $scripturl . '#c' . (int) $_REQUEST['c'],
@@ -140,8 +146,9 @@  discard block
 block discarded – undo
140 146
 		}
141 147
 		$smcFunc['db_free_result']($request);
142 148
 
143
-		if (empty($boards))
144
-			fatal_lang_error('error_no_boards_selected');
149
+		if (empty($boards)) {
150
+					fatal_lang_error('error_no_boards_selected');
151
+		}
145 152
 
146 153
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
147 154
 		$query_parameters['boards'] = $boards;
@@ -155,12 +162,12 @@  discard block
 block discarded – undo
155 162
 		}
156 163
 
157 164
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false);
158
-	}
159
-	elseif (!empty($_REQUEST['boards']))
165
+	} elseif (!empty($_REQUEST['boards']))
160 166
 	{
161 167
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
162
-		foreach ($_REQUEST['boards'] as $i => $b)
163
-			$_REQUEST['boards'][$i] = (int) $b;
168
+		foreach ($_REQUEST['boards'] as $i => $b) {
169
+					$_REQUEST['boards'][$i] = (int) $b;
170
+		}
164 171
 
165 172
 		$request = $smcFunc['db_query']('', '
166 173
 			SELECT b.id_board, b.num_posts
@@ -184,8 +191,9 @@  discard block
 block discarded – undo
184 191
 		}
185 192
 		$smcFunc['db_free_result']($request);
186 193
 
187
-		if (empty($boards))
188
-			fatal_lang_error('error_no_boards_selected');
194
+		if (empty($boards)) {
195
+					fatal_lang_error('error_no_boards_selected');
196
+		}
189 197
 
190 198
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
191 199
 		$query_parameters['boards'] = $boards;
@@ -199,8 +207,7 @@  discard block
 block discarded – undo
199 207
 		}
200 208
 
201 209
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false);
202
-	}
203
-	elseif (!empty($board))
210
+	} elseif (!empty($board))
204 211
 	{
205 212
 		$request = $smcFunc['db_query']('', '
206 213
 			SELECT num_posts, redirect
@@ -233,8 +240,7 @@  discard block
 block discarded – undo
233 240
 		}
234 241
 
235 242
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true);
236
-	}
237
-	else
243
+	} else
238 244
 	{
239 245
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240 246
 					AND b.id_board != {int:recycle_board}' : ''). '
@@ -269,8 +275,9 @@  discard block
 block discarded – undo
269 275
 	);
270 276
 
271 277
 	// If you selected a redirection board, don't try getting posts for it...
272
-	if ($context['is_redirect'])
273
-		$messages = 0;
278
+	if ($context['is_redirect']) {
279
+			$messages = 0;
280
+	}
274 281
 
275 282
 	$key = 'recent-' . $user_info['id'] . '-' . md5(json_encode(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start'];
276 283
 	if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null))
@@ -301,16 +308,18 @@  discard block
 block discarded – undo
301 308
 				$query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board);
302 309
 				$cache_results = true;
303 310
 				unset($query_parameters['max_id_msg']);
311
+			} else {
312
+							$done = true;
304 313
 			}
305
-			else
306
-				$done = true;
307 314
 		}
308 315
 		$messages = array();
309
-		while ($row = $smcFunc['db_fetch_assoc']($request))
310
-			$messages[] = $row['id_msg'];
316
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
317
+					$messages[] = $row['id_msg'];
318
+		}
311 319
 		$smcFunc['db_free_result']($request);
312
-		if (!empty($cache_results))
313
-			cache_put_data($key, $messages, 120);
320
+		if (!empty($cache_results)) {
321
+					cache_put_data($key, $messages, 120);
322
+		}
314 323
 	}
315 324
 
316 325
 	// Nothing here... Or at least, nothing you can see...
@@ -397,8 +406,9 @@  discard block
 block discarded – undo
397 406
 			'css_class' => 'windowbg',
398 407
 		);
399 408
 
400
-		if ($user_info['id'] == $row['id_first_member'])
401
-			$board_ids['own'][$row['id_board']][] = $row['id_msg'];
409
+		if ($user_info['id'] == $row['id_first_member']) {
410
+					$board_ids['own'][$row['id_board']][] = $row['id_msg'];
411
+		}
402 412
 		$board_ids['any'][$row['id_board']][] = $row['id_msg'];
403 413
 	}
404 414
 	$smcFunc['db_free_result']($request);
@@ -424,20 +434,23 @@  discard block
 block discarded – undo
424 434
 			$boards = boardsAllowedTo($permission);
425 435
 
426 436
 			// If 0 is the only thing in the array, they can do it everywhere!
427
-			if (!empty($boards) && $boards[0] == 0)
428
-				$boards = array_keys($board_ids[$type]);
437
+			if (!empty($boards) && $boards[0] == 0) {
438
+							$boards = array_keys($board_ids[$type]);
439
+			}
429 440
 
430 441
 			// Go through the boards, and look for posts they can do this on.
431 442
 			foreach ($boards as $board_id)
432 443
 			{
433 444
 				// Hmm, they have permission, but there are no topics from that board on this page.
434
-				if (!isset($board_ids[$type][$board_id]))
435
-					continue;
445
+				if (!isset($board_ids[$type][$board_id])) {
446
+									continue;
447
+				}
436 448
 
437 449
 				// Okay, looks like they can do it for these posts.
438
-				foreach ($board_ids[$type][$board_id] as $counter)
439
-					if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
450
+				foreach ($board_ids[$type][$board_id] as $counter) {
451
+									if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
440 452
 						$context['posts'][$counter][$allowed] = true;
453
+				}
441 454
 			}
442 455
 		}
443 456
 	}
@@ -480,17 +493,19 @@  discard block
 block discarded – undo
480 493
 	$context['showing_all_topics'] = isset($_GET['all']);
481 494
 	$context['start'] = (int) $_REQUEST['start'];
482 495
 	$context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
483
-	if ($_REQUEST['action'] == 'unread')
484
-		$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
485
-	else
486
-		$context['page_title'] = $txt['unread_replies'];
496
+	if ($_REQUEST['action'] == 'unread') {
497
+			$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
498
+	} else {
499
+			$context['page_title'] = $txt['unread_replies'];
500
+	}
487 501
 
488
-	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread'])
489
-		fatal_lang_error('loadavg_allunread_disabled', false);
490
-	elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies'])
491
-		fatal_lang_error('loadavg_unreadreplies_disabled', false);
492
-	elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread'])
493
-		fatal_lang_error('loadavg_unread_disabled', false);
502
+	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) {
503
+			fatal_lang_error('loadavg_allunread_disabled', false);
504
+	} elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) {
505
+			fatal_lang_error('loadavg_unreadreplies_disabled', false);
506
+	} elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) {
507
+			fatal_lang_error('loadavg_unread_disabled', false);
508
+	}
494 509
 
495 510
 	// Parameters for the main query.
496 511
 	$query_parameters = array();
@@ -503,12 +518,14 @@  discard block
 block discarded – undo
503 518
 		if (!empty($_REQUEST['boards']))
504 519
 		{
505 520
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
506
-			foreach ($_REQUEST['boards'] as $b)
507
-				$boards[] = (int) $b;
521
+			foreach ($_REQUEST['boards'] as $b) {
522
+							$boards[] = (int) $b;
523
+			}
508 524
 		}
509 525
 
510
-		if (!empty($board))
511
-			$boards[] = (int) $board;
526
+		if (!empty($board)) {
527
+					$boards[] = (int) $board;
528
+		}
512 529
 
513 530
 		// The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
514 531
 		$request = $smcFunc['db_query']('', '
@@ -525,30 +542,31 @@  discard block
 block discarded – undo
525 542
 			)
526 543
 		);
527 544
 
528
-		while ($row = $smcFunc['db_fetch_assoc']($request))
529
-			if (in_array($row['id_parent'], $boards))
545
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
546
+					if (in_array($row['id_parent'], $boards))
530 547
 				$boards[] = $row['id_board'];
548
+		}
531 549
 
532 550
 		$smcFunc['db_free_result']($request);
533 551
 
534
-		if (empty($boards))
535
-			fatal_lang_error('error_no_boards_selected');
552
+		if (empty($boards)) {
553
+					fatal_lang_error('error_no_boards_selected');
554
+		}
536 555
 
537 556
 		$query_this_board = 'id_board IN ({array_int:boards})';
538 557
 		$query_parameters['boards'] = $boards;
539 558
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
540
-	}
541
-	elseif (!empty($board))
559
+	} elseif (!empty($board))
542 560
 	{
543 561
 		$query_this_board = 'id_board = {int:board}';
544 562
 		$query_parameters['board'] = $board;
545 563
 		$context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
546
-	}
547
-	elseif (!empty($_REQUEST['boards']))
564
+	} elseif (!empty($_REQUEST['boards']))
548 565
 	{
549 566
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
550
-		foreach ($_REQUEST['boards'] as $i => $b)
551
-			$_REQUEST['boards'][$i] = (int) $b;
567
+		foreach ($_REQUEST['boards'] as $i => $b) {
568
+					$_REQUEST['boards'][$i] = (int) $b;
569
+		}
552 570
 
553 571
 		$request = $smcFunc['db_query']('', '
554 572
 			SELECT b.id_board
@@ -560,22 +578,24 @@  discard block
 block discarded – undo
560 578
 			)
561 579
 		);
562 580
 		$boards = array();
563
-		while ($row = $smcFunc['db_fetch_assoc']($request))
564
-			$boards[] = $row['id_board'];
581
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
582
+					$boards[] = $row['id_board'];
583
+		}
565 584
 		$smcFunc['db_free_result']($request);
566 585
 
567
-		if (empty($boards))
568
-			fatal_lang_error('error_no_boards_selected');
586
+		if (empty($boards)) {
587
+					fatal_lang_error('error_no_boards_selected');
588
+		}
569 589
 
570 590
 		$query_this_board = 'id_board IN ({array_int:boards})';
571 591
 		$query_parameters['boards'] = $boards;
572 592
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
573
-	}
574
-	elseif (!empty($_REQUEST['c']))
593
+	} elseif (!empty($_REQUEST['c']))
575 594
 	{
576 595
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
577
-		foreach ($_REQUEST['c'] as $i => $c)
578
-			$_REQUEST['c'][$i] = (int) $c;
596
+		foreach ($_REQUEST['c'] as $i => $c) {
597
+					$_REQUEST['c'][$i] = (int) $c;
598
+		}
579 599
 
580 600
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
581 601
 		$request = $smcFunc['db_query']('', '
@@ -588,18 +608,19 @@  discard block
 block discarded – undo
588 608
 			)
589 609
 		);
590 610
 		$boards = array();
591
-		while ($row = $smcFunc['db_fetch_assoc']($request))
592
-			$boards[] = $row['id_board'];
611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
612
+					$boards[] = $row['id_board'];
613
+		}
593 614
 		$smcFunc['db_free_result']($request);
594 615
 
595
-		if (empty($boards))
596
-			fatal_lang_error('error_no_boards_selected');
616
+		if (empty($boards)) {
617
+					fatal_lang_error('error_no_boards_selected');
618
+		}
597 619
 
598 620
 		$query_this_board = 'id_board IN ({array_int:boards})';
599 621
 		$query_parameters['boards'] = $boards;
600 622
 		$context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
601
-	}
602
-	else
623
+	} else
603 624
 	{
604 625
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
605 626
 		// Don't bother to show deleted posts!
@@ -613,12 +634,14 @@  discard block
 block discarded – undo
613 634
 			)
614 635
 		);
615 636
 		$boards = array();
616
-		while ($row = $smcFunc['db_fetch_assoc']($request))
617
-			$boards[] = $row['id_board'];
637
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
638
+					$boards[] = $row['id_board'];
639
+		}
618 640
 		$smcFunc['db_free_result']($request);
619 641
 
620
-		if (empty($boards))
621
-			fatal_lang_error('error_no_boards_available', false);
642
+		if (empty($boards)) {
643
+					fatal_lang_error('error_no_boards_available', false);
644
+		}
622 645
 
623 646
 		$query_this_board = 'id_board IN ({array_int:boards})';
624 647
 		$query_parameters['boards'] = $boards;
@@ -680,13 +703,14 @@  discard block
 block discarded – undo
680 703
 		'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies']
681 704
 	);
682 705
 
683
-	if ($context['showing_all_topics'])
684
-		$context['linktree'][] = array(
706
+	if ($context['showing_all_topics']) {
707
+			$context['linktree'][] = array(
685 708
 			'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
686 709
 			'name' => $txt['unread_topics_all']
687 710
 		);
688
-	else
689
-		$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
711
+	} else {
712
+			$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
713
+	}
690 714
 
691 715
 	loadTemplate('Recent');
692 716
 	loadTemplate('MessageIndex');
@@ -694,8 +718,9 @@  discard block
 block discarded – undo
694 718
 
695 719
 	// Setup the default topic icons... for checking they exist and the like ;)
696 720
 	$context['icon_sources'] = array();
697
-	foreach ($context['stable_icons'] as $icon)
698
-		$context['icon_sources'][$icon] = 'images_url';
721
+	foreach ($context['stable_icons'] as $icon) {
722
+			$context['icon_sources'][$icon] = 'images_url';
723
+	}
699 724
 
700 725
 	$is_topics = $_REQUEST['action'] == 'unread';
701 726
 
@@ -725,8 +750,7 @@  discard block
 block discarded – undo
725 750
 			);
726 751
 			list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
727 752
 			$smcFunc['db_free_result']($request);
728
-		}
729
-		else
753
+		} else
730 754
 		{
731 755
 			$request = $smcFunc['db_query']('', '
732 756
 				SELECT MIN(lmr.id_msg)
@@ -742,14 +766,14 @@  discard block
 block discarded – undo
742 766
 		}
743 767
 
744 768
 		// This is needed in case of topics marked unread.
745
-		if (empty($earliest_msg))
746
-			$earliest_msg = 0;
747
-		else
769
+		if (empty($earliest_msg)) {
770
+					$earliest_msg = 0;
771
+		} else
748 772
 		{
749 773
 			// Using caching, when possible, to ignore the below slow query.
750
-			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time())
751
-				$earliest_msg2 = $_SESSION['cached_log_time'][1];
752
-			else
774
+			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) {
775
+							$earliest_msg2 = $_SESSION['cached_log_time'][1];
776
+			} else
753 777
 			{
754 778
 				// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
755 779
 				$request = $smcFunc['db_query']('', '
@@ -764,8 +788,9 @@  discard block
 block discarded – undo
764 788
 				$smcFunc['db_free_result']($request);
765 789
 
766 790
 				// In theory this could be zero, if the first ever post is unread, so fudge it ;)
767
-				if ($earliest_msg2 == 0)
768
-					$earliest_msg2 = -1;
791
+				if ($earliest_msg2 == 0) {
792
+									$earliest_msg2 = -1;
793
+				}
769 794
 
770 795
 				$_SESSION['cached_log_time'] = array(time(), $earliest_msg2);
771 796
 			}
@@ -803,9 +828,9 @@  discard block
 block discarded – undo
803 828
 				'db_error_skip' => true,
804 829
 			))
805 830
 		) !== false;
831
+	} else {
832
+			$have_temp_table = false;
806 833
 	}
807
-	else
808
-		$have_temp_table = false;
809 834
 
810 835
 	if ($context['showing_all_topics'] && $have_temp_table)
811 836
 	{
@@ -851,14 +876,15 @@  discard block
 block discarded – undo
851 876
 
852 877
 			$context['topics'] = array();
853 878
 			$context['no_topic_listing'] = true;
854
-			if ($context['querystring_board_limits'] == ';start=%1$d')
855
-				$context['querystring_board_limits'] = '';
856
-			else
857
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
879
+			if ($context['querystring_board_limits'] == ';start=%1$d') {
880
+							$context['querystring_board_limits'] = '';
881
+			} else {
882
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
883
+			}
858 884
 			return;
885
+		} else {
886
+					$min_message = (int) $min_message;
859 887
 		}
860
-		else
861
-			$min_message = (int) $min_message;
862 888
 
863 889
 		$request = $smcFunc['db_query']('substring', '
864 890
 			SELECT ' . $select_clause . '
@@ -887,8 +913,7 @@  discard block
 block discarded – undo
887 913
 				'limit' => $context['topics_per_page'],
888 914
 			))
889 915
 		);
890
-	}
891
-	elseif ($is_topics)
916
+	} elseif ($is_topics)
892 917
 	{
893 918
 		$request = $smcFunc['db_query']('', '
894 919
 			SELECT COUNT(*), MIN(t.id_last_msg)
@@ -939,14 +964,15 @@  discard block
 block discarded – undo
939 964
 
940 965
 			$context['topics'] = array();
941 966
 			$context['no_topic_listing'] = true;
942
-			if ($context['querystring_board_limits'] == ';start=%d')
943
-				$context['querystring_board_limits'] = '';
944
-			else
945
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
967
+			if ($context['querystring_board_limits'] == ';start=%d') {
968
+							$context['querystring_board_limits'] = '';
969
+			} else {
970
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
971
+			}
946 972
 			return;
973
+		} else {
974
+					$min_message = (int) $min_message;
947 975
 		}
948
-		else
949
-			$min_message = (int) $min_message;
950 976
 
951 977
 		$request = $smcFunc['db_query']('substring', '
952 978
 			SELECT ' . $select_clause . '
@@ -976,8 +1002,7 @@  discard block
 block discarded – undo
976 1002
 				'limit' => $context['topics_per_page'],
977 1003
 			))
978 1004
 		);
979
-	}
980
-	else
1005
+	} else
981 1006
 	{
982 1007
 		if ($modSettings['totalMessages'] > 100000)
983 1008
 		{
@@ -1029,8 +1054,8 @@  discard block
 block discarded – undo
1029 1054
 			) !== false;
1030 1055
 
1031 1056
 			// If that worked, create a sample of the log_topics table too.
1032
-			if ($have_temp_table)
1033
-				$have_temp_table = $smcFunc['db_query']('', '
1057
+			if ($have_temp_table) {
1058
+							$have_temp_table = $smcFunc['db_query']('', '
1034 1059
 					CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in (
1035 1060
 						PRIMARY KEY (id_topic)
1036 1061
 					)
@@ -1043,6 +1068,7 @@  discard block
 block discarded – undo
1043 1068
 						'db_error_skip' => true,
1044 1069
 					)
1045 1070
 				) !== false;
1071
+			}
1046 1072
 		}
1047 1073
 
1048 1074
 		if (!empty($have_temp_table))
@@ -1058,8 +1084,7 @@  discard block
 block discarded – undo
1058 1084
 			);
1059 1085
 			list ($num_topics) = $smcFunc['db_fetch_row']($request);
1060 1086
 			$smcFunc['db_free_result']($request);
1061
-		}
1062
-		else
1087
+		} else
1063 1088
 		{
1064 1089
 			$request = $smcFunc['db_query']('unread_fetch_topic_count', '
1065 1090
 				SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg)
@@ -1100,15 +1125,16 @@  discard block
 block discarded – undo
1100 1125
 		{
1101 1126
 			$context['topics'] = array();
1102 1127
 			$context['no_topic_listing'] = true;
1103
-			if ($context['querystring_board_limits'] == ';start=%d')
1104
-				$context['querystring_board_limits'] = '';
1105
-			else
1106
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1128
+			if ($context['querystring_board_limits'] == ';start=%d') {
1129
+							$context['querystring_board_limits'] = '';
1130
+			} else {
1131
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1132
+			}
1107 1133
 			return;
1108 1134
 		}
1109 1135
 
1110
-		if (!empty($have_temp_table))
1111
-			$request = $smcFunc['db_query']('', '
1136
+		if (!empty($have_temp_table)) {
1137
+					$request = $smcFunc['db_query']('', '
1112 1138
 				SELECT t.id_topic
1113 1139
 				FROM {db_prefix}topics_posted_in AS t
1114 1140
 					LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic)
@@ -1122,8 +1148,8 @@  discard block
 block discarded – undo
1122 1148
 					'limit' => $context['topics_per_page'],
1123 1149
 				))
1124 1150
 			);
1125
-		else
1126
-			$request = $smcFunc['db_query']('', '
1151
+		} else {
1152
+					$request = $smcFunc['db_query']('', '
1127 1153
 				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1128 1154
 				FROM {db_prefix}topics AS t
1129 1155
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
@@ -1147,10 +1173,12 @@  discard block
 block discarded – undo
1147 1173
 					'sort' => $_REQUEST['sort'],
1148 1174
 				))
1149 1175
 			);
1176
+		}
1150 1177
 
1151 1178
 		$topics = array();
1152
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1153
-			$topics[] = $row['id_topic'];
1179
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1180
+					$topics[] = $row['id_topic'];
1181
+		}
1154 1182
 		$smcFunc['db_free_result']($request);
1155 1183
 
1156 1184
 		// Sanity... where have you gone?
@@ -1158,10 +1186,11 @@  discard block
 block discarded – undo
1158 1186
 		{
1159 1187
 			$context['topics'] = array();
1160 1188
 			$context['no_topic_listing'] = true;
1161
-			if ($context['querystring_board_limits'] == ';start=%d')
1162
-				$context['querystring_board_limits'] = '';
1163
-			else
1164
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1189
+			if ($context['querystring_board_limits'] == ';start=%d') {
1190
+							$context['querystring_board_limits'] = '';
1191
+			} else {
1192
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1193
+			}
1165 1194
 			return;
1166 1195
 		}
1167 1196
 
@@ -1195,8 +1224,9 @@  discard block
 block discarded – undo
1195 1224
 
1196 1225
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1197 1226
 	{
1198
-		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
1199
-			continue;
1227
+		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
1228
+					continue;
1229
+		}
1200 1230
 
1201 1231
 		$topic_ids[] = $row['id_topic'];
1202 1232
 
@@ -1204,11 +1234,13 @@  discard block
 block discarded – undo
1204 1234
 		{
1205 1235
 			// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
1206 1236
 			$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
1207
-			if ($smcFunc['strlen']($row['first_body']) > 128)
1208
-				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1237
+			if ($smcFunc['strlen']($row['first_body']) > 128) {
1238
+							$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1239
+			}
1209 1240
 			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1210
-			if ($smcFunc['strlen']($row['last_body']) > 128)
1211
-				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1241
+			if ($smcFunc['strlen']($row['last_body']) > 128) {
1242
+							$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1243
+			}
1212 1244
 
1213 1245
 			// Censor the subject and message preview.
1214 1246
 			censorText($row['first_subject']);
@@ -1219,23 +1251,22 @@  discard block
 block discarded – undo
1219 1251
 			{
1220 1252
 				$row['last_subject'] = $row['first_subject'];
1221 1253
 				$row['last_body'] = $row['first_body'];
1222
-			}
1223
-			else
1254
+			} else
1224 1255
 			{
1225 1256
 				censorText($row['last_subject']);
1226 1257
 				censorText($row['last_body']);
1227 1258
 			}
1228
-		}
1229
-		else
1259
+		} else
1230 1260
 		{
1231 1261
 			$row['first_body'] = '';
1232 1262
 			$row['last_body'] = '';
1233 1263
 			censorText($row['first_subject']);
1234 1264
 
1235
-			if ($row['id_first_msg'] == $row['id_last_msg'])
1236
-				$row['last_subject'] = $row['first_subject'];
1237
-			else
1238
-				censorText($row['last_subject']);
1265
+			if ($row['id_first_msg'] == $row['id_last_msg']) {
1266
+							$row['last_subject'] = $row['first_subject'];
1267
+			} else {
1268
+							censorText($row['last_subject']);
1269
+			}
1239 1270
 		}
1240 1271
 
1241 1272
 		// Decide how many pages the topic should have.
@@ -1247,22 +1278,24 @@  discard block
 block discarded – undo
1247 1278
 			$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false);
1248 1279
 
1249 1280
 			// If we can use all, show all.
1250
-			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
1251
-				$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1281
+			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) {
1282
+							$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1283
+			}
1284
+		} else {
1285
+					$pages = '';
1252 1286
 		}
1253 1287
 
1254
-		else
1255
-			$pages = '';
1256
-
1257 1288
 		// We need to check the topic icons exist... you can never be too sure!
1258 1289
 		if (!empty($modSettings['messageIconChecks_enable']))
1259 1290
 		{
1260 1291
 			// First icon first... as you'd expect.
1261
-			if (!isset($context['icon_sources'][$row['first_icon']]))
1262
-				$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1292
+			if (!isset($context['icon_sources'][$row['first_icon']])) {
1293
+							$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1294
+			}
1263 1295
 			// Last icon... last... duh.
1264
-			if (!isset($context['icon_sources'][$row['last_icon']]))
1265
-				$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1296
+			if (!isset($context['icon_sources'][$row['last_icon']])) {
1297
+							$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1298
+			}
1266 1299
 		}
1267 1300
 
1268 1301
 		// Force the recycling icon if appropriate
@@ -1276,12 +1309,14 @@  discard block
 block discarded – undo
1276 1309
 		$colorClass = 'windowbg';
1277 1310
 
1278 1311
 		// Sticky topics should get a different color, too.
1279
-		if ($row['is_sticky'])
1280
-			$colorClass .= ' sticky';
1312
+		if ($row['is_sticky']) {
1313
+					$colorClass .= ' sticky';
1314
+		}
1281 1315
 
1282 1316
 		// Locked topics get special treatment as well.
1283
-		if ($row['locked'])
1284
-			$colorClass .= ' locked';
1317
+		if ($row['locked']) {
1318
+					$colorClass .= ' locked';
1319
+		}
1285 1320
 
1286 1321
 		// And build the array.
1287 1322
 		$context['topics'][$row['id_topic']] = array(
@@ -1378,8 +1413,9 @@  discard block
 block discarded – undo
1378 1413
 		);
1379 1414
 		while ($row = $smcFunc['db_fetch_assoc']($result))
1380 1415
 		{
1381
-			if (empty($context['topics'][$row['id_topic']]['is_posted_in']))
1382
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1416
+			if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) {
1417
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1418
+			}
1383 1419
 		}
1384 1420
 		$smcFunc['db_free_result']($result);
1385 1421
 	}
@@ -1394,28 +1430,30 @@  discard block
 block discarded – undo
1394 1430
 			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1431
 		);
1396 1432
 
1397
-		if ($context['showCheckboxes'])
1398
-			$context['recent_buttons']['markselectread'] = array(
1433
+		if ($context['showCheckboxes']) {
1434
+					$context['recent_buttons']['markselectread'] = array(
1399 1435
 				'text' => 'quick_mod_markread',
1400 1436
 				'image' => 'markselectedread.png',
1401 1437
 				'url' => 'javascript:document.quickModForm.submit();',
1402 1438
 			);
1439
+		}
1403 1440
 
1404
-		if (!empty($context['topics']) && !$context['showing_all_topics'])
1405
-			$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1406
-	}
1407
-	elseif (!$is_topics && isset($context['topics_to_mark']))
1441
+		if (!empty($context['topics']) && !$context['showing_all_topics']) {
1442
+					$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1443
+		}
1444
+	} elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1445
 	{
1409 1446
 		$context['recent_buttons'] = array(
1410 1447
 			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1448
 		);
1412 1449
 
1413
-		if ($context['showCheckboxes'])
1414
-			$context['recent_buttons']['markselectread'] = array(
1450
+		if ($context['showCheckboxes']) {
1451
+					$context['recent_buttons']['markselectread'] = array(
1415 1452
 				'text' => 'quick_mod_markread',
1416 1453
 				'image' => 'markselectedread.png',
1417 1454
 				'url' => 'javascript:document.quickModForm.submit();',
1418 1455
 			);
1456
+		}
1419 1457
 	}
1420 1458
 
1421 1459
 	// Allow mods to add additional buttons here
Please login to merge, or discard this patch.
Sources/Subs.php 4 patches
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -5370,7 +5370,6 @@  discard block
 block discarded – undo
5370 5370
 
5371 5371
 /**
5372 5372
  * Tries different modes to make file/dirs writable. Wrapper function for chmod()
5373
-
5374 5373
  * @param string $file The file/dir full path.
5375 5374
  * @param int $value Not needed, added for legacy reasons.
5376 5375
  * @return boolean  true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable.
@@ -5410,7 +5409,6 @@  discard block
 block discarded – undo
5410 5409
 
5411 5410
 /**
5412 5411
  * Wrapper function for json_decode() with error handling.
5413
-
5414 5412
  * @param string $json The string to decode.
5415 5413
  * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default.
5416 5414
  * @param bool $logIt To specify if the error will be logged if theres any.
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
  * - caches the formatting data from the setting for optimization.
677 677
  *
678 678
  * @param float $number A number
679
- * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
679
+ * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
680 680
  * @return string A formatted number
681 681
  */
682 682
 function comma_format($number, $override_decimal_count = false)
@@ -5527,7 +5527,7 @@  discard block
 block discarded – undo
5527 5527
  * It assumes the data is already a string.
5528 5528
  * @param string $data The data to print
5529 5529
  * @param string $type The content type. Defaults to Json.
5530
- * @return void
5530
+ * @return false|null
5531 5531
  */
5532 5532
 function smf_serverResponse($data = '', $type = 'Content-Type: application/json')
5533 5533
 {
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 		if (empty($low_id))
600 600
 			$pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
601 601
 		else
602
-			$pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id);
602
+			$pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L' . $low_id);
603 603
 		
604 604
 		// Show all the pages.
605 605
 		$display_page = 1;
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
 
609 609
 		// Show the right arrow.
610 610
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
611
-		if ($start != $counter - $max_value && !$start_invalid){
611
+		if ($start != $counter - $max_value && !$start_invalid) {
612 612
 			if (empty($max_id))
613 613
 				$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
614 614
 			else
615
-				$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id);
615
+				$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page, $settings['page_index']['next_page'], 'M' . $max_id);
616 616
 		}
617 617
 			
618 618
 	}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			if (empty($low_id))
627 627
 				$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
628 628
 			else
629
-				$pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id);
629
+				$pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L' . $low_id);
630 630
 		else
631 631
 			$pageindex .= '';
632 632
 
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
 			if ($start >= $num_per_page * $nCont)
649 649
 			{
650 650
 				$tmpStart = $start - $num_per_page * $nCont;
651
-				if($nCont != 1 || empty($low_id))
651
+				if ($nCont != 1 || empty($low_id))
652 652
 					$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
653 653
 				else
654
-					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id);
654
+					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L' . $low_id);
655 655
 			}
656 656
 
657 657
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
 			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
667 667
 			{
668 668
 				$tmpStart = $start + $num_per_page * $nCont;
669
-				if($nCont != 1 || empty($max_id))
669
+				if ($nCont != 1 || empty($max_id))
670 670
 					$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
671 671
 				else
672
-					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id);
672
+					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M' . $max_id);
673 673
 			}
674 674
 
675 675
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 			if (empty($max_id))
691 691
 				$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
692 692
 			else
693
-				$pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id);
693
+				$pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M' . $max_id);
694 694
 	}
695 695
 	$pageindex .= $settings['page_index']['extra_after'];
696 696
 
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1126 1126
 				),
1127 1127
 				'content' => '$1',
1128
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1128
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1129 1129
 				{
1130 1130
 					$returnContext = '';
1131 1131
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 						}
1161 1161
 
1162 1162
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1163
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1163
+							$returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>';
1164 1164
 						else
1165 1165
 							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1166 1166
 					}
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 				'type' => 'unparsed_content',
1190 1190
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1191 1191
 				// @todo Maybe this can be simplified?
1192
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1192
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1193 1193
 				{
1194 1194
 					if (!isset($disabled['code']))
1195 1195
 					{
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 				'type' => 'unparsed_equals_content',
1227 1227
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1228 1228
 				// @todo Maybe this can be simplified?
1229
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1229
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1230 1230
 				{
1231 1231
 					if (!isset($disabled['code']))
1232 1232
 					{
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 				'type' => 'unparsed_content',
1271 1271
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1272 1272
 				// @todo Should this respect guest_hideContacts?
1273
-				'validate' => function (&$tag, &$data, $disabled)
1273
+				'validate' => function(&$tag, &$data, $disabled)
1274 1274
 				{
1275 1275
 					$data = strtr($data, array('<br>' => ''));
1276 1276
 				},
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 				'type' => 'unparsed_commas_content',
1290 1290
 				'test' => '\d+,\d+\]',
1291 1291
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1292
-				'validate' => function (&$tag, &$data, $disabled)
1292
+				'validate' => function(&$tag, &$data, $disabled)
1293 1293
 				{
1294 1294
 					if (isset($disabled['url']))
1295 1295
 						$tag['content'] = '$1';
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 				'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]',
1306 1306
 				'before' => '<div $1>',
1307 1307
 				'after' => '</div>',
1308
-				'validate' => function (&$tag, &$data, $disabled)
1308
+				'validate' => function(&$tag, &$data, $disabled)
1309 1309
 				{
1310 1310
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1311 1311
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1355 1355
 				),
1356 1356
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1357
-				'validate' => function (&$tag, &$data, $disabled)
1357
+				'validate' => function(&$tag, &$data, $disabled)
1358 1358
 				{
1359 1359
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1360 1360
 
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 				'tag' => 'img',
1378 1378
 				'type' => 'unparsed_content',
1379 1379
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1380
-				'validate' => function (&$tag, &$data, $disabled)
1380
+				'validate' => function(&$tag, &$data, $disabled)
1381 1381
 				{
1382 1382
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1383 1383
 
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 				'tag' => 'iurl',
1401 1401
 				'type' => 'unparsed_content',
1402 1402
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1403
-				'validate' => function (&$tag, &$data, $disabled)
1403
+				'validate' => function(&$tag, &$data, $disabled)
1404 1404
 				{
1405 1405
 					$data = strtr($data, array('<br>' => ''));
1406 1406
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 				'quoted' => 'optional',
1415 1415
 				'before' => '<a href="$1" class="bbc_link">',
1416 1416
 				'after' => '</a>',
1417
-				'validate' => function (&$tag, &$data, $disabled)
1417
+				'validate' => function(&$tag, &$data, $disabled)
1418 1418
 				{
1419 1419
 					if (substr($data, 0, 1) == '#')
1420 1420
 						$data = '#post_' . substr($data, 1);
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 				'tag' => 'php',
1495 1495
 				'type' => 'unparsed_content',
1496 1496
 				'content' => '<span class="phpcode">$1</span>',
1497
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1497
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1498 1498
 				{
1499 1499
 					if (!isset($disabled['php']))
1500 1500
 					{
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 				'test' => '[1-7]\]',
1593 1593
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1594 1594
 				'after' => '</span>',
1595
-				'validate' => function (&$tag, &$data, $disabled)
1595
+				'validate' => function(&$tag, &$data, $disabled)
1596 1596
 				{
1597 1597
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1598 1598
 					$data = $sizes[$data] . 'em';
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 				'tag' => 'time',
1631 1631
 				'type' => 'unparsed_content',
1632 1632
 				'content' => '$1',
1633
-				'validate' => function (&$tag, &$data, $disabled)
1633
+				'validate' => function(&$tag, &$data, $disabled)
1634 1634
 				{
1635 1635
 					if (is_numeric($data))
1636 1636
 						$data = timeformat($data);
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 				'tag' => 'url',
1659 1659
 				'type' => 'unparsed_content',
1660 1660
 				'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',
1661
-				'validate' => function (&$tag, &$data, $disabled)
1661
+				'validate' => function(&$tag, &$data, $disabled)
1662 1662
 				{
1663 1663
 					$data = strtr($data, array('<br>' => ''));
1664 1664
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 				'quoted' => 'optional',
1673 1673
 				'before' => '<a href="$1" class="bbc_link" target="_blank">',
1674 1674
 				'after' => '</a>',
1675
-				'validate' => function (&$tag, &$data, $disabled)
1675
+				'validate' => function(&$tag, &$data, $disabled)
1676 1676
 				{
1677 1677
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1678 1678
 					if (empty($scheme))
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 		{
1699 1699
 			if (isset($temp_bbc))
1700 1700
 				$bbc_codes = $temp_bbc;
1701
-			usort($codes, function ($a, $b) {
1701
+			usort($codes, function($a, $b) {
1702 1702
 				return strcmp($a['tag'], $b['tag']);
1703 1703
 			});
1704 1704
 			return $codes;
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
 										# a run of Unicode domain name characters and a dot
1937 1937
 										[\p{L}\p{M}\p{N}\-.:@]+\.
1938 1938
 										# and then a TLD valid in the DNS or the reserved "local" TLD
1939
-										(?:'. $modSettings['tld_regex'] .'|local)
1939
+										(?:'. $modSettings['tld_regex'] . '|local)
1940 1940
 									)
1941 1941
 									# followed by a non-domain character or end of line
1942 1942
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 						)?
2005 2005
 						';
2006 2006
 
2007
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
2007
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
2008 2008
 							$url = array_shift($matches);
2009 2009
 
2010 2010
 							$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -2741,7 +2741,7 @@  discard block
 block discarded – undo
2741 2741
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2742 2742
 		{
2743 2743
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2744
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2744
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2745 2745
 
2746 2746
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2747 2747
 
@@ -2758,7 +2758,7 @@  discard block
 block discarded – undo
2758 2758
 
2759 2759
 	// Replace away!
2760 2760
 	$message = preg_replace_callback($smileyPregSearch,
2761
-		function ($matches) use ($smileyPregReplacements)
2761
+		function($matches) use ($smileyPregReplacements)
2762 2762
 		{
2763 2763
 			return $smileyPregReplacements[$matches[1]];
2764 2764
 		}, $message);
@@ -2824,13 +2824,13 @@  discard block
 block discarded – undo
2824 2824
 	{
2825 2825
 		if (defined('SID') && SID != '')
2826 2826
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2827
-				function ($m) use ($scripturl)
2827
+				function($m) use ($scripturl)
2828 2828
 				{
2829
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2829
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2830 2830
 				}, $setLocation);
2831 2831
 		else
2832 2832
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2833
-				function ($m) use ($scripturl)
2833
+				function($m) use ($scripturl)
2834 2834
 				{
2835 2835
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2836 2836
 				}, $setLocation);
@@ -3153,7 +3153,7 @@  discard block
 block discarded – undo
3153 3153
 
3154 3154
 	// Add a generic "Are you sure?" confirmation message.
3155 3155
 	addInlineJavaScript('
3156
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3156
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3157 3157
 
3158 3158
 	// Now add the capping code for avatars.
3159 3159
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3514,7 +3514,7 @@  discard block
 block discarded – undo
3514 3514
 
3515 3515
 		else
3516 3516
 			echo '
3517
-	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3517
+	<script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>';
3518 3518
 	}
3519 3519
 
3520 3520
 	// Inline JavaScript - Actually useful some times!
@@ -3592,14 +3592,14 @@  discard block
 block discarded – undo
3592 3592
 
3593 3593
 		else
3594 3594
 			echo '
3595
-	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3595
+	<link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">';
3596 3596
 	}
3597 3597
 
3598 3598
 	// Print the rest after the minified files.
3599 3599
 	if (!empty($normal))
3600 3600
 		foreach ($normal as $nf)
3601 3601
 			echo '
3602
-	<link rel="stylesheet" href="', $nf ,'">';
3602
+	<link rel="stylesheet" href="', $nf, '">';
3603 3603
 
3604 3604
 	if ($db_show_debug === true)
3605 3605
 	{
@@ -3615,7 +3615,7 @@  discard block
 block discarded – undo
3615 3615
 	<style>';
3616 3616
 
3617 3617
 		foreach ($context['css_header'] as $css)
3618
-			echo $css .'
3618
+			echo $css . '
3619 3619
 	';
3620 3620
 
3621 3621
 		echo'
@@ -3644,27 +3644,27 @@  discard block
 block discarded – undo
3644 3644
 		return false;
3645 3645
 
3646 3646
 	// Did we already did this?
3647
-	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3647
+	$toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400);
3648 3648
 
3649 3649
 	// Already done?
3650 3650
 	if (!empty($toCache))
3651 3651
 		return true;
3652 3652
 
3653 3653
 	// No namespaces, sorry!
3654
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3654
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3655 3655
 
3656 3656
 	// Temp path.
3657
-	$cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/';
3657
+	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
3658 3658
 
3659 3659
 	// What kind of file are we going to create?
3660
-	$toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type;
3660
+	$toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type;
3661 3661
 
3662 3662
 	// File has to exists, if it isn't try to create it.
3663 3663
 	if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate))
3664 3664
 	{
3665 3665
 		loadLanguage('Errors');
3666 3666
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3667
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3667
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3668 3668
 
3669 3669
 		// The process failed so roll back to print each individual file.
3670 3670
 		return $data;
@@ -3699,14 +3699,14 @@  discard block
 block discarded – undo
3699 3699
 	{
3700 3700
 		loadLanguage('Errors');
3701 3701
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3702
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3702
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3703 3703
 
3704 3704
 		// The process failed so roll back to print each individual file.
3705 3705
 		return $data;
3706 3706
 	}
3707 3707
 
3708 3708
 	// And create a long lived cache entry.
3709
-	cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400);
3709
+	cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400);
3710 3710
 
3711 3711
 	return true;
3712 3712
 }
@@ -3766,7 +3766,7 @@  discard block
 block discarded – undo
3766 3766
 	else
3767 3767
 		$path = $modSettings['attachmentUploadDir'];
3768 3768
 
3769
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3769
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3770 3770
 }
3771 3771
 
3772 3772
 /**
@@ -3810,10 +3810,10 @@  discard block
 block discarded – undo
3810 3810
 		$valid_low = isValidIP($ip_parts[0]);
3811 3811
 		$valid_high = isValidIP($ip_parts[1]);
3812 3812
 		$count = 0;
3813
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
3813
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
3814 3814
 		$max = ($mode == ':' ? 'ffff' : '255');
3815 3815
 		$min = 0;
3816
-		if(!$valid_low)
3816
+		if (!$valid_low)
3817 3817
 		{
3818 3818
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
3819 3819
 			$valid_low = isValidIP($ip_parts[0]);
@@ -3827,7 +3827,7 @@  discard block
 block discarded – undo
3827 3827
 		}
3828 3828
 
3829 3829
 		$count = 0;
3830
-		if(!$valid_high)
3830
+		if (!$valid_high)
3831 3831
 		{
3832 3832
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
3833 3833
 			$valid_high = isValidIP($ip_parts[1]);
@@ -3840,7 +3840,7 @@  discard block
 block discarded – undo
3840 3840
 			}
3841 3841
 		}
3842 3842
 
3843
-		if($valid_high && $valid_low)
3843
+		if ($valid_high && $valid_low)
3844 3844
 		{
3845 3845
 			$ip_array['low'] = $ip_parts[0];
3846 3846
 			$ip_array['high'] = $ip_parts[1];
@@ -4022,7 +4022,7 @@  discard block
 block discarded – undo
4022 4022
 		addInlineJavaScript('
4023 4023
 	var user_menus = new smc_PopupMenu();
4024 4024
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4025
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4025
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4026 4026
 		if ($context['allow_pm'])
4027 4027
 			addInlineJavaScript('
4028 4028
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4644,7 +4644,7 @@  discard block
 block discarded – undo
4644 4644
 		// No? try a fallback to $sourcedir
4645 4645
 		else
4646 4646
 		{
4647
-			$absPath = $sourcedir .'/'. $file;
4647
+			$absPath = $sourcedir . '/' . $file;
4648 4648
 
4649 4649
 			if (file_exists($absPath))
4650 4650
 				require_once($absPath);
@@ -4725,15 +4725,15 @@  discard block
 block discarded – undo
4725 4725
 
4726 4726
 	// UTF-8 occurences of MS special characters
4727 4727
 	$findchars_utf8 = array(
4728
-		"\xe2\x80\x9a",	// single low-9 quotation mark
4729
-		"\xe2\x80\x9e",	// double low-9 quotation mark
4730
-		"\xe2\x80\xa6",	// horizontal ellipsis
4731
-		"\xe2\x80\x98",	// left single curly quote
4732
-		"\xe2\x80\x99",	// right single curly quote
4733
-		"\xe2\x80\x9c",	// left double curly quote
4734
-		"\xe2\x80\x9d",	// right double curly quote
4735
-		"\xe2\x80\x93",	// en dash
4736
-		"\xe2\x80\x94",	// em dash
4728
+		"\xe2\x80\x9a", // single low-9 quotation mark
4729
+		"\xe2\x80\x9e", // double low-9 quotation mark
4730
+		"\xe2\x80\xa6", // horizontal ellipsis
4731
+		"\xe2\x80\x98", // left single curly quote
4732
+		"\xe2\x80\x99", // right single curly quote
4733
+		"\xe2\x80\x9c", // left double curly quote
4734
+		"\xe2\x80\x9d", // right double curly quote
4735
+		"\xe2\x80\x93", // en dash
4736
+		"\xe2\x80\x94", // em dash
4737 4737
 	);
4738 4738
 
4739 4739
 	// windows 1252 / iso equivalents
@@ -4751,15 +4751,15 @@  discard block
 block discarded – undo
4751 4751
 
4752 4752
 	// safe replacements
4753 4753
 	$replacechars = array(
4754
-		',',	// &sbquo;
4755
-		',,',	// &bdquo;
4756
-		'...',	// &hellip;
4757
-		"'",	// &lsquo;
4758
-		"'",	// &rsquo;
4759
-		'"',	// &ldquo;
4760
-		'"',	// &rdquo;
4761
-		'-',	// &ndash;
4762
-		'--',	// &mdash;
4754
+		',', // &sbquo;
4755
+		',,', // &bdquo;
4756
+		'...', // &hellip;
4757
+		"'", // &lsquo;
4758
+		"'", // &rsquo;
4759
+		'"', // &ldquo;
4760
+		'"', // &rdquo;
4761
+		'-', // &ndash;
4762
+		'--', // &mdash;
4763 4763
 	);
4764 4764
 
4765 4765
 	if ($context['utf8'])
@@ -5177,7 +5177,7 @@  discard block
 block discarded – undo
5177 5177
  */
5178 5178
 function inet_dtop($bin)
5179 5179
 {
5180
-	if(empty($bin))
5180
+	if (empty($bin))
5181 5181
 		return '';
5182 5182
 
5183 5183
 	global $db_type;
@@ -5208,28 +5208,28 @@  discard block
 block discarded – undo
5208 5208
  */
5209 5209
 function _safe_serialize($value)
5210 5210
 {
5211
-	if(is_null($value))
5211
+	if (is_null($value))
5212 5212
 		return 'N;';
5213 5213
 
5214
-	if(is_bool($value))
5215
-		return 'b:'. (int) $value .';';
5214
+	if (is_bool($value))
5215
+		return 'b:' . (int) $value . ';';
5216 5216
 
5217
-	if(is_int($value))
5218
-		return 'i:'. $value .';';
5217
+	if (is_int($value))
5218
+		return 'i:' . $value . ';';
5219 5219
 
5220
-	if(is_float($value))
5221
-		return 'd:'. str_replace(',', '.', $value) .';';
5220
+	if (is_float($value))
5221
+		return 'd:' . str_replace(',', '.', $value) . ';';
5222 5222
 
5223
-	if(is_string($value))
5224
-		return 's:'. strlen($value) .':"'. $value .'";';
5223
+	if (is_string($value))
5224
+		return 's:' . strlen($value) . ':"' . $value . '";';
5225 5225
 
5226
-	if(is_array($value))
5226
+	if (is_array($value))
5227 5227
 	{
5228 5228
 		$out = '';
5229
-		foreach($value as $k => $v)
5229
+		foreach ($value as $k => $v)
5230 5230
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5231 5231
 
5232
-		return 'a:'. count($value) .':{'. $out .'}';
5232
+		return 'a:' . count($value) . ':{' . $out . '}';
5233 5233
 	}
5234 5234
 
5235 5235
 	// safe_serialize cannot serialize resources or objects.
@@ -5271,7 +5271,7 @@  discard block
 block discarded – undo
5271 5271
 function _safe_unserialize($str)
5272 5272
 {
5273 5273
 	// Input  is not a string.
5274
-	if(empty($str) || !is_string($str))
5274
+	if (empty($str) || !is_string($str))
5275 5275
 		return false;
5276 5276
 
5277 5277
 	$stack = array();
@@ -5285,40 +5285,40 @@  discard block
 block discarded – undo
5285 5285
 	 *   3 - in array, expecting value or another array
5286 5286
 	 */
5287 5287
 	$state = 0;
5288
-	while($state != 1)
5288
+	while ($state != 1)
5289 5289
 	{
5290 5290
 		$type = isset($str[0]) ? $str[0] : '';
5291
-		if($type == '}')
5291
+		if ($type == '}')
5292 5292
 			$str = substr($str, 1);
5293 5293
 
5294
-		else if($type == 'N' && $str[1] == ';')
5294
+		else if ($type == 'N' && $str[1] == ';')
5295 5295
 		{
5296 5296
 			$value = null;
5297 5297
 			$str = substr($str, 2);
5298 5298
 		}
5299
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5299
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5300 5300
 		{
5301 5301
 			$value = $matches[1] == '1' ? true : false;
5302 5302
 			$str = substr($str, 4);
5303 5303
 		}
5304
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5304
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5305 5305
 		{
5306
-			$value = (int)$matches[1];
5306
+			$value = (int) $matches[1];
5307 5307
 			$str = $matches[2];
5308 5308
 		}
5309
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5309
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5310 5310
 		{
5311
-			$value = (float)$matches[1];
5311
+			$value = (float) $matches[1];
5312 5312
 			$str = $matches[3];
5313 5313
 		}
5314
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5314
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5315 5315
 		{
5316
-			$value = substr($matches[2], 0, (int)$matches[1]);
5317
-			$str = substr($matches[2], (int)$matches[1] + 2);
5316
+			$value = substr($matches[2], 0, (int) $matches[1]);
5317
+			$str = substr($matches[2], (int) $matches[1] + 2);
5318 5318
 		}
5319
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5319
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5320 5320
 		{
5321
-			$expectedLength = (int)$matches[1];
5321
+			$expectedLength = (int) $matches[1];
5322 5322
 			$str = $matches[2];
5323 5323
 		}
5324 5324
 
@@ -5326,10 +5326,10 @@  discard block
 block discarded – undo
5326 5326
 		else
5327 5327
 			return false;
5328 5328
 
5329
-		switch($state)
5329
+		switch ($state)
5330 5330
 		{
5331 5331
 			case 3: // In array, expecting value or another array.
5332
-				if($type == 'a')
5332
+				if ($type == 'a')
5333 5333
 				{
5334 5334
 					$stack[] = &$list;
5335 5335
 					$list[$key] = array();
@@ -5338,7 +5338,7 @@  discard block
 block discarded – undo
5338 5338
 					$state = 2;
5339 5339
 					break;
5340 5340
 				}
5341
-				if($type != '}')
5341
+				if ($type != '}')
5342 5342
 				{
5343 5343
 					$list[$key] = $value;
5344 5344
 					$state = 2;
@@ -5349,29 +5349,29 @@  discard block
 block discarded – undo
5349 5349
 				return false;
5350 5350
 
5351 5351
 			case 2: // in array, expecting end of array or a key
5352
-				if($type == '}')
5352
+				if ($type == '}')
5353 5353
 				{
5354 5354
 					// Array size is less than expected.
5355
-					if(count($list) < end($expected))
5355
+					if (count($list) < end($expected))
5356 5356
 						return false;
5357 5357
 
5358 5358
 					unset($list);
5359
-					$list = &$stack[count($stack)-1];
5359
+					$list = &$stack[count($stack) - 1];
5360 5360
 					array_pop($stack);
5361 5361
 
5362 5362
 					// Go to terminal state if we're at the end of the root array.
5363 5363
 					array_pop($expected);
5364 5364
 
5365
-					if(count($expected) == 0)
5365
+					if (count($expected) == 0)
5366 5366
 						$state = 1;
5367 5367
 
5368 5368
 					break;
5369 5369
 				}
5370 5370
 
5371
-				if($type == 'i' || $type == 's')
5371
+				if ($type == 'i' || $type == 's')
5372 5372
 				{
5373 5373
 					// Array size exceeds expected length.
5374
-					if(count($list) >= end($expected))
5374
+					if (count($list) >= end($expected))
5375 5375
 						return false;
5376 5376
 
5377 5377
 					$key = $value;
@@ -5384,7 +5384,7 @@  discard block
 block discarded – undo
5384 5384
 
5385 5385
 			// Expecting array or value.
5386 5386
 			case 0:
5387
-				if($type == 'a')
5387
+				if ($type == 'a')
5388 5388
 				{
5389 5389
 					$data = array();
5390 5390
 					$list = &$data;
@@ -5393,7 +5393,7 @@  discard block
 block discarded – undo
5393 5393
 					break;
5394 5394
 				}
5395 5395
 
5396
-				if($type != '}')
5396
+				if ($type != '}')
5397 5397
 				{
5398 5398
 					$data = $value;
5399 5399
 					$state = 1;
@@ -5406,7 +5406,7 @@  discard block
 block discarded – undo
5406 5406
 	}
5407 5407
 
5408 5408
 	// Trailing data in input.
5409
-	if(!empty($str))
5409
+	if (!empty($str))
5410 5410
 		return false;
5411 5411
 
5412 5412
 	return $data;
@@ -5460,7 +5460,7 @@  discard block
 block discarded – undo
5460 5460
 	// Set different modes.
5461 5461
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5462 5462
 
5463
-	foreach($chmodValues as $val)
5463
+	foreach ($chmodValues as $val)
5464 5464
 	{
5465 5465
 		// If it's writable, break out of the loop.
5466 5466
 		if (is_writable($file))
@@ -5495,13 +5495,13 @@  discard block
 block discarded – undo
5495 5495
 	$returnArray = @json_decode($json, $returnAsArray);
5496 5496
 
5497 5497
 	// PHP 5.3 so no json_last_error_msg()
5498
-	switch(json_last_error())
5498
+	switch (json_last_error())
5499 5499
 	{
5500 5500
 		case JSON_ERROR_NONE:
5501 5501
 			$jsonError = false;
5502 5502
 			break;
5503 5503
 		case JSON_ERROR_DEPTH:
5504
-			$jsonError =  'JSON_ERROR_DEPTH';
5504
+			$jsonError = 'JSON_ERROR_DEPTH';
5505 5505
 			break;
5506 5506
 		case JSON_ERROR_STATE_MISMATCH:
5507 5507
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5529,10 +5529,10 @@  discard block
 block discarded – undo
5529 5529
 		loadLanguage('Errors');
5530 5530
 
5531 5531
 		if (!empty($jsonDebug))
5532
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5532
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5533 5533
 
5534 5534
 		else
5535
-			log_error($txt['json_'. $jsonError], 'critical');
5535
+			log_error($txt['json_' . $jsonError], 'critical');
5536 5536
 
5537 5537
 		// Everyone expects an array.
5538 5538
 		return array();
@@ -5636,7 +5636,7 @@  discard block
 block discarded – undo
5636 5636
 		});
5637 5637
 
5638 5638
 		// Convert Punycode to Unicode
5639
-		$tlds = array_map(function ($input) {
5639
+		$tlds = array_map(function($input) {
5640 5640
 			$prefix = 'xn--';
5641 5641
 			$safe_char = 0xFFFC;
5642 5642
 			$base = 36;
@@ -5652,7 +5652,7 @@  discard block
 block discarded – undo
5652 5652
 
5653 5653
 			foreach ($enco_parts as $encoded)
5654 5654
 			{
5655
-				if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0)
5655
+				if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0)
5656 5656
 				{
5657 5657
 					$output_parts[] = $encoded;
5658 5658
 					continue;
@@ -5663,7 +5663,7 @@  discard block
 block discarded – undo
5663 5663
 				$idx = 0;
5664 5664
 				$char = 0x80;
5665 5665
 				$decoded = array();
5666
-				$output='';
5666
+				$output = '';
5667 5667
 				$delim_pos = strrpos($encoded, '-');
5668 5668
 
5669 5669
 				if ($delim_pos > strlen($prefix))
@@ -5679,7 +5679,7 @@  discard block
 block discarded – undo
5679 5679
 
5680 5680
 				for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len)
5681 5681
 				{
5682
-					for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base)
5682
+					for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base)
5683 5683
 					{
5684 5684
 						$cp = ord($encoded{$enco_idx++});
5685 5685
 						$digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base));
@@ -5720,15 +5720,15 @@  discard block
 block discarded – undo
5720 5720
 
5721 5721
 					// 2 bytes
5722 5722
 					elseif ($v < (1 << 11))
5723
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5723
+						$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
5724 5724
 
5725 5725
 					// 3 bytes
5726 5726
 					elseif ($v < (1 << 16))
5727
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5727
+						$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5728 5728
 
5729 5729
 					// 4 bytes
5730 5730
 					elseif ($v < (1 << 21))
5731
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5731
+						$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5732 5732
 
5733 5733
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5734 5734
 					else
@@ -5835,7 +5835,7 @@  discard block
 block discarded – undo
5835 5835
 	}
5836 5836
 
5837 5837
 	// This recursive function creates the index array from the strings
5838
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5838
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5839 5839
 	{
5840 5840
 		static $depth = 0;
5841 5841
 		$depth++;
@@ -5862,7 +5862,7 @@  discard block
 block discarded – undo
5862 5862
 	};
5863 5863
 
5864 5864
 	// This recursive function turns the index array into a regular expression
5865
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
5865
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
5866 5866
 	{
5867 5867
 		static $depth = 0;
5868 5868
 		$depth++;
@@ -5886,11 +5886,11 @@  discard block
 block discarded – undo
5886 5886
 
5887 5887
 				if (count(array_keys($value)) == 1)
5888 5888
 				{
5889
-					$new_key_array = explode('(?'.'>', $sub_regex);
5889
+					$new_key_array = explode('(?' . '>', $sub_regex);
5890 5890
 					$new_key .= $new_key_array[0];
5891 5891
 				}
5892 5892
 				else
5893
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5893
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
5894 5894
 			}
5895 5895
 
5896 5896
 			if ($depth > 1)
@@ -5930,7 +5930,7 @@  discard block
 block discarded – undo
5930 5930
 		$index = $add_string_to_index($string, $index);
5931 5931
 
5932 5932
 	while (!empty($index))
5933
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5933
+		$regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
5934 5934
 
5935 5935
 	// Restore PHP's internal character encoding to whatever it was originally
5936 5936
 	if (!empty($current_encoding))
Please login to merge, or discard this patch.
Braces   +1321 added lines, -983 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
  * Update some basic statistics.
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
 						$smcFunc['db_free_result']($result);
123 124
 
124 125
 						// Add this to the number of unapproved members
125
-						if (!empty($changes['unapprovedMembers']))
126
-							$changes['unapprovedMembers'] += $coppa_approvals;
127
-						else
128
-							$changes['unapprovedMembers'] = $coppa_approvals;
126
+						if (!empty($changes['unapprovedMembers'])) {
127
+													$changes['unapprovedMembers'] += $coppa_approvals;
128
+						} else {
129
+													$changes['unapprovedMembers'] = $coppa_approvals;
130
+						}
129 131
 					}
130 132
 				}
131 133
 			}
@@ -133,9 +135,9 @@  discard block
 block discarded – undo
133 135
 			break;
134 136
 
135 137
 		case 'message':
136
-			if ($parameter1 === true && $parameter2 !== null)
137
-				updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
138
-			else
138
+			if ($parameter1 === true && $parameter2 !== null) {
139
+							updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
140
+			} else
139 141
 			{
140 142
 				// SUM and MAX on a smaller table is better for InnoDB tables.
141 143
 				$result = $smcFunc['db_query']('', '
@@ -175,23 +177,25 @@  discard block
 block discarded – undo
175 177
 				$parameter2 = text2words($parameter2);
176 178
 
177 179
 				$inserts = array();
178
-				foreach ($parameter2 as $word)
179
-					$inserts[] = array($word, $parameter1);
180
+				foreach ($parameter2 as $word) {
181
+									$inserts[] = array($word, $parameter1);
182
+				}
180 183
 
181
-				if (!empty($inserts))
182
-					$smcFunc['db_insert']('ignore',
184
+				if (!empty($inserts)) {
185
+									$smcFunc['db_insert']('ignore',
183 186
 						'{db_prefix}log_search_subjects',
184 187
 						array('word' => 'string', 'id_topic' => 'int'),
185 188
 						$inserts,
186 189
 						array('word', 'id_topic')
187 190
 					);
191
+				}
188 192
 			}
189 193
 			break;
190 194
 
191 195
 		case 'topic':
192
-			if ($parameter1 === true)
193
-				updateSettings(array('totalTopics' => true), true);
194
-			else
196
+			if ($parameter1 === true) {
197
+							updateSettings(array('totalTopics' => true), true);
198
+			} else
195 199
 			{
196 200
 				// Get the number of topics - a SUM is better for InnoDB tables.
197 201
 				// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
 		case 'postgroups':
214 218
 			// Parameter two is the updated columns: we should check to see if we base groups off any of these.
215
-			if ($parameter2 !== null && !in_array('posts', $parameter2))
216
-				return;
219
+			if ($parameter2 !== null && !in_array('posts', $parameter2)) {
220
+							return;
221
+			}
217 222
 
218 223
 			$postgroups = cache_get_data('updateStats:postgroups', 360);
219 224
 			if ($postgroups == null || $parameter1 == null)
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
 					)
229 234
 				);
230 235
 				$postgroups = array();
231
-				while ($row = $smcFunc['db_fetch_assoc']($request))
232
-					$postgroups[$row['id_group']] = $row['min_posts'];
236
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+									$postgroups[$row['id_group']] = $row['min_posts'];
238
+				}
233 239
 				$smcFunc['db_free_result']($request);
234 240
 
235 241
 				// Sort them this way because if it's done with MySQL it causes a filesort :(.
@@ -239,8 +245,9 @@  discard block
 block discarded – undo
239 245
 			}
240 246
 
241 247
 			// Oh great, they've screwed their post groups.
242
-			if (empty($postgroups))
243
-				return;
248
+			if (empty($postgroups)) {
249
+							return;
250
+			}
244 251
 
245 252
 			// Set all membergroups from most posts to least posts.
246 253
 			$conditions = '';
@@ -298,10 +305,9 @@  discard block
 block discarded – undo
298 305
 	{
299 306
 		$condition = 'id_member IN ({array_int:members})';
300 307
 		$parameters['members'] = $members;
301
-	}
302
-	elseif ($members === null)
303
-		$condition = '1=1';
304
-	else
308
+	} elseif ($members === null) {
309
+			$condition = '1=1';
310
+	} else
305 311
 	{
306 312
 		$condition = 'id_member = {int:member}';
307 313
 		$parameters['member'] = $members;
@@ -341,9 +347,9 @@  discard block
 block discarded – undo
341 347
 		if (count($vars_to_integrate) != 0)
342 348
 		{
343 349
 			// Fetch a list of member_names if necessary
344
-			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
345
-				$member_names = array($user_info['username']);
346
-			else
350
+			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) {
351
+							$member_names = array($user_info['username']);
352
+			} else
347 353
 			{
348 354
 				$member_names = array();
349 355
 				$request = $smcFunc['db_query']('', '
@@ -352,14 +358,16 @@  discard block
 block discarded – undo
352 358
 					WHERE ' . $condition,
353 359
 					$parameters
354 360
 				);
355
-				while ($row = $smcFunc['db_fetch_assoc']($request))
356
-					$member_names[] = $row['member_name'];
361
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
362
+									$member_names[] = $row['member_name'];
363
+				}
357 364
 				$smcFunc['db_free_result']($request);
358 365
 			}
359 366
 
360
-			if (!empty($member_names))
361
-				foreach ($vars_to_integrate as $var)
367
+			if (!empty($member_names)) {
368
+							foreach ($vars_to_integrate as $var)
362 369
 					call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats));
370
+			}
363 371
 		}
364 372
 	}
365 373
 
@@ -367,16 +375,17 @@  discard block
 block discarded – undo
367 375
 	foreach ($data as $var => $val)
368 376
 	{
369 377
 		$type = 'string';
370
-		if (in_array($var, $knownInts))
371
-			$type = 'int';
372
-		elseif (in_array($var, $knownFloats))
373
-			$type = 'float';
374
-		elseif ($var == 'birthdate')
375
-			$type = 'date';
376
-		elseif ($var == 'member_ip')
377
-			$type = 'inet';
378
-		elseif ($var == 'member_ip2')
379
-			$type = 'inet';
378
+		if (in_array($var, $knownInts)) {
379
+					$type = 'int';
380
+		} elseif (in_array($var, $knownFloats)) {
381
+					$type = 'float';
382
+		} elseif ($var == 'birthdate') {
383
+					$type = 'date';
384
+		} elseif ($var == 'member_ip') {
385
+					$type = 'inet';
386
+		} elseif ($var == 'member_ip2') {
387
+					$type = 'inet';
388
+		}
380 389
 
381 390
 		// Doing an increment?
382 391
 		if ($type == 'int' && ($val === '+' || $val === '-'))
@@ -390,8 +399,9 @@  discard block
 block discarded – undo
390 399
 		{
391 400
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
392 401
 			{
393
-				if ($match[1] != '+ ')
394
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
402
+				if ($match[1] != '+ ') {
403
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
404
+				}
395 405
 				$type = 'raw';
396 406
 			}
397 407
 		}
@@ -412,8 +422,9 @@  discard block
 block discarded – undo
412 422
 	// Clear any caching?
413 423
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members))
414 424
 	{
415
-		if (!is_array($members))
416
-			$members = array($members);
425
+		if (!is_array($members)) {
426
+					$members = array($members);
427
+		}
417 428
 
418 429
 		foreach ($members as $member)
419 430
 		{
@@ -446,29 +457,32 @@  discard block
 block discarded – undo
446 457
 {
447 458
 	global $modSettings, $smcFunc;
448 459
 
449
-	if (empty($changeArray) || !is_array($changeArray))
450
-		return;
460
+	if (empty($changeArray) || !is_array($changeArray)) {
461
+			return;
462
+	}
451 463
 
452 464
 	$toRemove = array();
453 465
 
454 466
 	// Go check if there is any setting to be removed.
455
-	foreach ($changeArray as $k => $v)
456
-		if ($v === null)
467
+	foreach ($changeArray as $k => $v) {
468
+			if ($v === null)
457 469
 		{
458 470
 			// Found some, remove them from the original array and add them to ours.
459 471
 			unset($changeArray[$k]);
472
+	}
460 473
 			$toRemove[] = $k;
461 474
 		}
462 475
 
463 476
 	// Proceed with the deletion.
464
-	if (!empty($toRemove))
465
-		$smcFunc['db_query']('', '
477
+	if (!empty($toRemove)) {
478
+			$smcFunc['db_query']('', '
466 479
 			DELETE FROM {db_prefix}settings
467 480
 			WHERE variable IN ({array_string:remove})',
468 481
 			array(
469 482
 				'remove' => $toRemove,
470 483
 			)
471 484
 		);
485
+	}
472 486
 
473 487
 	// In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.
474 488
 	if ($update)
@@ -497,19 +511,22 @@  discard block
 block discarded – undo
497 511
 	foreach ($changeArray as $variable => $value)
498 512
 	{
499 513
 		// Don't bother if it's already like that ;).
500
-		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value)
501
-			continue;
514
+		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) {
515
+					continue;
516
+		}
502 517
 		// If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it.
503
-		elseif (!isset($modSettings[$variable]) && empty($value))
504
-			continue;
518
+		elseif (!isset($modSettings[$variable]) && empty($value)) {
519
+					continue;
520
+		}
505 521
 
506 522
 		$replaceArray[] = array($variable, $value);
507 523
 
508 524
 		$modSettings[$variable] = $value;
509 525
 	}
510 526
 
511
-	if (empty($replaceArray))
512
-		return;
527
+	if (empty($replaceArray)) {
528
+			return;
529
+	}
513 530
 
514 531
 	$smcFunc['db_insert']('replace',
515 532
 		'{db_prefix}settings',
@@ -555,20 +572,25 @@  discard block
 block discarded – undo
555 572
 	$start = (int) $start;
556 573
 	$start_invalid = $start < 0;
557 574
 	
558
-	if (!empty($options['low_id']))
559
-		$low_id = $options['low_id'];
560
-	if (!empty($options['max_id']))
561
-		$max_id = $options['max_id'];
575
+	if (!empty($options['low_id'])) {
576
+			$low_id = $options['low_id'];
577
+	}
578
+	if (!empty($options['max_id'])) {
579
+			$max_id = $options['max_id'];
580
+	}
562 581
 
563 582
 	// Make sure $start is a proper variable - not less than 0.
564
-	if ($start_invalid)
565
-		$start = 0;
583
+	if ($start_invalid) {
584
+			$start = 0;
585
+	}
566 586
 	// Not greater than the upper bound.
567
-	elseif ($start >= $max_value)
568
-		$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
587
+	elseif ($start >= $max_value) {
588
+			$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
589
+	}
569 590
 	// And it has to be a multiple of $num_per_page!
570
-	else
571
-		$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
591
+	else {
592
+			$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
593
+	}
572 594
 
573 595
 	$context['current_page'] = $start / $num_per_page;
574 596
 
@@ -596,101 +618,115 @@  discard block
 block discarded – undo
596 618
 	if (empty($modSettings['compactTopicPagesEnable']))
597 619
 	{
598 620
 		// Show the left arrow.
599
-		if (empty($low_id))
600
-			$pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
601
-		else
602
-			$pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id);
621
+		if (empty($low_id)) {
622
+					$pageindex .= $start == 0 ? ' ' : sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
623
+		} else {
624
+					$pageindex .= $start == 0 ? ' ' : sprintf($base_link_page, ($start - $num_per_page), $settings['page_index']['previous_page'], 'L'.$low_id);
625
+		}
603 626
 		
604 627
 		// Show all the pages.
605 628
 		$display_page = 1;
606
-		for ($counter = 0; $counter < $max_value; $counter += $num_per_page)
607
-			$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
629
+		for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
630
+					$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
631
+		}
608 632
 
609 633
 		// Show the right arrow.
610 634
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
611 635
 		if ($start != $counter - $max_value && !$start_invalid){
612
-			if (empty($max_id))
613
-				$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
614
-			else
615
-				$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id);
636
+			if (empty($max_id)) {
637
+							$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
638
+			} else {
639
+							$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link_page, $display_page , $settings['page_index']['next_page'], 'M'.$max_id);
640
+			}
616 641
 		}
617 642
 			
618
-	}
619
-	else
643
+	} else
620 644
 	{
621 645
 		// If they didn't enter an odd value, pretend they did.
622 646
 		$PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2;
623 647
 
624 648
 		// Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page)
625
-		if (!empty($start) && $show_prevnext)
626
-			if (empty($low_id))
649
+		if (!empty($start) && $show_prevnext) {
650
+					if (empty($low_id))
627 651
 				$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
628
-			else
629
-				$pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id);
630
-		else
631
-			$pageindex .= '';
652
+		} else {
653
+							$pageindex .= sprintf($base_link_page, $start - $num_per_page, $settings['page_index']['previous_page'], 'L'.$low_id);
654
+			}
655
+		else {
656
+					$pageindex .= '';
657
+		}
632 658
 
633 659
 		// Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15)
634
-		if ($start > $num_per_page * $PageContiguous)
635
-			$pageindex .= sprintf($base_link, 0, '1');
660
+		if ($start > $num_per_page * $PageContiguous) {
661
+					$pageindex .= sprintf($base_link, 0, '1');
662
+		}
636 663
 
637 664
 		// Show the ... after the first page.  (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page)
638
-		if ($start > $num_per_page * ($PageContiguous + 1))
639
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
665
+		if ($start > $num_per_page * ($PageContiguous + 1)) {
666
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
640 667
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
641 668
 				'{FIRST_PAGE}' => $num_per_page,
642 669
 				'{LAST_PAGE}' => $start - $num_per_page * $PageContiguous,
643 670
 				'{PER_PAGE}' => $num_per_page,
644 671
 			));
672
+		}
645 673
 
646 674
 		// Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page)
647
-		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
648
-			if ($start >= $num_per_page * $nCont)
675
+		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) {
676
+					if ($start >= $num_per_page * $nCont)
649 677
 			{
650 678
 				$tmpStart = $start - $num_per_page * $nCont;
651
-				if($nCont != 1 || empty($low_id))
652
-					$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
653
-				else
654
-					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id);
679
+		}
680
+				if($nCont != 1 || empty($low_id)) {
681
+									$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
682
+				} else {
683
+									$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'L'.$low_id);
684
+				}
655 685
 			}
656 686
 
657 687
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
658
-		if (!$start_invalid)
659
-			$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
660
-		else
661
-			$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
688
+		if (!$start_invalid) {
689
+					$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
690
+		} else {
691
+					$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
692
+		}
662 693
 
663 694
 		// Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page)
664 695
 		$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
665
-		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
666
-			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
696
+		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) {
697
+					if ($start + $num_per_page * $nCont <= $tmpMaxPages)
667 698
 			{
668 699
 				$tmpStart = $start + $num_per_page * $nCont;
669
-				if($nCont != 1 || empty($max_id))
670
-					$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
671
-				else
672
-					$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id);
700
+		}
701
+				if($nCont != 1 || empty($max_id)) {
702
+									$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
703
+				} else {
704
+									$pageindex .= sprintf($base_link_page, $tmpStart, $tmpStart / $num_per_page + 1, 'M'.$max_id);
705
+				}
673 706
 			}
674 707
 
675 708
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
676
-		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
677
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
709
+		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) {
710
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
678 711
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
679 712
 				'{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1),
680 713
 				'{LAST_PAGE}' => $tmpMaxPages,
681 714
 				'{PER_PAGE}' => $num_per_page,
682 715
 			));
716
+		}
683 717
 
684 718
 		// Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15<  next page)
685
-		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
686
-			$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
719
+		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) {
720
+					$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
721
+		}
687 722
 
688 723
 		// Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<)
689
-		if ($start != $tmpMaxPages && $show_prevnext)
690
-			if (empty($max_id))
724
+		if ($start != $tmpMaxPages && $show_prevnext) {
725
+					if (empty($max_id))
691 726
 				$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
692
-			else
693
-				$pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id);
727
+		} else {
728
+							$pageindex .= sprintf($base_link_page, $start + $num_per_page, $settings['page_index']['next_page'], 'M'.$max_id);
729
+			}
694 730
 	}
695 731
 	$pageindex .= $settings['page_index']['extra_after'];
696 732
 
@@ -716,8 +752,9 @@  discard block
 block discarded – undo
716 752
 	if ($decimal_separator === null)
717 753
 	{
718 754
 		// Not set for whatever reason?
719
-		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1)
720
-			return $number;
755
+		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) {
756
+					return $number;
757
+		}
721 758
 
722 759
 		// Cache these each load...
723 760
 		$thousands_separator = $matches[1];
@@ -751,17 +788,20 @@  discard block
 block discarded – undo
751 788
 	static $local_cache;
752 789
 
753 790
 	// Offset the time.
754
-	if (!$offset_type)
755
-		$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
791
+	if (!$offset_type) {
792
+			$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
793
+	}
756 794
 	// Just the forum offset?
757
-	elseif ($offset_type == 'forum')
758
-		$time = $log_time + $modSettings['time_offset'] * 3600;
759
-	else
760
-		$time = $log_time;
795
+	elseif ($offset_type == 'forum') {
796
+			$time = $log_time + $modSettings['time_offset'] * 3600;
797
+	} else {
798
+			$time = $log_time;
799
+	}
761 800
 
762 801
 	// We can't have a negative date (on Windows, at least.)
763
-	if ($log_time < 0)
764
-		$log_time = 0;
802
+	if ($log_time < 0) {
803
+			$log_time = 0;
804
+	}
765 805
 
766 806
 	// Today and Yesterday?
767 807
 	if ($modSettings['todayMod'] >= 1 && $show_today === true)
@@ -778,56 +818,65 @@  discard block
 block discarded – undo
778 818
 		{
779 819
 			$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
780 820
 			$today_fmt = $h . ':%M' . $s . ' %p';
821
+		} else {
822
+					$today_fmt = '%H:%M' . $s;
781 823
 		}
782
-		else
783
-			$today_fmt = '%H:%M' . $s;
784 824
 
785 825
 		// Same day of the year, same year.... Today!
786
-		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
787
-			return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
826
+		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
827
+					return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
828
+		}
788 829
 
789 830
 		// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
790
-		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
791
-			return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
831
+		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) {
832
+					return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
833
+		}
792 834
 	}
793 835
 
794 836
 	$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];
795 837
 
796
-	if (!isset($local_cache))
797
-		$local_cache = setlocale(LC_TIME, $txt['lang_locale']);
838
+	if (!isset($local_cache)) {
839
+			$local_cache = setlocale(LC_TIME, $txt['lang_locale']);
840
+	}
798 841
 
799 842
 	if ($local_cache !== false)
800 843
 	{
801 844
 		//check if other process change the local
802 845
 		if ($process_safe === true)
803 846
 		{
804
-			if (setlocale(LC_TIME, '0') != $local_cache)
805
-				setlocale(LC_TIME, $txt['lang_locale']);
847
+			if (setlocale(LC_TIME, '0') != $local_cache) {
848
+							setlocale(LC_TIME, $txt['lang_locale']);
849
+			}
806 850
 		}
807 851
 
808
-		if (!isset($non_twelve_hour))
809
-			$non_twelve_hour = trim(strftime('%p')) === '';
810
-		if ($non_twelve_hour && strpos($str, '%p') !== false)
811
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
852
+		if (!isset($non_twelve_hour)) {
853
+					$non_twelve_hour = trim(strftime('%p')) === '';
854
+		}
855
+		if ($non_twelve_hour && strpos($str, '%p') !== false) {
856
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
857
+		}
812 858
 
813
-		foreach (array('%a', '%A', '%b', '%B') as $token)
814
-			if (strpos($str, $token) !== false)
859
+		foreach (array('%a', '%A', '%b', '%B') as $token) {
860
+					if (strpos($str, $token) !== false)
815 861
 				$str = str_replace($token, strftime($token, $time), $str);
816
-	}
817
-	else
862
+		}
863
+	} else
818 864
 	{
819 865
 		// Do-it-yourself time localization.  Fun.
820
-		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
821
-			if (strpos($str, $token) !== false)
866
+		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
867
+					if (strpos($str, $token) !== false)
822 868
 				$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
869
+		}
823 870
 
824
-		if (strpos($str, '%p') !== false)
825
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
871
+		if (strpos($str, '%p') !== false) {
872
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
873
+		}
826 874
 	}
827 875
 
828 876
 	// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
829
-	if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
830
-		$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);
877
+	if ($context['server']['is_windows'] && strpos($str, '%e') !== false) {
878
+			$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);
879
+	}
831 880
 
832 881
 	// Format any other characters..
833 882
 	return strftime($str, $time);
@@ -849,16 +898,19 @@  discard block
 block discarded – undo
849 898
 	static $translation = array();
850 899
 
851 900
 	// Determine the character set... Default to UTF-8
852
-	if (empty($context['character_set']))
853
-		$charset = 'UTF-8';
901
+	if (empty($context['character_set'])) {
902
+			$charset = 'UTF-8';
903
+	}
854 904
 	// Use ISO-8859-1 in place of non-supported ISO-8859 charsets...
855
-	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15')))
856
-		$charset = 'ISO-8859-1';
857
-	else
858
-		$charset = $context['character_set'];
905
+	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) {
906
+			$charset = 'ISO-8859-1';
907
+	} else {
908
+			$charset = $context['character_set'];
909
+	}
859 910
 
860
-	if (empty($translation))
861
-		$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
911
+	if (empty($translation)) {
912
+			$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
913
+	}
862 914
 
863 915
 	return strtr($string, $translation);
864 916
 }
@@ -880,8 +932,9 @@  discard block
 block discarded – undo
880 932
 	global $smcFunc;
881 933
 
882 934
 	// It was already short enough!
883
-	if ($smcFunc['strlen']($subject) <= $len)
884
-		return $subject;
935
+	if ($smcFunc['strlen']($subject) <= $len) {
936
+			return $subject;
937
+	}
885 938
 
886 939
 	// Shorten it by the length it was too long, and strip off junk from the end.
887 940
 	return $smcFunc['substr']($subject, 0, $len) . '...';
@@ -900,10 +953,11 @@  discard block
 block discarded – undo
900 953
 {
901 954
 	global $user_info, $modSettings;
902 955
 
903
-	if ($timestamp === null)
904
-		$timestamp = time();
905
-	elseif ($timestamp == 0)
906
-		return 0;
956
+	if ($timestamp === null) {
957
+			$timestamp = time();
958
+	} elseif ($timestamp == 0) {
959
+			return 0;
960
+	}
907 961
 
908 962
 	return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
909 963
 }
@@ -932,8 +986,9 @@  discard block
 block discarded – undo
932 986
 		$array[$i] = $array[$j];
933 987
 		$array[$j] = $temp;
934 988
 
935
-		for ($i = 1; $p[$i] == 0; $i++)
936
-			$p[$i] = 1;
989
+		for ($i = 1; $p[$i] == 0; $i++) {
990
+					$p[$i] = 1;
991
+		}
937 992
 
938 993
 		$orders[] = $array;
939 994
 	}
@@ -965,12 +1020,14 @@  discard block
 block discarded – undo
965 1020
 	static $disabled;
966 1021
 
967 1022
 	// Don't waste cycles
968
-	if ($message === '')
969
-		return '';
1023
+	if ($message === '') {
1024
+			return '';
1025
+	}
970 1026
 
971 1027
 	// Just in case it wasn't determined yet whether UTF-8 is enabled.
972
-	if (!isset($context['utf8']))
973
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1028
+	if (!isset($context['utf8'])) {
1029
+			$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1030
+	}
974 1031
 
975 1032
 	// Clean up any cut/paste issues we may have
976 1033
 	$message = sanitizeMSCutPaste($message);
@@ -982,13 +1039,15 @@  discard block
 block discarded – undo
982 1039
 		return $message;
983 1040
 	}
984 1041
 
985
-	if ($smileys !== null && ($smileys == '1' || $smileys == '0'))
986
-		$smileys = (bool) $smileys;
1042
+	if ($smileys !== null && ($smileys == '1' || $smileys == '0')) {
1043
+			$smileys = (bool) $smileys;
1044
+	}
987 1045
 
988 1046
 	if (empty($modSettings['enableBBC']) && $message !== false)
989 1047
 	{
990
-		if ($smileys === true)
991
-			parsesmileys($message);
1048
+		if ($smileys === true) {
1049
+					parsesmileys($message);
1050
+		}
992 1051
 
993 1052
 		return $message;
994 1053
 	}
@@ -1001,8 +1060,9 @@  discard block
 block discarded – undo
1001 1060
 	}
1002 1061
 
1003 1062
 	// Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker
1004
-	if (!empty($modSettings['autoLinkUrls']))
1005
-		set_tld_regex();
1063
+	if (!empty($modSettings['autoLinkUrls'])) {
1064
+			set_tld_regex();
1065
+	}
1006 1066
 
1007 1067
 	// Allow mods access before entering the main parse_bbc loop
1008 1068
 	call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
@@ -1016,12 +1076,14 @@  discard block
 block discarded – undo
1016 1076
 
1017 1077
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
1018 1078
 
1019
-			foreach ($temp as $tag)
1020
-				$disabled[trim($tag)] = true;
1079
+			foreach ($temp as $tag) {
1080
+							$disabled[trim($tag)] = true;
1081
+			}
1021 1082
 		}
1022 1083
 
1023
-		if (empty($modSettings['enableEmbeddedFlash']))
1024
-			$disabled['flash'] = true;
1084
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1085
+					$disabled['flash'] = true;
1086
+		}
1025 1087
 
1026 1088
 		/* The following bbc are formatted as an array, with keys as follows:
1027 1089
 
@@ -1142,8 +1204,9 @@  discard block
 block discarded – undo
1142 1204
 					$returnContext = '';
1143 1205
 
1144 1206
 					// BBC or the entire attachments feature is disabled
1145
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1146
-						return $data;
1207
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1208
+											return $data;
1209
+					}
1147 1210
 
1148 1211
 					// Save the attach ID.
1149 1212
 					$attachID = $data;
@@ -1154,8 +1217,9 @@  discard block
 block discarded – undo
1154 1217
 					$currentAttachment = parseAttachBBC($attachID);
1155 1218
 
1156 1219
 					// parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do.
1157
-					if (is_string($currentAttachment))
1158
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1220
+					if (is_string($currentAttachment)) {
1221
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1222
+					}
1159 1223
 
1160 1224
 					if (!empty($currentAttachment['is_image']))
1161 1225
 					{
@@ -1171,15 +1235,17 @@  discard block
 block discarded – undo
1171 1235
 							$height = ' height="' . $currentAttachment['height'] . '"';
1172 1236
 						}
1173 1237
 
1174
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1175
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1176
-						else
1177
-							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1238
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1239
+													$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1240
+						} else {
1241
+													$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1242
+						}
1178 1243
 					}
1179 1244
 
1180 1245
 					// No image. Show a link.
1181
-					else
1182
-						$returnContext .= $currentAttachment['link'];
1246
+					else {
1247
+											$returnContext .= $currentAttachment['link'];
1248
+					}
1183 1249
 
1184 1250
 					// Gotta append what we just did.
1185 1251
 					$data = $returnContext;
@@ -1210,8 +1276,9 @@  discard block
 block discarded – undo
1210 1276
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1211 1277
 						{
1212 1278
 							// Do PHP code coloring?
1213
-							if ($php_parts[$php_i] != '&lt;?php')
1214
-								continue;
1279
+							if ($php_parts[$php_i] != '&lt;?php') {
1280
+															continue;
1281
+							}
1215 1282
 
1216 1283
 							$php_string = '';
1217 1284
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1227,8 +1294,9 @@  discard block
 block discarded – undo
1227 1294
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1228 1295
 
1229 1296
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1230
-						if ($context['browser']['is_opera'])
1231
-							$data .= '&nbsp;';
1297
+						if ($context['browser']['is_opera']) {
1298
+													$data .= '&nbsp;';
1299
+						}
1232 1300
 					}
1233 1301
 				},
1234 1302
 				'block_level' => true,
@@ -1247,8 +1315,9 @@  discard block
 block discarded – undo
1247 1315
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1248 1316
 						{
1249 1317
 							// Do PHP code coloring?
1250
-							if ($php_parts[$php_i] != '&lt;?php')
1251
-								continue;
1318
+							if ($php_parts[$php_i] != '&lt;?php') {
1319
+															continue;
1320
+							}
1252 1321
 
1253 1322
 							$php_string = '';
1254 1323
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1264,8 +1333,9 @@  discard block
 block discarded – undo
1264 1333
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1265 1334
 
1266 1335
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1267
-						if ($context['browser']['is_opera'])
1268
-							$data[0] .= '&nbsp;';
1336
+						if ($context['browser']['is_opera']) {
1337
+													$data[0] .= '&nbsp;';
1338
+						}
1269 1339
 					}
1270 1340
 				},
1271 1341
 				'block_level' => true,
@@ -1303,11 +1373,13 @@  discard block
 block discarded – undo
1303 1373
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1304 1374
 				'validate' => function (&$tag, &$data, $disabled)
1305 1375
 				{
1306
-					if (isset($disabled['url']))
1307
-						$tag['content'] = '$1';
1376
+					if (isset($disabled['url'])) {
1377
+											$tag['content'] = '$1';
1378
+					}
1308 1379
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1309
-					if (empty($scheme))
1310
-						$data[0] = '//' . ltrim($data[0], ':/');
1380
+					if (empty($scheme)) {
1381
+											$data[0] = '//' . ltrim($data[0], ':/');
1382
+					}
1311 1383
 				},
1312 1384
 				'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>',
1313 1385
 			),
@@ -1321,10 +1393,11 @@  discard block
 block discarded – undo
1321 1393
 				{
1322 1394
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1323 1395
 
1324
-					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches))
1325
-						$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1326
-					else
1327
-						$css = '';
1396
+					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) {
1397
+											$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1398
+					} else {
1399
+											$css = '';
1400
+					}
1328 1401
 
1329 1402
 					$data = $class . $css;
1330 1403
 				},
@@ -1374,14 +1447,16 @@  discard block
 block discarded – undo
1374 1447
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1375 1448
 					if ($image_proxy_enabled)
1376 1449
 					{
1377
-						if (empty($scheme))
1378
-							$data = 'http://' . ltrim($data, ':/');
1450
+						if (empty($scheme)) {
1451
+													$data = 'http://' . ltrim($data, ':/');
1452
+						}
1379 1453
 
1380
-						if ($scheme != 'https')
1381
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1454
+						if ($scheme != 'https') {
1455
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1456
+						}
1457
+					} elseif (empty($scheme)) {
1458
+											$data = '//' . ltrim($data, ':/');
1382 1459
 					}
1383
-					elseif (empty($scheme))
1384
-						$data = '//' . ltrim($data, ':/');
1385 1460
 				},
1386 1461
 				'disabled_content' => '($1)',
1387 1462
 			),
@@ -1397,14 +1472,16 @@  discard block
 block discarded – undo
1397 1472
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1398 1473
 					if ($image_proxy_enabled)
1399 1474
 					{
1400
-						if (empty($scheme))
1401
-							$data = 'http://' . ltrim($data, ':/');
1475
+						if (empty($scheme)) {
1476
+													$data = 'http://' . ltrim($data, ':/');
1477
+						}
1402 1478
 
1403
-						if ($scheme != 'https')
1404
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1479
+						if ($scheme != 'https') {
1480
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1481
+						}
1482
+					} elseif (empty($scheme)) {
1483
+											$data = '//' . ltrim($data, ':/');
1405 1484
 					}
1406
-					elseif (empty($scheme))
1407
-						$data = '//' . ltrim($data, ':/');
1408 1485
 				},
1409 1486
 				'disabled_content' => '($1)',
1410 1487
 			),
@@ -1416,8 +1493,9 @@  discard block
 block discarded – undo
1416 1493
 				{
1417 1494
 					$data = strtr($data, array('<br>' => ''));
1418 1495
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1419
-					if (empty($scheme))
1420
-						$data = '//' . ltrim($data, ':/');
1496
+					if (empty($scheme)) {
1497
+											$data = '//' . ltrim($data, ':/');
1498
+					}
1421 1499
 				},
1422 1500
 			),
1423 1501
 			array(
@@ -1428,13 +1506,14 @@  discard block
 block discarded – undo
1428 1506
 				'after' => '</a>',
1429 1507
 				'validate' => function (&$tag, &$data, $disabled)
1430 1508
 				{
1431
-					if (substr($data, 0, 1) == '#')
1432
-						$data = '#post_' . substr($data, 1);
1433
-					else
1509
+					if (substr($data, 0, 1) == '#') {
1510
+											$data = '#post_' . substr($data, 1);
1511
+					} else
1434 1512
 					{
1435 1513
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1436
-						if (empty($scheme))
1437
-							$data = '//' . ltrim($data, ':/');
1514
+						if (empty($scheme)) {
1515
+													$data = '//' . ltrim($data, ':/');
1516
+						}
1438 1517
 					}
1439 1518
 				},
1440 1519
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1512,8 +1591,9 @@  discard block
 block discarded – undo
1512 1591
 					{
1513 1592
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1514 1593
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1515
-						if ($add_begin)
1516
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1594
+						if ($add_begin) {
1595
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1596
+						}
1517 1597
 					}
1518 1598
 				},
1519 1599
 				'block_level' => false,
@@ -1644,10 +1724,11 @@  discard block
 block discarded – undo
1644 1724
 				'content' => '$1',
1645 1725
 				'validate' => function (&$tag, &$data, $disabled)
1646 1726
 				{
1647
-					if (is_numeric($data))
1648
-						$data = timeformat($data);
1649
-					else
1650
-						$tag['content'] = '[time]$1[/time]';
1727
+					if (is_numeric($data)) {
1728
+											$data = timeformat($data);
1729
+					} else {
1730
+											$tag['content'] = '[time]$1[/time]';
1731
+					}
1651 1732
 				},
1652 1733
 			),
1653 1734
 			array(
@@ -1674,8 +1755,9 @@  discard block
 block discarded – undo
1674 1755
 				{
1675 1756
 					$data = strtr($data, array('<br>' => ''));
1676 1757
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1677
-					if (empty($scheme))
1678
-						$data = '//' . ltrim($data, ':/');
1758
+					if (empty($scheme)) {
1759
+											$data = '//' . ltrim($data, ':/');
1760
+					}
1679 1761
 				},
1680 1762
 			),
1681 1763
 			array(
@@ -1687,8 +1769,9 @@  discard block
 block discarded – undo
1687 1769
 				'validate' => function (&$tag, &$data, $disabled)
1688 1770
 				{
1689 1771
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1690
-					if (empty($scheme))
1691
-						$data = '//' . ltrim($data, ':/');
1772
+					if (empty($scheme)) {
1773
+											$data = '//' . ltrim($data, ':/');
1774
+					}
1692 1775
 				},
1693 1776
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1694 1777
 				'disabled_after' => ' ($1)',
@@ -1708,8 +1791,9 @@  discard block
 block discarded – undo
1708 1791
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1709 1792
 		if ($message === false)
1710 1793
 		{
1711
-			if (isset($temp_bbc))
1712
-				$bbc_codes = $temp_bbc;
1794
+			if (isset($temp_bbc)) {
1795
+							$bbc_codes = $temp_bbc;
1796
+			}
1713 1797
 			usort($codes, function ($a, $b) {
1714 1798
 				return strcmp($a['tag'], $b['tag']);
1715 1799
 			});
@@ -1729,8 +1813,9 @@  discard block
 block discarded – undo
1729 1813
 		);
1730 1814
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1731 1815
 		{
1732
-			foreach ($itemcodes as $c => $dummy)
1733
-				$bbc_codes[$c] = array();
1816
+			foreach ($itemcodes as $c => $dummy) {
1817
+							$bbc_codes[$c] = array();
1818
+			}
1734 1819
 		}
1735 1820
 
1736 1821
 		// Shhhh!
@@ -1751,12 +1836,14 @@  discard block
 block discarded – undo
1751 1836
 		foreach ($codes as $code)
1752 1837
 		{
1753 1838
 			// Make it easier to process parameters later
1754
-			if (!empty($code['parameters']))
1755
-				ksort($code['parameters'], SORT_STRING);
1839
+			if (!empty($code['parameters'])) {
1840
+							ksort($code['parameters'], SORT_STRING);
1841
+			}
1756 1842
 
1757 1843
 			// If we are not doing every tag only do ones we are interested in.
1758
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1759
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1844
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
1845
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1846
+			}
1760 1847
 		}
1761 1848
 		$codes = null;
1762 1849
 	}
@@ -1767,8 +1854,9 @@  discard block
 block discarded – undo
1767 1854
 		// It's likely this will change if the message is modified.
1768 1855
 		$cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']);
1769 1856
 
1770
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1771
-			return $temp;
1857
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
1858
+					return $temp;
1859
+		}
1772 1860
 
1773 1861
 		$cache_t = microtime();
1774 1862
 	}
@@ -1800,8 +1888,9 @@  discard block
 block discarded – undo
1800 1888
 		$disabled['flash'] = true;
1801 1889
 
1802 1890
 		// @todo Change maybe?
1803
-		if (!isset($_GET['images']))
1804
-			$disabled['img'] = true;
1891
+		if (!isset($_GET['images'])) {
1892
+					$disabled['img'] = true;
1893
+		}
1805 1894
 
1806 1895
 		// @todo Interface/setting to add more?
1807 1896
 	}
@@ -1825,8 +1914,9 @@  discard block
 block discarded – undo
1825 1914
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
1826 1915
 
1827 1916
 		// Failsafe.
1828
-		if ($pos === false || $last_pos > $pos)
1829
-			$pos = strlen($message) + 1;
1917
+		if ($pos === false || $last_pos > $pos) {
1918
+					$pos = strlen($message) + 1;
1919
+		}
1830 1920
 
1831 1921
 		// Can't have a one letter smiley, URL, or email! (sorry.)
1832 1922
 		if ($last_pos < $pos - 1)
@@ -1845,8 +1935,9 @@  discard block
 block discarded – undo
1845 1935
 
1846 1936
 				// <br> should be empty.
1847 1937
 				$empty_tags = array('br', 'hr');
1848
-				foreach ($empty_tags as $tag)
1849
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1938
+				foreach ($empty_tags as $tag) {
1939
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '[' . $tag . ' /]', $data);
1940
+				}
1850 1941
 
1851 1942
 				// b, u, i, s, pre... basic tags.
1852 1943
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote');
@@ -1855,8 +1946,9 @@  discard block
 block discarded – undo
1855 1946
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
1856 1947
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
1857 1948
 
1858
-					if ($diff > 0)
1859
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1949
+					if ($diff > 0) {
1950
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1951
+					}
1860 1952
 				}
1861 1953
 
1862 1954
 				// Do <img ...> - with security... action= -> action-.
@@ -1869,8 +1961,9 @@  discard block
 block discarded – undo
1869 1961
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
1870 1962
 
1871 1963
 						// Remove action= from the URL - no funny business, now.
1872
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
1873
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1964
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
1965
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
1966
+						}
1874 1967
 
1875 1968
 						// Check if the image is larger than allowed.
1876 1969
 						if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
@@ -1891,9 +1984,9 @@  discard block
 block discarded – undo
1891 1984
 
1892 1985
 							// Set the new image tag.
1893 1986
 							$replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]';
1987
+						} else {
1988
+													$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1894 1989
 						}
1895
-						else
1896
-							$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1897 1990
 					}
1898 1991
 
1899 1992
 					$data = strtr($data, $replaces);
@@ -1906,16 +1999,18 @@  discard block
 block discarded – undo
1906 1999
 				$no_autolink_area = false;
1907 2000
 				if (!empty($open_tags))
1908 2001
 				{
1909
-					foreach ($open_tags as $open_tag)
1910
-						if (in_array($open_tag['tag'], $no_autolink_tags))
2002
+					foreach ($open_tags as $open_tag) {
2003
+											if (in_array($open_tag['tag'], $no_autolink_tags))
1911 2004
 							$no_autolink_area = true;
2005
+					}
1912 2006
 				}
1913 2007
 
1914 2008
 				// Don't go backwards.
1915 2009
 				// @todo Don't think is the real solution....
1916 2010
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
1917
-				if ($pos < $lastAutoPos)
1918
-					$no_autolink_area = true;
2011
+				if ($pos < $lastAutoPos) {
2012
+									$no_autolink_area = true;
2013
+				}
1919 2014
 				$lastAutoPos = $pos;
1920 2015
 
1921 2016
 				if (!$no_autolink_area)
@@ -2024,17 +2119,19 @@  discard block
 block discarded – undo
2024 2119
 							if ($scheme == 'mailto')
2025 2120
 							{
2026 2121
 								$email_address = str_replace('mailto:', '', $url);
2027
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
2028
-									return '[email=' . $email_address . ']' . $url . '[/email]';
2029
-								else
2030
-									return $url;
2122
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2123
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2124
+								} else {
2125
+																	return $url;
2126
+								}
2031 2127
 							}
2032 2128
 
2033 2129
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
2034
-							if (empty($scheme))
2035
-								$fullUrl = '//' . ltrim($url, ':/');
2036
-							else
2037
-								$fullUrl = $url;
2130
+							if (empty($scheme)) {
2131
+															$fullUrl = '//' . ltrim($url, ':/');
2132
+							} else {
2133
+															$fullUrl = $url;
2134
+							}
2038 2135
 
2039 2136
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
2040 2137
 						}, $data);
@@ -2083,16 +2180,18 @@  discard block
 block discarded – undo
2083 2180
 		}
2084 2181
 
2085 2182
 		// Are we there yet?  Are we there yet?
2086
-		if ($pos >= strlen($message) - 1)
2087
-			break;
2183
+		if ($pos >= strlen($message) - 1) {
2184
+					break;
2185
+		}
2088 2186
 
2089 2187
 		$tags = strtolower($message[$pos + 1]);
2090 2188
 
2091 2189
 		if ($tags == '/' && !empty($open_tags))
2092 2190
 		{
2093 2191
 			$pos2 = strpos($message, ']', $pos + 1);
2094
-			if ($pos2 == $pos + 2)
2095
-				continue;
2192
+			if ($pos2 == $pos + 2) {
2193
+							continue;
2194
+			}
2096 2195
 
2097 2196
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2098 2197
 
@@ -2102,8 +2201,9 @@  discard block
 block discarded – undo
2102 2201
 			do
2103 2202
 			{
2104 2203
 				$tag = array_pop($open_tags);
2105
-				if (!$tag)
2106
-					break;
2204
+				if (!$tag) {
2205
+									break;
2206
+				}
2107 2207
 
2108 2208
 				if (!empty($tag['block_level']))
2109 2209
 				{
@@ -2117,10 +2217,11 @@  discard block
 block discarded – undo
2117 2217
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2118 2218
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2119 2219
 					{
2120
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2121
-							if ($temp['tag'] == $look_for)
2220
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2221
+													if ($temp['tag'] == $look_for)
2122 2222
 							{
2123 2223
 								$block_level = !empty($temp['block_level']);
2224
+						}
2124 2225
 								break;
2125 2226
 							}
2126 2227
 					}
@@ -2142,15 +2243,15 @@  discard block
 block discarded – undo
2142 2243
 			{
2143 2244
 				$open_tags = $to_close;
2144 2245
 				continue;
2145
-			}
2146
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2246
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2147 2247
 			{
2148 2248
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2149 2249
 				{
2150
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2151
-						if ($temp['tag'] == $look_for)
2250
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2251
+											if ($temp['tag'] == $look_for)
2152 2252
 						{
2153 2253
 							$block_level = !empty($temp['block_level']);
2254
+					}
2154 2255
 							break;
2155 2256
 						}
2156 2257
 				}
@@ -2158,8 +2259,9 @@  discard block
 block discarded – undo
2158 2259
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2159 2260
 				if (!$block_level)
2160 2261
 				{
2161
-					foreach ($to_close as $tag)
2162
-						array_push($open_tags, $tag);
2262
+					foreach ($to_close as $tag) {
2263
+											array_push($open_tags, $tag);
2264
+					}
2163 2265
 					continue;
2164 2266
 				}
2165 2267
 			}
@@ -2172,14 +2274,17 @@  discard block
 block discarded – undo
2172 2274
 
2173 2275
 				// See the comment at the end of the big loop - just eating whitespace ;).
2174 2276
 				$whitespace_regex = '';
2175
-				if (!empty($tag['block_level']))
2176
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2277
+				if (!empty($tag['block_level'])) {
2278
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2279
+				}
2177 2280
 				// Trim one line of whitespace after unnested tags, but all of it after nested ones
2178
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2179
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2281
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2282
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2283
+				}
2180 2284
 
2181
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2182
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2285
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2286
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2287
+				}
2183 2288
 			}
2184 2289
 
2185 2290
 			if (!empty($to_close))
@@ -2192,8 +2297,9 @@  discard block
 block discarded – undo
2192 2297
 		}
2193 2298
 
2194 2299
 		// No tags for this character, so just keep going (fastest possible course.)
2195
-		if (!isset($bbc_codes[$tags]))
2196
-			continue;
2300
+		if (!isset($bbc_codes[$tags])) {
2301
+					continue;
2302
+		}
2197 2303
 
2198 2304
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2199 2305
 		$tag = null;
@@ -2202,44 +2308,52 @@  discard block
 block discarded – undo
2202 2308
 			$pt_strlen = strlen($possible['tag']);
2203 2309
 
2204 2310
 			// Not a match?
2205
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2206
-				continue;
2311
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2312
+							continue;
2313
+			}
2207 2314
 
2208 2315
 			$next_c = $message[$pos + 1 + $pt_strlen];
2209 2316
 
2210 2317
 			// A test validation?
2211
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2212
-				continue;
2318
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2319
+							continue;
2320
+			}
2213 2321
 			// Do we want parameters?
2214 2322
 			elseif (!empty($possible['parameters']))
2215 2323
 			{
2216
-				if ($next_c != ' ')
2217
-					continue;
2218
-			}
2219
-			elseif (isset($possible['type']))
2324
+				if ($next_c != ' ') {
2325
+									continue;
2326
+				}
2327
+			} elseif (isset($possible['type']))
2220 2328
 			{
2221 2329
 				// Do we need an equal sign?
2222
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2223
-					continue;
2330
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2331
+									continue;
2332
+				}
2224 2333
 				// Maybe we just want a /...
2225
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2226
-					continue;
2334
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2335
+									continue;
2336
+				}
2227 2337
 				// An immediate ]?
2228
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2229
-					continue;
2338
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2339
+									continue;
2340
+				}
2230 2341
 			}
2231 2342
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2232
-			elseif ($next_c != ']')
2233
-				continue;
2343
+			elseif ($next_c != ']') {
2344
+							continue;
2345
+			}
2234 2346
 
2235 2347
 			// Check allowed tree?
2236
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2237
-				continue;
2238
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2239
-				continue;
2348
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2349
+							continue;
2350
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2351
+							continue;
2352
+			}
2240 2353
 			// If this is in the list of disallowed child tags, don't parse it.
2241
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2242
-				continue;
2354
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2355
+							continue;
2356
+			}
2243 2357
 
2244 2358
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2245 2359
 
@@ -2251,8 +2365,9 @@  discard block
 block discarded – undo
2251 2365
 				foreach ($open_tags as $open_quote)
2252 2366
 				{
2253 2367
 					// Every parent quote this quote has flips the styling
2254
-					if ($open_quote['tag'] == 'quote')
2255
-						$quote_alt = !$quote_alt;
2368
+					if ($open_quote['tag'] == 'quote') {
2369
+											$quote_alt = !$quote_alt;
2370
+					}
2256 2371
 				}
2257 2372
 				// Add a class to the quote to style alternating blockquotes
2258 2373
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2263,8 +2378,9 @@  discard block
 block discarded – undo
2263 2378
 			{
2264 2379
 				// Build a regular expression for each parameter for the current tag.
2265 2380
 				$preg = array();
2266
-				foreach ($possible['parameters'] as $p => $info)
2267
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2381
+				foreach ($possible['parameters'] as $p => $info) {
2382
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2383
+				}
2268 2384
 
2269 2385
 				// Extract the string that potentially holds our parameters.
2270 2386
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2284,24 +2400,27 @@  discard block
 block discarded – undo
2284 2400
 
2285 2401
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2286 2402
 
2287
-					if ($match)
2288
-						$blob_counter = count($blobs) + 1;
2403
+					if ($match) {
2404
+											$blob_counter = count($blobs) + 1;
2405
+					}
2289 2406
 				}
2290 2407
 
2291 2408
 				// Didn't match our parameter list, try the next possible.
2292
-				if (!$match)
2293
-					continue;
2409
+				if (!$match) {
2410
+									continue;
2411
+				}
2294 2412
 
2295 2413
 				$params = array();
2296 2414
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2297 2415
 				{
2298 2416
 					$key = strtok(ltrim($matches[$i]), '=');
2299
-					if (isset($possible['parameters'][$key]['value']))
2300
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2301
-					elseif (isset($possible['parameters'][$key]['validate']))
2302
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2303
-					else
2304
-						$params['{' . $key . '}'] = $matches[$i + 1];
2417
+					if (isset($possible['parameters'][$key]['value'])) {
2418
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2419
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2420
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2421
+					} else {
2422
+											$params['{' . $key . '}'] = $matches[$i + 1];
2423
+					}
2305 2424
 
2306 2425
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2307 2426
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2309,23 +2428,26 @@  discard block
 block discarded – undo
2309 2428
 
2310 2429
 				foreach ($possible['parameters'] as $p => $info)
2311 2430
 				{
2312
-					if (!isset($params['{' . $p . '}']))
2313
-						$params['{' . $p . '}'] = '';
2431
+					if (!isset($params['{' . $p . '}'])) {
2432
+											$params['{' . $p . '}'] = '';
2433
+					}
2314 2434
 				}
2315 2435
 
2316 2436
 				$tag = $possible;
2317 2437
 
2318 2438
 				// Put the parameters into the string.
2319
-				if (isset($tag['before']))
2320
-					$tag['before'] = strtr($tag['before'], $params);
2321
-				if (isset($tag['after']))
2322
-					$tag['after'] = strtr($tag['after'], $params);
2323
-				if (isset($tag['content']))
2324
-					$tag['content'] = strtr($tag['content'], $params);
2439
+				if (isset($tag['before'])) {
2440
+									$tag['before'] = strtr($tag['before'], $params);
2441
+				}
2442
+				if (isset($tag['after'])) {
2443
+									$tag['after'] = strtr($tag['after'], $params);
2444
+				}
2445
+				if (isset($tag['content'])) {
2446
+									$tag['content'] = strtr($tag['content'], $params);
2447
+				}
2325 2448
 
2326 2449
 				$pos1 += strlen($given_param_string);
2327
-			}
2328
-			else
2450
+			} else
2329 2451
 			{
2330 2452
 				$tag = $possible;
2331 2453
 				$params = array();
@@ -2336,8 +2458,9 @@  discard block
 block discarded – undo
2336 2458
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2337 2459
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2338 2460
 		{
2339
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2340
-				continue;
2461
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2462
+							continue;
2463
+			}
2341 2464
 
2342 2465
 			$tag = $itemcodes[$message[$pos + 1]];
2343 2466
 
@@ -2358,9 +2481,9 @@  discard block
 block discarded – undo
2358 2481
 			{
2359 2482
 				array_pop($open_tags);
2360 2483
 				$code = '</li>';
2484
+			} else {
2485
+							$code = '';
2361 2486
 			}
2362
-			else
2363
-				$code = '';
2364 2487
 
2365 2488
 			// Now we open a new tag.
2366 2489
 			$open_tags[] = array(
@@ -2407,12 +2530,14 @@  discard block
 block discarded – undo
2407 2530
 		}
2408 2531
 
2409 2532
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2410
-		if ($tag === null)
2411
-			continue;
2533
+		if ($tag === null) {
2534
+					continue;
2535
+		}
2412 2536
 
2413 2537
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2414
-		if (isset($inside['disallow_children']))
2415
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2538
+		if (isset($inside['disallow_children'])) {
2539
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2540
+		}
2416 2541
 
2417 2542
 		// Is this tag disabled?
2418 2543
 		if (isset($disabled[$tag['tag']]))
@@ -2422,14 +2547,13 @@  discard block
 block discarded – undo
2422 2547
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2423 2548
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2424 2549
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2425
-			}
2426
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2550
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2427 2551
 			{
2428 2552
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2429 2553
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2554
+			} else {
2555
+							$tag['content'] = $tag['disabled_content'];
2430 2556
 			}
2431
-			else
2432
-				$tag['content'] = $tag['disabled_content'];
2433 2557
 		}
2434 2558
 
2435 2559
 		// we use this a lot
@@ -2439,8 +2563,9 @@  discard block
 block discarded – undo
2439 2563
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2440 2564
 		{
2441 2565
 			$n = count($open_tags) - 1;
2442
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2443
-				$n--;
2566
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2567
+							$n--;
2568
+			}
2444 2569
 
2445 2570
 			// Close all the non block level tags so this tag isn't surrounded by them.
2446 2571
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2452,12 +2577,15 @@  discard block
 block discarded – undo
2452 2577
 
2453 2578
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2454 2579
 				$whitespace_regex = '';
2455
-				if (!empty($tag['block_level']))
2456
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2457
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2458
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2459
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2460
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2580
+				if (!empty($tag['block_level'])) {
2581
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2582
+				}
2583
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2584
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2585
+				}
2586
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2587
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2588
+				}
2461 2589
 
2462 2590
 				array_pop($open_tags);
2463 2591
 			}
@@ -2475,16 +2603,19 @@  discard block
 block discarded – undo
2475 2603
 		elseif ($tag['type'] == 'unparsed_content')
2476 2604
 		{
2477 2605
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2478
-			if ($pos2 === false)
2479
-				continue;
2606
+			if ($pos2 === false) {
2607
+							continue;
2608
+			}
2480 2609
 
2481 2610
 			$data = substr($message, $pos1, $pos2 - $pos1);
2482 2611
 
2483
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2484
-				$data = substr($data, 4);
2612
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2613
+							$data = substr($data, 4);
2614
+			}
2485 2615
 
2486
-			if (isset($tag['validate']))
2487
-				$tag['validate']($tag, $data, $disabled, $params);
2616
+			if (isset($tag['validate'])) {
2617
+							$tag['validate']($tag, $data, $disabled, $params);
2618
+			}
2488 2619
 
2489 2620
 			$code = strtr($tag['content'], array('$1' => $data));
2490 2621
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2500,34 +2631,40 @@  discard block
 block discarded – undo
2500 2631
 			if (isset($tag['quoted']))
2501 2632
 			{
2502 2633
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2503
-				if ($tag['quoted'] != 'optional' && !$quoted)
2504
-					continue;
2634
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2635
+									continue;
2636
+				}
2505 2637
 
2506
-				if ($quoted)
2507
-					$pos1 += 6;
2638
+				if ($quoted) {
2639
+									$pos1 += 6;
2640
+				}
2641
+			} else {
2642
+							$quoted = false;
2508 2643
 			}
2509
-			else
2510
-				$quoted = false;
2511 2644
 
2512 2645
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2513
-			if ($pos2 === false)
2514
-				continue;
2646
+			if ($pos2 === false) {
2647
+							continue;
2648
+			}
2515 2649
 
2516 2650
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2517
-			if ($pos3 === false)
2518
-				continue;
2651
+			if ($pos3 === false) {
2652
+							continue;
2653
+			}
2519 2654
 
2520 2655
 			$data = array(
2521 2656
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2522 2657
 				substr($message, $pos1, $pos2 - $pos1)
2523 2658
 			);
2524 2659
 
2525
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2526
-				$data[0] = substr($data[0], 4);
2660
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2661
+							$data[0] = substr($data[0], 4);
2662
+			}
2527 2663
 
2528 2664
 			// Validation for my parking, please!
2529
-			if (isset($tag['validate']))
2530
-				$tag['validate']($tag, $data, $disabled, $params);
2665
+			if (isset($tag['validate'])) {
2666
+							$tag['validate']($tag, $data, $disabled, $params);
2667
+			}
2531 2668
 
2532 2669
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2533 2670
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2544,23 +2681,27 @@  discard block
 block discarded – undo
2544 2681
 		elseif ($tag['type'] == 'unparsed_commas_content')
2545 2682
 		{
2546 2683
 			$pos2 = strpos($message, ']', $pos1);
2547
-			if ($pos2 === false)
2548
-				continue;
2684
+			if ($pos2 === false) {
2685
+							continue;
2686
+			}
2549 2687
 
2550 2688
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2551
-			if ($pos3 === false)
2552
-				continue;
2689
+			if ($pos3 === false) {
2690
+							continue;
2691
+			}
2553 2692
 
2554 2693
 			// We want $1 to be the content, and the rest to be csv.
2555 2694
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2556 2695
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2557 2696
 
2558
-			if (isset($tag['validate']))
2559
-				$tag['validate']($tag, $data, $disabled, $params);
2697
+			if (isset($tag['validate'])) {
2698
+							$tag['validate']($tag, $data, $disabled, $params);
2699
+			}
2560 2700
 
2561 2701
 			$code = $tag['content'];
2562
-			foreach ($data as $k => $d)
2563
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2702
+			foreach ($data as $k => $d) {
2703
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2704
+			}
2564 2705
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2565 2706
 			$pos += strlen($code) - 1 + 2;
2566 2707
 		}
@@ -2568,24 +2709,28 @@  discard block
 block discarded – undo
2568 2709
 		elseif ($tag['type'] == 'unparsed_commas')
2569 2710
 		{
2570 2711
 			$pos2 = strpos($message, ']', $pos1);
2571
-			if ($pos2 === false)
2572
-				continue;
2712
+			if ($pos2 === false) {
2713
+							continue;
2714
+			}
2573 2715
 
2574 2716
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2575 2717
 
2576
-			if (isset($tag['validate']))
2577
-				$tag['validate']($tag, $data, $disabled, $params);
2718
+			if (isset($tag['validate'])) {
2719
+							$tag['validate']($tag, $data, $disabled, $params);
2720
+			}
2578 2721
 
2579 2722
 			// Fix after, for disabled code mainly.
2580
-			foreach ($data as $k => $d)
2581
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2723
+			foreach ($data as $k => $d) {
2724
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2725
+			}
2582 2726
 
2583 2727
 			$open_tags[] = $tag;
2584 2728
 
2585 2729
 			// Replace them out, $1, $2, $3, $4, etc.
2586 2730
 			$code = $tag['before'];
2587
-			foreach ($data as $k => $d)
2588
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2731
+			foreach ($data as $k => $d) {
2732
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2733
+			}
2589 2734
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2590 2735
 			$pos += strlen($code) - 1 + 2;
2591 2736
 		}
@@ -2596,28 +2741,33 @@  discard block
 block discarded – undo
2596 2741
 			if (isset($tag['quoted']))
2597 2742
 			{
2598 2743
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2599
-				if ($tag['quoted'] != 'optional' && !$quoted)
2600
-					continue;
2744
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2745
+									continue;
2746
+				}
2601 2747
 
2602
-				if ($quoted)
2603
-					$pos1 += 6;
2748
+				if ($quoted) {
2749
+									$pos1 += 6;
2750
+				}
2751
+			} else {
2752
+							$quoted = false;
2604 2753
 			}
2605
-			else
2606
-				$quoted = false;
2607 2754
 
2608 2755
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2609
-			if ($pos2 === false)
2610
-				continue;
2756
+			if ($pos2 === false) {
2757
+							continue;
2758
+			}
2611 2759
 
2612 2760
 			$data = substr($message, $pos1, $pos2 - $pos1);
2613 2761
 
2614 2762
 			// Validation for my parking, please!
2615
-			if (isset($tag['validate']))
2616
-				$tag['validate']($tag, $data, $disabled, $params);
2763
+			if (isset($tag['validate'])) {
2764
+							$tag['validate']($tag, $data, $disabled, $params);
2765
+			}
2617 2766
 
2618 2767
 			// For parsed content, we must recurse to avoid security problems.
2619
-			if ($tag['type'] != 'unparsed_equals')
2620
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2768
+			if ($tag['type'] != 'unparsed_equals') {
2769
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2770
+			}
2621 2771
 
2622 2772
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2623 2773
 
@@ -2629,34 +2779,40 @@  discard block
 block discarded – undo
2629 2779
 		}
2630 2780
 
2631 2781
 		// If this is block level, eat any breaks after it.
2632
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2633
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2782
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2783
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2784
+		}
2634 2785
 
2635 2786
 		// Are we trimming outside this tag?
2636
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2637
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2787
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2788
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2789
+		}
2638 2790
 	}
2639 2791
 
2640 2792
 	// Close any remaining tags.
2641
-	while ($tag = array_pop($open_tags))
2642
-		$message .= "\n" . $tag['after'] . "\n";
2793
+	while ($tag = array_pop($open_tags)) {
2794
+			$message .= "\n" . $tag['after'] . "\n";
2795
+	}
2643 2796
 
2644 2797
 	// Parse the smileys within the parts where it can be done safely.
2645 2798
 	if ($smileys === true)
2646 2799
 	{
2647 2800
 		$message_parts = explode("\n", $message);
2648
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2649
-			parsesmileys($message_parts[$i]);
2801
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2802
+					parsesmileys($message_parts[$i]);
2803
+		}
2650 2804
 
2651 2805
 		$message = implode('', $message_parts);
2652 2806
 	}
2653 2807
 
2654 2808
 	// No smileys, just get rid of the markers.
2655
-	else
2656
-		$message = strtr($message, array("\n" => ''));
2809
+	else {
2810
+			$message = strtr($message, array("\n" => ''));
2811
+	}
2657 2812
 
2658
-	if ($message !== '' && $message[0] === ' ')
2659
-		$message = '&nbsp;' . substr($message, 1);
2813
+	if ($message !== '' && $message[0] === ' ') {
2814
+			$message = '&nbsp;' . substr($message, 1);
2815
+	}
2660 2816
 
2661 2817
 	// Cleanup whitespace.
2662 2818
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2665,15 +2821,16 @@  discard block
 block discarded – undo
2665 2821
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2666 2822
 
2667 2823
 	// Cache the output if it took some time...
2668
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2669
-		cache_put_data($cache_key, $message, 240);
2824
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
2825
+			cache_put_data($cache_key, $message, 240);
2826
+	}
2670 2827
 
2671 2828
 	// If this was a force parse revert if needed.
2672 2829
 	if (!empty($parse_tags))
2673 2830
 	{
2674
-		if (empty($temp_bbc))
2675
-			$bbc_codes = array();
2676
-		else
2831
+		if (empty($temp_bbc)) {
2832
+					$bbc_codes = array();
2833
+		} else
2677 2834
 		{
2678 2835
 			$bbc_codes = $temp_bbc;
2679 2836
 			unset($temp_bbc);
@@ -2700,8 +2857,9 @@  discard block
 block discarded – undo
2700 2857
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2701 2858
 
2702 2859
 	// No smiley set at all?!
2703
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2704
-		return;
2860
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
2861
+			return;
2862
+	}
2705 2863
 
2706 2864
 	// If smileyPregSearch hasn't been set, do it now.
2707 2865
 	if (empty($smileyPregSearch))
@@ -2712,8 +2870,7 @@  discard block
 block discarded – undo
2712 2870
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2713 2871
 			$smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
2714 2872
 			$smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
2715
-		}
2716
-		else
2873
+		} else
2717 2874
 		{
2718 2875
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2719 2876
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2737,9 +2894,9 @@  discard block
 block discarded – undo
2737 2894
 				$smcFunc['db_free_result']($result);
2738 2895
 
2739 2896
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
2897
+			} else {
2898
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2740 2899
 			}
2741
-			else
2742
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2743 2900
 		}
2744 2901
 
2745 2902
 		// The non-breaking-space is a complex thing...
@@ -2816,35 +2973,41 @@  discard block
 block discarded – undo
2816 2973
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
2817 2974
 
2818 2975
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
2819
-	if (!empty($context['flush_mail']))
2820
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2976
+	if (!empty($context['flush_mail'])) {
2977
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2821 2978
 		AddMailQueue(true);
2979
+	}
2822 2980
 
2823 2981
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
2824 2982
 
2825
-	if ($add)
2826
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2983
+	if ($add) {
2984
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
2985
+	}
2827 2986
 
2828 2987
 	// Put the session ID in.
2829
-	if (defined('SID') && SID != '')
2830
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2988
+	if (defined('SID') && SID != '') {
2989
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
2990
+	}
2831 2991
 	// Keep that debug in their for template debugging!
2832
-	elseif (isset($_GET['debug']))
2833
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2992
+	elseif (isset($_GET['debug'])) {
2993
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
2994
+	}
2834 2995
 
2835 2996
 	if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
2836 2997
 	{
2837
-		if (defined('SID') && SID != '')
2838
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2998
+		if (defined('SID') && SID != '') {
2999
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2839 3000
 				function ($m) use ($scripturl)
2840 3001
 				{
2841 3002
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3003
+		}
2842 3004
 				}, $setLocation);
2843
-		else
2844
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3005
+		else {
3006
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2845 3007
 				function ($m) use ($scripturl)
2846 3008
 				{
2847 3009
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3010
+		}
2848 3011
 				}, $setLocation);
2849 3012
 	}
2850 3013
 
@@ -2855,8 +3018,9 @@  discard block
 block discarded – undo
2855 3018
 	header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
2856 3019
 
2857 3020
 	// Debugging.
2858
-	if (isset($db_show_debug) && $db_show_debug === true)
2859
-		$_SESSION['debug_redirect'] = $db_cache;
3021
+	if (isset($db_show_debug) && $db_show_debug === true) {
3022
+			$_SESSION['debug_redirect'] = $db_cache;
3023
+	}
2860 3024
 
2861 3025
 	obExit(false);
2862 3026
 }
@@ -2875,51 +3039,60 @@  discard block
 block discarded – undo
2875 3039
 
2876 3040
 	// Attempt to prevent a recursive loop.
2877 3041
 	++$level;
2878
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
2879
-		exit;
2880
-	if ($from_fatal_error)
2881
-		$has_fatal_error = true;
3042
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
3043
+			exit;
3044
+	}
3045
+	if ($from_fatal_error) {
3046
+			$has_fatal_error = true;
3047
+	}
2882 3048
 
2883 3049
 	// Clear out the stat cache.
2884 3050
 	trackStats();
2885 3051
 
2886 3052
 	// If we have mail to send, send it.
2887
-	if (!empty($context['flush_mail']))
2888
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3053
+	if (!empty($context['flush_mail'])) {
3054
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2889 3055
 		AddMailQueue(true);
3056
+	}
2890 3057
 
2891 3058
 	$do_header = $header === null ? !$header_done : $header;
2892
-	if ($do_footer === null)
2893
-		$do_footer = $do_header;
3059
+	if ($do_footer === null) {
3060
+			$do_footer = $do_header;
3061
+	}
2894 3062
 
2895 3063
 	// Has the template/header been done yet?
2896 3064
 	if ($do_header)
2897 3065
 	{
2898 3066
 		// Was the page title set last minute? Also update the HTML safe one.
2899
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
2900
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3067
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3068
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3069
+		}
2901 3070
 
2902 3071
 		// Start up the session URL fixer.
2903 3072
 		ob_start('ob_sessrewrite');
2904 3073
 
2905
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
2906
-			$buffers = explode(',', $settings['output_buffers']);
2907
-		elseif (!empty($settings['output_buffers']))
2908
-			$buffers = $settings['output_buffers'];
2909
-		else
2910
-			$buffers = array();
3074
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3075
+					$buffers = explode(',', $settings['output_buffers']);
3076
+		} elseif (!empty($settings['output_buffers'])) {
3077
+					$buffers = $settings['output_buffers'];
3078
+		} else {
3079
+					$buffers = array();
3080
+		}
2911 3081
 
2912
-		if (isset($modSettings['integrate_buffer']))
2913
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3082
+		if (isset($modSettings['integrate_buffer'])) {
3083
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3084
+		}
2914 3085
 
2915
-		if (!empty($buffers))
2916
-			foreach ($buffers as $function)
3086
+		if (!empty($buffers)) {
3087
+					foreach ($buffers as $function)
2917 3088
 			{
2918 3089
 				$call = call_helper($function, true);
3090
+		}
2919 3091
 
2920 3092
 				// Is it valid?
2921
-				if (!empty($call))
2922
-					ob_start($call);
3093
+				if (!empty($call)) {
3094
+									ob_start($call);
3095
+				}
2923 3096
 			}
2924 3097
 
2925 3098
 		// Display the screen in the logical order.
@@ -2931,8 +3104,9 @@  discard block
 block discarded – undo
2931 3104
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
2932 3105
 
2933 3106
 		// Anything special to put out?
2934
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
2935
-			echo $context['insert_after_template'];
3107
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3108
+					echo $context['insert_after_template'];
3109
+		}
2936 3110
 
2937 3111
 		// Just so we don't get caught in an endless loop of errors from the footer...
2938 3112
 		if (!$footer_done)
@@ -2941,14 +3115,16 @@  discard block
 block discarded – undo
2941 3115
 			template_footer();
2942 3116
 
2943 3117
 			// (since this is just debugging... it's okay that it's after </html>.)
2944
-			if (!isset($_REQUEST['xml']))
2945
-				displayDebug();
3118
+			if (!isset($_REQUEST['xml'])) {
3119
+							displayDebug();
3120
+			}
2946 3121
 		}
2947 3122
 	}
2948 3123
 
2949 3124
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
2950
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
2951
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3125
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3126
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3127
+	}
2952 3128
 
2953 3129
 	// For session check verification.... don't switch browsers...
2954 3130
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -2957,9 +3133,10 @@  discard block
 block discarded – undo
2957 3133
 	call_integration_hook('integrate_exit', array($do_footer));
2958 3134
 
2959 3135
 	// Don't exit if we're coming from index.php; that will pass through normally.
2960
-	if (!$from_index)
2961
-		exit;
2962
-}
3136
+	if (!$from_index) {
3137
+			exit;
3138
+	}
3139
+	}
2963 3140
 
2964 3141
 /**
2965 3142
  * Get the size of a specified image with better error handling.
@@ -2978,8 +3155,9 @@  discard block
 block discarded – undo
2978 3155
 	$url = str_replace(' ', '%20', $url);
2979 3156
 
2980 3157
 	// Can we pull this from the cache... please please?
2981
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
2982
-		return $temp;
3158
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3159
+			return $temp;
3160
+	}
2983 3161
 	$t = microtime();
2984 3162
 
2985 3163
 	// Get the host to pester...
@@ -2989,12 +3167,10 @@  discard block
 block discarded – undo
2989 3167
 	if ($url == '' || $url == 'http://' || $url == 'https://')
2990 3168
 	{
2991 3169
 		return false;
2992
-	}
2993
-	elseif (!isset($match[1]))
3170
+	} elseif (!isset($match[1]))
2994 3171
 	{
2995 3172
 		$size = @getimagesize($url);
2996
-	}
2997
-	else
3173
+	} else
2998 3174
 	{
2999 3175
 		// Try to connect to the server... give it half a second.
3000 3176
 		$temp = 0;
@@ -3033,12 +3209,14 @@  discard block
 block discarded – undo
3033 3209
 	}
3034 3210
 
3035 3211
 	// If we didn't get it, we failed.
3036
-	if (!isset($size))
3037
-		$size = false;
3212
+	if (!isset($size)) {
3213
+			$size = false;
3214
+	}
3038 3215
 
3039 3216
 	// If this took a long time, we may never have to do it again, but then again we might...
3040
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
3041
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3217
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3218
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3219
+	}
3042 3220
 
3043 3221
 	// Didn't work.
3044 3222
 	return $size;
@@ -3056,8 +3234,9 @@  discard block
 block discarded – undo
3056 3234
 
3057 3235
 	// Under SSI this function can be called more then once.  That can cause some problems.
3058 3236
 	//   So only run the function once unless we are forced to run it again.
3059
-	if ($loaded && !$forceload)
3060
-		return;
3237
+	if ($loaded && !$forceload) {
3238
+			return;
3239
+	}
3061 3240
 
3062 3241
 	$loaded = true;
3063 3242
 
@@ -3069,14 +3248,16 @@  discard block
 block discarded – undo
3069 3248
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3070 3249
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3071 3250
 	{
3072
-		if (trim($context['news_lines'][$i]) == '')
3073
-			continue;
3251
+		if (trim($context['news_lines'][$i]) == '') {
3252
+					continue;
3253
+		}
3074 3254
 
3075 3255
 		// Clean it up for presentation ;).
3076 3256
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3077 3257
 	}
3078
-	if (!empty($context['news_lines']))
3079
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3258
+	if (!empty($context['news_lines'])) {
3259
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3260
+	}
3080 3261
 
3081 3262
 	if (!$user_info['is_guest'])
3082 3263
 	{
@@ -3085,40 +3266,48 @@  discard block
 block discarded – undo
3085 3266
 		$context['user']['alerts'] = &$user_info['alerts'];
3086 3267
 
3087 3268
 		// Personal message popup...
3088
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3089
-			$context['user']['popup_messages'] = true;
3090
-		else
3091
-			$context['user']['popup_messages'] = false;
3269
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3270
+					$context['user']['popup_messages'] = true;
3271
+		} else {
3272
+					$context['user']['popup_messages'] = false;
3273
+		}
3092 3274
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3093 3275
 
3094
-		if (allowedTo('moderate_forum'))
3095
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3276
+		if (allowedTo('moderate_forum')) {
3277
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3278
+		}
3096 3279
 
3097 3280
 		$context['user']['avatar'] = array();
3098 3281
 
3099 3282
 		// Check for gravatar first since we might be forcing them...
3100 3283
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3101 3284
 		{
3102
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3103
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3104
-			else
3105
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3285
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3286
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3287
+			} else {
3288
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3289
+			}
3106 3290
 		}
3107 3291
 		// Uploaded?
3108
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3109
-			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3292
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3293
+					$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3294
+		}
3110 3295
 		// Full URL?
3111
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3112
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3296
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3297
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3298
+		}
3113 3299
 		// Otherwise we assume it's server stored.
3114
-		elseif ($user_info['avatar']['url'] != '')
3115
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3300
+		elseif ($user_info['avatar']['url'] != '') {
3301
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3302
+		}
3116 3303
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3117
-		else
3118
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3304
+		else {
3305
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3306
+		}
3119 3307
 
3120
-		if (!empty($context['user']['avatar']))
3121
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3308
+		if (!empty($context['user']['avatar'])) {
3309
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3310
+		}
3122 3311
 
3123 3312
 		// Figure out how long they've been logged in.
3124 3313
 		$context['user']['total_time_logged_in'] = array(
@@ -3126,8 +3315,7 @@  discard block
 block discarded – undo
3126 3315
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3127 3316
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3128 3317
 		);
3129
-	}
3130
-	else
3318
+	} else
3131 3319
 	{
3132 3320
 		$context['user']['messages'] = 0;
3133 3321
 		$context['user']['unread_messages'] = 0;
@@ -3135,12 +3323,14 @@  discard block
 block discarded – undo
3135 3323
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3136 3324
 		$context['user']['popup_messages'] = false;
3137 3325
 
3138
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3139
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3326
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3327
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3328
+		}
3140 3329
 
3141 3330
 		// If we've upgraded recently, go easy on the passwords.
3142
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3143
-			$context['disable_login_hashing'] = true;
3331
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3332
+					$context['disable_login_hashing'] = true;
3333
+		}
3144 3334
 	}
3145 3335
 
3146 3336
 	// Setup the main menu items.
@@ -3153,8 +3343,8 @@  discard block
 block discarded – undo
3153 3343
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3154 3344
 
3155 3345
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3156
-	if ($context['show_pm_popup'])
3157
-		addInlineJavaScript('
3346
+	if ($context['show_pm_popup']) {
3347
+			addInlineJavaScript('
3158 3348
 		jQuery(document).ready(function($) {
3159 3349
 			new smc_Popup({
3160 3350
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3162,15 +3352,17 @@  discard block
 block discarded – undo
3162 3352
 				icon_class: \'generic_icons mail_new\'
3163 3353
 			});
3164 3354
 		});');
3355
+	}
3165 3356
 
3166 3357
 	// Add a generic "Are you sure?" confirmation message.
3167 3358
 	addInlineJavaScript('
3168 3359
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3169 3360
 
3170 3361
 	// Now add the capping code for avatars.
3171
-	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
3172
-		addInlineCss('
3362
+	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') {
3363
+			addInlineCss('
3173 3364
 img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3365
+	}
3174 3366
 
3175 3367
 	// This looks weird, but it's because BoardIndex.php references the variable.
3176 3368
 	$context['common_stats']['latest_member'] = array(
@@ -3187,11 +3379,13 @@  discard block
 block discarded – undo
3187 3379
 	);
3188 3380
 	$context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']);
3189 3381
 
3190
-	if (empty($settings['theme_version']))
3191
-		addJavaScriptVar('smf_scripturl', $scripturl);
3382
+	if (empty($settings['theme_version'])) {
3383
+			addJavaScriptVar('smf_scripturl', $scripturl);
3384
+	}
3192 3385
 
3193
-	if (!isset($context['page_title']))
3194
-		$context['page_title'] = '';
3386
+	if (!isset($context['page_title'])) {
3387
+			$context['page_title'] = '';
3388
+	}
3195 3389
 
3196 3390
 	// Set some specific vars.
3197 3391
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3201,21 +3395,23 @@  discard block
 block discarded – undo
3201 3395
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3202 3396
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3203 3397
 
3204
-	if (!empty($context['meta_keywords']))
3205
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3398
+	if (!empty($context['meta_keywords'])) {
3399
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3400
+	}
3206 3401
 
3207
-	if (!empty($context['canonical_url']))
3208
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3402
+	if (!empty($context['canonical_url'])) {
3403
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3404
+	}
3209 3405
 
3210
-	if (!empty($settings['og_image']))
3211
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3406
+	if (!empty($settings['og_image'])) {
3407
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3408
+	}
3212 3409
 
3213 3410
 	if (!empty($context['meta_description']))
3214 3411
 	{
3215 3412
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3216 3413
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3217
-	}
3218
-	else
3414
+	} else
3219 3415
 	{
3220 3416
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3221 3417
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3240,8 +3436,9 @@  discard block
 block discarded – undo
3240 3436
 	$memory_needed = memoryReturnBytes($needed);
3241 3437
 
3242 3438
 	// should we account for how much is currently being used?
3243
-	if ($in_use)
3244
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3439
+	if ($in_use) {
3440
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3441
+	}
3245 3442
 
3246 3443
 	// if more is needed, request it
3247 3444
 	if ($memory_current < $memory_needed)
@@ -3264,8 +3461,9 @@  discard block
 block discarded – undo
3264 3461
  */
3265 3462
 function memoryReturnBytes($val)
3266 3463
 {
3267
-	if (is_integer($val))
3268
-		return $val;
3464
+	if (is_integer($val)) {
3465
+			return $val;
3466
+	}
3269 3467
 
3270 3468
 	// Separate the number from the designator
3271 3469
 	$val = trim($val);
@@ -3301,10 +3499,11 @@  discard block
 block discarded – undo
3301 3499
 		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3302 3500
 
3303 3501
 		// Are we debugging the template/html content?
3304
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3305
-			header('Content-Type: application/xhtml+xml');
3306
-		elseif (!isset($_REQUEST['xml']))
3307
-			header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3502
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3503
+					header('Content-Type: application/xhtml+xml');
3504
+		} elseif (!isset($_REQUEST['xml'])) {
3505
+					header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3506
+		}
3308 3507
 	}
3309 3508
 
3310 3509
 	header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3313,8 +3512,9 @@  discard block
 block discarded – undo
3313 3512
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3314 3513
 	{
3315 3514
 		$position = array_search('body', $context['template_layers']);
3316
-		if ($position === false)
3317
-			$position = array_search('main', $context['template_layers']);
3515
+		if ($position === false) {
3516
+					$position = array_search('main', $context['template_layers']);
3517
+		}
3318 3518
 
3319 3519
 		if ($position !== false)
3320 3520
 		{
@@ -3342,23 +3542,25 @@  discard block
 block discarded – undo
3342 3542
 
3343 3543
 			foreach ($securityFiles as $i => $securityFile)
3344 3544
 			{
3345
-				if (!file_exists($boarddir . '/' . $securityFile))
3346
-					unset($securityFiles[$i]);
3545
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3546
+									unset($securityFiles[$i]);
3547
+				}
3347 3548
 			}
3348 3549
 
3349 3550
 			// We are already checking so many files...just few more doesn't make any difference! :P
3350
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3351
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3352
-
3353
-			else
3354
-				$path = $modSettings['attachmentUploadDir'];
3551
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3552
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3553
+			} else {
3554
+							$path = $modSettings['attachmentUploadDir'];
3555
+			}
3355 3556
 
3356 3557
 			secureDirectory($path, true);
3357 3558
 			secureDirectory($cachedir);
3358 3559
 
3359 3560
 			// If agreement is enabled, at least the english version shall exists
3360
-			if ($modSettings['requireAgreement'])
3361
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3561
+			if ($modSettings['requireAgreement']) {
3562
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3563
+			}
3362 3564
 
3363 3565
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3364 3566
 			{
@@ -3373,18 +3575,21 @@  discard block
 block discarded – undo
3373 3575
 					echo '
3374 3576
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3375 3577
 
3376
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3377
-						echo '
3578
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3579
+											echo '
3378 3580
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3581
+					}
3379 3582
 				}
3380 3583
 
3381
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3382
-					echo '
3584
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3585
+									echo '
3383 3586
 				<strong>', $txt['cache_writable'], '</strong><br>';
3587
+				}
3384 3588
 
3385
-				if (!empty($agreement))
3386
-					echo '
3589
+				if (!empty($agreement)) {
3590
+									echo '
3387 3591
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3592
+				}
3388 3593
 
3389 3594
 				echo '
3390 3595
 			</p>
@@ -3399,16 +3604,18 @@  discard block
 block discarded – undo
3399 3604
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3400 3605
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3401 3606
 
3402
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3403
-				echo '
3607
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3608
+							echo '
3404 3609
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3610
+			}
3405 3611
 
3406
-			if (!empty($_SESSION['ban']['expire_time']))
3407
-				echo '
3612
+			if (!empty($_SESSION['ban']['expire_time'])) {
3613
+							echo '
3408 3614
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3409
-			else
3410
-				echo '
3615
+			} else {
3616
+							echo '
3411 3617
 					<div>', $txt['your_ban_expires_never'], '</div>';
3618
+			}
3412 3619
 
3413 3620
 			echo '
3414 3621
 				</div>';
@@ -3424,8 +3631,9 @@  discard block
 block discarded – undo
3424 3631
 	global $forum_copyright, $software_year, $forum_version;
3425 3632
 
3426 3633
 	// Don't display copyright for things like SSI.
3427
-	if (!isset($forum_version) || !isset($software_year))
3428
-		return;
3634
+	if (!isset($forum_version) || !isset($software_year)) {
3635
+			return;
3636
+	}
3429 3637
 
3430 3638
 	// Put in the version...
3431 3639
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3443,9 +3651,10 @@  discard block
 block discarded – undo
3443 3651
 	$context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3));
3444 3652
 	$context['load_queries'] = $db_count;
3445 3653
 
3446
-	foreach (array_reverse($context['template_layers']) as $layer)
3447
-		loadSubTemplate($layer . '_below', true);
3448
-}
3654
+	foreach (array_reverse($context['template_layers']) as $layer) {
3655
+			loadSubTemplate($layer . '_below', true);
3656
+	}
3657
+	}
3449 3658
 
3450 3659
 /**
3451 3660
  * Output the Javascript files
@@ -3476,8 +3685,7 @@  discard block
 block discarded – undo
3476 3685
 			{
3477 3686
 				echo '
3478 3687
 		var ', $key, ';';
3479
-			}
3480
-			else
3688
+			} else
3481 3689
 			{
3482 3690
 				echo '
3483 3691
 		var ', $key, ' = ', $value, ';';
@@ -3492,26 +3700,27 @@  discard block
 block discarded – undo
3492 3700
 	foreach ($context['javascript_files'] as $id => $js_file)
3493 3701
 	{
3494 3702
 		// Last minute call! allow theme authors to disable single files.
3495
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3496
-			continue;
3703
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3704
+					continue;
3705
+		}
3497 3706
 
3498 3707
 		// By default all files don't get minimized unless the file explicitly says so!
3499 3708
 		if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3500 3709
 		{
3501
-			if ($do_deferred && !empty($js_file['options']['defer']))
3502
-				$toMinifyDefer[] = $js_file;
3503
-
3504
-			elseif (!$do_deferred && empty($js_file['options']['defer']))
3505
-				$toMinify[] = $js_file;
3710
+			if ($do_deferred && !empty($js_file['options']['defer'])) {
3711
+							$toMinifyDefer[] = $js_file;
3712
+			} elseif (!$do_deferred && empty($js_file['options']['defer'])) {
3713
+							$toMinify[] = $js_file;
3714
+			}
3506 3715
 
3507 3716
 			// Grab a random seed.
3508
-			if (!isset($minSeed))
3509
-				$minSeed = $js_file['options']['seed'];
3510
-		}
3511
-
3512
-		elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer'])))
3513
-			echo '
3717
+			if (!isset($minSeed)) {
3718
+							$minSeed = $js_file['options']['seed'];
3719
+			}
3720
+		} elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) {
3721
+					echo '
3514 3722
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
3723
+		}
3515 3724
 	}
3516 3725
 
3517 3726
 	if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer)))
@@ -3519,14 +3728,14 @@  discard block
 block discarded – undo
3519 3728
 		$result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred);
3520 3729
 
3521 3730
 		// Minify process couldn't work, print each individual files.
3522
-		if (!empty($result) && is_array($result))
3523
-			foreach ($result as $minFailedFile)
3731
+		if (!empty($result) && is_array($result)) {
3732
+					foreach ($result as $minFailedFile)
3524 3733
 				echo '
3525 3734
 	<script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>';
3526
-
3527
-		else
3528
-			echo '
3735
+		} else {
3736
+					echo '
3529 3737
 	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3738
+		}
3530 3739
 	}
3531 3740
 
3532 3741
 	// Inline JavaScript - Actually useful some times!
@@ -3537,8 +3746,9 @@  discard block
 block discarded – undo
3537 3746
 			echo '
3538 3747
 <script>';
3539 3748
 
3540
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3541
-				echo $js_code;
3749
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
3750
+							echo $js_code;
3751
+			}
3542 3752
 
3543 3753
 			echo '
3544 3754
 </script>';
@@ -3549,8 +3759,9 @@  discard block
 block discarded – undo
3549 3759
 			echo '
3550 3760
 	<script>';
3551 3761
 
3552
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3553
-				echo $js_code;
3762
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
3763
+							echo $js_code;
3764
+			}
3554 3765
 
3555 3766
 			echo '
3556 3767
 	</script>';
@@ -3575,8 +3786,9 @@  discard block
 block discarded – undo
3575 3786
 	foreach ($context['css_files'] as $id => $file)
3576 3787
 	{
3577 3788
 		// Last minute call! allow theme authors to disable single files.
3578
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3579
-			continue;
3789
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3790
+					continue;
3791
+		}
3580 3792
 
3581 3793
 		// By default all files don't get minimized unless the file explicitly says so!
3582 3794
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
@@ -3584,12 +3796,12 @@  discard block
 block discarded – undo
3584 3796
 			$toMinify[] = $file;
3585 3797
 
3586 3798
 			// Grab a random seed.
3587
-			if (!isset($minSeed))
3588
-				$minSeed = $file['options']['seed'];
3799
+			if (!isset($minSeed)) {
3800
+							$minSeed = $file['options']['seed'];
3801
+			}
3802
+		} else {
3803
+					$normal[] = $file['fileUrl'];
3589 3804
 		}
3590
-
3591
-		else
3592
-			$normal[] = $file['fileUrl'];
3593 3805
 	}
3594 3806
 
3595 3807
 	if (!empty($toMinify))
@@ -3597,28 +3809,30 @@  discard block
 block discarded – undo
3597 3809
 		$result = custMinify($toMinify, 'css');
3598 3810
 
3599 3811
 		// Minify process couldn't work, print each individual files.
3600
-		if (!empty($result) && is_array($result))
3601
-			foreach ($result as $minFailedFile)
3812
+		if (!empty($result) && is_array($result)) {
3813
+					foreach ($result as $minFailedFile)
3602 3814
 				echo '
3603 3815
 	<link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">';
3604
-
3605
-		else
3606
-			echo '
3816
+		} else {
3817
+					echo '
3607 3818
 	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3819
+		}
3608 3820
 	}
3609 3821
 
3610 3822
 	// Print the rest after the minified files.
3611
-	if (!empty($normal))
3612
-		foreach ($normal as $nf)
3823
+	if (!empty($normal)) {
3824
+			foreach ($normal as $nf)
3613 3825
 			echo '
3614 3826
 	<link rel="stylesheet" href="', $nf ,'">';
3827
+	}
3615 3828
 
3616 3829
 	if ($db_show_debug === true)
3617 3830
 	{
3618 3831
 		// Try to keep only what's useful.
3619 3832
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3620
-		foreach ($context['css_files'] as $file)
3621
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3833
+		foreach ($context['css_files'] as $file) {
3834
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3835
+		}
3622 3836
 	}
3623 3837
 
3624 3838
 	if (!empty($context['css_header']))
@@ -3626,9 +3840,10 @@  discard block
 block discarded – undo
3626 3840
 		echo '
3627 3841
 	<style>';
3628 3842
 
3629
-		foreach ($context['css_header'] as $css)
3630
-			echo $css .'
3843
+		foreach ($context['css_header'] as $css) {
3844
+					echo $css .'
3631 3845
 	';
3846
+		}
3632 3847
 
3633 3848
 		echo'
3634 3849
 	</style>';
@@ -3652,15 +3867,17 @@  discard block
 block discarded – undo
3652 3867
 	$type = !empty($type) && in_array($type, $types) ? $type : false;
3653 3868
 	$data = !empty($data) ? $data : false;
3654 3869
 
3655
-	if (empty($type) || empty($data))
3656
-		return false;
3870
+	if (empty($type) || empty($data)) {
3871
+			return false;
3872
+	}
3657 3873
 
3658 3874
 	// Did we already did this?
3659 3875
 	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3660 3876
 
3661 3877
 	// Already done?
3662
-	if (!empty($toCache))
3663
-		return true;
3878
+	if (!empty($toCache)) {
3879
+			return true;
3880
+	}
3664 3881
 
3665 3882
 	// No namespaces, sorry!
3666 3883
 	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
@@ -3742,8 +3959,9 @@  discard block
 block discarded – undo
3742 3959
 	global $modSettings, $smcFunc;
3743 3960
 
3744 3961
 	// Just make up a nice hash...
3745
-	if ($new)
3746
-		return sha1(md5($filename . time()) . mt_rand());
3962
+	if ($new) {
3963
+			return sha1(md5($filename . time()) . mt_rand());
3964
+	}
3747 3965
 
3748 3966
 	// Just make sure that attachment id is only a int
3749 3967
 	$attachment_id = (int) $attachment_id;
@@ -3760,23 +3978,25 @@  discard block
 block discarded – undo
3760 3978
 				'id_attach' => $attachment_id,
3761 3979
 			));
3762 3980
 
3763
-		if ($smcFunc['db_num_rows']($request) === 0)
3764
-			return false;
3981
+		if ($smcFunc['db_num_rows']($request) === 0) {
3982
+					return false;
3983
+		}
3765 3984
 
3766 3985
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
3767 3986
 		$smcFunc['db_free_result']($request);
3768 3987
 	}
3769 3988
 
3770 3989
 	// Still no hash? mmm...
3771
-	if (empty($file_hash))
3772
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
3990
+	if (empty($file_hash)) {
3991
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
3992
+	}
3773 3993
 
3774 3994
 	// Are we using multiple directories?
3775
-	if (is_array($modSettings['attachmentUploadDir']))
3776
-		$path = $modSettings['attachmentUploadDir'][$dir];
3777
-
3778
-	else
3779
-		$path = $modSettings['attachmentUploadDir'];
3995
+	if (is_array($modSettings['attachmentUploadDir'])) {
3996
+			$path = $modSettings['attachmentUploadDir'][$dir];
3997
+	} else {
3998
+			$path = $modSettings['attachmentUploadDir'];
3999
+	}
3780 4000
 
3781 4001
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3782 4002
 }
@@ -3791,8 +4011,9 @@  discard block
 block discarded – undo
3791 4011
 function ip2range($fullip)
3792 4012
 {
3793 4013
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
3794
-	if ($fullip == 'unknown')
3795
-		$fullip = '255.255.255.255';
4014
+	if ($fullip == 'unknown') {
4015
+			$fullip = '255.255.255.255';
4016
+	}
3796 4017
 
3797 4018
 	$ip_parts = explode('-', $fullip);
3798 4019
 	$ip_array = array();
@@ -3816,10 +4037,11 @@  discard block
 block discarded – undo
3816 4037
 		$ip_array['low'] = $ip_parts[0];
3817 4038
 		$ip_array['high'] = $ip_parts[1];
3818 4039
 		return $ip_array;
3819
-	}
3820
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
4040
+	} elseif (count($ip_parts) == 2) {
4041
+		// if ip 22.22.*-22.22.*
3821 4042
 	{
3822 4043
 		$valid_low = isValidIP($ip_parts[0]);
4044
+	}
3823 4045
 		$valid_high = isValidIP($ip_parts[1]);
3824 4046
 		$count = 0;
3825 4047
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -3834,7 +4056,9 @@  discard block
 block discarded – undo
3834 4056
 				$ip_parts[0] .= $mode . $min;
3835 4057
 				$valid_low = isValidIP($ip_parts[0]);
3836 4058
 				$count++;
3837
-				if ($count > 9) break;
4059
+				if ($count > 9) {
4060
+					break;
4061
+				}
3838 4062
 			}
3839 4063
 		}
3840 4064
 
@@ -3848,7 +4072,9 @@  discard block
 block discarded – undo
3848 4072
 				$ip_parts[1] .= $mode . $max;
3849 4073
 				$valid_high = isValidIP($ip_parts[1]);
3850 4074
 				$count++;
3851
-				if ($count > 9) break;
4075
+				if ($count > 9) {
4076
+					break;
4077
+				}
3852 4078
 			}
3853 4079
 		}
3854 4080
 
@@ -3873,46 +4099,54 @@  discard block
 block discarded – undo
3873 4099
 {
3874 4100
 	global $modSettings;
3875 4101
 
3876
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
3877
-		return $host;
4102
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4103
+			return $host;
4104
+	}
3878 4105
 	$t = microtime();
3879 4106
 
3880 4107
 	// Try the Linux host command, perhaps?
3881 4108
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
3882 4109
 	{
3883
-		if (!isset($modSettings['host_to_dis']))
3884
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3885
-		else
3886
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4110
+		if (!isset($modSettings['host_to_dis'])) {
4111
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4112
+		} else {
4113
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4114
+		}
3887 4115
 
3888 4116
 		// Did host say it didn't find anything?
3889
-		if (strpos($test, 'not found') !== false)
3890
-			$host = '';
4117
+		if (strpos($test, 'not found') !== false) {
4118
+					$host = '';
4119
+		}
3891 4120
 		// Invalid server option?
3892
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
3893
-			updateSettings(array('host_to_dis' => 1));
4121
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4122
+					updateSettings(array('host_to_dis' => 1));
4123
+		}
3894 4124
 		// Maybe it found something, after all?
3895
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
3896
-			$host = $match[1];
4125
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4126
+					$host = $match[1];
4127
+		}
3897 4128
 	}
3898 4129
 
3899 4130
 	// This is nslookup; usually only Windows, but possibly some Unix?
3900 4131
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
3901 4132
 	{
3902 4133
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
3903
-		if (strpos($test, 'Non-existent domain') !== false)
3904
-			$host = '';
3905
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
3906
-			$host = $match[1];
4134
+		if (strpos($test, 'Non-existent domain') !== false) {
4135
+					$host = '';
4136
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4137
+					$host = $match[1];
4138
+		}
3907 4139
 	}
3908 4140
 
3909 4141
 	// This is the last try :/.
3910
-	if (!isset($host) || $host === false)
3911
-		$host = @gethostbyaddr($ip);
4142
+	if (!isset($host) || $host === false) {
4143
+			$host = @gethostbyaddr($ip);
4144
+	}
3912 4145
 
3913 4146
 	// It took a long time, so let's cache it!
3914
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
3915
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4147
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4148
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4149
+	}
3916 4150
 
3917 4151
 	return $host;
3918 4152
 }
@@ -3948,20 +4182,21 @@  discard block
 block discarded – undo
3948 4182
 			{
3949 4183
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
3950 4184
 				$total = 0;
3951
-				for ($i = 0; $i < $max_chars; $i++)
3952
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4185
+				for ($i = 0; $i < $max_chars; $i++) {
4186
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4187
+				}
3953 4188
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
3954 4189
 			}
3955 4190
 		}
3956 4191
 		return array_unique($returned_ints);
3957
-	}
3958
-	else
4192
+	} else
3959 4193
 	{
3960 4194
 		// Trim characters before and after and add slashes for database insertion.
3961 4195
 		$returned_words = array();
3962
-		foreach ($words as $word)
3963
-			if (($word = trim($word, '-_\'')) !== '')
4196
+		foreach ($words as $word) {
4197
+					if (($word = trim($word, '-_\'')) !== '')
3964 4198
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4199
+		}
3965 4200
 
3966 4201
 		// Filter out all words that occur more than once.
3967 4202
 		return array_unique($returned_words);
@@ -3983,16 +4218,18 @@  discard block
 block discarded – undo
3983 4218
 	global $settings, $txt;
3984 4219
 
3985 4220
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
3986
-	if (function_exists('template_create_button') && !$force_use)
3987
-		return template_create_button($name, $alt, $label = '', $custom = '');
4221
+	if (function_exists('template_create_button') && !$force_use) {
4222
+			return template_create_button($name, $alt, $label = '', $custom = '');
4223
+	}
3988 4224
 
3989
-	if (!$settings['use_image_buttons'])
3990
-		return $txt[$alt];
3991
-	elseif (!empty($settings['use_buttons']))
3992
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
3993
-	else
3994
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
3995
-}
4225
+	if (!$settings['use_image_buttons']) {
4226
+			return $txt[$alt];
4227
+	} elseif (!empty($settings['use_buttons'])) {
4228
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4229
+	} else {
4230
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4231
+	}
4232
+	}
3996 4233
 
3997 4234
 /**
3998 4235
  * Sets up all of the top menu buttons
@@ -4035,9 +4272,10 @@  discard block
 block discarded – undo
4035 4272
 	var user_menus = new smc_PopupMenu();
4036 4273
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4037 4274
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4038
-		if ($context['allow_pm'])
4039
-			addInlineJavaScript('
4275
+		if ($context['allow_pm']) {
4276
+					addInlineJavaScript('
4040 4277
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4278
+		}
4041 4279
 
4042 4280
 		if (!empty($modSettings['enable_ajax_alerts']))
4043 4281
 		{
@@ -4197,88 +4435,96 @@  discard block
 block discarded – undo
4197 4435
 
4198 4436
 		// Now we put the buttons in the context so the theme can use them.
4199 4437
 		$menu_buttons = array();
4200
-		foreach ($buttons as $act => $button)
4201
-			if (!empty($button['show']))
4438
+		foreach ($buttons as $act => $button) {
4439
+					if (!empty($button['show']))
4202 4440
 			{
4203 4441
 				$button['active_button'] = false;
4442
+		}
4204 4443
 
4205 4444
 				// This button needs some action.
4206
-				if (isset($button['action_hook']))
4207
-					$needs_action_hook = true;
4445
+				if (isset($button['action_hook'])) {
4446
+									$needs_action_hook = true;
4447
+				}
4208 4448
 
4209 4449
 				// Make sure the last button truly is the last button.
4210 4450
 				if (!empty($button['is_last']))
4211 4451
 				{
4212
-					if (isset($last_button))
4213
-						unset($menu_buttons[$last_button]['is_last']);
4452
+					if (isset($last_button)) {
4453
+											unset($menu_buttons[$last_button]['is_last']);
4454
+					}
4214 4455
 					$last_button = $act;
4215 4456
 				}
4216 4457
 
4217 4458
 				// Go through the sub buttons if there are any.
4218
-				if (!empty($button['sub_buttons']))
4219
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4459
+				if (!empty($button['sub_buttons'])) {
4460
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4220 4461
 					{
4221 4462
 						if (empty($subbutton['show']))
4222 4463
 							unset($button['sub_buttons'][$key]);
4464
+				}
4223 4465
 
4224 4466
 						// 2nd level sub buttons next...
4225 4467
 						if (!empty($subbutton['sub_buttons']))
4226 4468
 						{
4227 4469
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4228 4470
 							{
4229
-								if (empty($sub_button2['show']))
4230
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4471
+								if (empty($sub_button2['show'])) {
4472
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4473
+								}
4231 4474
 							}
4232 4475
 						}
4233 4476
 					}
4234 4477
 
4235 4478
 				// Does this button have its own icon?
4236
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4237
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4238
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4239
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4240
-				elseif (isset($button['icon']))
4241
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4242
-				else
4243
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4479
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4480
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4481
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4482
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4483
+				} elseif (isset($button['icon'])) {
4484
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4485
+				} else {
4486
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4487
+				}
4244 4488
 
4245 4489
 				$menu_buttons[$act] = $button;
4246 4490
 			}
4247 4491
 
4248
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4249
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4492
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4493
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4494
+		}
4250 4495
 	}
4251 4496
 
4252 4497
 	$context['menu_buttons'] = $menu_buttons;
4253 4498
 
4254 4499
 	// Logging out requires the session id in the url.
4255
-	if (isset($context['menu_buttons']['logout']))
4256
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4500
+	if (isset($context['menu_buttons']['logout'])) {
4501
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4502
+	}
4257 4503
 
4258 4504
 	// Figure out which action we are doing so we can set the active tab.
4259 4505
 	// Default to home.
4260 4506
 	$current_action = 'home';
4261 4507
 
4262
-	if (isset($context['menu_buttons'][$context['current_action']]))
4263
-		$current_action = $context['current_action'];
4264
-	elseif ($context['current_action'] == 'search2')
4265
-		$current_action = 'search';
4266
-	elseif ($context['current_action'] == 'theme')
4267
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4268
-	elseif ($context['current_action'] == 'register2')
4269
-		$current_action = 'register';
4270
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4271
-		$current_action = 'login';
4272
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4273
-		$current_action = 'moderate';
4508
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4509
+			$current_action = $context['current_action'];
4510
+	} elseif ($context['current_action'] == 'search2') {
4511
+			$current_action = 'search';
4512
+	} elseif ($context['current_action'] == 'theme') {
4513
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4514
+	} elseif ($context['current_action'] == 'register2') {
4515
+			$current_action = 'register';
4516
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4517
+			$current_action = 'login';
4518
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4519
+			$current_action = 'moderate';
4520
+	}
4274 4521
 
4275 4522
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4276 4523
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4277 4524
 	{
4278 4525
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4279 4526
 		$context[$current_action] = true;
4280
-	}
4281
-	elseif ($context['current_action'] == 'pm')
4527
+	} elseif ($context['current_action'] == 'pm')
4282 4528
 	{
4283 4529
 		$current_action = 'self_pm';
4284 4530
 		$context['self_pm'] = true;
@@ -4319,12 +4565,14 @@  discard block
 block discarded – undo
4319 4565
 	}
4320 4566
 
4321 4567
 	// Not all actions are simple.
4322
-	if (!empty($needs_action_hook))
4323
-		call_integration_hook('integrate_current_action', array(&$current_action));
4568
+	if (!empty($needs_action_hook)) {
4569
+			call_integration_hook('integrate_current_action', array(&$current_action));
4570
+	}
4324 4571
 
4325
-	if (isset($context['menu_buttons'][$current_action]))
4326
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4327
-}
4572
+	if (isset($context['menu_buttons'][$current_action])) {
4573
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4574
+	}
4575
+	}
4328 4576
 
4329 4577
 /**
4330 4578
  * Generate a random seed and ensure it's stored in settings.
@@ -4348,30 +4596,35 @@  discard block
 block discarded – undo
4348 4596
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4349 4597
 	global $context, $txt;
4350 4598
 
4351
-	if ($db_show_debug === true)
4352
-		$context['debug']['hooks'][] = $hook;
4599
+	if ($db_show_debug === true) {
4600
+			$context['debug']['hooks'][] = $hook;
4601
+	}
4353 4602
 
4354 4603
 	// Need to have some control.
4355
-	if (!isset($context['instances']))
4356
-		$context['instances'] = array();
4604
+	if (!isset($context['instances'])) {
4605
+			$context['instances'] = array();
4606
+	}
4357 4607
 
4358 4608
 	$results = array();
4359
-	if (empty($modSettings[$hook]))
4360
-		return $results;
4609
+	if (empty($modSettings[$hook])) {
4610
+			return $results;
4611
+	}
4361 4612
 
4362 4613
 	$functions = explode(',', $modSettings[$hook]);
4363 4614
 	// Loop through each function.
4364 4615
 	foreach ($functions as $function)
4365 4616
 	{
4366 4617
 		// Hook has been marked as "disabled". Skip it!
4367
-		if (strpos($function, '!') !== false)
4368
-			continue;
4618
+		if (strpos($function, '!') !== false) {
4619
+					continue;
4620
+		}
4369 4621
 
4370 4622
 		$call = call_helper($function, true);
4371 4623
 
4372 4624
 		// Is it valid?
4373
-		if (!empty($call))
4374
-			$results[$function] = call_user_func_array($call, $parameters);
4625
+		if (!empty($call)) {
4626
+					$results[$function] = call_user_func_array($call, $parameters);
4627
+		}
4375 4628
 
4376 4629
 		// Whatever it was suppose to call, it failed :(
4377 4630
 		elseif (!empty($function))
@@ -4387,8 +4640,9 @@  discard block
 block discarded – undo
4387 4640
 			}
4388 4641
 
4389 4642
 			// "Assume" the file resides on $boarddir somewhere...
4390
-			else
4391
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4643
+			else {
4644
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4645
+			}
4392 4646
 		}
4393 4647
 	}
4394 4648
 
@@ -4410,12 +4664,14 @@  discard block
 block discarded – undo
4410 4664
 	global $smcFunc, $modSettings;
4411 4665
 
4412 4666
 	// Any objects?
4413
-	if ($object)
4414
-		$function = $function . '#';
4667
+	if ($object) {
4668
+			$function = $function . '#';
4669
+	}
4415 4670
 
4416 4671
 	// Any files  to load?
4417
-	if (!empty($file) && is_string($file))
4418
-		$function = $file . (!empty($function) ? '|' . $function : '');
4672
+	if (!empty($file) && is_string($file)) {
4673
+			$function = $file . (!empty($function) ? '|' . $function : '');
4674
+	}
4419 4675
 
4420 4676
 	// Get the correct string.
4421 4677
 	$integration_call = $function;
@@ -4437,13 +4693,14 @@  discard block
 block discarded – undo
4437 4693
 		if (!empty($current_functions))
4438 4694
 		{
4439 4695
 			$current_functions = explode(',', $current_functions);
4440
-			if (in_array($integration_call, $current_functions))
4441
-				return;
4696
+			if (in_array($integration_call, $current_functions)) {
4697
+							return;
4698
+			}
4442 4699
 
4443 4700
 			$permanent_functions = array_merge($current_functions, array($integration_call));
4701
+		} else {
4702
+					$permanent_functions = array($integration_call);
4444 4703
 		}
4445
-		else
4446
-			$permanent_functions = array($integration_call);
4447 4704
 
4448 4705
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4449 4706
 	}
@@ -4452,8 +4709,9 @@  discard block
 block discarded – undo
4452 4709
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4453 4710
 
4454 4711
 	// Do nothing, if it's already there.
4455
-	if (in_array($integration_call, $functions))
4456
-		return;
4712
+	if (in_array($integration_call, $functions)) {
4713
+			return;
4714
+	}
4457 4715
 
4458 4716
 	$functions[] = $integration_call;
4459 4717
 	$modSettings[$hook] = implode(',', $functions);
@@ -4476,12 +4734,14 @@  discard block
 block discarded – undo
4476 4734
 	global $smcFunc, $modSettings;
4477 4735
 
4478 4736
 	// Any objects?
4479
-	if ($object)
4480
-		$function = $function . '#';
4737
+	if ($object) {
4738
+			$function = $function . '#';
4739
+	}
4481 4740
 
4482 4741
 	// Any files  to load?
4483
-	if (!empty($file) && is_string($file))
4484
-		$function = $file . '|' . $function;
4742
+	if (!empty($file) && is_string($file)) {
4743
+			$function = $file . '|' . $function;
4744
+	}
4485 4745
 
4486 4746
 	// Get the correct string.
4487 4747
 	$integration_call = $function;
@@ -4502,16 +4762,18 @@  discard block
 block discarded – undo
4502 4762
 	{
4503 4763
 		$current_functions = explode(',', $current_functions);
4504 4764
 
4505
-		if (in_array($integration_call, $current_functions))
4506
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4765
+		if (in_array($integration_call, $current_functions)) {
4766
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4767
+		}
4507 4768
 	}
4508 4769
 
4509 4770
 	// Turn the function list into something usable.
4510 4771
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4511 4772
 
4512 4773
 	// You can only remove it if it's available.
4513
-	if (!in_array($integration_call, $functions))
4514
-		return;
4774
+	if (!in_array($integration_call, $functions)) {
4775
+			return;
4776
+	}
4515 4777
 
4516 4778
 	$functions = array_diff($functions, array($integration_call));
4517 4779
 	$modSettings[$hook] = implode(',', $functions);
@@ -4532,17 +4794,20 @@  discard block
 block discarded – undo
4532 4794
 	global $context, $smcFunc, $txt, $db_show_debug;
4533 4795
 
4534 4796
 	// Really?
4535
-	if (empty($string))
4536
-		return false;
4797
+	if (empty($string)) {
4798
+			return false;
4799
+	}
4537 4800
 
4538 4801
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4539 4802
 	// A closure? should be a callable one.
4540
-	if (is_array($string) || $string instanceof Closure)
4541
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4803
+	if (is_array($string) || $string instanceof Closure) {
4804
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4805
+	}
4542 4806
 
4543 4807
 	// No full objects, sorry! pass a method or a property instead!
4544
-	if (is_object($string))
4545
-		return false;
4808
+	if (is_object($string)) {
4809
+			return false;
4810
+	}
4546 4811
 
4547 4812
 	// Stay vitaminized my friends...
4548 4813
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4551,8 +4816,9 @@  discard block
 block discarded – undo
4551 4816
 	$string = load_file($string);
4552 4817
 
4553 4818
 	// Loaded file failed
4554
-	if (empty($string))
4555
-		return false;
4819
+	if (empty($string)) {
4820
+			return false;
4821
+	}
4556 4822
 
4557 4823
 	// Found a method.
4558 4824
 	if (strpos($string, '::') !== false)
@@ -4573,8 +4839,9 @@  discard block
 block discarded – undo
4573 4839
 				// Add another one to the list.
4574 4840
 				if ($db_show_debug === true)
4575 4841
 				{
4576
-					if (!isset($context['debug']['instances']))
4577
-						$context['debug']['instances'] = array();
4842
+					if (!isset($context['debug']['instances'])) {
4843
+											$context['debug']['instances'] = array();
4844
+					}
4578 4845
 
4579 4846
 					$context['debug']['instances'][$class] = $class;
4580 4847
 				}
@@ -4584,13 +4851,15 @@  discard block
 block discarded – undo
4584 4851
 		}
4585 4852
 
4586 4853
 		// Right then. This is a call to a static method.
4587
-		else
4588
-			$func = array($class, $method);
4854
+		else {
4855
+					$func = array($class, $method);
4856
+		}
4589 4857
 	}
4590 4858
 
4591 4859
 	// Nope! just a plain regular function.
4592
-	else
4593
-		$func = $string;
4860
+	else {
4861
+			$func = $string;
4862
+	}
4594 4863
 
4595 4864
 	// Right, we got what we need, time to do some checks.
4596 4865
 	if (!is_callable($func, false, $callable_name))
@@ -4606,17 +4875,18 @@  discard block
 block discarded – undo
4606 4875
 	else
4607 4876
 	{
4608 4877
 		// What are we gonna do about it?
4609
-		if ($return)
4610
-			return $func;
4878
+		if ($return) {
4879
+					return $func;
4880
+		}
4611 4881
 
4612 4882
 		// If this is a plain function, avoid the heat of calling call_user_func().
4613 4883
 		else
4614 4884
 		{
4615
-			if (is_array($func))
4616
-				call_user_func($func);
4617
-
4618
-			else
4619
-				$func();
4885
+			if (is_array($func)) {
4886
+							call_user_func($func);
4887
+			} else {
4888
+							$func();
4889
+			}
4620 4890
 		}
4621 4891
 	}
4622 4892
 }
@@ -4633,31 +4903,34 @@  discard block
 block discarded – undo
4633 4903
 {
4634 4904
 	global $sourcedir, $txt, $boarddir, $settings;
4635 4905
 
4636
-	if (empty($string))
4637
-		return false;
4906
+	if (empty($string)) {
4907
+			return false;
4908
+	}
4638 4909
 
4639 4910
 	if (strpos($string, '|') !== false)
4640 4911
 	{
4641 4912
 		list ($file, $string) = explode('|', $string);
4642 4913
 
4643 4914
 		// Match the wildcards to their regular vars.
4644
-		if (empty($settings['theme_dir']))
4645
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4646
-
4647
-		else
4648
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4915
+		if (empty($settings['theme_dir'])) {
4916
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4917
+		} else {
4918
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4919
+		}
4649 4920
 
4650 4921
 		// Load the file if it can be loaded.
4651
-		if (file_exists($absPath))
4652
-			require_once($absPath);
4922
+		if (file_exists($absPath)) {
4923
+					require_once($absPath);
4924
+		}
4653 4925
 
4654 4926
 		// No? try a fallback to $sourcedir
4655 4927
 		else
4656 4928
 		{
4657 4929
 			$absPath = $sourcedir .'/'. $file;
4658 4930
 
4659
-			if (file_exists($absPath))
4660
-				require_once($absPath);
4931
+			if (file_exists($absPath)) {
4932
+							require_once($absPath);
4933
+			}
4661 4934
 
4662 4935
 			// Sorry, can't do much for you at this point.
4663 4936
 			else
@@ -4684,8 +4957,9 @@  discard block
 block discarded – undo
4684 4957
 	global $user_info, $smcFunc;
4685 4958
 
4686 4959
 	// Make sure we have something to work with.
4687
-	if (empty($topic))
4688
-		return array();
4960
+	if (empty($topic)) {
4961
+			return array();
4962
+	}
4689 4963
 
4690 4964
 
4691 4965
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -4708,8 +4982,9 @@  discard block
 block discarded – undo
4708 4982
 				'topic' => $topic,
4709 4983
 			)
4710 4984
 		);
4711
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4712
-			$temp[] = (int) $row['content_id'];
4985
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4986
+					$temp[] = (int) $row['content_id'];
4987
+		}
4713 4988
 
4714 4989
 		cache_put_data($cache_key, $temp, $ttl);
4715 4990
 	}
@@ -4730,8 +5005,9 @@  discard block
 block discarded – undo
4730 5005
 {
4731 5006
 	global $context;
4732 5007
 
4733
-	if (empty($string))
4734
-		return $string;
5008
+	if (empty($string)) {
5009
+			return $string;
5010
+	}
4735 5011
 
4736 5012
 	// UTF-8 occurences of MS special characters
4737 5013
 	$findchars_utf8 = array(
@@ -4772,10 +5048,11 @@  discard block
 block discarded – undo
4772 5048
 		'--',	// &mdash;
4773 5049
 	);
4774 5050
 
4775
-	if ($context['utf8'])
4776
-		$string = str_replace($findchars_utf8, $replacechars, $string);
4777
-	else
4778
-		$string = str_replace($findchars_iso, $replacechars, $string);
5051
+	if ($context['utf8']) {
5052
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5053
+	} else {
5054
+			$string = str_replace($findchars_iso, $replacechars, $string);
5055
+	}
4779 5056
 
4780 5057
 	return $string;
4781 5058
 }
@@ -4794,49 +5071,59 @@  discard block
 block discarded – undo
4794 5071
 {
4795 5072
 	global $context;
4796 5073
 
4797
-	if (!isset($matches[2]))
4798
-		return '';
5074
+	if (!isset($matches[2])) {
5075
+			return '';
5076
+	}
4799 5077
 
4800 5078
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4801 5079
 
4802 5080
 	// remove left to right / right to left overrides
4803
-	if ($num === 0x202D || $num === 0x202E)
4804
-		return '';
5081
+	if ($num === 0x202D || $num === 0x202E) {
5082
+			return '';
5083
+	}
4805 5084
 
4806 5085
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
4807
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
4808
-		return '&#' . $num . ';';
5086
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5087
+			return '&#' . $num . ';';
5088
+	}
4809 5089
 
4810 5090
 	if (empty($context['utf8']))
4811 5091
 	{
4812 5092
 		// no control characters
4813
-		if ($num < 0x20)
4814
-			return '';
5093
+		if ($num < 0x20) {
5094
+					return '';
5095
+		}
4815 5096
 		// text is text
4816
-		elseif ($num < 0x80)
4817
-			return chr($num);
5097
+		elseif ($num < 0x80) {
5098
+					return chr($num);
5099
+		}
4818 5100
 		// all others get html-ised
4819
-		else
4820
-			return '&#' . $matches[2] . ';';
4821
-	}
4822
-	else
5101
+		else {
5102
+					return '&#' . $matches[2] . ';';
5103
+		}
5104
+	} else
4823 5105
 	{
4824 5106
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
4825 5107
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
4826
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
4827
-			return '';
5108
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5109
+					return '';
5110
+		}
4828 5111
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4829
-		elseif ($num < 0x80)
4830
-			return chr($num);
5112
+		elseif ($num < 0x80) {
5113
+					return chr($num);
5114
+		}
4831 5115
 		// <0x800 (2048)
4832
-		elseif ($num < 0x800)
4833
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5116
+		elseif ($num < 0x800) {
5117
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5118
+		}
4834 5119
 		// < 0x10000 (65536)
4835
-		elseif ($num < 0x10000)
4836
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5120
+		elseif ($num < 0x10000) {
5121
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5122
+		}
4837 5123
 		// <= 0x10FFFF (1114111)
4838
-		else
4839
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5124
+		else {
5125
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5126
+		}
4840 5127
 	}
4841 5128
 }
4842 5129
 
@@ -4852,28 +5139,34 @@  discard block
 block discarded – undo
4852 5139
  */
4853 5140
 function fixchar__callback($matches)
4854 5141
 {
4855
-	if (!isset($matches[1]))
4856
-		return '';
5142
+	if (!isset($matches[1])) {
5143
+			return '';
5144
+	}
4857 5145
 
4858 5146
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
4859 5147
 
4860 5148
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
4861 5149
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
4862
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
4863
-		return '';
5150
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5151
+			return '';
5152
+	}
4864 5153
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4865
-	elseif ($num < 0x80)
4866
-		return chr($num);
5154
+	elseif ($num < 0x80) {
5155
+			return chr($num);
5156
+	}
4867 5157
 	// <0x800 (2048)
4868
-	elseif ($num < 0x800)
4869
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5158
+	elseif ($num < 0x800) {
5159
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5160
+	}
4870 5161
 	// < 0x10000 (65536)
4871
-	elseif ($num < 0x10000)
4872
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5162
+	elseif ($num < 0x10000) {
5163
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5164
+	}
4873 5165
 	// <= 0x10FFFF (1114111)
4874
-	else
4875
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4876
-}
5166
+	else {
5167
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5168
+	}
5169
+	}
4877 5170
 
4878 5171
 /**
4879 5172
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -4886,17 +5179,19 @@  discard block
 block discarded – undo
4886 5179
  */
4887 5180
 function entity_fix__callback($matches)
4888 5181
 {
4889
-	if (!isset($matches[2]))
4890
-		return '';
5182
+	if (!isset($matches[2])) {
5183
+			return '';
5184
+	}
4891 5185
 
4892 5186
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4893 5187
 
4894 5188
 	// we don't allow control characters, characters out of range, byte markers, etc
4895
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
4896
-		return '';
4897
-	else
4898
-		return '&#' . $num . ';';
4899
-}
5189
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5190
+			return '';
5191
+	} else {
5192
+			return '&#' . $num . ';';
5193
+	}
5194
+	}
4900 5195
 
4901 5196
 /**
4902 5197
  * Return a Gravatar URL based on
@@ -4920,18 +5215,23 @@  discard block
 block discarded – undo
4920 5215
 		$ratings = array('G', 'PG', 'R', 'X');
4921 5216
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
4922 5217
 		$url_params = array();
4923
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
4924
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
4925
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
4926
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
4927
-		if (!empty($modSettings['avatar_max_width_external']))
4928
-			$size_string = (int) $modSettings['avatar_max_width_external'];
4929
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
4930
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5218
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5219
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5220
+		}
5221
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5222
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5223
+		}
5224
+		if (!empty($modSettings['avatar_max_width_external'])) {
5225
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5226
+		}
5227
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5228
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
4931 5229
 				$size_string = $modSettings['avatar_max_height_external'];
5230
+		}
4932 5231
 
4933
-		if (!empty($size_string))
4934
-			$url_params[] = 's=' . $size_string;
5232
+		if (!empty($size_string)) {
5233
+					$url_params[] = 's=' . $size_string;
5234
+		}
4935 5235
 	}
4936 5236
 	$http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www';
4937 5237
 
@@ -4950,22 +5250,26 @@  discard block
 block discarded – undo
4950 5250
 	static $timezones = null, $lastwhen = null;
4951 5251
 
4952 5252
 	// No point doing this over if we already did it once
4953
-	if (!empty($timezones) && $when == $lastwhen)
4954
-		return $timezones;
4955
-	else
4956
-		$lastwhen = $when;
5253
+	if (!empty($timezones) && $when == $lastwhen) {
5254
+			return $timezones;
5255
+	} else {
5256
+			$lastwhen = $when;
5257
+	}
4957 5258
 
4958 5259
 	// Parseable datetime string?
4959
-	if (is_int($timestamp = strtotime($when)))
4960
-		$when = $timestamp;
5260
+	if (is_int($timestamp = strtotime($when))) {
5261
+			$when = $timestamp;
5262
+	}
4961 5263
 
4962 5264
 	// A Unix timestamp?
4963
-	elseif (is_numeric($when))
4964
-		$when = intval($when);
5265
+	elseif (is_numeric($when)) {
5266
+			$when = intval($when);
5267
+	}
4965 5268
 
4966 5269
 	// Invalid value? Just get current Unix timestamp.
4967
-	else
4968
-		$when = time();
5270
+	else {
5271
+			$when = time();
5272
+	}
4969 5273
 
4970 5274
 	// We'll need these too
4971 5275
 	$date_when = date_create('@' . $when);
@@ -5029,8 +5333,9 @@  discard block
 block discarded – undo
5029 5333
 	foreach ($priority_countries as $country)
5030 5334
 	{
5031 5335
 		$country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country)));
5032
-		if (!empty($country_tzids))
5033
-			$priority_tzids = array_merge($priority_tzids, $country_tzids);
5336
+		if (!empty($country_tzids)) {
5337
+					$priority_tzids = array_merge($priority_tzids, $country_tzids);
5338
+		}
5034 5339
 	}
5035 5340
 
5036 5341
 	// Process the preferred timezones first, then the rest.
@@ -5040,8 +5345,9 @@  discard block
 block discarded – undo
5040 5345
 	foreach ($tzids as $tzid)
5041 5346
 	{
5042 5347
 		// We don't want UTC right now
5043
-		if ($tzid == 'UTC')
5044
-			continue;
5348
+		if ($tzid == 'UTC') {
5349
+					continue;
5350
+		}
5045 5351
 
5046 5352
 		$tz = timezone_open($tzid);
5047 5353
 
@@ -5056,12 +5362,14 @@  discard block
 block discarded – undo
5056 5362
 		$tzgeo = timezone_location_get($tz);
5057 5363
 
5058 5364
 		// Don't overwrite our preferred tzids
5059
-		if (empty($zones[$tzkey]['tzid']))
5060
-			$zones[$tzkey]['tzid'] = $tzid;
5365
+		if (empty($zones[$tzkey]['tzid'])) {
5366
+					$zones[$tzkey]['tzid'] = $tzid;
5367
+		}
5061 5368
 
5062 5369
 		// A time zone from a prioritized country?
5063
-		if (in_array($tzid, $priority_tzids))
5064
-			$priority_zones[$tzkey] = true;
5370
+		if (in_array($tzid, $priority_tzids)) {
5371
+					$priority_zones[$tzkey] = true;
5372
+		}
5065 5373
 
5066 5374
 		// Keep track of the location and offset for this tzid
5067 5375
 		$tzid_parts = explode('/', $tzid);
@@ -5082,15 +5390,17 @@  discard block
 block discarded – undo
5082 5390
 
5083 5391
 		date_timezone_set($date_when, timezone_open($tzvalue['tzid']));
5084 5392
 
5085
-		if (!empty($timezone_descriptions[$tzvalue['tzid']]))
5086
-			$desc = $timezone_descriptions[$tzvalue['tzid']];
5087
-		else
5088
-			$desc = implode(', ', array_unique($tzvalue['locations']));
5393
+		if (!empty($timezone_descriptions[$tzvalue['tzid']])) {
5394
+					$desc = $timezone_descriptions[$tzvalue['tzid']];
5395
+		} else {
5396
+					$desc = implode(', ', array_unique($tzvalue['locations']));
5397
+		}
5089 5398
 
5090
-		if (isset($priority_zones[$tzkey]))
5091
-			$priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5092
-		else
5093
-			$timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5399
+		if (isset($priority_zones[$tzkey])) {
5400
+					$priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5401
+		} else {
5402
+					$timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5403
+		}
5094 5404
 	}
5095 5405
 
5096 5406
 	$timezones = array_merge(
@@ -5144,9 +5454,9 @@  discard block
 block discarded – undo
5144 5454
 			'Indian/Kerguelen' => 'TFT',
5145 5455
 		);
5146 5456
 
5147
-		if (!empty($missing_tz_abbrs[$tzid]))
5148
-			$tz_abbrev = $missing_tz_abbrs[$tzid];
5149
-		else
5457
+		if (!empty($missing_tz_abbrs[$tzid])) {
5458
+					$tz_abbrev = $missing_tz_abbrs[$tzid];
5459
+		} else
5150 5460
 		{
5151 5461
 			// Russia likes to experiment with time zones often, and names them as offsets from Moscow
5152 5462
 			$tz_location = timezone_location_get(timezone_open($tzid));
@@ -5174,8 +5484,9 @@  discard block
 block discarded – undo
5174 5484
  */
5175 5485
 function inet_ptod($ip_address)
5176 5486
 {
5177
-	if (!isValidIP($ip_address))
5178
-		return $ip_address;
5487
+	if (!isValidIP($ip_address)) {
5488
+			return $ip_address;
5489
+	}
5179 5490
 
5180 5491
 	$bin = inet_pton($ip_address);
5181 5492
 	return $bin;
@@ -5187,13 +5498,15 @@  discard block
 block discarded – undo
5187 5498
  */
5188 5499
 function inet_dtop($bin)
5189 5500
 {
5190
-	if(empty($bin))
5191
-		return '';
5501
+	if(empty($bin)) {
5502
+			return '';
5503
+	}
5192 5504
 
5193 5505
 	global $db_type;
5194 5506
 
5195
-	if ($db_type == 'postgresql')
5196
-		return $bin;
5507
+	if ($db_type == 'postgresql') {
5508
+			return $bin;
5509
+	}
5197 5510
 
5198 5511
 	$ip_address = inet_ntop($bin);
5199 5512
 
@@ -5218,26 +5531,32 @@  discard block
 block discarded – undo
5218 5531
  */
5219 5532
 function _safe_serialize($value)
5220 5533
 {
5221
-	if(is_null($value))
5222
-		return 'N;';
5534
+	if(is_null($value)) {
5535
+			return 'N;';
5536
+	}
5223 5537
 
5224
-	if(is_bool($value))
5225
-		return 'b:'. (int) $value .';';
5538
+	if(is_bool($value)) {
5539
+			return 'b:'. (int) $value .';';
5540
+	}
5226 5541
 
5227
-	if(is_int($value))
5228
-		return 'i:'. $value .';';
5542
+	if(is_int($value)) {
5543
+			return 'i:'. $value .';';
5544
+	}
5229 5545
 
5230
-	if(is_float($value))
5231
-		return 'd:'. str_replace(',', '.', $value) .';';
5546
+	if(is_float($value)) {
5547
+			return 'd:'. str_replace(',', '.', $value) .';';
5548
+	}
5232 5549
 
5233
-	if(is_string($value))
5234
-		return 's:'. strlen($value) .':"'. $value .'";';
5550
+	if(is_string($value)) {
5551
+			return 's:'. strlen($value) .':"'. $value .'";';
5552
+	}
5235 5553
 
5236 5554
 	if(is_array($value))
5237 5555
 	{
5238 5556
 		$out = '';
5239
-		foreach($value as $k => $v)
5240
-			$out .= _safe_serialize($k) . _safe_serialize($v);
5557
+		foreach($value as $k => $v) {
5558
+					$out .= _safe_serialize($k) . _safe_serialize($v);
5559
+		}
5241 5560
 
5242 5561
 		return 'a:'. count($value) .':{'. $out .'}';
5243 5562
 	}
@@ -5263,8 +5582,9 @@  discard block
 block discarded – undo
5263 5582
 
5264 5583
 	$out = _safe_serialize($value);
5265 5584
 
5266
-	if (isset($mbIntEnc))
5267
-		mb_internal_encoding($mbIntEnc);
5585
+	if (isset($mbIntEnc)) {
5586
+			mb_internal_encoding($mbIntEnc);
5587
+	}
5268 5588
 
5269 5589
 	return $out;
5270 5590
 }
@@ -5281,8 +5601,9 @@  discard block
 block discarded – undo
5281 5601
 function _safe_unserialize($str)
5282 5602
 {
5283 5603
 	// Input  is not a string.
5284
-	if(empty($str) || !is_string($str))
5285
-		return false;
5604
+	if(empty($str) || !is_string($str)) {
5605
+			return false;
5606
+	}
5286 5607
 
5287 5608
 	$stack = array();
5288 5609
 	$expected = array();
@@ -5298,43 +5619,38 @@  discard block
 block discarded – undo
5298 5619
 	while($state != 1)
5299 5620
 	{
5300 5621
 		$type = isset($str[0]) ? $str[0] : '';
5301
-		if($type == '}')
5302
-			$str = substr($str, 1);
5303
-
5304
-		else if($type == 'N' && $str[1] == ';')
5622
+		if($type == '}') {
5623
+					$str = substr($str, 1);
5624
+		} else if($type == 'N' && $str[1] == ';')
5305 5625
 		{
5306 5626
 			$value = null;
5307 5627
 			$str = substr($str, 2);
5308
-		}
5309
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5628
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5310 5629
 		{
5311 5630
 			$value = $matches[1] == '1' ? true : false;
5312 5631
 			$str = substr($str, 4);
5313
-		}
5314
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5632
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5315 5633
 		{
5316 5634
 			$value = (int)$matches[1];
5317 5635
 			$str = $matches[2];
5318
-		}
5319
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5636
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5320 5637
 		{
5321 5638
 			$value = (float)$matches[1];
5322 5639
 			$str = $matches[3];
5323
-		}
5324
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5640
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5325 5641
 		{
5326 5642
 			$value = substr($matches[2], 0, (int)$matches[1]);
5327 5643
 			$str = substr($matches[2], (int)$matches[1] + 2);
5328
-		}
5329
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5644
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5330 5645
 		{
5331 5646
 			$expectedLength = (int)$matches[1];
5332 5647
 			$str = $matches[2];
5333 5648
 		}
5334 5649
 
5335 5650
 		// Object or unknown/malformed type.
5336
-		else
5337
-			return false;
5651
+		else {
5652
+					return false;
5653
+		}
5338 5654
 
5339 5655
 		switch($state)
5340 5656
 		{
@@ -5362,8 +5678,9 @@  discard block
 block discarded – undo
5362 5678
 				if($type == '}')
5363 5679
 				{
5364 5680
 					// Array size is less than expected.
5365
-					if(count($list) < end($expected))
5366
-						return false;
5681
+					if(count($list) < end($expected)) {
5682
+											return false;
5683
+					}
5367 5684
 
5368 5685
 					unset($list);
5369 5686
 					$list = &$stack[count($stack)-1];
@@ -5372,8 +5689,9 @@  discard block
 block discarded – undo
5372 5689
 					// Go to terminal state if we're at the end of the root array.
5373 5690
 					array_pop($expected);
5374 5691
 
5375
-					if(count($expected) == 0)
5376
-						$state = 1;
5692
+					if(count($expected) == 0) {
5693
+											$state = 1;
5694
+					}
5377 5695
 
5378 5696
 					break;
5379 5697
 				}
@@ -5381,8 +5699,9 @@  discard block
 block discarded – undo
5381 5699
 				if($type == 'i' || $type == 's')
5382 5700
 				{
5383 5701
 					// Array size exceeds expected length.
5384
-					if(count($list) >= end($expected))
5385
-						return false;
5702
+					if(count($list) >= end($expected)) {
5703
+											return false;
5704
+					}
5386 5705
 
5387 5706
 					$key = $value;
5388 5707
 					$state = 3;
@@ -5416,8 +5735,9 @@  discard block
 block discarded – undo
5416 5735
 	}
5417 5736
 
5418 5737
 	// Trailing data in input.
5419
-	if(!empty($str))
5420
-		return false;
5738
+	if(!empty($str)) {
5739
+			return false;
5740
+	}
5421 5741
 
5422 5742
 	return $data;
5423 5743
 }
@@ -5440,8 +5760,9 @@  discard block
 block discarded – undo
5440 5760
 
5441 5761
 	$out = _safe_unserialize($str);
5442 5762
 
5443
-	if (isset($mbIntEnc))
5444
-		mb_internal_encoding($mbIntEnc);
5763
+	if (isset($mbIntEnc)) {
5764
+			mb_internal_encoding($mbIntEnc);
5765
+	}
5445 5766
 
5446 5767
 	return $out;
5447 5768
 }
@@ -5456,12 +5777,14 @@  discard block
 block discarded – undo
5456 5777
 function smf_chmod($file, $value = 0)
5457 5778
 {
5458 5779
 	// No file? no checks!
5459
-	if (empty($file))
5460
-		return false;
5780
+	if (empty($file)) {
5781
+			return false;
5782
+	}
5461 5783
 
5462 5784
 	// Already writable?
5463
-	if (is_writable($file))
5464
-		return true;
5785
+	if (is_writable($file)) {
5786
+			return true;
5787
+	}
5465 5788
 
5466 5789
 	// Do we have a file or a dir?
5467 5790
 	$isDir = is_dir($file);
@@ -5477,10 +5800,9 @@  discard block
 block discarded – undo
5477 5800
 		{
5478 5801
 			$isWritable = true;
5479 5802
 			break;
5803
+		} else {
5804
+					@chmod($file, $val);
5480 5805
 		}
5481
-
5482
-		else
5483
-			@chmod($file, $val);
5484 5806
 	}
5485 5807
 
5486 5808
 	return $isWritable;
@@ -5499,8 +5821,9 @@  discard block
 block discarded – undo
5499 5821
 	global $txt;
5500 5822
 
5501 5823
 	// Come on...
5502
-	if (empty($json) || !is_string($json))
5503
-		return array();
5824
+	if (empty($json) || !is_string($json)) {
5825
+			return array();
5826
+	}
5504 5827
 
5505 5828
 	$returnArray = @json_decode($json, $returnAsArray);
5506 5829
 
@@ -5538,11 +5861,11 @@  discard block
 block discarded – undo
5538 5861
 		$jsonDebug = $jsonDebug[0];
5539 5862
 		loadLanguage('Errors');
5540 5863
 
5541
-		if (!empty($jsonDebug))
5542
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5543
-
5544
-		else
5545
-			log_error($txt['json_'. $jsonError], 'critical');
5864
+		if (!empty($jsonDebug)) {
5865
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5866
+		} else {
5867
+					log_error($txt['json_'. $jsonError], 'critical');
5868
+		}
5546 5869
 
5547 5870
 		// Everyone expects an array.
5548 5871
 		return array();
@@ -5572,8 +5895,9 @@  discard block
 block discarded – undo
5572 5895
 	global $db_show_debug, $modSettings;
5573 5896
 
5574 5897
 	// Defensive programming anyone?
5575
-	if (empty($data))
5576
-		return false;
5898
+	if (empty($data)) {
5899
+			return false;
5900
+	}
5577 5901
 
5578 5902
 	// Don't need extra stuff...
5579 5903
 	$db_show_debug = false;
@@ -5581,11 +5905,11 @@  discard block
 block discarded – undo
5581 5905
 	// Kill anything else.
5582 5906
 	ob_end_clean();
5583 5907
 
5584
-	if (!empty($modSettings['CompressedOutput']))
5585
-		@ob_start('ob_gzhandler');
5586
-
5587
-	else
5588
-		ob_start();
5908
+	if (!empty($modSettings['CompressedOutput'])) {
5909
+			@ob_start('ob_gzhandler');
5910
+	} else {
5911
+			ob_start();
5912
+	}
5589 5913
 
5590 5914
 	// Set the header.
5591 5915
 	header($type);
@@ -5617,8 +5941,9 @@  discard block
 block discarded – undo
5617 5941
 	static $done = false;
5618 5942
 
5619 5943
 	// If we don't need to do anything, don't
5620
-	if (!$update && $done)
5621
-		return;
5944
+	if (!$update && $done) {
5945
+			return;
5946
+	}
5622 5947
 
5623 5948
 	// Should we get a new copy of the official list of TLDs?
5624 5949
 	if ($update)
@@ -5639,10 +5964,11 @@  discard block
 block discarded – undo
5639 5964
 		// Clean $tlds and convert it to an array
5640 5965
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
5641 5966
 			$line = trim($line);
5642
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
5643
-				return false;
5644
-			else
5645
-				return true;
5967
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
5968
+							return false;
5969
+			} else {
5970
+							return true;
5971
+			}
5646 5972
 		});
5647 5973
 
5648 5974
 		// Convert Punycode to Unicode
@@ -5696,8 +6022,9 @@  discard block
 block discarded – undo
5696 6022
 						$idx += $digit * $w;
5697 6023
 						$t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias));
5698 6024
 
5699
-						if ($digit < $t)
5700
-							break;
6025
+						if ($digit < $t) {
6026
+													break;
6027
+						}
5701 6028
 
5702 6029
 						$w = (int) ($w * ($base - $t));
5703 6030
 					}
@@ -5706,8 +6033,9 @@  discard block
 block discarded – undo
5706 6033
 					$delta = intval($is_first ? ($delta / $damp) : ($delta / 2));
5707 6034
 					$delta += intval($delta / ($deco_len + 1));
5708 6035
 
5709
-					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base)
5710
-						$delta = intval($delta / ($base - $tmin));
6036
+					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) {
6037
+											$delta = intval($delta / ($base - $tmin));
6038
+					}
5711 6039
 
5712 6040
 					$bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew));
5713 6041
 					$is_first = false;
@@ -5716,8 +6044,9 @@  discard block
 block discarded – undo
5716 6044
 
5717 6045
 					if ($deco_len > 0)
5718 6046
 					{
5719
-						for ($i = $deco_len; $i > $idx; $i--)
5720
-							$decoded[$i] = $decoded[($i - 1)];
6047
+						for ($i = $deco_len; $i > $idx; $i--) {
6048
+													$decoded[$i] = $decoded[($i - 1)];
6049
+						}
5721 6050
 					}
5722 6051
 					$decoded[$idx++] = $char;
5723 6052
 				}
@@ -5725,24 +6054,29 @@  discard block
 block discarded – undo
5725 6054
 				foreach ($decoded as $k => $v)
5726 6055
 				{
5727 6056
 					// 7bit are transferred literally
5728
-					if ($v < 128)
5729
-						$output .= chr($v);
6057
+					if ($v < 128) {
6058
+											$output .= chr($v);
6059
+					}
5730 6060
 
5731 6061
 					// 2 bytes
5732
-					elseif ($v < (1 << 11))
5733
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6062
+					elseif ($v < (1 << 11)) {
6063
+											$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6064
+					}
5734 6065
 
5735 6066
 					// 3 bytes
5736
-					elseif ($v < (1 << 16))
5737
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6067
+					elseif ($v < (1 << 16)) {
6068
+											$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6069
+					}
5738 6070
 
5739 6071
 					// 4 bytes
5740
-					elseif ($v < (1 << 21))
5741
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6072
+					elseif ($v < (1 << 21)) {
6073
+											$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6074
+					}
5742 6075
 
5743 6076
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5744
-					else
5745
-						$output .= $safe_char;
6077
+					else {
6078
+											$output .= $safe_char;
6079
+					}
5746 6080
 				}
5747 6081
 
5748 6082
 				$output_parts[] = $output;
@@ -5837,8 +6171,7 @@  discard block
 block discarded – undo
5837 6171
 
5838 6172
 		$strlen = 'mb_strlen';
5839 6173
 		$substr = 'mb_substr';
5840
-	}
5841
-	else
6174
+	} else
5842 6175
 	{
5843 6176
 		$strlen = $smcFunc['strlen'];
5844 6177
 		$substr = $smcFunc['substr'];
@@ -5852,20 +6185,21 @@  discard block
 block discarded – undo
5852 6185
 
5853 6186
 		$first = $substr($string, 0, 1);
5854 6187
 
5855
-		if (empty($index[$first]))
5856
-			$index[$first] = array();
6188
+		if (empty($index[$first])) {
6189
+					$index[$first] = array();
6190
+		}
5857 6191
 
5858 6192
 		if ($strlen($string) > 1)
5859 6193
 		{
5860 6194
 			// Sanity check on recursion
5861
-			if ($depth > 99)
5862
-				$index[$first][$substr($string, 1)] = '';
5863
-
5864
-			else
5865
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6195
+			if ($depth > 99) {
6196
+							$index[$first][$substr($string, 1)] = '';
6197
+			} else {
6198
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6199
+			}
6200
+		} else {
6201
+					$index[$first][''] = '';
5866 6202
 		}
5867
-		else
5868
-			$index[$first][''] = '';
5869 6203
 
5870 6204
 		$depth--;
5871 6205
 		return $index;
@@ -5888,9 +6222,9 @@  discard block
 block discarded – undo
5888 6222
 			$key_regex = preg_quote($key, $delim);
5889 6223
 			$new_key = $key;
5890 6224
 
5891
-			if (empty($value))
5892
-				$sub_regex = '';
5893
-			else
6225
+			if (empty($value)) {
6226
+							$sub_regex = '';
6227
+			} else
5894 6228
 			{
5895 6229
 				$sub_regex = $index_to_regex($value, $delim);
5896 6230
 
@@ -5898,22 +6232,22 @@  discard block
 block discarded – undo
5898 6232
 				{
5899 6233
 					$new_key_array = explode('(?'.'>', $sub_regex);
5900 6234
 					$new_key .= $new_key_array[0];
6235
+				} else {
6236
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
5901 6237
 				}
5902
-				else
5903
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5904 6238
 			}
5905 6239
 
5906
-			if ($depth > 1)
5907
-				$regex[$new_key] = $key_regex . $sub_regex;
5908
-			else
6240
+			if ($depth > 1) {
6241
+							$regex[$new_key] = $key_regex . $sub_regex;
6242
+			} else
5909 6243
 			{
5910 6244
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
5911 6245
 				{
5912 6246
 					$regex[$new_key] = $key_regex . $sub_regex;
5913 6247
 					unset($index[$key]);
6248
+				} else {
6249
+									break;
5914 6250
 				}
5915
-				else
5916
-					break;
5917 6251
 			}
5918 6252
 		}
5919 6253
 
@@ -5922,10 +6256,11 @@  discard block
 block discarded – undo
5922 6256
 			$l1 = $strlen($k1);
5923 6257
 			$l2 = $strlen($k2);
5924 6258
 
5925
-			if ($l1 == $l2)
5926
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
5927
-			else
5928
-				return $l1 > $l2 ? -1 : 1;
6259
+			if ($l1 == $l2) {
6260
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6261
+			} else {
6262
+							return $l1 > $l2 ? -1 : 1;
6263
+			}
5929 6264
 		});
5930 6265
 
5931 6266
 		$depth--;
@@ -5936,15 +6271,18 @@  discard block
 block discarded – undo
5936 6271
 	$index = array();
5937 6272
 	$regexes = array();
5938 6273
 
5939
-	foreach ($strings as $string)
5940
-		$index = $add_string_to_index($string, $index);
6274
+	foreach ($strings as $string) {
6275
+			$index = $add_string_to_index($string, $index);
6276
+	}
5941 6277
 
5942
-	while (!empty($index))
5943
-		$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6278
+	while (!empty($index)) {
6279
+			$regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6280
+	}
5944 6281
 
5945 6282
 	// Restore PHP's internal character encoding to whatever it was originally
5946
-	if (!empty($current_encoding))
5947
-		mb_internal_encoding($current_encoding);
6283
+	if (!empty($current_encoding)) {
6284
+			mb_internal_encoding($current_encoding);
6285
+	}
5948 6286
 
5949 6287
 	return $regexes;
5950 6288
 }
Please login to merge, or discard this patch.
Sources/Stats.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -555,7 +555,7 @@
 block discarded – undo
555 555
 				'subject' => $row_liked_message['subject'],
556 556
 				'num' => $row_liked_message['likes'],
557 557
 				'href' => $scripturl . '?msg=' . $row_liked_message['id_msg'],
558
-				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
558
+				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] . '">' . $row_liked_message['subject'] . '</a>'
559 559
 			);
560 560
 
561 561
 			if ($max_liked_message < $row_liked_message['likes'])
Please login to merge, or discard this patch.
Braces   +112 added lines, -78 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
  * Display some useful/interesting board statistics.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 
31 32
 	isAllowedTo('view_stats');
32 33
 	// Page disabled - redirect them out
33
-	if (empty($modSettings['trackStats']))
34
-		fatal_lang_error('feature_disabled', true);
34
+	if (empty($modSettings['trackStats'])) {
35
+			fatal_lang_error('feature_disabled', true);
36
+	}
35 37
 
36 38
 	if (!empty($_REQUEST['expand']))
37 39
 	{
@@ -39,31 +41,34 @@  discard block
 block discarded – undo
39 41
 
40 42
 		$month = (int) substr($_REQUEST['expand'], 4);
41 43
 		$year = (int) substr($_REQUEST['expand'], 0, 4);
42
-		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12)
43
-			$_SESSION['expanded_stats'][$year][] = $month;
44
-	}
45
-	elseif (!empty($_REQUEST['collapse']))
44
+		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) {
45
+					$_SESSION['expanded_stats'][$year][] = $month;
46
+		}
47
+	} elseif (!empty($_REQUEST['collapse']))
46 48
 	{
47 49
 		$context['robot_no_index'] = true;
48 50
 
49 51
 		$month = (int) substr($_REQUEST['collapse'], 4);
50 52
 		$year = (int) substr($_REQUEST['collapse'], 0, 4);
51
-		if (!empty($_SESSION['expanded_stats'][$year]))
52
-			$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
53
+		if (!empty($_SESSION['expanded_stats'][$year])) {
54
+					$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
55
+		}
53 56
 	}
54 57
 
55 58
 	// Handle the XMLHttpRequest.
56 59
 	if (isset($_REQUEST['xml']))
57 60
 	{
58 61
 		// Collapsing stats only needs adjustments of the session variables.
59
-		if (!empty($_REQUEST['collapse']))
60
-			obExit(false);
62
+		if (!empty($_REQUEST['collapse'])) {
63
+					obExit(false);
64
+		}
61 65
 
62 66
 		$context['sub_template'] = 'stats';
63 67
 		$context['yearly'] = array();
64 68
 
65
-		if (empty($month) || empty($year))
66
-			return;
69
+		if (empty($month) || empty($year)) {
70
+					return;
71
+		}
67 72
 
68 73
 		getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
69 74
 		$context['yearly'][$year]['months'][$month]['date'] = array(
@@ -220,8 +225,9 @@  discard block
 block discarded – undo
220 225
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
221 226
 		);
222 227
 
223
-		if ($max_num_posts < $row_members['posts'])
224
-			$max_num_posts = $row_members['posts'];
228
+		if ($max_num_posts < $row_members['posts']) {
229
+					$max_num_posts = $row_members['posts'];
230
+		}
225 231
 	}
226 232
 	$smcFunc['db_free_result']($members_result);
227 233
 
@@ -257,8 +263,9 @@  discard block
 block discarded – undo
257 263
 			'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>'
258 264
 		);
259 265
 
260
-		if ($max_num_posts < $row_board['num_posts'])
261
-			$max_num_posts = $row_board['num_posts'];
266
+		if ($max_num_posts < $row_board['num_posts']) {
267
+					$max_num_posts = $row_board['num_posts'];
268
+		}
262 269
 	}
263 270
 	$smcFunc['db_free_result']($boards_result);
264 271
 
@@ -284,12 +291,13 @@  discard block
 block discarded – undo
284 291
 			)
285 292
 		);
286 293
 		$topic_ids = array();
287
-		while ($row = $smcFunc['db_fetch_assoc']($request))
288
-			$topic_ids[] = $row['id_topic'];
294
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
295
+					$topic_ids[] = $row['id_topic'];
296
+		}
289 297
 		$smcFunc['db_free_result']($request);
298
+	} else {
299
+			$topic_ids = array();
290 300
 	}
291
-	else
292
-		$topic_ids = array();
293 301
 
294 302
 	// Topic replies top 10.
295 303
 	$topic_reply_result = $smcFunc['db_query']('', '
@@ -329,8 +337,9 @@  discard block
 block discarded – undo
329 337
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>'
330 338
 		);
331 339
 
332
-		if ($max_num_replies < $row_topic_reply['num_replies'])
333
-			$max_num_replies = $row_topic_reply['num_replies'];
340
+		if ($max_num_replies < $row_topic_reply['num_replies']) {
341
+					$max_num_replies = $row_topic_reply['num_replies'];
342
+		}
334 343
 	}
335 344
 	$smcFunc['db_free_result']($topic_reply_result);
336 345
 
@@ -354,12 +363,13 @@  discard block
 block discarded – undo
354 363
 			)
355 364
 		);
356 365
 		$topic_ids = array();
357
-		while ($row = $smcFunc['db_fetch_assoc']($request))
358
-			$topic_ids[] = $row['id_topic'];
366
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
367
+					$topic_ids[] = $row['id_topic'];
368
+		}
359 369
 		$smcFunc['db_free_result']($request);
370
+	} else {
371
+			$topic_ids = array();
360 372
 	}
361
-	else
362
-		$topic_ids = array();
363 373
 
364 374
 	// Topic views top 10.
365 375
 	$topic_view_result = $smcFunc['db_query']('', '
@@ -399,8 +409,9 @@  discard block
 block discarded – undo
399 409
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>'
400 410
 		);
401 411
 
402
-		if ($max_num < $row_topic_views['num_views'])
403
-			$max_num = $row_topic_views['num_views'];
412
+		if ($max_num < $row_topic_views['num_views']) {
413
+					$max_num = $row_topic_views['num_views'];
414
+		}
404 415
 	}
405 416
 	$smcFunc['db_free_result']($topic_view_result);
406 417
 
@@ -425,15 +436,17 @@  discard block
 block discarded – undo
425 436
 			)
426 437
 		);
427 438
 		$members = array();
428
-		while ($row = $smcFunc['db_fetch_assoc']($request))
429
-			$members[$row['id_member_started']] = $row['hits'];
439
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
440
+					$members[$row['id_member_started']] = $row['hits'];
441
+		}
430 442
 		$smcFunc['db_free_result']($request);
431 443
 
432 444
 		cache_put_data('stats_top_starters', $members, 360);
433 445
 	}
434 446
 
435
-	if (empty($members))
436
-		$members = array(0 => 0);
447
+	if (empty($members)) {
448
+			$members = array(0 => 0);
449
+	}
437 450
 
438 451
 	// Topic poster top 10.
439 452
 	$members_result = $smcFunc['db_query']('', '
@@ -458,8 +471,9 @@  discard block
 block discarded – undo
458 471
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
459 472
 		);
460 473
 
461
-		if ($max_num < $members[$row_members['id_member']])
462
-			$max_num = $members[$row_members['id_member']];
474
+		if ($max_num < $members[$row_members['id_member']]) {
475
+					$max_num = $members[$row_members['id_member']];
476
+		}
463 477
 	}
464 478
 	ksort($context['stats_blocks']['starters']);
465 479
 	$smcFunc['db_free_result']($members_result);
@@ -488,8 +502,9 @@  discard block
 block discarded – undo
488 502
 	while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
489 503
 	{
490 504
 		$temp2[] = (int) $row_members['id_member'];
491
-		if (count($context['stats_blocks']['time_online']) >= 10)
492
-			continue;
505
+		if (count($context['stats_blocks']['time_online']) >= 10) {
506
+					continue;
507
+		}
493 508
 
494 509
 		// Figure out the days, hours and minutes.
495 510
 		$timeDays = floor($row_members['total_time_logged_in'] / 86400);
@@ -497,10 +512,12 @@  discard block
 block discarded – undo
497 512
 
498 513
 		// Figure out which things to show... (days, hours, minutes, etc.)
499 514
 		$timelogged = '';
500
-		if ($timeDays > 0)
501
-			$timelogged .= $timeDays . $txt['totalTimeLogged5'];
502
-		if ($timeHours > 0)
503
-			$timelogged .= $timeHours . $txt['totalTimeLogged6'];
515
+		if ($timeDays > 0) {
516
+					$timelogged .= $timeDays . $txt['totalTimeLogged5'];
517
+		}
518
+		if ($timeHours > 0) {
519
+					$timelogged .= $timeHours . $txt['totalTimeLogged6'];
520
+		}
504 521
 		$timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7'];
505 522
 
506 523
 		$context['stats_blocks']['time_online'][] = array(
@@ -512,17 +529,20 @@  discard block
 block discarded – undo
512 529
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
513 530
 		);
514 531
 
515
-		if ($max_time_online < $row_members['total_time_logged_in'])
516
-			$max_time_online = $row_members['total_time_logged_in'];
532
+		if ($max_time_online < $row_members['total_time_logged_in']) {
533
+					$max_time_online = $row_members['total_time_logged_in'];
534
+		}
517 535
 	}
518 536
 	$smcFunc['db_free_result']($members_result);
519 537
 
520
-	foreach ($context['stats_blocks']['time_online'] as $i => $member)
521
-		$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
538
+	foreach ($context['stats_blocks']['time_online'] as $i => $member) {
539
+			$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
540
+	}
522 541
 
523 542
 	// Cache the ones we found for a bit, just so we don't have to look again.
524
-	if ($temp !== $temp2)
525
-		cache_put_data('stats_total_time_members', $temp2, 480);
543
+	if ($temp !== $temp2) {
544
+			cache_put_data('stats_total_time_members', $temp2, 480);
545
+	}
526 546
 
527 547
 	// Likes.
528 548
 	if (!empty($modSettings['enable_likes']))
@@ -558,13 +578,15 @@  discard block
 block discarded – undo
558 578
 				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
559 579
 			);
560 580
 
561
-			if ($max_liked_message < $row_liked_message['likes'])
562
-				$max_liked_message = $row_liked_message['likes'];
581
+			if ($max_liked_message < $row_liked_message['likes']) {
582
+							$max_liked_message = $row_liked_message['likes'];
583
+			}
563 584
 		}
564 585
 		$smcFunc['db_free_result']($liked_messages);
565 586
 
566
-		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages)
567
-			$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
587
+		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) {
588
+					$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
589
+		}
568 590
 
569 591
 		// Liked users top 10.
570 592
 		$context['stats_blocks']['liked_users'] = array();
@@ -595,14 +617,16 @@  discard block
 block discarded – undo
595 617
 				'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>',
596 618
 			);
597 619
 
598
-			if ($max_liked_users < $row_liked_users['count'])
599
-				$max_liked_users = $row_liked_users['count'];
620
+			if ($max_liked_users < $row_liked_users['count']) {
621
+							$max_liked_users = $row_liked_users['count'];
622
+			}
600 623
 		}
601 624
 
602 625
 		$smcFunc['db_free_result']($liked_users);
603 626
 
604
-		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users)
605
-			$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
627
+		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) {
628
+					$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
629
+		}
606 630
 	}
607 631
 
608 632
 	// Activity by month.
@@ -620,8 +644,8 @@  discard block
 block discarded – undo
620 644
 		$ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']);
621 645
 		$expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]);
622 646
 
623
-		if (!isset($context['yearly'][$row_months['stats_year']]))
624
-			$context['yearly'][$row_months['stats_year']] = array(
647
+		if (!isset($context['yearly'][$row_months['stats_year']])) {
648
+					$context['yearly'][$row_months['stats_year']] = array(
625 649
 				'year' => $row_months['stats_year'],
626 650
 				'new_topics' => 0,
627 651
 				'new_posts' => 0,
@@ -633,6 +657,7 @@  discard block
 block discarded – undo
633 657
 				'expanded' => false,
634 658
 				'current_year' => $row_months['stats_year'] == date('Y'),
635 659
 			);
660
+		}
636 661
 
637 662
 		$context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array(
638 663
 			'id' => $ID_MONTH,
@@ -678,26 +703,30 @@  discard block
 block discarded – undo
678 703
 		$context['yearly'][$year]['hits'] = comma_format($data['hits']);
679 704
 
680 705
 		// Keep a list of collapsed years.
681
-		if (!$data['expanded'] && !$data['current_year'])
682
-			$context['collapsed_years'][] = $year;
706
+		if (!$data['expanded'] && !$data['current_year']) {
707
+					$context['collapsed_years'][] = $year;
708
+		}
683 709
 	}
684 710
 
685
-	if (empty($_SESSION['expanded_stats']))
686
-		return;
711
+	if (empty($_SESSION['expanded_stats'])) {
712
+			return;
713
+	}
687 714
 
688 715
 	$condition_text = array();
689 716
 	$condition_params = array();
690
-	foreach ($_SESSION['expanded_stats'] as $year => $months)
691
-		if (!empty($months))
717
+	foreach ($_SESSION['expanded_stats'] as $year => $months) {
718
+			if (!empty($months))
692 719
 		{
693 720
 			$condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})';
721
+	}
694 722
 			$condition_params['year_' . $year] = $year;
695 723
 			$condition_params['months_' . $year] = $months;
696 724
 		}
697 725
 
698 726
 	// No daily stats to even look at?
699
-	if (empty($condition_text))
700
-		return;
727
+	if (empty($condition_text)) {
728
+			return;
729
+	}
701 730
 
702 731
 	getDailyStats(implode(' OR ', $condition_text), $condition_params);
703 732
 
@@ -723,8 +752,8 @@  discard block
 block discarded – undo
723 752
 		ORDER BY stats_day ASC',
724 753
 		$condition_parameters
725 754
 	);
726
-	while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
727
-		$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
755
+	while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) {
756
+			$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
728 757
 			'day' => sprintf('%02d', $row_days['stats_day']),
729 758
 			'month' => sprintf('%02d', $row_days['stats_month']),
730 759
 			'year' => $row_days['stats_year'],
@@ -734,6 +763,7 @@  discard block
 block discarded – undo
734 763
 			'most_members_online' => comma_format($row_days['most_on']),
735 764
 			'hits' => comma_format($row_days['hits'])
736 765
 		);
766
+	}
737 767
 	$smcFunc['db_free_result']($days_result);
738 768
 }
739 769
 
@@ -751,16 +781,19 @@  discard block
 block discarded – undo
751 781
 	global $modSettings, $user_info, $forum_version, $sourcedir;
752 782
 
753 783
 	// First, is it disabled?
754
-	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key']))
755
-		die();
784
+	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) {
785
+			die();
786
+	}
756 787
 
757 788
 	// Are we saying who we are, and are we right? (OR an admin)
758
-	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key']))
759
-		die();
789
+	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) {
790
+			die();
791
+	}
760 792
 
761 793
 	// Verify the referer...
762
-	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085'))
763
-		die();
794
+	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) {
795
+			die();
796
+	}
764 797
 
765 798
 	// Get some server versions.
766 799
 	require_once($sourcedir . '/Subs-Admin.php');
@@ -786,16 +819,17 @@  discard block
 block discarded – undo
786 819
 	);
787 820
 
788 821
 	// Encode all the data, for security.
789
-	foreach ($stats_to_send as $k => $v)
790
-		$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
822
+	foreach ($stats_to_send as $k => $v) {
823
+			$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
824
+	}
791 825
 
792 826
 	// Turn this into the query string!
793 827
 	$stats_to_send = implode('&', $stats_to_send);
794 828
 
795 829
 	// If we're an admin, just plonk them out.
796
-	if ($user_info['is_admin'])
797
-		echo $stats_to_send;
798
-	else
830
+	if ($user_info['is_admin']) {
831
+			echo $stats_to_send;
832
+	} else
799 833
 	{
800 834
 		// Connect to the collection script.
801 835
 		$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
Please login to merge, or discard this patch.
Sources/Modlog.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 					'class' => 'centercol',
257 257
 				),
258 258
 				'data' => array(
259
-					'function' => function ($entry)
259
+					'function' => function($entry)
260 260
 					{
261 261
 						return '<input type="checkbox" class="input_check" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>';
262 262
 					},
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		if (empty($entries[$k]['action_text']))
639 639
 			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
640 640
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641
-			function ($matches) use ($entries, $k)
641
+			function($matches) use ($entries, $k)
642 642
 			{
643 643
 				return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : '';
644 644
 			}, $entries[$k]['action_text']);
Please login to merge, or discard this patch.
Braces   +97 added lines, -73 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
  * Prepares the information from the moderation log for viewing.
@@ -32,14 +33,16 @@  discard block
 block discarded – undo
32 33
 
33 34
 	// Are we looking at the moderation log or the administration log.
34 35
 	$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1;
35
-	if ($context['log_type'] == 3)
36
-		isAllowedTo('admin_forum');
36
+	if ($context['log_type'] == 3) {
37
+			isAllowedTo('admin_forum');
38
+	}
37 39
 
38 40
 	// These change dependant on whether we are viewing the moderation or admin log.
39
-	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin')
40
-		$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
41
-	else
42
-		$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
41
+	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') {
42
+			$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
43
+	} else {
44
+			$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
45
+	}
43 46
 
44 47
 	$context['can_delete'] = allowedTo('admin_forum');
45 48
 
@@ -67,8 +70,7 @@  discard block
 block discarded – undo
67 70
 		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
68 71
 		logAction('clearlog_' . $log_type, array(), $log_type);
69 72
 
70
-	}
71
-	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
73
+	} elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
72 74
 	{
73 75
 		checkSession();
74 76
 		validateToken('mod-ml');
@@ -114,15 +116,17 @@  discard block
 block discarded – undo
114 116
 		'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])
115 117
 	);
116 118
 
117
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
118
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
119
-	else
120
-		$search_params_string = $search_params['string'];
119
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
120
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
121
+	} else {
122
+			$search_params_string = $search_params['string'];
123
+	}
121 124
 
122
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
123
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
124
-	else
125
-		$search_params_type = $search_params['type'];
125
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
126
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
127
+	} else {
128
+			$search_params_type = $search_params['type'];
129
+	}
126 130
 
127 131
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
128 132
 	$search_params = array(
@@ -297,13 +301,14 @@  discard block
 block discarded – undo
297 301
 	$context['sub_template'] = 'show_list';
298 302
 	$context['default_list'] = 'moderation_log_list';
299 303
 
300
-	if (isset($context['moderation_menu_name']))
301
-		$context[$context['moderation_menu_name']]['tab_data'] = array(
304
+	if (isset($context['moderation_menu_name'])) {
305
+			$context[$context['moderation_menu_name']]['tab_data'] = array(
302 306
 			'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'],
303 307
 			'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog',
304 308
 			'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc']
305 309
 		);
306
-}
310
+	}
311
+	}
307 312
 
308 313
 /**
309 314
  * Get the number of mod log entries.
@@ -407,30 +412,35 @@  discard block
 block discarded – undo
407 412
 		// Add on some of the column stuff info
408 413
 		if (!empty($row['id_board']))
409 414
 		{
410
-			if ($row['action'] == 'move')
411
-				$row['extra']['board_to'] = $row['id_board'];
412
-			else
413
-				$row['extra']['board'] = $row['id_board'];
415
+			if ($row['action'] == 'move') {
416
+							$row['extra']['board_to'] = $row['id_board'];
417
+			} else {
418
+							$row['extra']['board'] = $row['id_board'];
419
+			}
414 420
 		}
415 421
 
416
-		if (!empty($row['id_topic']))
417
-			$row['extra']['topic'] = $row['id_topic'];
418
-		if (!empty($row['id_msg']))
419
-			$row['extra']['message'] = $row['id_msg'];
422
+		if (!empty($row['id_topic'])) {
423
+					$row['extra']['topic'] = $row['id_topic'];
424
+		}
425
+		if (!empty($row['id_msg'])) {
426
+					$row['extra']['message'] = $row['id_msg'];
427
+		}
420 428
 
421 429
 		// Is this associated with a topic?
422
-		if (isset($row['extra']['topic']))
423
-			$topics[(int) $row['extra']['topic']][] = $row['id_action'];
424
-		if (isset($row['extra']['new_topic']))
425
-			$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
430
+		if (isset($row['extra']['topic'])) {
431
+					$topics[(int) $row['extra']['topic']][] = $row['id_action'];
432
+		}
433
+		if (isset($row['extra']['new_topic'])) {
434
+					$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
435
+		}
426 436
 
427 437
 		// How about a member?
428 438
 		if (isset($row['extra']['member']))
429 439
 		{
430 440
 			// Guests don't have names!
431
-			if (empty($row['extra']['member']))
432
-				$row['extra']['member'] = $txt['modlog_parameter_guest'];
433
-			else
441
+			if (empty($row['extra']['member'])) {
442
+							$row['extra']['member'] = $txt['modlog_parameter_guest'];
443
+			} else
434 444
 			{
435 445
 				// Try to find it...
436 446
 				$members[(int) $row['extra']['member']][] = $row['id_action'];
@@ -438,35 +448,42 @@  discard block
 block discarded – undo
438 448
 		}
439 449
 
440 450
 		// Associated with a board?
441
-		if (isset($row['extra']['board_to']))
442
-			$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
443
-		if (isset($row['extra']['board_from']))
444
-			$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
445
-		if (isset($row['extra']['board']))
446
-			$boards[(int) $row['extra']['board']][] = $row['id_action'];
451
+		if (isset($row['extra']['board_to'])) {
452
+					$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
453
+		}
454
+		if (isset($row['extra']['board_from'])) {
455
+					$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
456
+		}
457
+		if (isset($row['extra']['board'])) {
458
+					$boards[(int) $row['extra']['board']][] = $row['id_action'];
459
+		}
447 460
 
448 461
 		// A message?
449
-		if (isset($row['extra']['message']))
450
-			$messages[(int) $row['extra']['message']][] = $row['id_action'];
462
+		if (isset($row['extra']['message'])) {
463
+					$messages[(int) $row['extra']['message']][] = $row['id_action'];
464
+		}
451 465
 
452 466
 		// IP Info?
453
-		if (isset($row['extra']['ip_range']))
454
-			if ($seeIP)
467
+		if (isset($row['extra']['ip_range'])) {
468
+					if ($seeIP)
455 469
 				$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
456
-			else
457
-				$row['extra']['ip_range'] = $txt['logged'];
470
+		} else {
471
+							$row['extra']['ip_range'] = $txt['logged'];
472
+			}
458 473
 
459 474
 		// Email?
460
-		if (isset($row['extra']['email']))
461
-			$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
475
+		if (isset($row['extra']['email'])) {
476
+					$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
477
+		}
462 478
 
463 479
 		// Bans are complex.
464 480
 		if ($row['action'] == 'ban' || $row['action'] == 'banremove')
465 481
 		{
466 482
 			$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')];
467
-			foreach (array('member', 'email', 'ip_range', 'hostname') as $type)
468
-				if (isset($row['extra'][$type]))
483
+			foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
484
+							if (isset($row['extra'][$type]))
469 485
 					$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
486
+			}
470 487
 		}
471 488
 
472 489
 		// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
@@ -502,12 +519,13 @@  discard block
 block discarded – undo
502 519
 			foreach ($boards[$row['id_board']] as $action)
503 520
 			{
504 521
 				// Make the board number into a link - dealing with moving too.
505
-				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board'])
506
-					$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
507
-				elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board'])
508
-					$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
509
-				elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board'])
510
-					$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
522
+				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
523
+									$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
524
+				} elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
525
+									$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
526
+				} elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
527
+									$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
528
+				}
511 529
 			}
512 530
 		}
513 531
 		$smcFunc['db_free_result']($request);
@@ -541,10 +559,11 @@  discard block
 block discarded – undo
541 559
 				);
542 560
 
543 561
 				// Make the topic number into a link - dealing with splitting too.
544
-				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic'])
545
-					$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
546
-				elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic'])
547
-					$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
562
+				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
563
+									$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
564
+				} elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) {
565
+									$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
566
+				}
548 567
 			}
549 568
 		}
550 569
 		$smcFunc['db_free_result']($request);
@@ -577,8 +596,9 @@  discard block
 block discarded – undo
577 596
 				);
578 597
 
579 598
 				// Make the message number into a link.
580
-				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg'])
581
-					$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
599
+				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
600
+									$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
601
+				}
582 602
 			}
583 603
 		}
584 604
 		$smcFunc['db_free_result']($request);
@@ -618,25 +638,29 @@  discard block
 block discarded – undo
618 638
 	foreach ($entries as $k => $entry)
619 639
 	{
620 640
 		// Make any message info links so its easier to go find that message.
621
-		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id'])))
622
-			$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
641
+		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
642
+					$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
643
+		}
623 644
 
624 645
 		// Mark up any deleted members, topics and boards.
625
-		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type)
626
-			if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
646
+		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
647
+					if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
627 648
 				$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
649
+		}
628 650
 
629 651
 		if (isset($entry['extra']['report']))
630 652
 		{
631 653
 			// Member profile reports go in a different area
632
-			if (stristr($entry['action'], 'user_report'))
633
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
634
-			else
635
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
654
+			if (stristr($entry['action'], 'user_report')) {
655
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
656
+			} else {
657
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
658
+			}
636 659
 		}
637 660
 
638
-		if (empty($entries[$k]['action_text']))
639
-			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
661
+		if (empty($entries[$k]['action_text'])) {
662
+					$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
663
+		}
640 664
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641 665
 			function ($matches) use ($entries, $k)
642 666
 			{
Please login to merge, or discard this patch.