Completed
Branch release-2.1 (3c29ac)
by Mathias
08:54
created
Themes/default/Packages.template.php 3 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.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 				{
913 913
 					// 1. Some mod [ Download ].
914 914
 					echo '
915
-						<strong><span id="ps_img_', $i, '_pkg_', $id, '" class="toggle_up" alt="*" style="display: none;"></span> ', $package['can_install'] || !empty($package['can_emulate_install']) ? '<strong>' . $package['name'] . '</strong> <a href="' . $package['download']['href'] . '">[ ' . $txt['download'] . ' ]</a>': $package['name'], '</strong>
915
+						<strong><span id="ps_img_', $i, '_pkg_', $id, '" class="toggle_up" alt="*" style="display: none;"></span> ', $package['can_install'] || !empty($package['can_emulate_install']) ? '<strong>' . $package['name'] . '</strong> <a href="' . $package['download']['href'] . '">[ ' . $txt['download'] . ' ]</a>' : $package['name'], '</strong>
916 916
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
917 917
 
918 918
 					// Show the mod type?
@@ -1284,10 +1284,10 @@  discard block
 block discarded – undo
1284 1284
 	<head>
1285 1285
 		<meta charset="', $context['character_set'], '">
1286 1286
 		<title>', $txt['operation_title'], '</title>
1287
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
1288
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/admin.css', $modSettings['browser_cache'] ,'">
1289
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
1290
-		<script src="', $settings['default_theme_url'], '/scripts/theme.js', $modSettings['browser_cache'] ,'"></script>
1287
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
1288
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/admin.css', $modSettings['browser_cache'], '">
1289
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
1290
+		<script src="', $settings['default_theme_url'], '/scripts/theme.js', $modSettings['browser_cache'], '"></script>
1291 1291
 	</head>
1292 1292
 	<body>
1293 1293
 		<div class="padding windowbg">
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.
index.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Get everything started up...
27 27
 define('SMF', 1);
28
-if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0)
28
+if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0)
29 29
 	@set_magic_quotes_runtime(0);
30 30
 error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
31 31
 $time_start = microtime();
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
91 91
 {
92 92
 	// If zlib is being used, turn off output compression.
93
-	if (ini_get('zlib.output_compression') >=  1 || ini_get('output_handler') == 'ob_gzhandler')
93
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
94 94
 		$modSettings['enableCompressedOutput'] = '0';
95 95
 	else
96 96
 	{
Please login to merge, or discard this patch.
Braces   +37 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Get everything started up...
27 27
 define('SMF', 1);
28
-if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0)
28
+if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0) {
29 29
 	@set_magic_quotes_runtime(0);
30
+}
30 31
 error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
31 32
 $time_start = microtime();
32 33
 
@@ -34,16 +35,18 @@  discard block
 block discarded – undo
34 35
 ob_start();
35 36
 
36 37
 // Do some cleaning, just in case.
37
-foreach (array('db_character_set', 'cachedir') as $variable)
38
+foreach (array('db_character_set', 'cachedir') as $variable) {
38 39
 	if (isset($GLOBALS[$variable]))
39 40
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
41
+}
40 42
 
41 43
 // Load the settings...
42 44
 require_once(dirname(__FILE__) . '/Settings.php');
43 45
 
44 46
 // Make absolutely sure the cache directory is defined.
45
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
47
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
46 48
 	$cachedir = $boarddir . '/cache';
49
+}
47 50
 
48 51
 // Without those we can't go anywhere
49 52
 require_once($sourcedir . '/QueryString.php');
@@ -53,8 +56,9 @@  discard block
 block discarded – undo
53 56
 require_once($sourcedir . '/Load.php');
54 57
 
55 58
 // If $maintenance is set specifically to 2, then we're upgrading or something.
56
-if (!empty($maintenance) && $maintenance == 2)
59
+if (!empty($maintenance) && $maintenance == 2) {
57 60
 	display_maintenance_message();
61
+}
58 62
 
59 63
 // Create a variable to store some SMF specific functions in.
60 64
 $smcFunc = array();
@@ -69,8 +73,9 @@  discard block
 block discarded – undo
69 73
 cleanRequest();
70 74
 
71 75
 // Seed the random generator.
72
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
76
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
73 77
 	smf_seed_generator();
78
+}
74 79
 
75 80
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
76 81
 if (isset($_GET['scheduled']))
@@ -90,9 +95,9 @@  discard block
 block discarded – undo
90 95
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
91 96
 {
92 97
 	// If zlib is being used, turn off output compression.
93
-	if (ini_get('zlib.output_compression') >=  1 || ini_get('output_handler') == 'ob_gzhandler')
94
-		$modSettings['enableCompressedOutput'] = '0';
95
-	else
98
+	if (ini_get('zlib.output_compression') >=  1 || ini_get('output_handler') == 'ob_gzhandler') {
99
+			$modSettings['enableCompressedOutput'] = '0';
100
+	} else
96 101
 	{
97 102
 		ob_end_clean();
98 103
 		ob_start('ob_gzhandler');
@@ -141,18 +146,21 @@  discard block
 block discarded – undo
141 146
 	loadPermissions();
142 147
 
143 148
 	// Attachments don't require the entire theme to be loaded.
144
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
145
-		detectBrowser();
149
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
150
+			detectBrowser();
151
+	}
146 152
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
147
-	else
148
-		loadTheme();
153
+	else {
154
+			loadTheme();
155
+	}
149 156
 
150 157
 	// Check if the user should be disallowed access.
151 158
 	is_not_banned();
152 159
 
153 160
 	// If we are in a topic and don't have permission to approve it then duck out now.
154
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
155
-		fatal_lang_error('not_a_topic', false);
161
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
162
+			fatal_lang_error('not_a_topic', false);
163
+	}
156 164
 
157 165
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
158 166
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -163,8 +171,9 @@  discard block
 block discarded – undo
163 171
 		writeLog();
164 172
 
165 173
 		// Track forum statistics and hits...?
166
-		if (!empty($modSettings['hitStats']))
167
-			trackStats(array('hits' => '+'));
174
+		if (!empty($modSettings['hitStats'])) {
175
+					trackStats(array('hits' => '+'));
176
+		}
168 177
 	}
169 178
 	unset($no_stat_actions);
170 179
 
@@ -178,13 +187,14 @@  discard block
 block discarded – undo
178 187
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
179 188
 		}
180 189
 		// Don't even try it, sonny.
181
-		else
182
-			return 'InMaintenance';
190
+		else {
191
+					return 'InMaintenance';
192
+		}
183 193
 	}
184 194
 	// If guest access is off, a guest can only do one of the very few following actions.
185
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
186
-		return 'KickGuest';
187
-	elseif (empty($_REQUEST['action']))
195
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
196
+			return 'KickGuest';
197
+	} elseif (empty($_REQUEST['action']))
188 198
 	{
189 199
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
190 200
 		if (empty($board) && empty($topic))
@@ -200,8 +210,9 @@  discard block
 block discarded – undo
200 210
 
201 211
 				$call = call_helper($defaultAction, true);
202 212
 
203
-				if (!empty($call))
204
-					return $call;
213
+				if (!empty($call)) {
214
+									return $call;
215
+				}
205 216
 			}
206 217
 
207 218
 			// No default action huh? then go to our good old BoardIndex.
@@ -331,8 +342,9 @@  discard block
 block discarded – undo
331 342
 
332 343
 			$call = call_helper($fallbackAction, true);
333 344
 
334
-			if (!empty($call))
335
-				return $call;
345
+			if (!empty($call)) {
346
+							return $call;
347
+			}
336 348
 		}
337 349
 
338 350
 		// No fallback action, huh?
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/Profile.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			col_name, field_name, field_desc, field_type, field_order, show_reg, field_length, field_options,
883 883
 			default_value, bbc, enclose, placement
884 884
 		FROM {db_prefix}custom_fields
885
-		WHERE ' . $where .'
885
+		WHERE ' . $where . '
886 886
 		ORDER BY field_order',
887 887
 		array(
888 888
 			'area' => $area,
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 		else
951 951
 		{
952 952
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
953
-			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '' ). '>' . un_htmlspecialchars($value) . '</textarea>';
953
+			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>';
954 954
 		}
955 955
 
956 956
 		// Parse BBCode
Please login to merge, or discard this patch.
Braces   +155 added lines, -118 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * The main designating function for modifying profiles. Loads up info, determins what to do, etc.
@@ -30,18 +31,21 @@  discard block
 block discarded – undo
30 31
 	global $db_show_debug, $smcFunc;
31 32
 
32 33
 	// Don't reload this as we may have processed error strings.
33
-	if (empty($post_errors))
34
-		loadLanguage('Profile+Drafts');
34
+	if (empty($post_errors)) {
35
+			loadLanguage('Profile+Drafts');
36
+	}
35 37
 	loadTemplate('Profile');
36 38
 
37 39
 	require_once($sourcedir . '/Subs-Menu.php');
38 40
 
39 41
 	// Did we get the user by name...
40
-	if (isset($_REQUEST['user']))
41
-		$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
42
+	if (isset($_REQUEST['user'])) {
43
+			$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
44
+	}
42 45
 	// ... or by id_member?
43
-	elseif (!empty($_REQUEST['u']))
44
-		$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
46
+	elseif (!empty($_REQUEST['u'])) {
47
+			$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
48
+	}
45 49
 	// If it was just ?action=profile, edit your own profile, but only if you're not a guest.
46 50
 	else
47 51
 	{
@@ -51,8 +55,9 @@  discard block
 block discarded – undo
51 55
 	}
52 56
 
53 57
 	// Check if loadMemberData() has returned a valid result.
54
-	if (!$memberResult)
55
-		fatal_lang_error('not_a_user', false, 404);
58
+	if (!$memberResult) {
59
+			fatal_lang_error('not_a_user', false, 404);
60
+	}
56 61
 
57 62
 	// If all went well, we have a valid member ID!
58 63
 	list ($memID) = $memberResult;
@@ -68,8 +73,9 @@  discard block
 block discarded – undo
68 73
 
69 74
 	// Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission.
70 75
 	// And we care about what the current user can do, not what the user whose profile it is.
71
-	if ($user_info['mod_cache']['gq'] != '0=1')
72
-		$user_info['permissions'][] = 'approve_group_requests';
76
+	if ($user_info['mod_cache']['gq'] != '0=1') {
77
+			$user_info['permissions'][] = 'approve_group_requests';
78
+	}
73 79
 
74 80
 	// If paid subscriptions are enabled, make sure we actually have at least one subscription available...
75 81
 	$context['subs_available'] = false;
@@ -437,21 +443,25 @@  discard block
 block discarded – undo
437 443
 		foreach ($section['areas'] as $area_id => $area)
438 444
 		{
439 445
 			// If it said no permissions that meant it wasn't valid!
440
-			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any']))
441
-				$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
446
+			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) {
447
+							$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
448
+			}
442 449
 			// Otherwise pick the right set.
443
-			else
444
-				$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
450
+			else {
451
+							$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
452
+			}
445 453
 
446 454
 			// Password required in most cases
447
-			if (!empty($area['password']))
448
-				$context['password_areas'][] = $area_id;
455
+			if (!empty($area['password'])) {
456
+							$context['password_areas'][] = $area_id;
457
+			}
449 458
 		}
450 459
 	}
451 460
 
452 461
 	// Is there an updated message to show?
453
-	if (isset($_GET['updated']))
454
-		$context['profile_updated'] = $txt['profile_updated_own'];
462
+	if (isset($_GET['updated'])) {
463
+			$context['profile_updated'] = $txt['profile_updated_own'];
464
+	}
455 465
 
456 466
 	// Set a few options for the menu.
457 467
 	$menuOptions = array(
@@ -466,8 +476,9 @@  discard block
 block discarded – undo
466 476
 	$profile_include_data = createMenu($profile_areas, $menuOptions);
467 477
 
468 478
 	// No menu means no access.
469
-	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession()))
470
-		fatal_lang_error('no_access', false);
479
+	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) {
480
+			fatal_lang_error('no_access', false);
481
+	}
471 482
 
472 483
 	// Make a note of the Unique ID for this menu.
473 484
 	$context['profile_menu_id'] = $context['max_menu_id'];
@@ -493,8 +504,9 @@  discard block
 block discarded – undo
493 504
 			if ($current_area == $area_id)
494 505
 			{
495 506
 				// This can't happen - but is a security check.
496
-				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false))
497
-					fatal_lang_error('no_access', false);
507
+				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) {
508
+									fatal_lang_error('no_access', false);
509
+				}
498 510
 
499 511
 				// Are we saving data in a valid area?
500 512
 				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
@@ -513,12 +525,14 @@  discard block
 block discarded – undo
513 525
 				}
514 526
 
515 527
 				// Does this require session validating?
516
-				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner']))
517
-					$security_checks['validate'] = true;
528
+				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) {
529
+									$security_checks['validate'] = true;
530
+				}
518 531
 
519 532
 				// Permissions for good measure.
520
-				if (!empty($profile_include_data['permission']))
521
-					$security_checks['permission'] = $profile_include_data['permission'];
533
+				if (!empty($profile_include_data['permission'])) {
534
+									$security_checks['permission'] = $profile_include_data['permission'];
535
+				}
522 536
 
523 537
 				// Either way got something.
524 538
 				$found_area = true;
@@ -527,21 +541,26 @@  discard block
 block discarded – undo
527 541
 	}
528 542
 
529 543
 	// Oh dear, some serious security lapse is going on here... we'll put a stop to that!
530
-	if (!$found_area)
531
-		fatal_lang_error('no_access', false);
544
+	if (!$found_area) {
545
+			fatal_lang_error('no_access', false);
546
+	}
532 547
 
533 548
 	// Release this now.
534 549
 	unset($profile_areas);
535 550
 
536 551
 	// Now the context is setup have we got any security checks to carry out additional to that above?
537
-	if (isset($security_checks['session']))
538
-		checkSession($security_checks['session']);
539
-	if (isset($security_checks['validate']))
540
-		validateSession();
541
-	if (isset($security_checks['validateToken']))
542
-		validateToken($token_name, $token_type);
543
-	if (isset($security_checks['permission']))
544
-		isAllowedTo($security_checks['permission']);
552
+	if (isset($security_checks['session'])) {
553
+			checkSession($security_checks['session']);
554
+	}
555
+	if (isset($security_checks['validate'])) {
556
+			validateSession();
557
+	}
558
+	if (isset($security_checks['validateToken'])) {
559
+			validateToken($token_name, $token_type);
560
+	}
561
+	if (isset($security_checks['permission'])) {
562
+			isAllowedTo($security_checks['permission']);
563
+	}
545 564
 
546 565
 	// Create a token if needed.
547 566
 	if (isset($security_checks['needsToken']) || isset($security_checks['validateToken']))
@@ -551,8 +570,9 @@  discard block
 block discarded – undo
551 570
 	}
552 571
 
553 572
 	// File to include?
554
-	if (isset($profile_include_data['file']))
555
-		require_once($sourcedir . '/' . $profile_include_data['file']);
573
+	if (isset($profile_include_data['file'])) {
574
+			require_once($sourcedir . '/' . $profile_include_data['file']);
575
+	}
556 576
 
557 577
 	// Build the link tree.
558 578
 	$context['linktree'][] = array(
@@ -560,17 +580,19 @@  discard block
 block discarded – undo
560 580
 		'name' => sprintf($txt['profile_of_username'], $context['member']['name']),
561 581
 	);
562 582
 
563
-	if (!empty($profile_include_data['label']))
564
-		$context['linktree'][] = array(
583
+	if (!empty($profile_include_data['label'])) {
584
+			$context['linktree'][] = array(
565 585
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'],
566 586
 			'name' => $profile_include_data['label'],
567 587
 		);
588
+	}
568 589
 
569
-	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label'])
570
-		$context['linktree'][] = array(
590
+	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) {
591
+			$context['linktree'][] = array(
571 592
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'],
572 593
 			'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0],
573 594
 		);
595
+	}
574 596
 
575 597
 	// Set the template for this area and add the profile layer.
576 598
 	$context['sub_template'] = $profile_include_data['function'];
@@ -596,12 +618,14 @@  discard block
 block discarded – undo
596 618
 		if ($check_password)
597 619
 		{
598 620
 			// Check to ensure we're forcing SSL for authentication
599
-			if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
600
-				fatal_lang_error('login_ssl_required');
621
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
622
+							fatal_lang_error('login_ssl_required');
623
+			}
601 624
 
602 625
 			// You didn't even enter a password!
603
-			if (trim($_POST['oldpasswrd']) == '')
604
-				$post_errors[] = 'no_password';
626
+			if (trim($_POST['oldpasswrd']) == '') {
627
+							$post_errors[] = 'no_password';
628
+			}
605 629
 
606 630
 			// Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
607 631
 			$_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']);
@@ -610,33 +634,35 @@  discard block
 block discarded – undo
610 634
 			$good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true);
611 635
 
612 636
 			// Bad password!!!
613
-			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd']))
614
-				$post_errors[] = 'bad_password';
637
+			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) {
638
+							$post_errors[] = 'bad_password';
639
+			}
615 640
 
616 641
 			// Warn other elements not to jump the gun and do custom changes!
617
-			if (in_array('bad_password', $post_errors))
618
-				$context['password_auth_failed'] = true;
642
+			if (in_array('bad_password', $post_errors)) {
643
+							$context['password_auth_failed'] = true;
644
+			}
619 645
 		}
620 646
 
621 647
 		// Change the IP address in the database.
622
-		if ($context['user']['is_owner'])
623
-			$profile_vars['member_ip'] = $user_info['ip'];
648
+		if ($context['user']['is_owner']) {
649
+					$profile_vars['member_ip'] = $user_info['ip'];
650
+		}
624 651
 
625 652
 		// Now call the sub-action function...
626 653
 		if ($current_area == 'activateaccount')
627 654
 		{
628
-			if (empty($post_errors))
629
-				activateAccount($memID);
630
-		}
631
-		elseif ($current_area == 'deleteaccount')
655
+			if (empty($post_errors)) {
656
+							activateAccount($memID);
657
+			}
658
+		} elseif ($current_area == 'deleteaccount')
632 659
 		{
633 660
 			if (empty($post_errors))
634 661
 			{
635 662
 				deleteAccount2($memID);
636 663
 				redirectexit();
637 664
 			}
638
-		}
639
-		elseif ($current_area == 'groupmembership' && empty($post_errors))
665
+		} elseif ($current_area == 'groupmembership' && empty($post_errors))
640 666
 		{
641 667
 			$msg = groupMembership2($profile_vars, $post_errors, $memID);
642 668
 
@@ -647,10 +673,9 @@  discard block
 block discarded – undo
647 673
 		elseif ($current_area == 'authentication')
648 674
 		{
649 675
 			authentication($memID, true);
650
-		}
651
-		elseif (in_array($current_area, array('account', 'forumprofile', 'theme')))
652
-			saveProfileFields();
653
-		else
676
+		} elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) {
677
+					saveProfileFields();
678
+		} else
654 679
 		{
655 680
 			$force_redirect = true;
656 681
 			// Ensure we include this.
@@ -666,34 +691,36 @@  discard block
 block discarded – undo
666 691
 			// Load the language file so we can give a nice explanation of the errors.
667 692
 			loadLanguage('Errors');
668 693
 			$context['post_errors'] = $post_errors;
669
-		}
670
-		elseif (!empty($profile_vars))
694
+		} elseif (!empty($profile_vars))
671 695
 		{
672 696
 			// If we've changed the password, notify any integration that may be listening in.
673
-			if (isset($profile_vars['passwd']))
674
-				call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
697
+			if (isset($profile_vars['passwd'])) {
698
+							call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
699
+			}
675 700
 
676 701
 			updateMemberData($memID, $profile_vars);
677 702
 
678 703
 			// What if this is the newest member?
679
-			if ($modSettings['latestMember'] == $memID)
680
-				updateStats('member');
681
-			elseif (isset($profile_vars['real_name']))
682
-				updateSettings(array('memberlist_updated' => time()));
704
+			if ($modSettings['latestMember'] == $memID) {
705
+							updateStats('member');
706
+			} elseif (isset($profile_vars['real_name'])) {
707
+							updateSettings(array('memberlist_updated' => time()));
708
+			}
683 709
 
684 710
 			// If the member changed his/her birthdate, update calendar statistics.
685
-			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name']))
686
-				updateSettings(array(
711
+			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) {
712
+							updateSettings(array(
687 713
 					'calendar_updated' => time(),
688 714
 				));
715
+			}
689 716
 
690 717
 			// Anything worth logging?
691 718
 			if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled']))
692 719
 			{
693 720
 				$log_changes = array();
694 721
 				require_once($sourcedir . '/Logging.php');
695
-				foreach ($context['log_changes'] as $k => $v)
696
-					$log_changes[] = array(
722
+				foreach ($context['log_changes'] as $k => $v) {
723
+									$log_changes[] = array(
697 724
 						'action' => $k,
698 725
 						'log_type' => 'user',
699 726
 						'extra' => array_merge($v, array(
@@ -701,14 +728,16 @@  discard block
 block discarded – undo
701 728
 							'member_affected' => $memID,
702 729
 						)),
703 730
 					);
731
+				}
704 732
 
705 733
 				logActions($log_changes);
706 734
 			}
707 735
 
708 736
 			// Have we got any post save functions to execute?
709
-			if (!empty($context['profile_execute_on_save']))
710
-				foreach ($context['profile_execute_on_save'] as $saveFunc)
737
+			if (!empty($context['profile_execute_on_save'])) {
738
+							foreach ($context['profile_execute_on_save'] as $saveFunc)
711 739
 					$saveFunc();
740
+			}
712 741
 
713 742
 			// Let them know it worked!
714 743
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']);
@@ -722,27 +751,31 @@  discard block
 block discarded – undo
722 751
 	if (!empty($post_errors))
723 752
 	{
724 753
 		// Set all the errors so the template knows what went wrong.
725
-		foreach ($post_errors as $error_type)
726
-			$context['modify_error'][$error_type] = true;
754
+		foreach ($post_errors as $error_type) {
755
+					$context['modify_error'][$error_type] = true;
756
+		}
727 757
 	}
728 758
 	// If it's you then we should redirect upon save.
729
-	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview'])
730
-		redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
731
-	elseif (!empty($force_redirect))
732
-		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
759
+	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) {
760
+			redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
761
+	} elseif (!empty($force_redirect)) {
762
+			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
763
+	}
733 764
 
734 765
 
735 766
 	// Get the right callable.
736 767
 	$call = call_helper($profile_include_data['function'], true);
737 768
 
738 769
 	// Is it valid?
739
-	if (!empty($call))
740
-		call_user_func($call, $memID);
770
+	if (!empty($call)) {
771
+			call_user_func($call, $memID);
772
+	}
741 773
 
742 774
 	// Set the page title if it's not already set...
743
-	if (!isset($context['page_title']))
744
-		$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
745
-}
775
+	if (!isset($context['page_title'])) {
776
+			$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
777
+	}
778
+	}
746 779
 
747 780
 /**
748 781
  * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user.
@@ -865,16 +898,18 @@  discard block
 block discarded – undo
865 898
 	if (!allowedTo('admin_forum') && $area != 'register')
866 899
 	{
867 900
 		// If it's the owner they can see two types of private fields, regardless.
868
-		if ($memID == $user_info['id'])
869
-			$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
870
-		else
871
-			$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
901
+		if ($memID == $user_info['id']) {
902
+					$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
903
+		} else {
904
+					$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
905
+		}
872 906
 	}
873 907
 
874
-	if ($area == 'register')
875
-		$where .= ' AND show_reg != 0';
876
-	elseif ($area != 'summary')
877
-		$where .= ' AND show_profile = {string:area}';
908
+	if ($area == 'register') {
909
+			$where .= ' AND show_reg != 0';
910
+	} elseif ($area != 'summary') {
911
+			$where .= ' AND show_profile = {string:area}';
912
+	}
878 913
 
879 914
 	// Load all the relevant fields - and data.
880 915
 	$request = $smcFunc['db_query']('', '
@@ -900,13 +935,15 @@  discard block
 block discarded – undo
900 935
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
901 936
 		{
902 937
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
903
-			if (in_array($row['field_type'], array('select', 'radio')))
904
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
938
+			if (in_array($row['field_type'], array('select', 'radio'))) {
939
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
940
+			}
905 941
 		}
906 942
 
907 943
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
908
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled')
909
-			continue;
944
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') {
945
+					continue;
946
+		}
910 947
 
911 948
 		// HTML for the input form.
912 949
 		$output_html = $value;
@@ -915,8 +952,7 @@  discard block
 block discarded – undo
915 952
 			$true = (!$exists && $row['default_value']) || $value;
916 953
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . ' class="input_check">';
917 954
 			$output_html = $true ? $txt['yes'] : $txt['no'];
918
-		}
919
-		elseif ($row['field_type'] == 'select')
955
+		} elseif ($row['field_type'] == 'select')
920 956
 		{
921 957
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
922 958
 			$options = explode(',', $row['field_options']);
@@ -924,13 +960,13 @@  discard block
 block discarded – undo
924 960
 			{
925 961
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
926 962
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
927
-				if ($true)
928
-					$output_html = $v;
963
+				if ($true) {
964
+									$output_html = $v;
965
+				}
929 966
 			}
930 967
 
931 968
 			$input_html .= '</select>';
932
-		}
933
-		elseif ($row['field_type'] == 'radio')
969
+		} elseif ($row['field_type'] == 'radio')
934 970
 		{
935 971
 			$input_html = '<fieldset>';
936 972
 			$options = explode(',', $row['field_options']);
@@ -938,36 +974,37 @@  discard block
 block discarded – undo
938 974
 			{
939 975
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
940 976
 				$input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" class="input_radio" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>';
941
-				if ($true)
942
-					$output_html = $v;
977
+				if ($true) {
978
+									$output_html = $v;
979
+				}
943 980
 			}
944 981
 			$input_html .= '</fieldset>';
945
-		}
946
-		elseif ($row['field_type'] == 'text')
982
+		} elseif ($row['field_type'] == 'text')
947 983
 		{
948 984
 			$input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '" class="input_text"' . ($row['show_reg'] == 2 ? ' required' : '') . '>';
949
-		}
950
-		else
985
+		} else
951 986
 		{
952 987
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
953 988
 			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '' ). '>' . un_htmlspecialchars($value) . '</textarea>';
954 989
 		}
955 990
 
956 991
 		// Parse BBCode
957
-		if ($row['bbc'])
958
-			$output_html = parse_bbc($output_html);
959
-		elseif ($row['field_type'] == 'textarea')
960
-			// Allow for newlines at least
992
+		if ($row['bbc']) {
993
+					$output_html = parse_bbc($output_html);
994
+		} elseif ($row['field_type'] == 'textarea') {
995
+					// Allow for newlines at least
961 996
 			$output_html = strtr($output_html, array("\n" => '<br>'));
997
+		}
962 998
 
963 999
 		// Enclosing the user input within some other text?
964
-		if (!empty($row['enclose']) && !empty($output_html))
965
-			$output_html = strtr($row['enclose'], array(
1000
+		if (!empty($row['enclose']) && !empty($output_html)) {
1001
+					$output_html = strtr($row['enclose'], array(
966 1002
 				'{SCRIPTURL}' => $scripturl,
967 1003
 				'{IMAGES_URL}' => $settings['images_url'],
968 1004
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
969 1005
 				'{INPUT}' => un_htmlspecialchars($output_html),
970 1006
 			));
1007
+		}
971 1008
 
972 1009
 		$context['custom_fields'][] = array(
973 1010
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.
Sources/Subs-Calendar.php 1 patch
Braces   +144 added lines, -99 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get all birthdays within the given time range.
@@ -61,10 +62,11 @@  discard block
 block discarded – undo
61 62
 	$bday = array();
62 63
 	while ($row = $smcFunc['db_fetch_assoc']($result))
63 64
 	{
64
-		if ($year_low != $year_high)
65
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
66
-		else
67
-			$age_year = $year_low;
65
+		if ($year_low != $year_high) {
66
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
67
+		} else {
68
+					$age_year = $year_low;
69
+		}
68 70
 
69 71
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
70 72
 			'id' => $row['id_member'],
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$smcFunc['db_free_result']($result);
77 79
 
78 80
 	// Set is_last, so the themes know when to stop placing separators.
79
-	foreach ($bday as $mday => $array)
80
-		$bday[$mday][count($array) - 1]['is_last'] = true;
81
+	foreach ($bday as $mday => $array) {
82
+			$bday[$mday][count($array) - 1]['is_last'] = true;
83
+	}
81 84
 
82 85
 	return $bday;
83 86
 }
@@ -125,8 +128,9 @@  discard block
 block discarded – undo
125 128
 	while ($row = $smcFunc['db_fetch_assoc']($result))
126 129
 	{
127 130
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
128
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
129
-			continue;
131
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
132
+					continue;
133
+		}
130 134
 
131 135
 		// Force a censor of the title - as often these are used by others.
132 136
 		censorText($row['title'], $use_permissions ? false : true);
@@ -141,13 +145,14 @@  discard block
 block discarded – undo
141 145
 		{
142 146
 			// Attempt to avoid DST problems.
143 147
 			// @todo Resolve this properly at some point.
144
-			if (strftime('%Y-%m-%d', $date) == $lastDate)
145
-				$date += 3601;
148
+			if (strftime('%Y-%m-%d', $date) == $lastDate) {
149
+							$date += 3601;
150
+			}
146 151
 			$lastDate = strftime('%Y-%m-%d', $date);
147 152
 
148 153
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
149
-			if ($use_permissions)
150
-				$events[strftime('%Y-%m-%d', $date)][] = array(
154
+			if ($use_permissions) {
155
+							$events[strftime('%Y-%m-%d', $date)][] = array(
151 156
 					'id' => $row['id_event'],
152 157
 					'title' => $row['title'],
153 158
 					'start_date' => $row['start_date'],
@@ -162,9 +167,10 @@  discard block
 block discarded – undo
162 167
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
163 168
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
164 169
 				);
170
+			}
165 171
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
166
-			else
167
-				$events[strftime('%Y-%m-%d', $date)][] = array(
172
+			else {
173
+							$events[strftime('%Y-%m-%d', $date)][] = array(
168 174
 					'id' => $row['id_event'],
169 175
 					'title' => $row['title'],
170 176
 					'start_date' => $row['start_date'],
@@ -181,6 +187,7 @@  discard block
 block discarded – undo
181 187
 					'poster' => $row['id_member'],
182 188
 					'allowed_groups' => explode(',', $row['member_groups']),
183 189
 				);
190
+			}
184 191
 		}
185 192
 	}
186 193
 	$smcFunc['db_free_result']($result);
@@ -188,8 +195,9 @@  discard block
 block discarded – undo
188 195
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
189 196
 	if ($use_permissions)
190 197
 	{
191
-		foreach ($events as $mday => $array)
192
-			$events[$mday][count($array) - 1]['is_last'] = true;
198
+		foreach ($events as $mday => $array) {
199
+					$events[$mday][count($array) - 1]['is_last'] = true;
200
+		}
193 201
 	}
194 202
 
195 203
 	return $events;
@@ -207,11 +215,12 @@  discard block
 block discarded – undo
207 215
 	global $smcFunc;
208 216
 
209 217
 	// Get the lowest and highest dates for "all years".
210
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
211
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
218
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
219
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
212 220
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
213
-	else
214
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
221
+	} else {
222
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
223
+	}
215 224
 
216 225
 	// Find some holidays... ;).
217 226
 	$result = $smcFunc['db_query']('', '
@@ -231,10 +240,11 @@  discard block
 block discarded – undo
231 240
 	$holidays = array();
232 241
 	while ($row = $smcFunc['db_fetch_assoc']($result))
233 242
 	{
234
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
235
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
236
-		else
237
-			$event_year = substr($low_date, 0, 4);
243
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
244
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
245
+		} else {
246
+					$event_year = substr($low_date, 0, 4);
247
+		}
238 248
 
239 249
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
240 250
 	}
@@ -258,10 +268,12 @@  discard block
 block discarded – undo
258 268
 	isAllowedTo('calendar_post');
259 269
 
260 270
 	// No board?  No topic?!?
261
-	if (empty($board))
262
-		fatal_lang_error('missing_board_id', false);
263
-	if (empty($topic))
264
-		fatal_lang_error('missing_topic_id', false);
271
+	if (empty($board)) {
272
+			fatal_lang_error('missing_board_id', false);
273
+	}
274
+	if (empty($topic)) {
275
+			fatal_lang_error('missing_topic_id', false);
276
+	}
265 277
 
266 278
 	// Administrator, Moderator, or owner.  Period.
267 279
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -279,12 +291,14 @@  discard block
 block discarded – undo
279 291
 		if ($row = $smcFunc['db_fetch_assoc']($result))
280 292
 		{
281 293
 			// Not the owner of the topic.
282
-			if ($row['id_member_started'] != $user_info['id'])
283
-				fatal_lang_error('not_your_topic', 'user');
294
+			if ($row['id_member_started'] != $user_info['id']) {
295
+							fatal_lang_error('not_your_topic', 'user');
296
+			}
284 297
 		}
285 298
 		// Topic/Board doesn't exist.....
286
-		else
287
-			fatal_lang_error('calendar_no_topic', 'general');
299
+		else {
300
+					fatal_lang_error('calendar_no_topic', 'general');
301
+		}
288 302
 		$smcFunc['db_free_result']($result);
289 303
 	}
290 304
 }
@@ -372,14 +386,16 @@  discard block
 block discarded – undo
372 386
 	if (!empty($calendarOptions['start_day']))
373 387
 	{
374 388
 		$nShift -= $calendarOptions['start_day'];
375
-		if ($nShift < 0)
376
-			$nShift = 7 + $nShift;
389
+		if ($nShift < 0) {
390
+					$nShift = 7 + $nShift;
391
+		}
377 392
 	}
378 393
 
379 394
 	// Number of rows required to fit the month.
380 395
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
381
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
382
-		$nRows++;
396
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
397
+			$nRows++;
398
+	}
383 399
 
384 400
 	// Fetch the arrays for birthdays, posted events, and holidays.
385 401
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -392,8 +408,9 @@  discard block
 block discarded – undo
392 408
 	{
393 409
 		$calendarGrid['week_days'][] = $count;
394 410
 		$count++;
395
-		if ($count == 7)
396
-			$count = 0;
411
+		if ($count == 7) {
412
+					$count = 0;
413
+		}
397 414
 	}
398 415
 
399 416
 	// Iterate through each week.
@@ -410,8 +427,9 @@  discard block
 block discarded – undo
410 427
 		{
411 428
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
412 429
 
413
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
414
-				$nDay = 0;
430
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
431
+							$nDay = 0;
432
+			}
415 433
 
416 434
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
417 435
 
@@ -429,8 +447,9 @@  discard block
 block discarded – undo
429 447
 	}
430 448
 
431 449
 	// What is the last day of the month?
432
-	if ($is_previous === true)
433
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
450
+	if ($is_previous === true) {
451
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
452
+	}
434 453
 
435 454
 	// We'll use the shift in the template.
436 455
 	$calendarGrid['shift'] = $nShift;
@@ -464,8 +483,9 @@  discard block
 block discarded – undo
464 483
 	{
465 484
 		// Here we offset accordingly to get things to the real start of a week.
466 485
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
467
-		if ($date_diff < 0)
468
-			$date_diff += 7;
486
+		if ($date_diff < 0) {
487
+					$date_diff += 7;
488
+		}
469 489
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
470 490
 		$day = (int) strftime('%d', $new_timestamp);
471 491
 		$month = (int) strftime('%m', $new_timestamp);
@@ -616,8 +636,9 @@  discard block
 block discarded – undo
616 636
 	// Holidays between now and now + days.
617 637
 	for ($i = $now; $i < $now + $days_for_index; $i += 86400)
618 638
 	{
619
-		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
620
-			$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
639
+		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
640
+					$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
641
+		}
621 642
 	}
622 643
 
623 644
 	// Happy Birthday, guys and gals!
@@ -626,8 +647,9 @@  discard block
 block discarded – undo
626 647
 		$loop_date = strftime('%Y-%m-%d', $i);
627 648
 		if (isset($cached_data['birthdays'][$loop_date]))
628 649
 		{
629
-			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
630
-				$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
650
+			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
651
+							$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
652
+			}
631 653
 			$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
632 654
 		}
633 655
 	}
@@ -639,8 +661,9 @@  discard block
 block discarded – undo
639 661
 		$loop_date = strftime('%Y-%m-%d', $i);
640 662
 
641 663
 		// No events today? Check the next day.
642
-		if (empty($cached_data['events'][$loop_date]))
643
-			continue;
664
+		if (empty($cached_data['events'][$loop_date])) {
665
+					continue;
666
+		}
644 667
 
645 668
 		// Loop through all events to add a few last-minute values.
646 669
 		foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -653,9 +676,9 @@  discard block
 block discarded – undo
653 676
 			{
654 677
 				unset($cached_data['events'][$loop_date][$ev]);
655 678
 				continue;
679
+			} else {
680
+							$duplicates[$this_event['topic'] . $this_event['title']] = true;
656 681
 			}
657
-			else
658
-				$duplicates[$this_event['topic'] . $this_event['title']] = true;
659 682
 
660 683
 			// Might be set to true afterwards, depending on the permissions.
661 684
 			$this_event['can_edit'] = false;
@@ -663,15 +686,18 @@  discard block
 block discarded – undo
663 686
 			$this_event['date'] = $loop_date;
664 687
 		}
665 688
 
666
-		if (!empty($cached_data['events'][$loop_date]))
667
-			$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
689
+		if (!empty($cached_data['events'][$loop_date])) {
690
+					$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
691
+		}
668 692
 	}
669 693
 
670 694
 	// Mark the last item so that a list separator can be used in the template.
671
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
672
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
673
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
674
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
695
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
696
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
697
+	}
698
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
699
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
700
+	}
675 701
 
676 702
 	return array(
677 703
 		'data' => $return_data,
@@ -716,16 +742,20 @@  discard block
 block discarded – undo
716 742
 	if (!isset($_POST['deleteevent']))
717 743
 	{
718 744
 		// No month?  No year?
719
-		if (!isset($_POST['month']))
720
-			fatal_lang_error('event_month_missing', false);
721
-		if (!isset($_POST['year']))
722
-			fatal_lang_error('event_year_missing', false);
745
+		if (!isset($_POST['month'])) {
746
+					fatal_lang_error('event_month_missing', false);
747
+		}
748
+		if (!isset($_POST['year'])) {
749
+					fatal_lang_error('event_year_missing', false);
750
+		}
723 751
 
724 752
 		// Check the month and year...
725
-		if ($_POST['month'] < 1 || $_POST['month'] > 12)
726
-			fatal_lang_error('invalid_month', false);
727
-		if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
728
-			fatal_lang_error('invalid_year', false);
753
+		if ($_POST['month'] < 1 || $_POST['month'] > 12) {
754
+					fatal_lang_error('invalid_month', false);
755
+		}
756
+		if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
757
+					fatal_lang_error('invalid_year', false);
758
+		}
729 759
 	}
730 760
 
731 761
 	// Make sure they're allowed to post...
@@ -734,32 +764,39 @@  discard block
 block discarded – undo
734 764
 	if (isset($_POST['span']))
735 765
 	{
736 766
 		// Make sure it's turned on and not some fool trying to trick it.
737
-		if (empty($modSettings['cal_allowspan']))
738
-			fatal_lang_error('no_span', false);
739
-		if ($_POST['span'] < 1 || $_POST['span'] > $modSettings['cal_maxspan'])
740
-			fatal_lang_error('invalid_days_numb', false);
767
+		if (empty($modSettings['cal_allowspan'])) {
768
+					fatal_lang_error('no_span', false);
769
+		}
770
+		if ($_POST['span'] < 1 || $_POST['span'] > $modSettings['cal_maxspan']) {
771
+					fatal_lang_error('invalid_days_numb', false);
772
+		}
741 773
 	}
742 774
 
743 775
 	// There is no need to validate the following values if we are just deleting the event.
744 776
 	if (!isset($_POST['deleteevent']))
745 777
 	{
746 778
 		// No day?
747
-		if (!isset($_POST['day']))
748
-			fatal_lang_error('event_day_missing', false);
749
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
750
-			fatal_lang_error('event_title_missing', false);
751
-		elseif (!isset($_POST['evtitle']))
752
-			$_POST['evtitle'] = $_POST['subject'];
779
+		if (!isset($_POST['day'])) {
780
+					fatal_lang_error('event_day_missing', false);
781
+		}
782
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
783
+					fatal_lang_error('event_title_missing', false);
784
+		} elseif (!isset($_POST['evtitle'])) {
785
+					$_POST['evtitle'] = $_POST['subject'];
786
+		}
753 787
 
754 788
 		// Bad day?
755
-		if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
756
-			fatal_lang_error('invalid_date', false);
789
+		if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
790
+					fatal_lang_error('invalid_date', false);
791
+		}
757 792
 
758 793
 		// No title?
759
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
760
-			fatal_lang_error('no_event_title', false);
761
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
762
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
794
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
795
+					fatal_lang_error('no_event_title', false);
796
+		}
797
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
798
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
799
+		}
763 800
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
764 801
 	}
765 802
 }
@@ -786,8 +823,9 @@  discard block
 block discarded – undo
786 823
 	);
787 824
 
788 825
 	// No results, return false.
789
-	if ($smcFunc['db_num_rows'] === 0)
790
-		return false;
826
+	if ($smcFunc['db_num_rows'] === 0) {
827
+			return false;
828
+	}
791 829
 
792 830
 	// Grab the results and return.
793 831
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -815,13 +853,15 @@  discard block
 block discarded – undo
815 853
 
816 854
 	// Make sure the start date is in ISO order.
817 855
 	// @todo $year, $month, and $day are not set
818
-	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3)
819
-		trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
856
+	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) {
857
+			trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
858
+	}
820 859
 
821 860
 	// Set the end date (if not yet given)
822 861
 	// @todo $year, $month, and $day are not set
823
-	if (!isset($eventOptions['end_date']))
824
-		$eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
862
+	if (!isset($eventOptions['end_date'])) {
863
+			$eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
864
+	}
825 865
 
826 866
 	// If no topic and board are given, they are not linked to a topic.
827 867
 	$eventOptions['board'] = isset($eventOptions['board']) ? (int) $eventOptions['board'] : 0;
@@ -888,15 +928,17 @@  discard block
 block discarded – undo
888 928
 	$eventOptions['title'] = $smcFunc['htmlspecialchars']($eventOptions['title'], ENT_QUOTES);
889 929
 
890 930
 	// Scan the start date for validity and get its components.
891
-	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3)
892
-		trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
931
+	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3) {
932
+			trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
933
+	}
893 934
 
894 935
 	// Default span to 0 days.
895 936
 	$eventOptions['span'] = isset($eventOptions['span']) ? (int) $eventOptions['span'] : 0;
896 937
 
897 938
 	// Set the end date to the start date + span (if the end date wasn't already given).
898
-	if (!isset($eventOptions['end_date']))
899
-		$eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
939
+	if (!isset($eventOptions['end_date'])) {
940
+			$eventOptions['end_date'] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
941
+	}
900 942
 
901 943
 	$event_columns = array(
902 944
 		'start_date' => '{date:start_date}',
@@ -918,8 +960,9 @@  discard block
 block discarded – undo
918 960
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
919 961
 
920 962
 	$column_clauses = array();
921
-	foreach ($event_columns as $col => $crit)
922
-		$column_clauses[] = $col . ' = ' . $crit;
963
+	foreach ($event_columns as $col => $crit) {
964
+			$column_clauses[] = $col . ' = ' . $crit;
965
+	}
923 966
 
924 967
 	$smcFunc['db_query']('', '
925 968
 		UPDATE {db_prefix}calendar
@@ -993,8 +1036,9 @@  discard block
 block discarded – undo
993 1036
 	);
994 1037
 
995 1038
 	// If nothing returned, we are in poo, poo.
996
-	if ($smcFunc['db_num_rows']($request) === 0)
997
-		return false;
1039
+	if ($smcFunc['db_num_rows']($request) === 0) {
1040
+			return false;
1041
+	}
998 1042
 
999 1043
 	$row = $smcFunc['db_fetch_assoc']($request);
1000 1044
 	$smcFunc['db_free_result']($request);
@@ -1048,8 +1092,9 @@  discard block
 block discarded – undo
1048 1092
 		)
1049 1093
 	);
1050 1094
 	$holidays = array();
1051
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1052
-		$holidays[] = $row;
1095
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1096
+			$holidays[] = $row;
1097
+	}
1053 1098
 	$smcFunc['db_free_result']($request);
1054 1099
 
1055 1100
 	return $holidays;
Please login to merge, or discard this patch.
Sources/Subs-MembersOnline.php 1 patch
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Retrieve a list and several other statistics of the users currently online.
@@ -45,12 +46,14 @@  discard block
 block discarded – undo
45 46
 	}
46 47
 
47 48
 	// Not allowed sort method? Bang! Error!
48
-	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options))
49
-		trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
49
+	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) {
50
+			trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
51
+	}
50 52
 
51 53
 	// Get it from the cache and send it back.
52
-	if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null)
53
-		return $temp;
54
+	if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) {
55
+			return $temp;
56
+	}
54 57
 
55 58
 	// Initialize the array that'll be returned later on.
56 59
 	$membersOnlineStats = array(
@@ -67,8 +70,9 @@  discard block
 block discarded – undo
67 70
 	// Get any spiders if enabled.
68 71
 	$spiders = array();
69 72
 	$spider_finds = array();
70
-	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
71
-		$spiders = smf_json_decode($modSettings['spider_name_cache'], true);
73
+	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
74
+			$spiders = smf_json_decode($modSettings['spider_name_cache'], true);
75
+	}
72 76
 
73 77
 	// Load the users online right now.
74 78
 	$request = $smcFunc['db_query']('', '
@@ -96,9 +100,7 @@  discard block
 block discarded – undo
96 100
 			$membersOnlineStats['num_guests']++;
97 101
 
98 102
 			continue;
99
-		}
100
-
101
-		elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
103
+		} elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
102 104
 		{
103 105
 			// Just increase the stats and don't add this hidden user to any list.
104 106
 			$membersOnlineStats['num_users_hidden']++;
@@ -106,10 +108,11 @@  discard block
 block discarded – undo
106 108
 		}
107 109
 
108 110
 		// Some basic color coding...
109
-		if (!empty($row['online_color']))
110
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
111
-		else
112
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
111
+		if (!empty($row['online_color'])) {
112
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
113
+		} else {
114
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
115
+		}
113 116
 
114 117
 		// Buddies get counted and highlighted.
115 118
 		$is_buddy = in_array($row['id_member'], $user_info['buddies']);
@@ -136,12 +139,13 @@  discard block
 block discarded – undo
136 139
 		$membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
137 140
 
138 141
 		// Store all distinct (primary) membergroups that are shown.
139
-		if (!isset($membersOnlineStats['online_groups'][$row['id_group']]))
140
-			$membersOnlineStats['online_groups'][$row['id_group']] = array(
142
+		if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) {
143
+					$membersOnlineStats['online_groups'][$row['id_group']] = array(
141 144
 				'id' => $row['id_group'],
142 145
 				'name' => $row['group_name'],
143 146
 				'color' => $row['online_color']
144 147
 			);
148
+		}
145 149
 	}
146 150
 	$smcFunc['db_free_result']($request);
147 151
 
@@ -204,11 +208,12 @@  discard block
 block discarded – undo
204 208
 	$settingsToUpdate = array();
205 209
 
206 210
 	// More members on now than ever were?  Update it!
207
-	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline'])
208
-		$settingsToUpdate = array(
211
+	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) {
212
+			$settingsToUpdate = array(
209 213
 			'mostOnline' => $total_users_online,
210 214
 			'mostDate' => time()
211 215
 		);
216
+	}
212 217
 
213 218
 	$date = strftime('%Y-%m-%d', forum_time(false));
214 219
 
@@ -240,8 +245,9 @@  discard block
 block discarded – undo
240 245
 		{
241 246
 			list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request);
242 247
 
243
-			if ($total_users_online > $modSettings['mostOnlineToday'])
244
-				trackStats(array('most_on' => $total_users_online));
248
+			if ($total_users_online > $modSettings['mostOnlineToday']) {
249
+							trackStats(array('most_on' => $total_users_online));
250
+			}
245 251
 
246 252
 			$total_users_online = max($total_users_online, $modSettings['mostOnlineToday']);
247 253
 		}
@@ -258,8 +264,9 @@  discard block
 block discarded – undo
258 264
 		$settingsToUpdate['mostOnlineToday'] = $total_users_online;
259 265
 	}
260 266
 
261
-	if (!empty($settingsToUpdate))
262
-		updateSettings($settingsToUpdate);
263
-}
267
+	if (!empty($settingsToUpdate)) {
268
+			updateSettings($settingsToUpdate);
269
+	}
270
+	}
264 271
 
265 272
 ?>
266 273
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Recent.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get the latest posts of a forum.
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 		censorText($row['body']);
60 61
 
61 62
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
62
-		if ($smcFunc['strlen']($row['body']) > 128)
63
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
63
+		if ($smcFunc['strlen']($row['body']) > 128) {
64
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
65
+		}
64 66
 
65 67
 		// Build the array.
66 68
 		$posts[] = array(
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, -76 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 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);
@@ -121,19 +125,21 @@  discard block
 block discarded – undo
121 125
 		$result = array();
122 126
 
123 127
 		// You gotta be able to post attachments.
124
-		if (!$this->_canPostAttachment)
125
-			return $this->setResponse(array(
128
+		if (!$this->_canPostAttachment) {
129
+					return $this->setResponse(array(
126 130
 				'text' => 'attached_file_cannot',
127 131
 				'type' => 'error',
128 132
 				'data' => false,
129 133
 			));
134
+		}
130 135
 
131 136
 		// Process them at once!
132 137
 		$this->processAttachments();
133 138
 
134 139
 		// The attachments was created and moved the the right folder, time to update the DB.
135
-		if (!empty($_SESSION['temp_attachments']))
136
-			$this->createAtttach();
140
+		if (!empty($_SESSION['temp_attachments'])) {
141
+					$this->createAtttach();
142
+		}
137 143
 
138 144
 		// Set the response.
139 145
 		$this->setResponse();
@@ -146,8 +152,9 @@  discard block
 block discarded – undo
146 152
 	{
147 153
 		global $context, $modSettings, $smcFunc, $user_info, $txt;
148 154
 
149
-		if (!isset($_FILES['attachment']['name']))
150
-			$_FILES['attachment']['tmp_name'] = array();
155
+		if (!isset($_FILES['attachment']['name'])) {
156
+					$_FILES['attachment']['tmp_name'] = array();
157
+		}
151 158
 
152 159
 		// If there are attachments, calculate the total size and how many.
153 160
 		$context['attachments']['total_size'] = 0;
@@ -157,25 +164,30 @@  discard block
 block discarded – undo
157 164
 		if (isset($_REQUEST['msg']))
158 165
 		{
159 166
 			$context['attachments']['quantity'] = count($context['current_attachments']);
160
-			foreach ($context['current_attachments'] as $attachment)
161
-				$context['attachments']['total_size'] += $attachment['size'];
167
+			foreach ($context['current_attachments'] as $attachment) {
168
+							$context['attachments']['total_size'] += $attachment['size'];
169
+			}
162 170
 		}
163 171
 
164 172
 		// A bit of house keeping first.
165
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
166
-			unset($_SESSION['temp_attachments']);
173
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
174
+					unset($_SESSION['temp_attachments']);
175
+		}
167 176
 
168 177
 		// Our infamous SESSION var, we are gonna have soo much fun with it!
169
-		if (!isset($_SESSION['temp_attachments']))
170
-			$_SESSION['temp_attachments'] = array();
178
+		if (!isset($_SESSION['temp_attachments'])) {
179
+					$_SESSION['temp_attachments'] = array();
180
+		}
171 181
 
172 182
 		// Make sure we're uploading to the right place.
173
-		if (!empty($modSettings['automanage_attachments']))
174
-			automanage_attachments_check_directory();
183
+		if (!empty($modSettings['automanage_attachments'])) {
184
+					automanage_attachments_check_directory();
185
+		}
175 186
 
176 187
 		// Is the attachments folder actually there?
177
-		if (!empty($context['dir_creation_error']))
178
-			$this->_generalErrors[] = $context['dir_creation_error'];
188
+		if (!empty($context['dir_creation_error'])) {
189
+					$this->_generalErrors[] = $context['dir_creation_error'];
190
+		}
179 191
 
180 192
 		// The current attach folder ha some issues...
181 193
 		elseif (!is_dir($this->_attchDir))
@@ -200,13 +212,12 @@  discard block
 block discarded – undo
200 212
 			);
201 213
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
202 214
 			$smcFunc['db_free_result']($request);
203
-		}
204
-
205
-		else
206
-			$context['attachments'] = array(
215
+		} else {
216
+					$context['attachments'] = array(
207 217
 				'quantity' => 0,
208 218
 				'total_size' => 0,
209 219
 			);
220
+		}
210 221
 
211 222
 		// Check for other general errors here.
212 223
 
@@ -214,9 +225,10 @@  discard block
 block discarded – undo
214 225
 		if (!empty($this->_generalErrors))
215 226
 		{
216 227
 			// And delete the files 'cos they ain't going nowhere.
217
-			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
218
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
228
+			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
229
+							if (file_exists($_FILES['attachment']['tmp_name'][$n]))
219 230
 					unlink($_FILES['attachment']['tmp_name'][$n]);
231
+			}
220 232
 
221 233
 			$_FILES['attachment']['tmp_name'] = array();
222 234
 
@@ -227,26 +239,29 @@  discard block
 block discarded – undo
227 239
 		// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
228 240
 		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
229 241
 		{
230
-			if ($_FILES['attachment']['name'][$n] == '')
231
-				continue;
242
+			if ($_FILES['attachment']['name'][$n] == '') {
243
+							continue;
244
+			}
232 245
 
233 246
 			// First, let's first check for PHP upload errors.
234 247
 			$errors = array();
235 248
 			if (!empty($_FILES['attachment']['error'][$n]))
236 249
 			{
237
-				if ($_FILES['attachment']['error'][$n] == 2)
238
-					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
239
-
240
-				else
241
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
250
+				if ($_FILES['attachment']['error'][$n] == 2) {
251
+									$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
252
+				} else {
253
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
254
+				}
242 255
 
243 256
 				// Log this one, because...
244
-				if ($_FILES['attachment']['error'][$n] == 6)
245
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
257
+				if ($_FILES['attachment']['error'][$n] == 6) {
258
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
259
+				}
246 260
 
247 261
 				// Weird, no errors were cached, still fill out a generic one.
248
-				if (empty($errors))
249
-					$errors[] = 'attach_php_error';
262
+				if (empty($errors)) {
263
+									$errors[] = 'attach_php_error';
264
+				}
250 265
 			}
251 266
 
252 267
 			// Try to move and rename the file before doing any more checks on it.
@@ -266,16 +281,18 @@  discard block
 block discarded – undo
266 281
 				);
267 282
 
268 283
 				// Move the file to the attachments folder with a temp name for now.
269
-				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
270
-					smf_chmod($destName, 0644);
284
+				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
285
+									smf_chmod($destName, 0644);
286
+				}
271 287
 
272 288
 				// This is madness!!
273 289
 				else
274 290
 				{
275 291
 					// File couldn't be moved.
276 292
 					$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
277
-					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
278
-						unlink($_FILES['attachment']['tmp_name'][$n]);
293
+					if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
294
+											unlink($_FILES['attachment']['tmp_name'][$n]);
295
+					}
279 296
 				}
280 297
 			}
281 298
 
@@ -288,13 +305,15 @@  discard block
 block discarded – undo
288 305
 					'errors' => $errors,
289 306
 				);
290 307
 
291
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
292
-					unlink($_FILES['attachment']['tmp_name'][$n]);
308
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
309
+									unlink($_FILES['attachment']['tmp_name'][$n]);
310
+				}
293 311
 			}
294 312
 
295 313
 			// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
296
-			if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
297
-				attachmentChecks($attachID);
314
+			if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
315
+							attachmentChecks($attachID);
316
+			}
298 317
 		}
299 318
 
300 319
 		// Mod authors, finally a hook to hang an alternate attachment upload system upon
@@ -333,23 +352,24 @@  discard block
 block discarded – undo
333 352
 				'errors' => $attachment['errors'],
334 353
 			);
335 354
 
336
-			if (empty($attachment['errors']))
337
-				if (createAttachment($attachmentOptions))
355
+			if (empty($attachment['errors'])) {
356
+							if (createAttachment($attachmentOptions))
338 357
 				{
339 358
 					// Avoid JS getting confused.
340 359
 					$attachmentOptions['attachID'] = $attachmentOptions['id'];
360
+			}
341 361
 					unset($attachmentOptions['id']);
342 362
 
343 363
 					$_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID'];
344 364
 
345
-					if (!empty($attachmentOptions['thumb']))
346
-						$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
347
-
348
-					if ($this->_msg)
349
-						assignAttachments($_SESSION['already_attached'], $this->_msg);
350
-				}
365
+					if (!empty($attachmentOptions['thumb'])) {
366
+											$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
367
+					}
351 368
 
352
-			elseif (!empty($attachmentOptions['errors']))
369
+					if ($this->_msg) {
370
+											assignAttachments($_SESSION['already_attached'], $this->_msg);
371
+					}
372
+				} elseif (!empty($attachmentOptions['errors']))
353 373
 			{
354 374
 				// Sort out the errors for display and delete any associated files.
355 375
 				$log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file');
@@ -361,14 +381,16 @@  discard block
 block discarded – undo
361 381
 					if (!is_array($error))
362 382
 					{
363 383
 						$attachmentOptions['errors'][] = $txt[$error];
364
-						if (in_array($error, $log_these))
365
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
384
+						if (in_array($error, $log_these)) {
385
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
386
+						}
387
+					} else {
388
+											$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
366 389
 					}
367
-					else
368
-						$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
369 390
 				}
370
-				if (file_exists($attachment['tmp_name']))
371
-					unlink($attachment['tmp_name']);
391
+				if (file_exists($attachment['tmp_name'])) {
392
+									unlink($attachment['tmp_name']);
393
+				}
372 394
 			}
373 395
 
374 396
 			// Regardless of errors, pass the results.
@@ -376,8 +398,9 @@  discard block
 block discarded – undo
376 398
 		}
377 399
 
378 400
 		// Temp save this on the db.
379
-		if (!empty($_SESSION['already_attached']))
380
-			$this->_attachSuccess = $_SESSION['already_attached'];
401
+		if (!empty($_SESSION['already_attached'])) {
402
+					$this->_attachSuccess = $_SESSION['already_attached'];
403
+		}
381 404
 
382 405
 		unset($_SESSION['temp_attachments']);
383 406
 	}
@@ -397,14 +420,16 @@  discard block
 block discarded – undo
397 420
 		if ($this->_sa == 'add')
398 421
 		{
399 422
 			// Is there any generic errors? made some sense out of them!
400
-			if ($this->_generalErrors)
401
-				foreach ($this->_generalErrors as $k => $v)
423
+			if ($this->_generalErrors) {
424
+							foreach ($this->_generalErrors as $k => $v)
402 425
 					$this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]);
426
+			}
403 427
 
404 428
 			// Gotta urlencode the filename.
405
-			if ($this->_attachResults)
406
-				foreach ($this->_attachResults as $k => $v)
429
+			if ($this->_attachResults) {
430
+							foreach ($this->_attachResults as $k => $v)
407 431
 					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
432
+			}
408 433
 
409 434
 			$this->_response = array(
410 435
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -413,9 +438,10 @@  discard block
 block discarded – undo
413 438
 		}
414 439
 
415 440
 		// Rest of us mere mortals gets no special treatment...
416
-		elseif (!empty($data))
417
-			if (!empty($data['text']) && !empty($txt[$data['text']]))
441
+		elseif (!empty($data)) {
442
+					if (!empty($data['text']) && !empty($txt[$data['text']]))
418 443
 				$this->_response['text'] = $txt[$data['text']];
444
+		}
419 445
 	}
420 446
 
421 447
 	protected function sendResponse()
@@ -424,11 +450,11 @@  discard block
 block discarded – undo
424 450
 
425 451
 		ob_end_clean();
426 452
 
427
-		if (!empty($modSettings['CompressedOutput']))
428
-			@ob_start('ob_gzhandler');
429
-
430
-		else
431
-			ob_start();
453
+		if (!empty($modSettings['CompressedOutput'])) {
454
+					@ob_start('ob_gzhandler');
455
+		} else {
456
+					ob_start();
457
+		}
432 458
 
433 459
 		// Set the header.
434 460
 		header('Content-Type: application/json; charset='. $context['character_set'] .'');
Please login to merge, or discard this patch.
Sources/Logging.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
176 176
 	{
177 177
 		// Write the change
178
-		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
178
+		$write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
179 179
 		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
180 180
 
181 181
 		// survey says ...
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br>
249 249
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br>
250 250
 	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br>
251
-	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
251
+	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), '
252 252
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
253 253
 
254 254
 	if (function_exists('memory_get_peak_usage'))
Please login to merge, or discard this patch.
Braces   +134 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Put this user in the online log.
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 		// Don't update for every page - this isn't wholly accurate but who cares.
34 35
 		if ($topic)
35 36
 		{
36
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
37
-				$force = false;
37
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
38
+							$force = false;
39
+			}
38 40
 			$_SESSION['last_topic_id'] = $topic;
39 41
 		}
40 42
 	}
@@ -47,22 +49,24 @@  discard block
 block discarded – undo
47 49
 	}
48 50
 
49 51
 	// Don't mark them as online more than every so often.
50
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
51
-		return;
52
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
53
+			return;
54
+	}
52 55
 
53 56
 	if (!empty($modSettings['who_enabled']))
54 57
 	{
55 58
 		$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
56 59
 
57 60
 		// In the case of a dlattach action, session_var may not be set.
58
-		if (!isset($context['session_var']))
59
-			$context['session_var'] = $_SESSION['session_var'];
61
+		if (!isset($context['session_var'])) {
62
+					$context['session_var'] = $_SESSION['session_var'];
63
+		}
60 64
 
61 65
 		unset($serialized['sesc'], $serialized[$context['session_var']]);
62 66
 		$serialized = json_encode($serialized);
67
+	} else {
68
+			$serialized = '';
63 69
 	}
64
-	else
65
-		$serialized = '';
66 70
 
67 71
 	// Guests use 0, members use their session ID.
68 72
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -102,17 +106,18 @@  discard block
 block discarded – undo
102 106
 		);
103 107
 
104 108
 		// Guess it got deleted.
105
-		if ($smcFunc['db_affected_rows']() == 0)
109
+		if ($smcFunc['db_affected_rows']() == 0) {
110
+					$_SESSION['log_time'] = 0;
111
+		}
112
+	} else {
106 113
 			$_SESSION['log_time'] = 0;
107 114
 	}
108
-	else
109
-		$_SESSION['log_time'] = 0;
110 115
 
111 116
 	// Otherwise, we have to delete and insert.
112 117
 	if (empty($_SESSION['log_time']))
113 118
 	{
114
-		if ($do_delete || !empty($user_info['id']))
115
-			$smcFunc['db_query']('', '
119
+		if ($do_delete || !empty($user_info['id'])) {
120
+					$smcFunc['db_query']('', '
116 121
 				DELETE FROM {db_prefix}log_online
117 122
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
118 123
 				array(
@@ -120,6 +125,7 @@  discard block
 block discarded – undo
120 125
 					'log_time' => time() - $modSettings['lastActive'] * 60,
121 126
 				)
122 127
 			);
128
+		}
123 129
 
124 130
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
125 131
 			'{db_prefix}log_online',
@@ -133,21 +139,24 @@  discard block
 block discarded – undo
133 139
 	$_SESSION['log_time'] = time();
134 140
 
135 141
 	// Well, they are online now.
136
-	if (empty($_SESSION['timeOnlineUpdated']))
137
-		$_SESSION['timeOnlineUpdated'] = time();
142
+	if (empty($_SESSION['timeOnlineUpdated'])) {
143
+			$_SESSION['timeOnlineUpdated'] = time();
144
+	}
138 145
 
139 146
 	// Set their login time, if not already done within the last minute.
140 147
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
141 148
 	{
142 149
 		// Don't count longer than 15 minutes.
143
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
144
-			$_SESSION['timeOnlineUpdated'] = time();
150
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
151
+					$_SESSION['timeOnlineUpdated'] = time();
152
+		}
145 153
 
146 154
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
147 155
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
148 156
 
149
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
150
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
157
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
158
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
159
+		}
151 160
 
152 161
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
153 162
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -184,8 +193,7 @@  discard block
 block discarded – undo
184 193
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
185 194
 			// Copy the file back and run for your life!
186 195
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
187
-		}
188
-		else
196
+		} else
189 197
 		{
190 198
 			@touch($boarddir . '/' . 'Settings.php');
191 199
 			return true;
@@ -205,22 +213,27 @@  discard block
 block discarded – undo
205 213
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
206 214
 
207 215
 	// Add to Settings.php if you want to show the debugging information.
208
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
209
-		return;
216
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
217
+			return;
218
+	}
210 219
 
211
-	if (empty($_SESSION['view_queries']))
212
-		$_SESSION['view_queries'] = 0;
213
-	if (empty($context['debug']['language_files']))
214
-		$context['debug']['language_files'] = array();
215
-	if (empty($context['debug']['sheets']))
216
-		$context['debug']['sheets'] = array();
220
+	if (empty($_SESSION['view_queries'])) {
221
+			$_SESSION['view_queries'] = 0;
222
+	}
223
+	if (empty($context['debug']['language_files'])) {
224
+			$context['debug']['language_files'] = array();
225
+	}
226
+	if (empty($context['debug']['sheets'])) {
227
+			$context['debug']['sheets'] = array();
228
+	}
217 229
 
218 230
 	$files = get_included_files();
219 231
 	$total_size = 0;
220 232
 	for ($i = 0, $n = count($files); $i < $n; $i++)
221 233
 	{
222
-		if (file_exists($files[$i]))
223
-			$total_size += filesize($files[$i]);
234
+		if (file_exists($files[$i])) {
235
+					$total_size += filesize($files[$i]);
236
+		}
224 237
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
225 238
 	}
226 239
 
@@ -229,8 +242,9 @@  discard block
 block discarded – undo
229 242
 	{
230 243
 		foreach ($db_cache as $q => $qq)
231 244
 		{
232
-			if (!empty($qq['w']))
233
-				$warnings += count($qq['w']);
245
+			if (!empty($qq['w'])) {
246
+							$warnings += count($qq['w']);
247
+			}
234 248
 		}
235 249
 
236 250
 		$_SESSION['debug'] = &$db_cache;
@@ -251,12 +265,14 @@  discard block
 block discarded – undo
251 265
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
252 266
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
253 267
 
254
-	if (function_exists('memory_get_peak_usage'))
255
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
268
+	if (function_exists('memory_get_peak_usage')) {
269
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
270
+	}
256 271
 
257 272
 	// What tokens are active?
258
-	if (isset($_SESSION['token']))
259
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
273
+	if (isset($_SESSION['token'])) {
274
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
275
+	}
260 276
 
261 277
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
262 278
 	{
@@ -269,10 +285,12 @@  discard block
 block discarded – undo
269 285
 			$total_t += $cache_hit['t'];
270 286
 			$total_s += $cache_hit['s'];
271 287
 		}
272
-		if (!isset($cache_misses))
273
-			$cache_misses = array();
274
-		foreach ($cache_misses as $missed)
275
-			$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
288
+		if (!isset($cache_misses)) {
289
+					$cache_misses = array();
290
+		}
291
+		foreach ($cache_misses as $missed) {
292
+					$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
293
+		}
276 294
 
277 295
 		echo '
278 296
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -283,38 +301,44 @@  discard block
 block discarded – undo
283 301
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
284 302
 	<br>';
285 303
 
286
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
287
-		foreach ($db_cache as $q => $qq)
304
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
305
+			foreach ($db_cache as $q => $qq)
288 306
 		{
289 307
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
308
+	}
290 309
 			// Temporary tables created in earlier queries are not explainable.
291 310
 			if ($is_select)
292 311
 			{
293
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
294
-					if (strpos(trim($qq['q']), $tmp) !== false)
312
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
313
+									if (strpos(trim($qq['q']), $tmp) !== false)
295 314
 					{
296 315
 						$is_select = false;
316
+				}
297 317
 						break;
298 318
 					}
299 319
 			}
300 320
 			// But actual creation of the temporary tables are.
301
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
302
-				$is_select = true;
321
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
322
+							$is_select = true;
323
+			}
303 324
 
304 325
 			// Make the filenames look a bit better.
305
-			if (isset($qq['f']))
306
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
326
+			if (isset($qq['f'])) {
327
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
328
+			}
307 329
 
308 330
 			echo '
309 331
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
310 332
 	&nbsp;&nbsp;&nbsp;';
311
-			if (!empty($qq['f']) && !empty($qq['l']))
312
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
333
+			if (!empty($qq['f']) && !empty($qq['l'])) {
334
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
335
+			}
313 336
 
314
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
315
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
316
-			elseif (isset($qq['t']))
317
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
337
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
338
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
+			} elseif (isset($qq['t'])) {
340
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
341
+			}
318 342
 			echo '
319 343
 	<br>';
320 344
 		}
@@ -339,12 +363,14 @@  discard block
 block discarded – undo
339 363
 	global $modSettings, $smcFunc;
340 364
 	static $cache_stats = array();
341 365
 
342
-	if (empty($modSettings['trackStats']))
343
-		return false;
344
-	if (!empty($stats))
345
-		return $cache_stats = array_merge($cache_stats, $stats);
346
-	elseif (empty($cache_stats))
347
-		return false;
366
+	if (empty($modSettings['trackStats'])) {
367
+			return false;
368
+	}
369
+	if (!empty($stats)) {
370
+			return $cache_stats = array_merge($cache_stats, $stats);
371
+	} elseif (empty($cache_stats)) {
372
+			return false;
373
+	}
348 374
 
349 375
 	$setStringUpdate = '';
350 376
 	$insert_keys = array();
@@ -357,10 +383,11 @@  discard block
 block discarded – undo
357 383
 		$setStringUpdate .= '
358 384
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
359 385
 
360
-		if ($change === '+')
361
-			$cache_stats[$field] = 1;
362
-		else
363
-			$update_parameters[$field] = $change;
386
+		if ($change === '+') {
387
+					$cache_stats[$field] = 1;
388
+		} else {
389
+					$update_parameters[$field] = $change;
390
+		}
364 391
 		$insert_keys[$field] = 'int';
365 392
 	}
366 393
 
@@ -424,43 +451,50 @@  discard block
 block discarded – undo
424 451
 	);
425 452
 
426 453
 	// Make sure this particular log is enabled first...
427
-	if (empty($modSettings['modlog_enabled']))
428
-		unset ($log_types['moderate']);
429
-	if (empty($modSettings['userlog_enabled']))
430
-		unset ($log_types['user']);
431
-	if (empty($modSettings['adminlog_enabled']))
432
-		unset ($log_types['admin']);
454
+	if (empty($modSettings['modlog_enabled'])) {
455
+			unset ($log_types['moderate']);
456
+	}
457
+	if (empty($modSettings['userlog_enabled'])) {
458
+			unset ($log_types['user']);
459
+	}
460
+	if (empty($modSettings['adminlog_enabled'])) {
461
+			unset ($log_types['admin']);
462
+	}
433 463
 
434 464
 	call_integration_hook('integrate_log_types', array(&$log_types));
435 465
 
436 466
 	foreach ($logs as $log)
437 467
 	{
438
-		if (!isset($log_types[$log['log_type']]))
439
-			return false;
468
+		if (!isset($log_types[$log['log_type']])) {
469
+					return false;
470
+		}
440 471
 
441
-		if (!is_array($log['extra']))
442
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
472
+		if (!is_array($log['extra'])) {
473
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
474
+		}
443 475
 
444 476
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
445 477
 		if (isset($log['extra']['topic']))
446 478
 		{
447
-			if (!is_numeric($log['extra']['topic']))
448
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
479
+			if (!is_numeric($log['extra']['topic'])) {
480
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
481
+			}
449 482
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
450 483
 			unset($log['extra']['topic']);
484
+		} else {
485
+					$topic_id = 0;
451 486
 		}
452
-		else
453
-			$topic_id = 0;
454 487
 
455 488
 		if (isset($log['extra']['message']))
456 489
 		{
457
-			if (!is_numeric($log['extra']['message']))
458
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
490
+			if (!is_numeric($log['extra']['message'])) {
491
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
492
+			}
459 493
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
460 494
 			unset($log['extra']['message']);
495
+		} else {
496
+					$msg_id = 0;
461 497
 		}
462
-		else
463
-			$msg_id = 0;
464 498
 
465 499
 		// @todo cache this?
466 500
 		// Is there an associated report on this?
@@ -487,23 +521,26 @@  discard block
 block discarded – undo
487 521
 			$smcFunc['db_free_result']($request);
488 522
 		}
489 523
 
490
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
491
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
524
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
525
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
526
+		}
492 527
 
493 528
 		if (isset($log['extra']['board']))
494 529
 		{
495
-			if (!is_numeric($log['extra']['board']))
496
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
530
+			if (!is_numeric($log['extra']['board'])) {
531
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
532
+			}
497 533
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
498 534
 			unset($log['extra']['board']);
535
+		} else {
536
+					$board_id = 0;
499 537
 		}
500
-		else
501
-			$board_id = 0;
502 538
 
503 539
 		if (isset($log['extra']['board_to']))
504 540
 		{
505
-			if (!is_numeric($log['extra']['board_to']))
506
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
541
+			if (!is_numeric($log['extra']['board_to'])) {
542
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
543
+			}
507 544
 			if (empty($board_id))
508 545
 			{
509 546
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -511,10 +548,11 @@  discard block
 block discarded – undo
511 548
 			}
512 549
 		}
513 550
 
514
-		if (isset($log['extra']['member_affected']))
515
-			$memID = $log['extra']['member_affected'];
516
-		else
517
-			$memID = $user_info['id'];
551
+		if (isset($log['extra']['member_affected'])) {
552
+					$memID = $log['extra']['member_affected'];
553
+		} else {
554
+					$memID = $user_info['id'];
555
+		}
518 556
 
519 557
 		$inserts[] = array(
520 558
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.