Completed
Push — release-2.1 ( 306c59...efe294 )
by
unknown
08:30
created
Themes/default/Register.template.php 1 patch
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -28,14 +28,15 @@  discard block
 block discarded – undo
28 28
 			<div id="confirm_buttons">';
29 29
 
30 30
 	// Age restriction in effect?
31
-	if ($context['show_coppa'])
32
-		echo '
31
+	if ($context['show_coppa']) {
32
+			echo '
33 33
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
34 34
 				<br>
35 35
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
36
-	else
37
-		echo '
36
+	} else {
37
+			echo '
38 38
 				<input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">';
39
+	}
39 40
 
40 41
 	echo '
41 42
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -78,9 +79,10 @@  discard block
 block discarded – undo
78 79
 			<ul>';
79 80
 
80 81
 		// Cycle through each error and display an error message.
81
-		foreach ($context['registration_errors'] as $error)
82
-			echo '
82
+		foreach ($context['registration_errors'] as $error) {
83
+					echo '
83 84
 				<li>', $error, '</li>';
85
+		}
84 86
 
85 87
 		echo '
86 88
 			</ul>
@@ -149,14 +151,15 @@  discard block
 block discarded – undo
149 151
 		echo '
150 152
 					<dl class="register_form">';
151 153
 
152
-		foreach ($context['custom_fields'] as $field)
153
-			if ($field['show_reg'] > 1)
154
+		foreach ($context['custom_fields'] as $field) {
155
+					if ($field['show_reg'] > 1)
154 156
 				echo '
155 157
 						<dt>
156 158
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
157 159
 							<span class="smalltext">', $field['desc'], '</span>
158 160
 						</dt>
159 161
 						<dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>';
162
+		}
160 163
 
161 164
 		echo '
162 165
 					</dl>';
@@ -167,14 +170,15 @@  discard block
 block discarded – undo
167 170
 			</div><!-- .roundframe -->';
168 171
 
169 172
 	// If we have either of these, show the extra group.
170
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
171
-		echo '
173
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
174
+			echo '
172 175
 			<div class="title_bar title_top">
173 176
 				<h3 class="titlebg">', $txt['additional_information'], '</h3>
174 177
 			</div>
175 178
 			<div class="roundframe noup">
176 179
 				<fieldset>
177 180
 					<dl class="register_form" id="custom_group">';
181
+	}
178 182
 
179 183
 	if (!empty($context['profile_fields']))
180 184
 	{
@@ -188,41 +192,45 @@  discard block
 block discarded – undo
188 192
 					$callback_func = 'template_profile_' . $field['callback_func'];
189 193
 					$callback_func();
190 194
 				}
191
-			}
192
-			else
195
+			} else
193 196
 			{
194 197
 				echo '
195 198
 						<dt>
196 199
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>';
197 200
 
198 201
 				// Does it have any subtext to show?
199
-				if (!empty($field['subtext']))
200
-					echo '
202
+				if (!empty($field['subtext'])) {
203
+									echo '
201 204
 							<span class="smalltext">', $field['subtext'], '</span>';
205
+				}
202 206
 
203 207
 				echo '
204 208
 						</dt>
205 209
 						<dd>';
206 210
 
207 211
 				// Want to put something infront of the box?
208
-				if (!empty($field['preinput']))
209
-					echo '
212
+				if (!empty($field['preinput'])) {
213
+									echo '
210 214
 							', $field['preinput'];
215
+				}
211 216
 
212 217
 				// What type of data are we showing?
213
-				if ($field['type'] == 'label')
214
-					echo '
218
+				if ($field['type'] == 'label') {
219
+									echo '
215 220
 							', $field['value'];
221
+				}
216 222
 
217 223
 				// Maybe it's a text box - very likely!
218
-				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url')))
219
-					echo '
224
+				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) {
225
+									echo '
220 226
 							<input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
227
+				}
221 228
 
222 229
 				// You "checking" me out? ;)
223
-				elseif ($field['type'] == 'check')
224
-					echo '
230
+				elseif ($field['type'] == 'check') {
231
+									echo '
225 232
 							<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
233
+				}
226 234
 
227 235
 				// Always fun - select boxes!
228 236
 				elseif ($field['type'] == 'select')
@@ -233,14 +241,16 @@  discard block
 block discarded – undo
233 241
 					if (isset($field['options']))
234 242
 					{
235 243
 						// Is this some code to generate the options?
236
-						if (!is_array($field['options']))
237
-							$field['options'] = eval($field['options']);
244
+						if (!is_array($field['options'])) {
245
+													$field['options'] = eval($field['options']);
246
+						}
238 247
 
239 248
 						// Assuming we now have some!
240
-						if (is_array($field['options']))
241
-							foreach ($field['options'] as $value => $name)
249
+						if (is_array($field['options'])) {
250
+													foreach ($field['options'] as $value => $name)
242 251
 								echo '
243 252
 								<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
253
+						}
244 254
 					}
245 255
 
246 256
 					echo '
@@ -248,9 +258,10 @@  discard block
 block discarded – undo
248 258
 				}
249 259
 
250 260
 				// Something to end with?
251
-				if (!empty($field['postinput']))
252
-					echo '
261
+				if (!empty($field['postinput'])) {
262
+									echo '
253 263
 							', $field['postinput'];
264
+				}
254 265
 
255 266
 				echo '
256 267
 						</dd>';
@@ -261,25 +272,27 @@  discard block
 block discarded – undo
261 272
 	// Are there any custom fields?
262 273
 	if (!empty($context['custom_fields']))
263 274
 	{
264
-		foreach ($context['custom_fields'] as $field)
265
-			if ($field['show_reg'] < 2)
275
+		foreach ($context['custom_fields'] as $field) {
276
+					if ($field['show_reg'] < 2)
266 277
 				echo '
267 278
 						<dt>
268 279
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
269 280
 							<span class="smalltext">', $field['desc'], '</span>
270 281
 						</dt>
271 282
 						<dd>', $field['input_html'], '</dd>';
283
+		}
272 284
 	}
273 285
 
274 286
 	// If we have either of these, close the list like a proper gent.
275
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
276
-		echo '
287
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
288
+			echo '
277 289
 					</dl>
278 290
 				</fieldset>
279 291
 			</div><!-- .roundframe -->';
292
+	}
280 293
 
281
-	if ($context['visual_verification'])
282
-		echo '
294
+	if ($context['visual_verification']) {
295
+			echo '
283 296
 			<div class="title_bar title_top">
284 297
 				<h3 class="titlebg">', $txt['verification'], '</h3>
285 298
 			</div>
@@ -288,19 +301,21 @@  discard block
 block discarded – undo
288 301
 					', template_control_verification($context['visual_verification_id'], 'all'), '
289 302
 				</fieldset>
290 303
 			</div>';
304
+	}
291 305
 
292 306
 	echo '
293 307
 			<div id="confirm_buttons" class="flow_auto">';
294 308
 
295 309
 	// Age restriction in effect?
296
-	if (!$context['require_agreement'] && $context['show_coppa'])
297
-		echo '
310
+	if (!$context['require_agreement'] && $context['show_coppa']) {
311
+			echo '
298 312
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
299 313
 				<br>
300 314
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
301
-	else
302
-		echo '
315
+	} else {
316
+			echo '
303 317
 				<input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">';
318
+	}
304 319
 
305 320
 	echo '
306 321
 			</div>
@@ -362,25 +377,28 @@  discard block
 block discarded – undo
362 377
 				<p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>';
363 378
 
364 379
 	// Can they send by post?
365
-	if (!empty($context['coppa']['post']))
366
-		echo '
380
+	if (!empty($context['coppa']['post'])) {
381
+			echo '
367 382
 				<h4>1) ', $txt['coppa_send_by_post'], '</h4>
368 383
 				<div class="coppa_contact">
369 384
 					', $context['coppa']['post'], '
370 385
 				</div>';
386
+	}
371 387
 
372 388
 	// Can they send by fax??
373
-	if (!empty($context['coppa']['fax']))
374
-		echo '
389
+	if (!empty($context['coppa']['fax'])) {
390
+			echo '
375 391
 				<h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4>
376 392
 				<div class="coppa_contact">
377 393
 					', $context['coppa']['fax'], '
378 394
 				</div>';
395
+	}
379 396
 
380 397
 	// Offer an alternative Phone Number?
381
-	if ($context['coppa']['phone'])
382
-		echo '
398
+	if ($context['coppa']['phone']) {
399
+			echo '
383 400
 				<p>', $context['coppa']['phone'], '</p>';
401
+	}
384 402
 
385 403
 	echo '
386 404
 			</div><!-- #coppa -->';
@@ -445,19 +463,20 @@  discard block
 block discarded – undo
445 463
 	<body style="margin: 1ex;">
446 464
 		<div class="windowbg description" style="text-align: center;">';
447 465
 
448
-	if (isBrowser('is_ie') || isBrowser('is_ie11'))
449
-		echo '
466
+	if (isBrowser('is_ie') || isBrowser('is_ie11')) {
467
+			echo '
450 468
 			<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav">
451 469
 				<param name="AutoStart" value="1">
452 470
 				<param name="FileName" value="', $context['verification_sound_href'], '">
453 471
 			</object>';
454
-	else
455
-		echo '
472
+	} else {
473
+			echo '
456 474
 			<audio src="', $context['verification_sound_href'], '" controls>
457 475
 				<object type="audio/x-wav" data="', $context['verification_sound_href'], '">
458 476
 					<a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a>
459 477
 				</object>
460 478
 			</audio>';
479
+	}
461 480
 
462 481
 	echo '
463 482
 			<br>
@@ -485,11 +504,12 @@  discard block
 block discarded – undo
485 504
 				</div>
486 505
 				<div id="register_screen" class="windowbg2 noup">';
487 506
 
488
-	if (!empty($context['registration_done']))
489
-		echo '
507
+	if (!empty($context['registration_done'])) {
508
+			echo '
490 509
 					<div class="infobox">
491 510
 						', $context['registration_done'], '
492 511
 					</div>';
512
+	}
493 513
 
494 514
 	echo '
495 515
 					<dl class="register_form" id="admin_register_form">
@@ -525,9 +545,10 @@  discard block
 block discarded – undo
525 545
 						<dd>
526 546
 							<select name="group" id="group_select" tabindex="', $context['tabindex']++, '">';
527 547
 
528
-		foreach ($context['member_groups'] as $id => $name)
529
-			echo '
548
+		foreach ($context['member_groups'] as $id => $name) {
549
+					echo '
530 550
 								<option value="', $id, '">', $name, '</option>';
551
+		}
531 552
 
532 553
 		echo '
533 554
 							</select>
@@ -535,8 +556,8 @@  discard block
 block discarded – undo
535 556
 	}
536 557
 
537 558
 	// If there is any field marked as required, show it here!
538
-	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
539
-		foreach ($context['custom_fields'] as $field)
559
+	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) {
560
+			foreach ($context['custom_fields'] as $field)
540 561
 			if ($field['show_reg'] > 1)
541 562
 				echo '
542 563
 						<dt>
@@ -546,6 +567,7 @@  discard block
 block discarded – undo
546 567
 						<dd>
547 568
 							', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '
548 569
 						</dd>';
570
+	}
549 571
 
550 572
 	echo '
551 573
 						<dt>
@@ -582,13 +604,13 @@  discard block
 block discarded – undo
582 604
 {
583 605
 	global $context, $scripturl, $txt;
584 606
 
585
-	if (!empty($context['saved_successful']))
586
-		echo '
607
+	if (!empty($context['saved_successful'])) {
608
+			echo '
587 609
 		<div class="infobox">', $txt['settings_saved'], '</div>';
588
-
589
-	elseif (!empty($context['could_not_save']))
590
-		echo '
610
+	} elseif (!empty($context['could_not_save'])) {
611
+			echo '
591 612
 		<div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>';
613
+	}
592 614
 
593 615
 	// Just a big box to edit the text file ;)
594 616
 	echo '
@@ -598,9 +620,10 @@  discard block
 block discarded – undo
598 620
 			</div>';
599 621
 
600 622
 	// Warning for if the file isn't writable.
601
-	if (!empty($context['warning']))
602
-		echo '
623
+	if (!empty($context['warning'])) {
624
+			echo '
603 625
 			<p class="error">', $context['warning'], '</p>';
626
+	}
604 627
 
605 628
 	echo '
606 629
 			<div class="windowbg2 noup" id="registration_agreement">';
@@ -617,9 +640,10 @@  discard block
 block discarded – undo
617 640
 						<strong>', $txt['admin_agreement_select_language'], ':</strong>
618 641
 						<select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">';
619 642
 
620
-		foreach ($context['editable_agreements'] as $file => $name)
621
-			echo '
643
+		foreach ($context['editable_agreements'] as $file => $name) {
644
+					echo '
622 645
 							<option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>';
646
+		}
623 647
 
624 648
 		echo '
625 649
 						</select>
@@ -659,9 +683,10 @@  discard block
 block discarded – undo
659 683
 {
660 684
 	global $context, $scripturl, $txt;
661 685
 
662
-	if (!empty($context['saved_successful']))
663
-		echo '
686
+	if (!empty($context['saved_successful'])) {
687
+			echo '
664 688
 	<div class="infobox">', $txt['settings_saved'], '</div>';
689
+	}
665 690
 
666 691
 	echo '
667 692
 	<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Braces   +535 added lines, -410 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 			<script>
24 24
 				disableAutoComplete();
25 25
 			</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 			', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 			<div class="infobox">
35 36
 				', $context['profile_updated'], '
36 37
 			</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -99,19 +101,19 @@  discard block
 block discarded – undo
99 101
 		</div>
100 102
 		<div class="alerts_unread">';
101 103
 
102
-	if (empty($context['unread_alerts']))
103
-		template_alerts_all_read();
104
-
105
-	else
104
+	if (empty($context['unread_alerts'])) {
105
+			template_alerts_all_read();
106
+	} else
106 107
 	{
107
-		foreach ($context['unread_alerts'] as $id_alert => $details)
108
-			echo '
108
+		foreach ($context['unread_alerts'] as $id_alert => $details) {
109
+					echo '
109 110
 			<div class="unread">
110 111
 				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111 112
 				<div class="details">
112 113
 					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113 114
 				</div>
114 115
 			</div>';
116
+		}
115 117
 	}
116 118
 
117 119
 	echo '
@@ -158,37 +160,41 @@  discard block
 block discarded – undo
158 160
 	if (!empty($context['print_custom_fields']['above_member']))
159 161
 	{
160 162
 		$fields = '';
161
-		foreach ($context['print_custom_fields']['above_member'] as $field)
162
-			if (!empty($field['output_html']))
163
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
164
+					if (!empty($field['output_html']))
163 165
 				$fields .= '
164 166
 					<li>' . $field['output_html'] . '</li>';
167
+		}
165 168
 
166
-		if (!empty($fields))
167
-			echo '
169
+		if (!empty($fields)) {
170
+					echo '
168 171
 			<div class="custom_fields_above_name">
169 172
 				<ul>', $fields, '
170 173
 				</ul>
171 174
 			</div>';
175
+		}
172 176
 	}
173 177
 
174 178
 	echo '
175 179
 			<div class="username clear">
176 180
 				<h4>';
177 181
 
178
-	if (!empty($context['print_custom_fields']['before_member']))
179
-		foreach ($context['print_custom_fields']['before_member'] as $field)
182
+	if (!empty($context['print_custom_fields']['before_member'])) {
183
+			foreach ($context['print_custom_fields']['before_member'] as $field)
180 184
 			if (!empty($field['output_html']))
181 185
 				echo '
182 186
 					<span>', $field['output_html'], '</span>';
187
+	}
183 188
 
184 189
 	echo '
185 190
 					', $context['member']['name'];
186 191
 
187
-	if (!empty($context['print_custom_fields']['after_member']))
188
-		foreach ($context['print_custom_fields']['after_member'] as $field)
192
+	if (!empty($context['print_custom_fields']['after_member'])) {
193
+			foreach ($context['print_custom_fields']['after_member'] as $field)
189 194
 			if (!empty($field['output_html']))
190 195
 				echo '
191 196
 					<span>', $field['output_html'], '</span>';
197
+	}
192 198
 
193 199
 
194 200
 	echo '
@@ -201,39 +207,44 @@  discard block
 block discarded – undo
201 207
 	if (!empty($context['print_custom_fields']['below_avatar']))
202 208
 	{
203 209
 		$fields = '';
204
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
205
-			if (!empty($field['output_html']))
210
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
211
+					if (!empty($field['output_html']))
206 212
 				$fields .= '
207 213
 					<li>' . $field['output_html'] . '</li>';
214
+		}
208 215
 
209
-		if (!empty($fields))
210
-			echo '
216
+		if (!empty($fields)) {
217
+					echo '
211 218
 			<div class="custom_fields_below_avatar">
212 219
 				<ul>', $fields, '
213 220
 				</ul>
214 221
 			</div>';
222
+		}
215 223
 	}
216 224
 
217 225
 	echo '
218 226
 			<ul class="icon_fields clear">';
219 227
 
220 228
 	// Email is only visible if it's your profile or you have the moderate_forum permission
221
-	if ($context['member']['show_email'])
222
-		echo '
229
+	if ($context['member']['show_email']) {
230
+			echo '
223 231
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
232
+	}
224 233
 
225 234
 	// Don't show an icon if they haven't specified a website.
226
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
227
-		echo '
235
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
236
+			echo '
228 237
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
238
+	}
229 239
 
230 240
 	// Are there any custom profile fields as icons?
231 241
 	if (!empty($context['print_custom_fields']['icons']))
232 242
 	{
233
-		foreach ($context['print_custom_fields']['icons'] as $field)
234
-			if (!empty($field['output_html']))
243
+		foreach ($context['print_custom_fields']['icons'] as $field) {
244
+					if (!empty($field['output_html']))
235 245
 				echo '
236 246
 				<li class="custom_field">', $field['output_html'], '</li>';
247
+		}
237 248
 	}
238 249
 
239 250
 	echo '
@@ -242,24 +253,27 @@  discard block
 block discarded – undo
242 253
 				', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
243 254
 
244 255
 	// Can they add this member as a buddy?
245
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
246
-		echo '
256
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
257
+			echo '
247 258
 				<br>
248 259
 				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
260
+	}
249 261
 
250 262
 	echo '
251 263
 			</span>';
252 264
 
253
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
254
-		echo '
265
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
266
+			echo '
255 267
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
268
+	}
256 269
 
257 270
 	echo '
258 271
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
259 272
 
260
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
261
-		echo '
273
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
274
+			echo '
262 275
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
276
+	}
263 277
 
264 278
 	echo '
265 279
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -268,17 +282,19 @@  discard block
 block discarded – undo
268 282
 	if (!empty($context['print_custom_fields']['bottom_poster']))
269 283
 	{
270 284
 		$fields = '';
271
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
272
-			if (!empty($field['output_html']))
285
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
286
+					if (!empty($field['output_html']))
273 287
 				$fields .= '
274 288
 					<li>' . $field['output_html'] . '</li>';
289
+		}
275 290
 
276
-		if (!empty($fields))
277
-			echo '
291
+		if (!empty($fields)) {
292
+					echo '
278 293
 			<div class="custom_fields_bottom">
279 294
 				<ul class="nolist">', $fields, '
280 295
 				</ul>
281 296
 			</div>';
297
+		}
282 298
 	}
283 299
 
284 300
 	echo '
@@ -287,30 +303,35 @@  discard block
 block discarded – undo
287 303
 		<div id="detailedinfo">
288 304
 			<dl class="settings">';
289 305
 
290
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
291
-		echo '
306
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
307
+			echo '
292 308
 				<dt>', $txt['username'], ': </dt>
293 309
 				<dd>', $context['member']['username'], '</dd>';
310
+	}
294 311
 
295
-	if (!isset($context['disabled_fields']['posts']))
296
-		echo '
312
+	if (!isset($context['disabled_fields']['posts'])) {
313
+			echo '
297 314
 				<dt>', $txt['profile_posts'], ': </dt>
298 315
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
316
+	}
299 317
 
300
-	if ($context['member']['show_email'])
301
-		echo '
318
+	if ($context['member']['show_email']) {
319
+			echo '
302 320
 				<dt>', $txt['email'], ': </dt>
303 321
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
322
+	}
304 323
 
305
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
306
-		echo '
324
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
325
+			echo '
307 326
 				<dt>', $txt['custom_title'], ': </dt>
308 327
 				<dd>', $context['member']['title'], '</dd>';
328
+	}
309 329
 
310
-	if (!empty($context['member']['blurb']))
311
-		echo '
330
+	if (!empty($context['member']['blurb'])) {
331
+			echo '
312 332
 				<dt>', $txt['personal_text'], ': </dt>
313 333
 				<dd>', $context['member']['blurb'], '</dd>';
334
+	}
314 335
 
315 336
 	echo '
316 337
 				<dt>', $txt['age'], ':</dt>
@@ -324,19 +345,21 @@  discard block
 block discarded – undo
324 345
 	{
325 346
 		$fields = array();
326 347
 
327
-		foreach ($context['print_custom_fields']['standard'] as $field)
328
-			if (!empty($field['output_html']))
348
+		foreach ($context['print_custom_fields']['standard'] as $field) {
349
+					if (!empty($field['output_html']))
329 350
 				$fields[] = $field;
351
+		}
330 352
 
331 353
 		if (count($fields) > 0)
332 354
 		{
333 355
 			echo '
334 356
 			<dl class="settings">';
335 357
 
336
-			foreach ($fields as $field)
337
-				echo '
358
+			foreach ($fields as $field) {
359
+							echo '
338 360
 				<dt>', $field['name'], ':</dt>
339 361
 				<dd>', $field['output_html'], '</dd>';
362
+			}
340 363
 
341 364
 			echo '
342 365
 			</dl>';
@@ -355,9 +378,10 @@  discard block
 block discarded – undo
355 378
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
356 379
 
357 380
 		// Can we provide information on what this means?
358
-		if (!empty($context['warning_status']))
359
-			echo '
381
+		if (!empty($context['warning_status'])) {
382
+					echo '
360 383
 					<span class="smalltext">(', $context['warning_status'], ')</span>';
384
+		}
361 385
 
362 386
 		echo '
363 387
 				</dd>';
@@ -367,11 +391,12 @@  discard block
 block discarded – undo
367 391
 	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
368 392
 	{
369 393
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
370
-		if (!empty($context['activate_message']))
371
-			echo '
394
+		if (!empty($context['activate_message'])) {
395
+					echo '
372 396
 				<dt class="clear">
373 397
 					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
374 398
 				</dt>';
399
+		}
375 400
 
376 401
 		// If the current member is banned, show a message and possibly a link to the ban.
377 402
 		if (!empty($context['member']['bans']))
@@ -383,10 +408,11 @@  discard block
 block discarded – undo
383 408
 				<dt class="clear" id="ban_info" style="display: none;">
384 409
 					<strong>', $txt['user_banned_by_following'], ':</strong>';
385 410
 
386
-			foreach ($context['member']['bans'] as $ban)
387
-				echo '
411
+			foreach ($context['member']['bans'] as $ban) {
412
+							echo '
388 413
 					<br>
389 414
 					<span class="smalltext">', $ban['explanation'], '</span>';
415
+			}
390 416
 
391 417
 			echo '
392 418
 				</dt>';
@@ -400,30 +426,34 @@  discard block
 block discarded – undo
400 426
 	// If the person looking is allowed, they can check the members IP address and hostname.
401 427
 	if ($context['can_see_ip'])
402 428
 	{
403
-		if (!empty($context['member']['ip']))
404
-		echo '
429
+		if (!empty($context['member']['ip'])) {
430
+				echo '
405 431
 				<dt>', $txt['ip'], ': </dt>
406 432
 				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
433
+		}
407 434
 
408
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
409
-			echo '
435
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
436
+					echo '
410 437
 				<dt>', $txt['hostname'], ': </dt>
411 438
 				<dd>', $context['member']['hostname'], '</dd>';
439
+		}
412 440
 	}
413 441
 
414 442
 	echo '
415 443
 				<dt>', $txt['local_time'], ':</dt>
416 444
 				<dd>', $context['member']['local_time'], '</dd>';
417 445
 
418
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
419
-		echo '
446
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
447
+			echo '
420 448
 				<dt>', $txt['language'], ':</dt>
421 449
 				<dd>', $context['member']['language'], '</dd>';
450
+	}
422 451
 
423
-	if ($context['member']['show_last_login'])
424
-		echo '
452
+	if ($context['member']['show_last_login']) {
453
+			echo '
425 454
 				<dt>', $txt['lastLoggedIn'], ': </dt>
426 455
 				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
456
+	}
427 457
 
428 458
 	echo '
429 459
 			</dl>';
@@ -432,42 +462,47 @@  discard block
 block discarded – undo
432 462
 	if (!empty($context['print_custom_fields']['above_signature']))
433 463
 	{
434 464
 		$fields = '';
435
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
436
-			if (!empty($field['output_html']))
465
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
466
+					if (!empty($field['output_html']))
437 467
 				$fields .= '
438 468
 					<li>' . $field['output_html'] . '</li>';
469
+		}
439 470
 
440
-		if (!empty($fields))
441
-			echo '
471
+		if (!empty($fields)) {
472
+					echo '
442 473
 			<div class="custom_fields_above_signature">
443 474
 				<ul class="nolist">', $fields, '
444 475
 				</ul>
445 476
 			</div>';
477
+		}
446 478
 	}
447 479
 
448 480
 	// Show the users signature.
449
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
450
-		echo '
481
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
482
+			echo '
451 483
 			<div class="signature">
452 484
 				<h5>', $txt['signature'], ':</h5>
453 485
 				', $context['member']['signature'], '
454 486
 			</div>';
487
+	}
455 488
 
456 489
 	// Are there any custom profile fields for below the signature?
457 490
 	if (!empty($context['print_custom_fields']['below_signature']))
458 491
 	{
459 492
 		$fields = '';
460
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
461
-			if (!empty($field['output_html']))
493
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
494
+					if (!empty($field['output_html']))
462 495
 				$fields .=  '
463 496
 					<li>' . $field['output_html'] . '</li>';
497
+		}
464 498
 
465
-		if (!empty($fields))
466
-			echo '
499
+		if (!empty($fields)) {
500
+					echo '
467 501
 			<div class="custom_fields_below_signature">
468 502
 				<ul class="nolist">', $fields, '
469 503
 				</ul>
470 504
 			</div>';
505
+		}
471 506
 	}
472 507
 
473 508
 	echo '
@@ -509,62 +544,70 @@  discard block
 block discarded – undo
509 544
 			</div>
510 545
 			<div class="list_posts">';
511 546
 
512
-			if (!$post['approved'])
513
-				echo '
547
+			if (!$post['approved']) {
548
+							echo '
514 549
 				<div class="approve_post">
515 550
 					<em>', $txt['post_awaiting_approval'], '</em>
516 551
 				</div>';
552
+			}
517 553
 
518 554
 			echo '
519 555
 				', $post['body'], '
520 556
 			</div>';
521 557
 
522
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
523
-				echo '
558
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
559
+							echo '
524 560
 			<div class="floatright">
525 561
 				<ul class="quickbuttons">';
562
+			}
526 563
 
527 564
 			// If they *can* reply?
528
-			if ($post['can_reply'])
529
-				echo '
565
+			if ($post['can_reply']) {
566
+							echo '
530 567
 					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
568
+			}
531 569
 
532 570
 			// If they *can* quote?
533
-			if ($post['can_quote'])
534
-				echo '
571
+			if ($post['can_quote']) {
572
+							echo '
535 573
 					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
574
+			}
536 575
 
537 576
 			// How about... even... remove it entirely?!
538
-			if ($post['can_delete'])
539
-				echo '
577
+			if ($post['can_delete']) {
578
+							echo '
540 579
 					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
580
+			}
541 581
 
542
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
543
-				echo '
582
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
583
+							echo '
544 584
 				</ul>
545 585
 			</div><!-- .floatright -->';
586
+			}
546 587
 
547 588
 			echo '
548 589
 		</div><!-- $post[css_class] -->';
549 590
 		}
591
+	} else {
592
+			template_show_list('attachments');
550 593
 	}
551
-	else
552
-		template_show_list('attachments');
553 594
 
554 595
 	// No posts? Just end with a informative message.
555
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
556
-		echo '
596
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
597
+			echo '
557 598
 		<div class="windowbg2">
558 599
 			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
559 600
 		</div>';
601
+	}
560 602
 
561 603
 	// Show more page numbers.
562
-	if (!empty($context['page_index']))
563
-		echo '
604
+	if (!empty($context['page_index'])) {
605
+			echo '
564 606
 		<div class="pagesection">
565 607
 			<div class="pagelinks">', $context['page_index'], '</div>
566 608
 		</div>';
567
-}
609
+	}
610
+	}
568 611
 
569 612
 /**
570 613
  * Template for showing alerts within the alerts popup
@@ -574,11 +617,12 @@  discard block
 block discarded – undo
574 617
 	global $context, $txt, $scripturl;
575 618
 
576 619
 	// Do we have an update message?
577
-	if (!empty($context['update_message']))
578
-		echo '
620
+	if (!empty($context['update_message'])) {
621
+			echo '
579 622
 		<div class="infobox">
580 623
 			', $context['update_message'], '
581 624
 		</div>';
625
+	}
582 626
 
583 627
 	echo '
584 628
 		<div class="cat_bar">
@@ -587,18 +631,18 @@  discard block
 block discarded – undo
587 631
 			</h3>
588 632
 		</div>';
589 633
 
590
-	if (empty($context['alerts']))
591
-		echo '
634
+	if (empty($context['alerts'])) {
635
+			echo '
592 636
 		<div class="information">
593 637
 			', $txt['alerts_none'], '
594 638
 		</div>';
595
-
596
-	else
639
+	} else
597 640
 	{
598 641
 		// Start the form if checkboxes are in use
599
-		if ($context['showCheckboxes'])
600
-			echo '
642
+		if ($context['showCheckboxes']) {
643
+					echo '
601 644
 		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">';
645
+		}
602 646
 
603 647
 		echo '
604 648
 			<table id="alerts" class="table_grid">';
@@ -614,9 +658,10 @@  discard block
 block discarded – undo
614 658
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
615 659
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>';
616 660
 
617
-					if ($context['showCheckboxes'])
618
-						echo '
661
+					if ($context['showCheckboxes']) {
662
+											echo '
619 663
 							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>';
664
+					}
620 665
 
621 666
 			echo '
622 667
 						</ul>
@@ -631,8 +676,8 @@  discard block
 block discarded – undo
631 676
 					', $context['pagination'], '
632 677
 				</div>';
633 678
 
634
-		if ($context['showCheckboxes'])
635
-			echo '
679
+		if ($context['showCheckboxes']) {
680
+					echo '
636 681
 				<div class="floatright">
637 682
 					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
638 683
 					<select name="mark_as">
@@ -643,14 +688,16 @@  discard block
 block discarded – undo
643 688
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
644 689
 					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
645 690
 				</div>';
691
+		}
646 692
 
647 693
 	echo '
648 694
 			</div>';
649 695
 
650
-	if ($context['showCheckboxes'])
651
-		echo '
696
+	if ($context['showCheckboxes']) {
697
+			echo '
652 698
 		</form>';
653 699
 	}
700
+	}
654 701
 }
655 702
 
656 703
 /**
@@ -671,12 +718,12 @@  discard block
 block discarded – undo
671 718
 		</div>' : '';
672 719
 
673 720
 	// No drafts? Just show an informative message.
674
-	if (empty($context['drafts']))
675
-		echo '
721
+	if (empty($context['drafts'])) {
722
+			echo '
676 723
 		<div class="windowbg2 centertext">
677 724
 			', $txt['draft_none'], '
678 725
 		</div>';
679
-	else
726
+	} else
680 727
 	{
681 728
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
682 729
 		foreach ($context['drafts'] as $draft)
@@ -688,13 +735,15 @@  discard block
 block discarded – undo
688 735
 				<h5>
689 736
 					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
690 737
 
691
-			if (!empty($draft['sticky']))
692
-				echo '
738
+			if (!empty($draft['sticky'])) {
739
+							echo '
693 740
 					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
741
+			}
694 742
 
695
-			if (!empty($draft['locked']))
696
-				echo '
743
+			if (!empty($draft['locked'])) {
744
+							echo '
697 745
 					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
746
+			}
698 747
 
699 748
 			echo '
700 749
 				</h5>
@@ -727,13 +776,13 @@  discard block
 block discarded – undo
727 776
 {
728 777
 	global $context, $scripturl, $txt;
729 778
 
730
-	if (!empty($context['saved_successful']))
731
-		echo '
779
+	if (!empty($context['saved_successful'])) {
780
+			echo '
732 781
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
733
-
734
-	elseif (!empty($context['saved_failed']))
735
-		echo '
782
+	} elseif (!empty($context['saved_failed'])) {
783
+			echo '
736 784
 	<div class="errorbox">', $context['saved_failed'], '</div>';
785
+	}
737 786
 
738 787
 	echo '
739 788
 	<div id="edit_buddies">
@@ -748,14 +797,16 @@  discard block
 block discarded – undo
748 797
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
749 798
 					<th scope="col">', $txt['status'], '</th>';
750 799
 
751
-	if (allowedTo('moderate_forum'))
752
-		echo '
800
+	if (allowedTo('moderate_forum')) {
801
+			echo '
753 802
 					<th scope="col">', $txt['email'], '</th>';
803
+	}
754 804
 
755
-	if (!empty($context['custom_pf']))
756
-		foreach ($context['custom_pf'] as $column)
805
+	if (!empty($context['custom_pf'])) {
806
+			foreach ($context['custom_pf'] as $column)
757 807
 				echo '
758 808
 					<th scope="col">', $column['label'], '</th>';
809
+	}
759 810
 
760 811
 	echo '
761 812
 					<th scope="col">', $txt['remove'], '</th>
@@ -764,13 +815,14 @@  discard block
 block discarded – undo
764 815
 			<tbody>';
765 816
 
766 817
 	// If they don't have any buddies don't list them!
767
-	if (empty($context['buddies']))
768
-		echo '
818
+	if (empty($context['buddies'])) {
819
+			echo '
769 820
 				<tr class="windowbg">
770 821
 					<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '">
771 822
 						<strong>', $txt['no_buddies'], '</strong>
772 823
 					</td>
773 824
 				</tr>';
825
+	}
774 826
 
775 827
 		// Now loop through each buddy showing info on each.
776 828
 	else
@@ -784,17 +836,19 @@  discard block
 block discarded – undo
784 836
 						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
785 837
 					</td>';
786 838
 
787
-			if ($buddy['show_email'])
788
-				echo '
839
+			if ($buddy['show_email']) {
840
+							echo '
789 841
 					<td>
790 842
 						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
791 843
 					</td>';
844
+			}
792 845
 
793 846
 			// Show the custom profile fields for this user.
794
-			if (!empty($context['custom_pf']))
795
-				foreach ($context['custom_pf'] as $key => $column)
847
+			if (!empty($context['custom_pf'])) {
848
+							foreach ($context['custom_pf'] as $key => $column)
796 849
 					echo '
797 850
 					<td class="lefttext">', $buddy['options'][$key], '</td>';
851
+			}
798 852
 
799 853
 			echo '
800 854
 					<td>
@@ -827,9 +881,10 @@  discard block
 block discarded – undo
827 881
 			</dl>
828 882
 		</div>';
829 883
 
830
-	if (!empty($context['token_check']))
831
-		echo '
884
+	if (!empty($context['token_check'])) {
885
+			echo '
832 886
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
887
+	}
833 888
 
834 889
 	echo '
835 890
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -855,13 +910,13 @@  discard block
 block discarded – undo
855 910
 {
856 911
 	global $context, $scripturl, $txt;
857 912
 
858
-	if (!empty($context['saved_successful']))
859
-		echo '
913
+	if (!empty($context['saved_successful'])) {
914
+			echo '
860 915
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
861
-
862
-	elseif (!empty($context['saved_failed']))
863
-		echo '
916
+	} elseif (!empty($context['saved_failed'])) {
917
+			echo '
864 918
 	<div class="errorbox">', $context['saved_failed'], '</div>';
919
+	}
865 920
 
866 921
 	echo '
867 922
 	<div id="edit_buddies">
@@ -876,9 +931,10 @@  discard block
 block discarded – undo
876 931
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
877 932
 					<th scope="col">', $txt['status'], '</th>';
878 933
 
879
-	if (allowedTo('moderate_forum'))
880
-		echo '
934
+	if (allowedTo('moderate_forum')) {
935
+			echo '
881 936
 					<th scope="col">', $txt['email'], '</th>';
937
+	}
882 938
 
883 939
 	echo '
884 940
 					<th scope="col">', $txt['ignore_remove'], '</th>
@@ -887,13 +943,14 @@  discard block
 block discarded – undo
887 943
 			<tbody>';
888 944
 
889 945
 	// If they don't have anyone on their ignore list, don't list it!
890
-	if (empty($context['ignore_list']))
891
-		echo '
946
+	if (empty($context['ignore_list'])) {
947
+			echo '
892 948
 				<tr class="windowbg">
893 949
 					<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '">
894 950
 						<strong>', $txt['no_ignore'], '</strong>
895 951
 					</td>
896 952
 				</tr>';
953
+	}
897 954
 
898 955
 	// Now loop through each buddy showing info on each.
899 956
 	foreach ($context['ignore_list'] as $member)
@@ -905,11 +962,12 @@  discard block
 block discarded – undo
905 962
 						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
906 963
 					</td>';
907 964
 
908
-		if ($member['show_email'])
909
-			echo '
965
+		if ($member['show_email']) {
966
+					echo '
910 967
 					<td>
911 968
 						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
912 969
 					</td>';
970
+		}
913 971
 		echo '
914 972
 					<td>
915 973
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
@@ -939,9 +997,10 @@  discard block
 block discarded – undo
939 997
 			</dl>
940 998
 		</div>';
941 999
 
942
-	if (!empty($context['token_check']))
943
-		echo '
1000
+	if (!empty($context['token_check'])) {
1001
+			echo '
944 1002
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1003
+	}
945 1004
 
946 1005
 	echo '
947 1006
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -987,9 +1046,10 @@  discard block
 block discarded – undo
987 1046
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
988 1047
 
989 1048
 	// Second address detected?
990
-	if (!empty($context['last_ip2']))
991
-		echo '
1049
+	if (!empty($context['last_ip2'])) {
1050
+			echo '
992 1051
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
1052
+	}
993 1053
 
994 1054
 	echo '
995 1055
 				</dd>';
@@ -1055,9 +1115,10 @@  discard block
 block discarded – undo
1055 1115
 		</div>
1056 1116
 		<div class="windowbg2 noup">';
1057 1117
 
1058
-		foreach ($context['whois_servers'] as $server)
1059
-			echo '
1118
+		foreach ($context['whois_servers'] as $server) {
1119
+					echo '
1060 1120
 			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1121
+		}
1061 1122
 		echo '
1062 1123
 		</div>
1063 1124
 		<br>';
@@ -1069,13 +1130,12 @@  discard block
 block discarded – undo
1069 1130
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1070 1131
 		</div>';
1071 1132
 
1072
-	if (empty($context['ips']))
1073
-		echo '
1133
+	if (empty($context['ips'])) {
1134
+			echo '
1074 1135
 		<p class="windowbg2 description">
1075 1136
 			<em>', $txt['no_members_from_ip'], '</em>
1076 1137
 		</p>';
1077
-
1078
-	else
1138
+	} else
1079 1139
 	{
1080 1140
 		echo '
1081 1141
 		<table class="table_grid">
@@ -1088,12 +1148,13 @@  discard block
 block discarded – undo
1088 1148
 			<tbody>';
1089 1149
 
1090 1150
 		// Loop through each of the members and display them.
1091
-		foreach ($context['ips'] as $ip => $memberlist)
1092
-			echo '
1151
+		foreach ($context['ips'] as $ip => $memberlist) {
1152
+					echo '
1093 1153
 				<tr class="windowbg">
1094 1154
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1095 1155
 					<td>', implode(', ', $memberlist), '</td>
1096 1156
 				</tr>';
1157
+		}
1097 1158
 
1098 1159
 		echo '
1099 1160
 			</tbody>
@@ -1135,11 +1196,10 @@  discard block
 block discarded – undo
1135 1196
 			</h3>
1136 1197
 		</div>';
1137 1198
 
1138
-	if ($context['member']['has_all_permissions'])
1139
-		echo '
1199
+	if ($context['member']['has_all_permissions']) {
1200
+			echo '
1140 1201
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1141
-
1142
-	else
1202
+	} else
1143 1203
 	{
1144 1204
 		echo '
1145 1205
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1154,9 +1214,10 @@  discard block
 block discarded – undo
1154 1214
 			<div class="windowbg smalltext">
1155 1215
 				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1156 1216
 
1157
-			foreach ($context['no_access_boards'] as $no_access_board)
1158
-				echo '
1217
+			foreach ($context['no_access_boards'] as $no_access_board) {
1218
+							echo '
1159 1219
 				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1220
+			}
1160 1221
 			echo '
1161 1222
 			</div>';
1162 1223
 		}
@@ -1188,12 +1249,13 @@  discard block
 block discarded – undo
1188 1249
 							</td>
1189 1250
 							<td class="smalltext">';
1190 1251
 
1191
-				if ($permission['is_denied'])
1192
-					echo '
1252
+				if ($permission['is_denied']) {
1253
+									echo '
1193 1254
 								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1194
-				else
1195
-					echo '
1255
+				} else {
1256
+									echo '
1196 1257
 								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1258
+				}
1197 1259
 
1198 1260
 				echo '
1199 1261
 							</td>
@@ -1204,10 +1266,10 @@  discard block
 block discarded – undo
1204 1266
 				</table>
1205 1267
 			</div><!-- .tborder -->
1206 1268
 			<br>';
1207
-		}
1208
-		else
1209
-			echo '
1269
+		} else {
1270
+					echo '
1210 1271
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1272
+		}
1211 1273
 
1212 1274
 		// Board permission section.
1213 1275
 		echo '
@@ -1218,14 +1280,16 @@  discard block
 block discarded – undo
1218 1280
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1219 1281
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1220 1282
 
1221
-		if (!empty($context['boards']))
1222
-			echo '
1283
+		if (!empty($context['boards'])) {
1284
+					echo '
1223 1285
 							<option value="" disabled>---------------------------</option>';
1286
+		}
1224 1287
 
1225 1288
 		// Fill the box with any local permission boards.
1226
-		foreach ($context['boards'] as $board)
1227
-			echo '
1289
+		foreach ($context['boards'] as $board) {
1290
+					echo '
1228 1291
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1292
+		}
1229 1293
 
1230 1294
 		echo '
1231 1295
 						</select>
@@ -1254,13 +1318,13 @@  discard block
 block discarded – undo
1254 1318
 						</td>
1255 1319
 						<td class="smalltext">';
1256 1320
 
1257
-				if ($permission['is_denied'])
1258
-					echo '
1321
+				if ($permission['is_denied']) {
1322
+									echo '
1259 1323
 							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1260
-
1261
-				else
1262
-					echo '
1324
+				} else {
1325
+									echo '
1263 1326
 							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1327
+				}
1264 1328
 
1265 1329
 				echo '
1266 1330
 						</td>
@@ -1269,10 +1333,10 @@  discard block
 block discarded – undo
1269 1333
 			echo '
1270 1334
 				</tbody>
1271 1335
 			</table>';
1272
-		}
1273
-		else
1274
-			echo '
1336
+		} else {
1337
+					echo '
1275 1338
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1339
+		}
1276 1340
 	echo '
1277 1341
 		</div><!-- #permissions -->';
1278 1342
 	}
@@ -1313,9 +1377,10 @@  discard block
 block discarded – undo
1313 1377
 			</div>';
1314 1378
 
1315 1379
 	// If they haven't post at all, don't draw the graph.
1316
-	if (empty($context['posts_by_time']))
1317
-		echo '
1380
+	if (empty($context['posts_by_time'])) {
1381
+			echo '
1318 1382
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1383
+	}
1319 1384
 
1320 1385
 	// Otherwise do!
1321 1386
 	else
@@ -1324,8 +1389,8 @@  discard block
 block discarded – undo
1324 1389
 			<ul class="activity_stats flow_hidden">';
1325 1390
 
1326 1391
 		// The labels.
1327
-		foreach ($context['posts_by_time'] as $time_of_day)
1328
-			echo '
1392
+		foreach ($context['posts_by_time'] as $time_of_day) {
1393
+					echo '
1329 1394
 				<li', $time_of_day['is_last'] ? ' class="last"' : '', '>
1330 1395
 					<div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '">
1331 1396
 						<div style="height: ', (int) $time_of_day['relative_percent'], 'px;">
@@ -1334,6 +1399,7 @@  discard block
 block discarded – undo
1334 1399
 					</div>
1335 1400
 					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1336 1401
 				</li>';
1402
+		}
1337 1403
 
1338 1404
 		echo '
1339 1405
 			</ul>';
@@ -1352,11 +1418,10 @@  discard block
 block discarded – undo
1352 1418
 					</h3>
1353 1419
 				</div>';
1354 1420
 
1355
-	if (empty($context['popular_boards']))
1356
-		echo '
1421
+	if (empty($context['popular_boards'])) {
1422
+			echo '
1357 1423
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1358
-
1359
-	else
1424
+	} else
1360 1425
 	{
1361 1426
 		echo '
1362 1427
 				<dl class="stats">';
@@ -1386,10 +1451,10 @@  discard block
 block discarded – undo
1386 1451
 					</h3>
1387 1452
 				</div>';
1388 1453
 
1389
-	if (empty($context['board_activity']))
1390
-		echo '
1454
+	if (empty($context['board_activity'])) {
1455
+			echo '
1391 1456
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1392
-	else
1457
+	} else
1393 1458
 	{
1394 1459
 		echo '
1395 1460
 				<dl class="stats">';
@@ -1440,90 +1505,97 @@  discard block
 block discarded – undo
1440 1505
 				<h3 class="catbg profile_hd">';
1441 1506
 
1442 1507
 		// Don't say "Profile" if this isn't the profile...
1443
-		if (!empty($context['profile_header_text']))
1444
-			echo '
1508
+		if (!empty($context['profile_header_text'])) {
1509
+					echo '
1445 1510
 					', $context['profile_header_text'];
1446
-		else
1447
-			echo '
1511
+		} else {
1512
+					echo '
1448 1513
 					', $txt['profile'];
1514
+		}
1449 1515
 
1450 1516
 		echo '
1451 1517
 				</h3>
1452 1518
 			</div>';
1453 1519
 
1454 1520
 	// Have we some description?
1455
-	if ($context['page_desc'])
1456
-		echo '
1521
+	if ($context['page_desc']) {
1522
+			echo '
1457 1523
 			<p class="information">', $context['page_desc'], '</p>';
1524
+	}
1458 1525
 
1459 1526
 	echo '
1460 1527
 			<div class="roundframe">';
1461 1528
 
1462 1529
 	// Any bits at the start?
1463
-	if (!empty($context['profile_prehtml']))
1464
-		echo '
1530
+	if (!empty($context['profile_prehtml'])) {
1531
+			echo '
1465 1532
 				<div>', $context['profile_prehtml'], '</div>';
1533
+	}
1466 1534
 
1467
-	if (!empty($context['profile_fields']))
1468
-		echo '
1535
+	if (!empty($context['profile_fields'])) {
1536
+			echo '
1469 1537
 				<dl class="settings">';
1538
+	}
1470 1539
 
1471 1540
 	// Start the big old loop 'of love.
1472 1541
 	$lastItem = 'hr';
1473 1542
 	foreach ($context['profile_fields'] as $key => $field)
1474 1543
 	{
1475 1544
 		// We add a little hack to be sure we never get more than one hr in a row!
1476
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1477
-			continue;
1545
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1546
+					continue;
1547
+		}
1478 1548
 
1479 1549
 		$lastItem = $field['type'];
1480
-		if ($field['type'] == 'hr')
1481
-			echo '
1550
+		if ($field['type'] == 'hr') {
1551
+					echo '
1482 1552
 				</dl>
1483 1553
 				<hr>
1484 1554
 				<dl class="settings">';
1485
-
1486
-		elseif ($field['type'] == 'callback')
1555
+		} elseif ($field['type'] == 'callback')
1487 1556
 		{
1488 1557
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1489 1558
 			{
1490 1559
 				$callback_func = 'template_profile_' . $field['callback_func'];
1491 1560
 				$callback_func();
1492 1561
 			}
1493
-		}
1494
-		else
1562
+		} else
1495 1563
 		{
1496 1564
 			echo '
1497 1565
 					<dt>
1498 1566
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1499 1567
 
1500 1568
 			// Does it have any subtext to show?
1501
-			if (!empty($field['subtext']))
1502
-				echo '
1569
+			if (!empty($field['subtext'])) {
1570
+							echo '
1503 1571
 						<br>
1504 1572
 						<span class="smalltext">', $field['subtext'], '</span>';
1573
+			}
1505 1574
 
1506 1575
 			echo '
1507 1576
 					</dt>
1508 1577
 					<dd>';
1509 1578
 
1510 1579
 			// Want to put something infront of the box?
1511
-			if (!empty($field['preinput']))
1512
-				echo '
1580
+			if (!empty($field['preinput'])) {
1581
+							echo '
1513 1582
 						', $field['preinput'];
1583
+			}
1514 1584
 
1515 1585
 			// What type of data are we showing?
1516
-			if ($field['type'] == 'label')
1517
-				echo '
1586
+			if ($field['type'] == 'label') {
1587
+							echo '
1518 1588
 						', $field['value'];
1589
+			}
1519 1590
 
1520 1591
 			// Maybe it's a text box - very likely!
1521 1592
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1522 1593
 			{
1523
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1524
-					$type = 'number';
1525
-				else
1526
-					$type = $field['type'];
1594
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1595
+									$type = 'number';
1596
+				} else {
1597
+									$type = $field['type'];
1598
+				}
1527 1599
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1528 1600
 
1529 1601
 
@@ -1531,10 +1603,11 @@  discard block
 block discarded – undo
1531 1603
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1532 1604
 			}
1533 1605
 			// You "checking" me out? ;)
1534
-			elseif ($field['type'] == 'check')
1535
-				echo '
1606
+			elseif ($field['type'] == 'check') {
1607
+							echo '
1536 1608
 						<input type="hidden" name="', $key, '" value="0">
1537 1609
 						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1610
+			}
1538 1611
 
1539 1612
 			// Always fun - select boxes!
1540 1613
 			elseif ($field['type'] == 'select')
@@ -1545,14 +1618,16 @@  discard block
 block discarded – undo
1545 1618
 				if (isset($field['options']))
1546 1619
 				{
1547 1620
 					// Is this some code to generate the options?
1548
-					if (!is_array($field['options']))
1549
-						$field['options'] = $field['options']();
1621
+					if (!is_array($field['options'])) {
1622
+											$field['options'] = $field['options']();
1623
+					}
1550 1624
 
1551 1625
 					// Assuming we now have some!
1552
-					if (is_array($field['options']))
1553
-						foreach ($field['options'] as $value => $name)
1626
+					if (is_array($field['options'])) {
1627
+											foreach ($field['options'] as $value => $name)
1554 1628
 							echo '
1555 1629
 							<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
1630
+					}
1556 1631
 				}
1557 1632
 
1558 1633
 				echo '
@@ -1560,31 +1635,34 @@  discard block
 block discarded – undo
1560 1635
 			}
1561 1636
 
1562 1637
 			// Something to end with?
1563
-			if (!empty($field['postinput']))
1564
-				echo '
1638
+			if (!empty($field['postinput'])) {
1639
+							echo '
1565 1640
 						', $field['postinput'];
1641
+			}
1566 1642
 
1567 1643
 			echo '
1568 1644
 					</dd>';
1569 1645
 		}
1570 1646
 	}
1571 1647
 
1572
-	if (!empty($context['profile_fields']))
1573
-		echo '
1648
+	if (!empty($context['profile_fields'])) {
1649
+			echo '
1574 1650
 				</dl>';
1651
+	}
1575 1652
 
1576 1653
 	// Are there any custom profile fields - if so print them!
1577 1654
 	if (!empty($context['custom_fields']))
1578 1655
 	{
1579
-		if ($lastItem != 'hr')
1580
-			echo '
1656
+		if ($lastItem != 'hr') {
1657
+					echo '
1581 1658
 				<hr>';
1659
+		}
1582 1660
 
1583 1661
 		echo '
1584 1662
 				<dl class="settings">';
1585 1663
 
1586
-		foreach ($context['custom_fields'] as $field)
1587
-			echo '
1664
+		foreach ($context['custom_fields'] as $field) {
1665
+					echo '
1588 1666
 					<dt>
1589 1667
 						<strong>', $field['name'], ': </strong><br>
1590 1668
 						<span class="smalltext">', $field['desc'], '</span>
@@ -1592,19 +1670,21 @@  discard block
 block discarded – undo
1592 1670
 					<dd>
1593 1671
 						', $field['input_html'], '
1594 1672
 					</dd>';
1673
+		}
1595 1674
 
1596 1675
 		echo '
1597 1676
 				</dl>';
1598 1677
 	}
1599 1678
 
1600 1679
 	// Any closing HTML?
1601
-	if (!empty($context['profile_posthtml']))
1602
-		echo '
1680
+	if (!empty($context['profile_posthtml'])) {
1681
+			echo '
1603 1682
 				<div>', $context['profile_posthtml'], '</div>';
1683
+	}
1604 1684
 
1605 1685
 	// Only show the password box if it's actually needed.
1606
-	if ($context['require_password'])
1607
-		echo '
1686
+	if ($context['require_password']) {
1687
+			echo '
1608 1688
 				<dl class="settings">
1609 1689
 					<dt>
1610 1690
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1614,18 +1694,21 @@  discard block
 block discarded – undo
1614 1694
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1615 1695
 					</dd>
1616 1696
 				</dl>';
1697
+	}
1617 1698
 
1618 1699
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1619
-	if (!empty($context['submit_button_text']))
1620
-		echo '
1700
+	if (!empty($context['submit_button_text'])) {
1701
+			echo '
1621 1702
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1622
-	else
1623
-		echo '
1703
+	} else {
1704
+			echo '
1624 1705
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1706
+	}
1625 1707
 
1626
-	if (!empty($context['token_check']))
1627
-		echo '
1708
+	if (!empty($context['token_check'])) {
1709
+			echo '
1628 1710
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1711
+	}
1629 1712
 
1630 1713
 	echo '
1631 1714
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1635,10 +1718,11 @@  discard block
 block discarded – undo
1635 1718
 		</form>';
1636 1719
 
1637 1720
 	// Any final spellchecking stuff?
1638
-	if (!empty($context['show_spellchecking']))
1639
-		echo '
1721
+	if (!empty($context['show_spellchecking'])) {
1722
+			echo '
1640 1723
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1641
-}
1724
+	}
1725
+	}
1642 1726
 
1643 1727
 /**
1644 1728
  * Personal Message settings.
@@ -1675,10 +1759,11 @@  discard block
 block discarded – undo
1675 1759
 						<select name="pm_receive_from" id="pm_receive_from">
1676 1760
 							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1677 1761
 
1678
-	if (!empty($modSettings['enable_buddylist']))
1679
-		echo '
1762
+	if (!empty($modSettings['enable_buddylist'])) {
1763
+			echo '
1680 1764
 							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1681 1765
 							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1766
+	}
1682 1767
 
1683 1768
 	echo '
1684 1769
 							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1721,11 +1806,12 @@  discard block
 block discarded – undo
1721 1806
 		if (empty($setting) || !is_array($setting))
1722 1807
 		{
1723 1808
 			// Insert a separator (unless this is the first item in the list)
1724
-			if ($i !== $first_option_key)
1725
-				echo '
1809
+			if ($i !== $first_option_key) {
1810
+							echo '
1726 1811
 				</dl>
1727 1812
 				<hr>
1728 1813
 				<dl class="settings">';
1814
+			}
1729 1815
 
1730 1816
 			// Should we give a name to this section?
1731 1817
 			if (is_string($setting) && !empty($setting))
@@ -1734,69 +1820,67 @@  discard block
 block discarded – undo
1734 1820
 				echo '
1735 1821
 					<dt><strong>' . $setting . '</strong></dt>
1736 1822
 					<dd></dd>';
1823
+			} else {
1824
+							$titled_section = false;
1737 1825
 			}
1738
-			else
1739
-				$titled_section = false;
1740 1826
 
1741 1827
 			continue;
1742 1828
 		}
1743 1829
 
1744 1830
 		// Is this disabled?
1745
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1746
-			continue;
1747
-
1748
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1749
-			continue;
1750
-
1751
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1752
-			continue;
1753
-
1754
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1755
-			continue;
1756
-
1757
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1758
-			continue;
1759
-
1760
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1761
-			continue;
1762
-
1763
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1764
-			continue;
1831
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1832
+					continue;
1833
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1834
+					continue;
1835
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1836
+					continue;
1837
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1838
+					continue;
1839
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1840
+					continue;
1841
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1842
+					continue;
1843
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1844
+					continue;
1845
+		}
1765 1846
 
1766 1847
 		// Some of these may not be set...  Set to defaults here
1767 1848
 		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1768
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1769
-			$context['member']['options'][$setting['id']] = 0;
1770
-
1771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1772
-			$setting['type'] = 'checkbox';
1773
-
1774
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1775
-			$setting['type'] = 'number';
1849
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1850
+					$context['member']['options'][$setting['id']] = 0;
1851
+		}
1776 1852
 
1777
-		elseif ($setting['type'] == 'string')
1778
-			$setting['type'] = 'text';
1853
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1854
+					$setting['type'] = 'checkbox';
1855
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1856
+					$setting['type'] = 'number';
1857
+		} elseif ($setting['type'] == 'string') {
1858
+					$setting['type'] = 'text';
1859
+		}
1779 1860
 
1780
-		if (isset($setting['options']))
1781
-			$setting['type'] = 'list';
1861
+		if (isset($setting['options'])) {
1862
+					$setting['type'] = 'list';
1863
+		}
1782 1864
 
1783 1865
 		echo '
1784 1866
 					<dt>
1785 1867
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1786 1868
 
1787
-		if (isset($setting['description']))
1788
-			echo '
1869
+		if (isset($setting['description'])) {
1870
+					echo '
1789 1871
 						<br>
1790 1872
 						<span class="smalltext">', $setting['description'], '</span>';
1873
+		}
1791 1874
 		echo '
1792 1875
 					</dt>
1793 1876
 					<dd>';
1794 1877
 
1795 1878
 		// Display checkbox options
1796
-		if ($setting['type'] == 'checkbox')
1797
-			echo '
1879
+		if ($setting['type'] == 'checkbox') {
1880
+					echo '
1798 1881
 						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1799 1882
 						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1883
+		}
1800 1884
 
1801 1885
 		// How about selection lists, we all love them
1802 1886
 		elseif ($setting['type'] == 'list')
@@ -1804,9 +1888,10 @@  discard block
 block discarded – undo
1804 1888
 			echo '
1805 1889
 						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1806 1890
 
1807
-			foreach ($setting['options'] as $value => $label)
1808
-				echo '
1891
+			foreach ($setting['options'] as $value => $label) {
1892
+							echo '
1809 1893
 							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1894
+			}
1810 1895
 
1811 1896
 			echo '
1812 1897
 						</select>';
@@ -1822,14 +1907,13 @@  discard block
 block discarded – undo
1822 1907
 
1823 1908
 				echo '
1824 1909
 						<input type="number"', $min . $max . $step;
1825
-			}
1826
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
1827
-				echo'
1910
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
1911
+							echo'
1828 1912
 						<input type="url"';
1829
-
1830
-			else
1831
-				echo '
1913
+			} else {
1914
+							echo '
1832 1915
 						<input type="text"';
1916
+			}
1833 1917
 
1834 1918
 			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1835 1919
 		}
@@ -1866,8 +1950,8 @@  discard block
 block discarded – undo
1866 1950
 				<dl class="settings">';
1867 1951
 
1868 1952
 	// Allow notification on announcements to be disabled?
1869
-	if (!empty($modSettings['allow_disableAnnounce']))
1870
-		echo '
1953
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1954
+			echo '
1871 1955
 					<dt>
1872 1956
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1873 1957
 					</dt>
@@ -1875,15 +1959,17 @@  discard block
 block discarded – undo
1875 1959
 						<input type="hidden" name="notify_announcements" value="0">
1876 1960
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1877 1961
 					</dd>';
1962
+	}
1878 1963
 
1879
-	if (!empty($modSettings['enable_ajax_alerts']))
1880
-		echo '
1964
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1965
+			echo '
1881 1966
 					<dt>
1882 1967
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1883 1968
 					</dt>
1884 1969
 					<dd>
1885 1970
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1886 1971
 					</dd>';
1972
+	}
1887 1973
 
1888 1974
 	echo '
1889 1975
 				</dl>
@@ -1915,9 +2001,10 @@  discard block
 block discarded – undo
1915 2001
 
1916 2002
 				$label = $txt['alert_opt_' . $opts[1]];
1917 2003
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1918
-				if ($label_pos == 'before')
1919
-					echo '
2004
+				if ($label_pos == 'before') {
2005
+									echo '
1920 2006
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2007
+				}
1921 2008
 
1922 2009
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1923 2010
 				switch ($opts[0])
@@ -1931,17 +2018,19 @@  discard block
 block discarded – undo
1931 2018
 						echo '
1932 2019
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1933 2020
 
1934
-						foreach ($opts['opts'] as $k => $v)
1935
-							echo '
2021
+						foreach ($opts['opts'] as $k => $v) {
2022
+													echo '
1936 2023
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
2024
+						}
1937 2025
 						echo '
1938 2026
 						</select>';
1939 2027
 						break;
1940 2028
 				}
1941 2029
 
1942
-				if ($label_pos == 'after')
1943
-					echo '
2030
+				if ($label_pos == 'after') {
2031
+									echo '
1944 2032
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2033
+				}
1945 2034
 
1946 2035
 				echo '
1947 2036
 					</td>
@@ -2058,11 +2147,12 @@  discard block
 block discarded – undo
2058 2147
 			<p class="information">', $txt['groupMembership_info'], '</p>';
2059 2148
 
2060 2149
 	// Do we have an update message?
2061
-	if (!empty($context['update_message']))
2062
-		echo '
2150
+	if (!empty($context['update_message'])) {
2151
+			echo '
2063 2152
 			<div class="infobox">
2064 2153
 				', $context['update_message'], '.
2065 2154
 			</div>';
2155
+	}
2066 2156
 
2067 2157
 	echo '
2068 2158
 			<div id="groups">';
@@ -2084,8 +2174,7 @@  discard block
 block discarded – undo
2084 2174
 						</div>
2085 2175
 					</div>
2086 2176
 				</div><!-- .groupmembership -->';
2087
-	}
2088
-	else
2177
+	} else
2089 2178
 	{
2090 2179
 		echo '
2091 2180
 				<div class="title_bar">
@@ -2097,27 +2186,30 @@  discard block
 block discarded – undo
2097 2186
 			echo '
2098 2187
 				<div class="windowbg" id="primdiv_', $group['id'], '">';
2099 2188
 
2100
-				if ($context['can_edit_primary'])
2101
-					echo '
2189
+				if ($context['can_edit_primary']) {
2190
+									echo '
2102 2191
 					<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2192
+				}
2103 2193
 
2104 2194
 				echo '
2105 2195
 					<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2106 2196
 
2107 2197
 				// Can they leave their group?
2108
-				if ($group['can_leave'])
2109
-					echo '
2198
+				if ($group['can_leave']) {
2199
+									echo '
2110 2200
 					<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2201
+				}
2111 2202
 
2112 2203
 				echo '
2113 2204
 				</div><!-- .windowbg -->';
2114 2205
 		}
2115 2206
 
2116
-		if ($context['can_edit_primary'])
2117
-			echo '
2207
+		if ($context['can_edit_primary']) {
2208
+					echo '
2118 2209
 				<div class="padding righttext">
2119 2210
 					<input type="submit" value="', $txt['make_primary'], '" class="button">
2120 2211
 				</div>';
2212
+		}
2121 2213
 
2122 2214
 		// Any groups they can join?
2123 2215
 		if (!empty($context['groups']['available']))
@@ -2133,17 +2225,16 @@  discard block
 block discarded – undo
2133 2225
 				<div class="windowbg">
2134 2226
 					<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2135 2227
 
2136
-				if ($group['type'] == 3)
2137
-					echo '
2228
+				if ($group['type'] == 3) {
2229
+									echo '
2138 2230
 					<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2139
-
2140
-				elseif ($group['type'] == 2 && $group['pending'])
2141
-					echo '
2231
+				} elseif ($group['type'] == 2 && $group['pending']) {
2232
+									echo '
2142 2233
 					<span class="floatright">', $txt['approval_pending'], '</span>';
2143
-
2144
-				elseif ($group['type'] == 2)
2145
-					echo '
2234
+				} elseif ($group['type'] == 2) {
2235
+									echo '
2146 2236
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2237
+				}
2147 2238
 
2148 2239
 				echo '
2149 2240
 				</div><!-- .windowbg -->';
@@ -2166,9 +2257,10 @@  discard block
 block discarded – undo
2166 2257
 
2167 2258
 						prevDiv.className = "windowbg";
2168 2259
 					}';
2169
-		if (isset($context['groups']['member'][$context['primary_group']]))
2170
-			echo '
2260
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2261
+					echo '
2171 2262
 					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2263
+		}
2172 2264
 
2173 2265
 		echo '
2174 2266
 				</script>';
@@ -2177,9 +2269,10 @@  discard block
 block discarded – undo
2177 2269
 	echo '
2178 2270
 			</div><!-- #groups -->';
2179 2271
 
2180
-	if (!empty($context['token_check']))
2181
-		echo '
2272
+	if (!empty($context['token_check'])) {
2273
+			echo '
2182 2274
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2275
+	}
2183 2276
 
2184 2277
 	echo '
2185 2278
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2227,14 +2320,15 @@  discard block
 block discarded – undo
2227 2320
 
2228 2321
 		foreach ($category['boards'] as $board)
2229 2322
 		{
2230
-			if ($i == $limit)
2231
-				echo '
2323
+			if ($i == $limit) {
2324
+							echo '
2232 2325
 						</ul>
2233 2326
 					</li>
2234 2327
 				</ul>
2235 2328
 				<ul class="ignoreboards floatright">
2236 2329
 					<li class="category">
2237 2330
 						<ul>';
2331
+			}
2238 2332
 
2239 2333
 			echo '
2240 2334
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2280,10 +2374,11 @@  discard block
 block discarded – undo
2280 2374
 
2281 2375
 	// Work out the starting color.
2282 2376
 	$context['current_color'] = $context['colors'][0];
2283
-	foreach ($context['colors'] as $limit => $color)
2284
-		if ($context['member']['warning'] >= $limit)
2377
+	foreach ($context['colors'] as $limit => $color) {
2378
+			if ($context['member']['warning'] >= $limit)
2285 2379
 			$context['current_color'] = $color;
2286
-}
2380
+	}
2381
+	}
2287 2382
 
2288 2383
 // Show all warnings of a user?
2289 2384
 function template_viewWarning()
@@ -2322,14 +2417,15 @@  discard block
 block discarded – undo
2322 2417
 				</dd>';
2323 2418
 
2324 2419
 	// There's some impact of this?
2325
-	if (!empty($context['level_effects'][$context['current_level']]))
2326
-		echo '
2420
+	if (!empty($context['level_effects'][$context['current_level']])) {
2421
+			echo '
2327 2422
 				<dt>
2328 2423
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2329 2424
 				</dt>
2330 2425
 				<dd>
2331 2426
 					', $context['level_effects'][$context['current_level']], '
2332 2427
 				</dd>';
2428
+	}
2333 2429
 
2334 2430
 	echo '
2335 2431
 			</dl>
@@ -2367,10 +2463,11 @@  discard block
 block discarded – undo
2367 2463
 
2368 2464
 			// Otherwise see what we can do...';
2369 2465
 
2370
-	foreach ($context['notification_templates'] as $k => $type)
2371
-		echo '
2466
+	foreach ($context['notification_templates'] as $k => $type) {
2467
+			echo '
2372 2468
 			if (index == ', $k, ')
2373 2469
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2470
+	}
2374 2471
 
2375 2472
 	echo '
2376 2473
 		}
@@ -2380,10 +2477,11 @@  discard block
 block discarded – undo
2380 2477
 			// Also set the right effect.
2381 2478
 			effectText = "";';
2382 2479
 
2383
-	foreach ($context['level_effects'] as $limit => $text)
2384
-		echo '
2480
+	foreach ($context['level_effects'] as $limit => $text) {
2481
+			echo '
2385 2482
 			if (slideAmount >= ', $limit, ')
2386 2483
 				effectText = "', $text, '";';
2484
+	}
2387 2485
 
2388 2486
 	echo '
2389 2487
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2398,32 +2496,35 @@  discard block
 block discarded – undo
2398 2496
 			</h3>
2399 2497
 		</div>';
2400 2498
 
2401
-	if (!$context['user']['is_owner'])
2402
-		echo '
2499
+	if (!$context['user']['is_owner']) {
2500
+			echo '
2403 2501
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2502
+	}
2404 2503
 
2405 2504
 	echo '
2406 2505
 		<div class="windowbg">
2407 2506
 			<dl class="settings">';
2408 2507
 
2409
-	if (!$context['user']['is_owner'])
2410
-		echo '
2508
+	if (!$context['user']['is_owner']) {
2509
+			echo '
2411 2510
 				<dt>
2412 2511
 					<strong>', $txt['profile_warning_name'], ':</strong>
2413 2512
 				</dt>
2414 2513
 				<dd>
2415 2514
 					<strong>', $context['member']['name'], '</strong>
2416 2515
 				</dd>';
2516
+	}
2417 2517
 
2418 2518
 	echo '
2419 2519
 				<dt>
2420 2520
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2421 2521
 
2422 2522
 	// Is there only so much they can apply?
2423
-	if ($context['warning_limit'])
2424
-		echo '
2523
+	if ($context['warning_limit']) {
2524
+			echo '
2425 2525
 					<br>
2426 2526
 					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2527
+	}
2427 2528
 
2428 2529
 	echo '
2429 2530
 				</dt>
@@ -2478,9 +2579,10 @@  discard block
 block discarded – undo
2478 2579
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2479 2580
 						<option value="-1" disabled>------------------------------</option>';
2480 2581
 
2481
-		foreach ($context['notification_templates'] as $id_template => $template)
2482
-			echo '
2582
+		foreach ($context['notification_templates'] as $id_template => $template) {
2583
+					echo '
2483 2584
 						<option value="', $id_template, '">', $template['title'], '</option>';
2585
+		}
2484 2586
 
2485 2587
 		echo '
2486 2588
 					</select>
@@ -2493,9 +2595,10 @@  discard block
 block discarded – undo
2493 2595
 			</dl>
2494 2596
 			<div class="righttext">';
2495 2597
 
2496
-	if (!empty($context['token_check']))
2497
-		echo '
2598
+	if (!empty($context['token_check'])) {
2599
+			echo '
2498 2600
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2601
+	}
2499 2602
 
2500 2603
 	echo '
2501 2604
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2511,8 +2614,8 @@  discard block
 block discarded – undo
2511 2614
 	echo '
2512 2615
 	<script>';
2513 2616
 
2514
-	if (!$context['user']['is_owner'])
2515
-		echo '
2617
+	if (!$context['user']['is_owner']) {
2618
+			echo '
2516 2619
 		modifyWarnNotify();
2517 2620
 		$(document).ready(function() {
2518 2621
 			$("#preview_button").click(function() {
@@ -2551,6 +2654,7 @@  discard block
 block discarded – undo
2551 2654
 			});
2552 2655
 			return false;
2553 2656
 		}';
2657
+	}
2554 2658
 
2555 2659
 	echo '
2556 2660
 	</script>';
@@ -2573,17 +2677,19 @@  discard block
 block discarded – undo
2573 2677
 			</div>';
2574 2678
 
2575 2679
 	// If deleting another account give them a lovely info box.
2576
-	if (!$context['user']['is_owner'])
2577
-		echo '
2680
+	if (!$context['user']['is_owner']) {
2681
+			echo '
2578 2682
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2683
+	}
2579 2684
 
2580 2685
 	echo '
2581 2686
 			<div class="windowbg2">';
2582 2687
 
2583 2688
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2584
-	if ($context['needs_approval'])
2585
-		echo '
2689
+	if ($context['needs_approval']) {
2690
+			echo '
2586 2691
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2692
+	}
2587 2693
 
2588 2694
 	// If the user is deleting their own account warn them first - and require a password!
2589 2695
 	if ($context['user']['is_owner'])
@@ -2595,9 +2701,10 @@  discard block
 block discarded – undo
2595 2701
 					<input type="password" name="oldpasswrd" size="20">
2596 2702
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2597 2703
 
2598
-		if (!empty($context['token_check']))
2599
-			echo '
2704
+		if (!empty($context['token_check'])) {
2705
+					echo '
2600 2706
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2707
+		}
2601 2708
 
2602 2709
 		echo '
2603 2710
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2627,10 +2734,11 @@  discard block
 block discarded – undo
2627 2734
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2628 2735
 					</select>';
2629 2736
 
2630
-			if ($context['show_perma_delete'])
2631
-				echo '
2737
+			if ($context['show_perma_delete']) {
2738
+							echo '
2632 2739
 					<br>
2633 2740
 					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2741
+			}
2634 2742
 
2635 2743
 			echo '
2636 2744
 				</div>';
@@ -2643,9 +2751,10 @@  discard block
 block discarded – undo
2643 2751
 				<div>
2644 2752
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2645 2753
 
2646
-		if (!empty($context['token_check']))
2647
-			echo '
2754
+		if (!empty($context['token_check'])) {
2755
+					echo '
2648 2756
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2757
+		}
2649 2758
 
2650 2759
 		echo '
2651 2760
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2671,8 +2780,8 @@  discard block
 block discarded – undo
2671 2780
 					<hr>';
2672 2781
 
2673 2782
 	// Only show the password box if it's actually needed.
2674
-	if ($context['require_password'])
2675
-		echo '
2783
+	if ($context['require_password']) {
2784
+			echo '
2676 2785
 					<dl class="settings">
2677 2786
 						<dt>
2678 2787
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2682,13 +2791,15 @@  discard block
 block discarded – undo
2682 2791
 							<input type="password" name="oldpasswrd" size="20">
2683 2792
 						</dd>
2684 2793
 					</dl>';
2794
+	}
2685 2795
 
2686 2796
 	echo '
2687 2797
 					<div class="righttext">';
2688 2798
 
2689
-	if (!empty($context['token_check']))
2690
-		echo '
2799
+	if (!empty($context['token_check'])) {
2800
+			echo '
2691 2801
 						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2802
+	}
2692 2803
 
2693 2804
 	echo '
2694 2805
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2715,9 +2826,10 @@  discard block
 block discarded – undo
2715 2826
 			<ul id="list_errors">';
2716 2827
 
2717 2828
 		// Cycle through each error and display an error message.
2718
-		foreach ($context['post_errors'] as $error)
2719
-			echo '
2829
+		foreach ($context['post_errors'] as $error) {
2830
+					echo '
2720 2831
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2832
+		}
2721 2833
 
2722 2834
 		echo '
2723 2835
 			</ul>';
@@ -2743,12 +2855,13 @@  discard block
 block discarded – undo
2743 2855
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2744 2856
 
2745 2857
 	// Fill the select box with all primary member groups that can be assigned to a member.
2746
-	foreach ($context['member_groups'] as $member_group)
2747
-		if (!empty($member_group['can_be_primary']))
2858
+	foreach ($context['member_groups'] as $member_group) {
2859
+			if (!empty($member_group['can_be_primary']))
2748 2860
 			echo '
2749 2861
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2750 2862
 										', $member_group['name'], '
2751 2863
 									</option>';
2864
+	}
2752 2865
 
2753 2866
 	echo '
2754 2867
 								</select>
@@ -2761,10 +2874,11 @@  discard block
 block discarded – undo
2761 2874
 									<input type="hidden" name="additional_groups[]" value="0">';
2762 2875
 
2763 2876
 	// For each membergroup show a checkbox so members can be assigned to more than one group.
2764
-	foreach ($context['member_groups'] as $member_group)
2765
-		if ($member_group['can_be_additional'])
2877
+	foreach ($context['member_groups'] as $member_group) {
2878
+			if ($member_group['can_be_additional'])
2766 2879
 			echo '
2767 2880
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2881
+	}
2768 2882
 
2769 2883
 	echo '
2770 2884
 								</span>
@@ -2824,9 +2938,10 @@  discard block
 block discarded – undo
2824 2938
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2825 2939
 								<br>';
2826 2940
 
2827
-	if ($context['show_spellchecking'])
2828
-		echo '
2941
+	if ($context['show_spellchecking']) {
2942
+			echo '
2829 2943
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2944
+	}
2830 2945
 
2831 2946
 	echo '
2832 2947
 							</dt>
@@ -2834,17 +2949,20 @@  discard block
 block discarded – undo
2834 2949
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2835 2950
 
2836 2951
 	// If there is a limit at all!
2837
-	if (!empty($context['signature_limits']['max_length']))
2838
-		echo '
2952
+	if (!empty($context['signature_limits']['max_length'])) {
2953
+			echo '
2839 2954
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2955
+	}
2840 2956
 
2841
-	if (!empty($context['show_preview_button']))
2842
-		echo '
2957
+	if (!empty($context['show_preview_button'])) {
2958
+			echo '
2843 2959
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2960
+	}
2844 2961
 
2845
-	if ($context['signature_warning'])
2846
-		echo '
2962
+	if ($context['signature_warning']) {
2963
+			echo '
2847 2964
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2965
+	}
2848 2966
 
2849 2967
 	// Some javascript used to count how many characters have been used so far in the signature.
2850 2968
 	echo '
@@ -2889,9 +3007,10 @@  discard block
 block discarded – undo
2889 3007
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2890 3008
 
2891 3009
 		// This lists all the file categories.
2892
-		foreach ($context['avatars'] as $avatar)
2893
-			echo '
3010
+		foreach ($context['avatars'] as $avatar) {
3011
+					echo '
2894 3012
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
3013
+		}
2895 3014
 
2896 3015
 		echo '
2897 3016
 										</select>
@@ -2923,20 +3042,22 @@  discard block
 block discarded – undo
2923 3042
 	}
2924 3043
 
2925 3044
 	// If the user can link to an off server avatar, show them a box to input the address.
2926
-	if (!empty($context['member']['avatar']['allow_external']))
2927
-		echo '
3045
+	if (!empty($context['member']['avatar']['allow_external'])) {
3046
+			echo '
2928 3047
 								<div id="avatar_external">
2929 3048
 									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2930 3049
 									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);">
2931 3050
 								</div>';
3051
+	}
2932 3052
 
2933 3053
 	// If the user is able to upload avatars to the server show them an upload box.
2934
-	if (!empty($context['member']['avatar']['allow_upload']))
2935
-		echo '
3054
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3055
+			echo '
2936 3056
 								<div id="avatar_upload">
2937 3057
 									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2938 3058
 									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2939 3059
 								</div>';
3060
+	}
2940 3061
 
2941 3062
 	// if the user is able to use Gravatar avatars show then the image preview
2942 3063
 	if (!empty($context['member']['avatar']['allow_gravatar']))
@@ -2945,16 +3066,17 @@  discard block
 block discarded – undo
2945 3066
 								<div id="avatar_gravatar">
2946 3067
 									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2947 3068
 
2948
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2949
-			echo '
3069
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
3070
+					echo '
2950 3071
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2951
-		else
3072
+		} else
2952 3073
 		{
2953 3074
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2954
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2955
-				$textbox_value = '';
2956
-			else
2957
-				$textbox_value = $context['member']['avatar']['external'];
3075
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
3076
+							$textbox_value = '';
3077
+			} else {
3078
+							$textbox_value = $context['member']['avatar']['external'];
3079
+			}
2958 3080
 
2959 3081
 			echo '
2960 3082
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -3026,8 +3148,9 @@  discard block
 block discarded – undo
3026 3148
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3027 3149
 
3028 3150
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3029
-	if (empty($suffix))
3030
-		return;
3151
+	if (empty($suffix)) {
3152
+			return;
3153
+	}
3031 3154
 
3032 3155
 	echo '
3033 3156
 								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -3052,9 +3175,10 @@  discard block
 block discarded – undo
3052 3175
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3053 3176
 
3054 3177
 	// Help the user by showing a list of common time formats.
3055
-	foreach ($context['easy_timeformats'] as $time_format)
3056
-		echo '
3178
+	foreach ($context['easy_timeformats'] as $time_format) {
3179
+			echo '
3057 3180
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3181
+	}
3058 3182
 
3059 3183
 	echo '
3060 3184
 								</select>
@@ -3092,9 +3216,10 @@  discard block
 block discarded – undo
3092 3216
 							<dd>
3093 3217
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.png\';">';
3094 3218
 
3095
-	foreach ($context['smiley_sets'] as $set)
3096
-		echo '
3219
+	foreach ($context['smiley_sets'] as $set) {
3220
+			echo '
3097 3221
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3222
+	}
3098 3223
 
3099 3224
 	echo '
3100 3225
 								</select>
@@ -3146,10 +3271,11 @@  discard block
 block discarded – undo
3146 3271
 										<img src="', $context['tfa_qr_url'], '" alt="">
3147 3272
 									</div>';
3148 3273
 
3149
-	if (!empty($context['from_ajax']))
3150
-		echo '
3274
+	if (!empty($context['from_ajax'])) {
3275
+			echo '
3151 3276
 					<br>
3152 3277
 					<a href="javascript:self.close();"></a>';
3278
+	}
3153 3279
 
3154 3280
 	echo '
3155 3281
 				</div>
@@ -3189,17 +3315,16 @@  discard block
 block discarded – undo
3189 3315
 							</dt>
3190 3316
 							<dd>';
3191 3317
 
3192
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3193
-		echo '
3318
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3319
+			echo '
3194 3320
 								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3195
-
3196
-	elseif (!$context['tfa_enabled'])
3197
-		echo '
3321
+	} elseif (!$context['tfa_enabled']) {
3322
+			echo '
3198 3323
 								', $txt['tfa_profile_disabled'];
3199
-
3200
-	else
3201
-		echo '
3324
+	} else {
3325
+			echo '
3202 3326
 								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3327
+	}
3203 3328
 
3204 3329
 	echo '
3205 3330
 							</dd>';
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 1 patch
Braces   +222 added lines, -162 removed lines patch added patch discarded remove patch
@@ -22,30 +22,32 @@  discard block
 block discarded – undo
22 22
 		<div id="calendar">';
23 23
 
24 24
 	// Show the mini-blocks if they're enabled.
25
-	if (empty($context['blocks_disabled']))
26
-		echo '
25
+	if (empty($context['blocks_disabled'])) {
26
+			echo '
27 27
 			<div id="month_grid">
28 28
 				', template_show_month_grid('prev', true), '
29 29
 				', template_show_month_grid('current', true), '
30 30
 				', template_show_month_grid('next', true), '
31 31
 			</div>';
32
+	}
32 33
 
33 34
 	// What view are we showing?
34
-	if ($context['calendar_view'] == 'viewlist')
35
-		echo '
35
+	if ($context['calendar_view'] == 'viewlist') {
36
+			echo '
36 37
 			<div id="main_grid">
37 38
 				', template_show_upcoming_list('main'), '
38 39
 			</div>';
39
-	elseif ($context['calendar_view'] == 'viewweek')
40
-		echo '
40
+	} elseif ($context['calendar_view'] == 'viewweek') {
41
+			echo '
41 42
 			<div id="main_grid">
42 43
 				', template_show_week_grid('main'), '
43 44
 			</div>';
44
-	else
45
-		echo '
45
+	} else {
46
+			echo '
46 47
 			<div id="main_grid">
47 48
 				', template_show_month_grid('main'), '
48 49
 			</div>';
50
+	}
49 51
 
50 52
 	// Close our wrapper.
51 53
 	echo '
@@ -64,20 +66,22 @@  discard block
 block discarded – undo
64 66
 	global $context, $scripturl, $txt;
65 67
 
66 68
 	// Bail out if we have nothing to work with
67
-	if (!isset($context['calendar_grid_' . $grid_name]))
68
-		return false;
69
+	if (!isset($context['calendar_grid_' . $grid_name])) {
70
+			return false;
71
+	}
69 72
 
70 73
 	// Protect programmer sanity
71 74
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
72 75
 
73 76
 	// Do we want a title?
74
-	if (empty($calendar_data['disable_title']))
75
-		echo '
77
+	if (empty($calendar_data['disable_title'])) {
78
+			echo '
76 79
 			<div class="cat_bar">
77 80
 				<h3 class="catbg centertext largetext">
78 81
 					<a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a>
79 82
 				</h3>
80 83
 			</div>';
84
+	}
81 85
 
82 86
 	// Give the user some controls to work with
83 87
 	template_calendar_top($calendar_data);
@@ -100,11 +104,13 @@  discard block
 block discarded – undo
100 104
 					<li class="windowbg">
101 105
 						<strong class="event_title">', $event['link'], '</strong>';
102 106
 
103
-				if ($event['can_edit'])
104
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
107
+				if ($event['can_edit']) {
108
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
109
+				}
105 110
 
106
-				if ($event['can_export'])
107
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
111
+				if ($event['can_export']) {
112
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
113
+				}
108 114
 
109 115
 				echo '
110 116
 						<br>';
@@ -112,14 +118,14 @@  discard block
 block discarded – undo
112 118
 				if (!empty($event['allday']))
113 119
 				{
114 120
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
115
-				}
116
-				else
121
+				} else
117 122
 				{
118 123
 					// Display event info relative to user's local timezone
119 124
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
120 125
 
121
-					if ($event['start_date_local'] != $event['end_date_local'])
122
-						echo trim($event['end_date_local']) . ', ';
126
+					if ($event['start_date_local'] != $event['end_date_local']) {
127
+											echo trim($event['end_date_local']) . ', ';
128
+					}
123 129
 
124 130
 					echo trim($event['end_time_local']);
125 131
 
@@ -128,23 +134,27 @@  discard block
 block discarded – undo
128 134
 					{
129 135
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
130 136
 
131
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
132
-							echo trim($event['start_date_orig']), ', ';
137
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
138
+													echo trim($event['start_date_orig']), ', ';
139
+						}
133 140
 
134 141
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
135 142
 
136
-						if ($event['start_date_orig'] != $event['end_date_orig'])
137
-							echo trim($event['end_date_orig']) . ', ';
143
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
144
+													echo trim($event['end_date_orig']) . ', ';
145
+						}
138 146
 
139 147
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
140 148
 					}
141 149
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
142
-					else
143
-						echo ' ', $event['tz_abbrev'], '</time>';
150
+					else {
151
+											echo ' ', $event['tz_abbrev'], '</time>';
152
+					}
144 153
 				}
145 154
 
146
-				if (!empty($event['location']))
147
-					echo '<br>', $event['location'];
155
+				if (!empty($event['location'])) {
156
+									echo '<br>', $event['location'];
157
+				}
148 158
 
149 159
 				echo '
150 160
 					</li>';
@@ -176,8 +186,9 @@  discard block
 block discarded – undo
176 186
 
177 187
 			$birthdays = array();
178 188
 
179
-			foreach ($date as $member)
180
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
189
+			foreach ($date as $member) {
190
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
191
+			}
181 192
 
182 193
 			echo implode(', ', $birthdays);
183 194
 
@@ -208,8 +219,9 @@  discard block
 block discarded – undo
208 219
 			$date_local = $date['date_local'];
209 220
 			unset($date['date_local']);
210 221
 
211
-			foreach ($date as $holiday)
212
-				$holidays[] = $holiday . ' (' . $date_local . ')';
222
+			foreach ($date as $holiday) {
223
+							$holidays[] = $holiday . ' (' . $date_local . ')';
224
+			}
213 225
 		}
214 226
 
215 227
 		echo implode(', ', $holidays);
@@ -233,17 +245,19 @@  discard block
 block discarded – undo
233 245
 	global $context, $txt, $scripturl, $modSettings;
234 246
 
235 247
 	// If the grid doesn't exist, no point in proceeding.
236
-	if (!isset($context['calendar_grid_' . $grid_name]))
237
-		return false;
248
+	if (!isset($context['calendar_grid_' . $grid_name])) {
249
+			return false;
250
+	}
238 251
 
239 252
 	// A handy little pointer variable.
240 253
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
241 254
 
242 255
 	// Some conditions for whether or not we should show the week links *here*.
243
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
244
-		$show_week_links = true;
245
-	else
246
-		$show_week_links = false;
256
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
257
+			$show_week_links = true;
258
+	} else {
259
+			$show_week_links = false;
260
+	}
247 261
 
248 262
 	// Assuming that we've not disabled it, show the title block!
249 263
 	if (empty($calendar_data['disable_title']))
@@ -253,18 +267,20 @@  discard block
 block discarded – undo
253 267
 				<h3 class="catbg centertext largetext">';
254 268
 
255 269
 		// Previous Link: If we're showing prev / next and it's not a mini-calendar.
256
-		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
257
-			echo '
270
+		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
271
+					echo '
258 272
 					<span class="floatleft">
259 273
 						<a href="', $calendar_data['previous_calendar']['href'], '">&#171;</a>
260 274
 					</span>';
275
+		}
261 276
 
262 277
 		// Next Link: if we're showing prev / next and it's not a mini-calendar.
263
-		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
264
-			echo '
278
+		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
279
+					echo '
265 280
 					<span class="floatright">
266 281
 						<a href="', $calendar_data['next_calendar']['href'], '">&#187;</a>
267 282
 					</span>';
283
+		}
268 284
 
269 285
 		// Arguably the most exciting part, the title!
270 286
 		echo '
@@ -274,8 +290,9 @@  discard block
 block discarded – undo
274 290
 	}
275 291
 
276 292
 	// Show the controls on main grids
277
-	if ($is_mini === false)
278
-		template_calendar_top($calendar_data);
293
+	if ($is_mini === false) {
294
+			template_calendar_top($calendar_data);
295
+	}
279 296
 
280 297
 	// Finally, the main calendar table.
281 298
 	echo '
@@ -288,14 +305,16 @@  discard block
 block discarded – undo
288 305
 				<tr>';
289 306
 
290 307
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
291
-		if ($show_week_links === true)
292
-			echo '
308
+		if ($show_week_links === true) {
309
+					echo '
293 310
 					<th></th>';
311
+		}
294 312
 
295 313
 		// Now, loop through each actual day of the week.
296
-		foreach ($calendar_data['week_days'] as $day)
297
-			echo '
314
+		foreach ($calendar_data['week_days'] as $day) {
315
+					echo '
298 316
 					<th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>';
317
+		}
299 318
 
300 319
 		echo '
301 320
 				</tr>';
@@ -313,11 +332,12 @@  discard block
 block discarded – undo
313 332
 				<tr class="days_wrapper">';
314 333
 
315 334
 		// This is where we add the actual week link, if enabled on this location.
316
-		if ($show_week_links === true)
317
-			echo '
335
+		if ($show_week_links === true) {
336
+					echo '
318 337
 					<td class="windowbg2 weeks">
319 338
 						<a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">&#187;</a>
320 339
 					</td>';
340
+		}
321 341
 
322 342
 		// Now loop through each day in the week we're on.
323 343
 		foreach ($week['days'] as $day)
@@ -333,27 +353,29 @@  discard block
 block discarded – undo
333 353
 				// Additional classes are given for events, holidays, and birthdays.
334 354
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
335 355
 				{
336
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
337
-						$classes[] = 'events';
338
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
339
-						$classes[] = 'events';
356
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
357
+											$classes[] = 'events';
358
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
359
+											$classes[] = 'events';
360
+					}
340 361
 				}
341 362
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
342 363
 				{
343
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
344
-						$classes[] = 'holidays';
345
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
346
-						$classes[] = 'holidays';
364
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
365
+											$classes[] = 'holidays';
366
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
367
+											$classes[] = 'holidays';
368
+					}
347 369
 				}
348 370
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
349 371
 				{
350
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
351
-						$classes[] = 'birthdays';
352
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
353
-						$classes[] = 'birthdays';
372
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
373
+											$classes[] = 'birthdays';
374
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
375
+											$classes[] = 'birthdays';
376
+					}
354 377
 				}
355
-			}
356
-			else
378
+			} else
357 379
 			{
358 380
 				// Default Classes (either compact or comfortable and disabled).
359 381
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -371,25 +393,27 @@  discard block
 block discarded – undo
371 393
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
372 394
 
373 395
 				// The actual day number - be it a link, or just plain old text!
374
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
375
-					echo '
396
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
397
+									echo '
376 398
 						<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
377
-				elseif ($is_mini)
378
-					echo '
399
+				} elseif ($is_mini) {
400
+									echo '
379 401
 						<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
380
-				else
381
-					echo '
402
+				} else {
403
+									echo '
382 404
 						<span class="day_text">', $title_prefix, $day['day'], '</span>';
405
+				}
383 406
 
384 407
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
385 408
 				if ($is_mini === false)
386 409
 				{
387 410
 					// Holidays are always fun, let's show them!
388
-					if (!empty($day['holidays']))
389
-						echo '
411
+					if (!empty($day['holidays'])) {
412
+											echo '
390 413
 						<div class="smalltext holiday">
391 414
 							<span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '
392 415
 						</div>';
416
+					}
393 417
 
394 418
 					// Happy Birthday Dear Member!
395 419
 					if (!empty($day['birthdays']))
@@ -407,15 +431,17 @@  discard block
 block discarded – undo
407 431
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
408 432
 
409 433
 							// 9...10! Let's stop there.
410
-							if ($birthday_count == 10 && $use_js_hide)
411
-								// !!TODO - Inline CSS and JavaScript should be moved.
434
+							if ($birthday_count == 10 && $use_js_hide) {
435
+															// !!TODO - Inline CSS and JavaScript should be moved.
412 436
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
437
+							}
413 438
 
414 439
 							++$birthday_count;
415 440
 						}
416
-						if ($use_js_hide)
417
-							echo '
441
+						if ($use_js_hide) {
442
+													echo '
418 443
 							</span>';
444
+						}
419 445
 
420 446
 						echo '
421 447
 						</div><!-- .smalltext -->';
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 					{
427 453
 						// Sort events by start time (all day events will be listed first)
428 454
 						uasort($day['events'], function($a, $b) {
429
-							if ($a['start_timestamp'] == $b['start_timestamp'])
430
-								return 0;
455
+							if ($a['start_timestamp'] == $b['start_timestamp']) {
456
+															return 0;
457
+							}
431 458
 
432 459
 							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
433 460
 						});
@@ -447,20 +474,22 @@  discard block
 block discarded – undo
447 474
 								', $event['link'], '<br>
448 475
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
449 476
 
450
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
451
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
452
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
453
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
454
-							elseif (!empty($event['allday']))
455
-								echo $txt['calendar_allday'];
477
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
478
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
479
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
480
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
481
+							} elseif (!empty($event['allday'])) {
482
+															echo $txt['calendar_allday'];
483
+							}
456 484
 
457 485
 							echo '
458 486
 								</span>';
459 487
 
460
-							if (!empty($event['location']))
461
-								echo '
488
+							if (!empty($event['location'])) {
489
+															echo '
462 490
 								<br>
463 491
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
492
+							}
464 493
 
465 494
 							if ($event['can_edit'] || $event['can_export'])
466 495
 							{
@@ -468,18 +497,20 @@  discard block
 block discarded – undo
468 497
 								<span class="modify_event_links">';
469 498
 
470 499
 								// If they can edit the event, show an icon they can click on....
471
-								if ($event['can_edit'])
472
-									echo '
500
+								if ($event['can_edit']) {
501
+																	echo '
473 502
 									<a class="modify_event" href="', $event['modify_href'], '">
474 503
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
475 504
 									</a>';
505
+								}
476 506
 
477 507
 								// Exporting!
478
-								if ($event['can_export'])
479
-									echo '
508
+								if ($event['can_export']) {
509
+																	echo '
480 510
 									<a class="modify_event" href="', $event['export_href'], '">
481 511
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
482 512
 									</a>';
513
+								}
483 514
 
484 515
 								echo '
485 516
 								</span><br class="clear">';
@@ -498,10 +529,11 @@  discard block
 block discarded – undo
498 529
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
499 530
 			elseif ($is_mini === false)
500 531
 			{
501
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
502
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
503
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
504
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
532
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
533
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
534
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
535
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
536
+				}
505 537
 			}
506 538
 
507 539
 			// Close this day and increase var count.
@@ -531,8 +563,9 @@  discard block
 block discarded – undo
531 563
 	global $context, $txt, $scripturl, $modSettings;
532 564
 
533 565
 	// We might have no reason to proceed, if the variable isn't there.
534
-	if (!isset($context['calendar_grid_' . $grid_name]))
535
-		return false;
566
+	if (!isset($context['calendar_grid_' . $grid_name])) {
567
+			return false;
568
+	}
536 569
 
537 570
 	// Handy pointer.
538 571
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -549,22 +582,25 @@  discard block
 block discarded – undo
549 582
 					<h3 class="catbg centertext largetext">';
550 583
 
551 584
 			// Previous Week Link...
552
-			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
553
-				echo '
585
+			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
586
+							echo '
554 587
 						<span class="floatleft">
555 588
 							<a href="', $calendar_data['previous_week']['href'], '">&#171;</a>
556 589
 						</span>';
590
+			}
557 591
 
558 592
 			// Next Week Link...
559
-			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
560
-				echo '
593
+			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
594
+							echo '
561 595
 						<span class="floatright">
562 596
 							<a href="', $calendar_data['next_week']['href'], '">&#187;</a>
563 597
 						</span>';
598
+			}
564 599
 
565 600
 			// The Month Title + Week Number...
566
-			if (!empty($calendar_data['week_title']))
567
-				echo $calendar_data['week_title'];
601
+			if (!empty($calendar_data['week_title'])) {
602
+							echo $calendar_data['week_title'];
603
+			}
568 604
 
569 605
 			echo '
570 606
 					</h3>
@@ -605,11 +641,12 @@  discard block
 block discarded – undo
605 641
 						<td class="', implode(' ', $classes), ' act_day">';
606 642
 
607 643
 			// Should the day number be a link?
608
-			if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
609
-				echo '
644
+			if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
645
+							echo '
610 646
 							<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
611
-			else
612
-				echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
647
+			} else {
648
+							echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
649
+			}
613 650
 
614 651
 			echo '
615 652
 						</td>
@@ -620,8 +657,9 @@  discard block
 block discarded – undo
620 657
 			{
621 658
 				// Sort events by start time (all day events will be listed first)
622 659
 				uasort($day['events'], function($a, $b) {
623
-					if ($a['start_timestamp'] == $b['start_timestamp'])
624
-						return 0;
660
+					if ($a['start_timestamp'] == $b['start_timestamp']) {
661
+											return 0;
662
+					}
625 663
 					return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
626 664
 				});
627 665
 
@@ -635,35 +673,39 @@  discard block
 block discarded – undo
635 673
 					echo $event['link'], '<br>
636 674
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
637 675
 
638
-					if (!empty($event['start_time_local']))
639
-						echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
640
-					else
641
-						echo $txt['calendar_allday'];
676
+					if (!empty($event['start_time_local'])) {
677
+											echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
678
+					} else {
679
+											echo $txt['calendar_allday'];
680
+					}
642 681
 
643 682
 					echo '
644 683
 								</span>';
645 684
 
646
-					if (!empty($event['location']))
647
-						echo '<br>
685
+					if (!empty($event['location'])) {
686
+											echo '<br>
648 687
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
688
+					}
649 689
 
650 690
 					if (!empty($event_icons_needed))
651 691
 					{
652 692
 						echo ' <span class="modify_event_links">';
653 693
 
654 694
 						// If they can edit the event, show a star they can click on....
655
-						if (!empty($event['can_edit']))
656
-							echo '
695
+						if (!empty($event['can_edit'])) {
696
+													echo '
657 697
 									<a class="modify_event" href="', $event['modify_href'], '">
658 698
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
659 699
 									</a>';
700
+						}
660 701
 
661 702
 						// Can we export? Sweet.
662
-						if (!empty($event['can_export']))
663
-							echo '
703
+						if (!empty($event['can_export'])) {
704
+													echo '
664 705
 									<a class="modify_event" href="', $event['export_href'], '">
665 706
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
666 707
 									</a>';
708
+						}
667 709
 
668 710
 						echo '
669 711
 								</span><br class="clear">';
@@ -681,22 +723,23 @@  discard block
 block discarded – undo
681 723
 							</div>
682 724
 							<br class="clear">';
683 725
 				}
684
-			}
685
-			else
726
+			} else
686 727
 			{
687
-				if (!empty($context['can_post']))
688
-					echo '
728
+				if (!empty($context['can_post'])) {
729
+									echo '
689 730
 							<div class="week_add_event">
690 731
 								<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a>
691 732
 							</div>';
733
+				}
692 734
 			}
693 735
 			echo '
694 736
 						</td>
695 737
 						<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
696 738
 
697 739
 			// Show any holidays!
698
-			if (!empty($day['holidays']))
699
-				echo implode('<br>', $day['holidays']);
740
+			if (!empty($day['holidays'])) {
741
+							echo implode('<br>', $day['holidays']);
742
+			}
700 743
 
701 744
 			echo '
702 745
 						</td>
@@ -705,11 +748,12 @@  discard block
 block discarded – undo
705 748
 			// Show any birthdays...
706 749
 			if (!empty($day['birthdays']))
707 750
 			{
708
-				foreach ($day['birthdays'] as $member)
709
-					echo '
751
+				foreach ($day['birthdays'] as $member) {
752
+									echo '
710 753
 							<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a>
711 754
 							', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '
712 755
 							', $member['is_last'] ? '' : '<br>';
756
+				}
713 757
 			}
714 758
 			echo '
715 759
 						</td>
@@ -755,26 +799,27 @@  discard block
 block discarded – undo
755 799
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date">
756 800
 				<input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '">
757 801
 			</form>';
758
-	}
759
-	else
802
+	} else
760 803
 	{
761 804
 		echo'
762 805
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
763 806
 				<select name="month" id="input_month">';
764 807
 
765 808
 		// Show a select box with all the months.
766
-		foreach ($txt['months_short'] as $number => $month)
767
-			echo '
809
+		foreach ($txt['months_short'] as $number => $month) {
810
+					echo '
768 811
 					<option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>';
812
+		}
769 813
 
770 814
 		echo '
771 815
 				</select>
772 816
 				<select name="year">';
773 817
 
774 818
 		// Show a link for every year...
775
-		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++)
776
-			echo '
819
+		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) {
820
+					echo '
777 821
 					<option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>';
822
+		}
778 823
 
779 824
 		echo '
780 825
 				</select>
@@ -796,9 +841,10 @@  discard block
 block discarded – undo
796 841
 	echo '
797 842
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">';
798 843
 
799
-	if (!empty($context['event']['new']))
800
-		echo '
844
+	if (!empty($context['event']['new'])) {
845
+			echo '
801 846
 			<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
847
+	}
802 848
 
803 849
 	// Start the main table.
804 850
 	echo '
@@ -809,8 +855,8 @@  discard block
 block discarded – undo
809 855
 					</h3>
810 856
 				</div>';
811 857
 
812
-	if (!empty($context['post_error']['messages']))
813
-		echo '
858
+	if (!empty($context['post_error']['messages'])) {
859
+			echo '
814 860
 				<div class="errorbox">
815 861
 					<dl class="event_error">
816 862
 						<dt>
@@ -821,6 +867,7 @@  discard block
 block discarded – undo
821 867
 						</dt>
822 868
 					</dl>
823 869
 				</div>';
870
+	}
824 871
 
825 872
 	echo '
826 873
 				<div class="roundframe noup">
@@ -848,9 +895,10 @@  discard block
 block discarded – undo
848 895
 			echo '
849 896
 									<optgroup label="', $category['name'], '">';
850 897
 
851
-			foreach ($category['boards'] as $board)
852
-				echo '
898
+			foreach ($category['boards'] as $board) {
899
+							echo '
853 900
 										<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
901
+			}
854 902
 			echo '
855 903
 									</optgroup>';
856 904
 		}
@@ -886,9 +934,10 @@  discard block
 block discarded – undo
886 934
 								<span class="label">', $txt['calendar_timezone'], '</span>
887 935
 								<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
888 936
 
889
-	foreach ($context['all_timezones'] as $tz => $tzname)
890
-		echo '
937
+	foreach ($context['all_timezones'] as $tz => $tzname) {
938
+			echo '
891 939
 									<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
940
+	}
892 941
 
893 942
 	echo '
894 943
 								</select>
@@ -904,9 +953,10 @@  discard block
 block discarded – undo
904 953
 					<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">';
905 954
 
906 955
 	// Delete button?
907
-	if (empty($context['event']['new']))
908
-		echo '
956
+	if (empty($context['event']['new'])) {
957
+			echo '
909 958
 					<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">';
959
+	}
910 960
 
911 961
 	echo '
912 962
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -934,9 +984,10 @@  discard block
 block discarded – undo
934 984
 		echo '
935 985
 				<td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">';
936 986
 
937
-		foreach ($v as $i)
938
-			echo '
987
+		foreach ($v as $i) {
988
+					echo '
939 989
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>';
990
+		}
940 991
 
941 992
 		echo '
942 993
 				</td>';
@@ -957,9 +1008,10 @@  discard block
 block discarded – undo
957 1008
 
958 1009
 	foreach ($context['clockicons'] as $t => $v)
959 1010
 	{
960
-		foreach ($v as $i)
961
-			echo '
1011
+		foreach ($v as $i) {
1012
+					echo '
962 1013
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1014
+		}
963 1015
 	}
964 1016
 
965 1017
 	echo '
@@ -984,13 +1036,14 @@  discard block
 block discarded – undo
984 1036
 
985 1037
 	foreach ($context['clockicons'] as $t => $v)
986 1038
 	{
987
-		foreach ($v as $i)
988
-			echo '
1039
+		foreach ($v as $i) {
1040
+					echo '
989 1041
 				if (', $t, ' >= ', $i, ')
990 1042
 				{
991 1043
 					turnon.push("', $t, '_', $i, '");
992 1044
 					', $t, ' -= ', $i, ';
993 1045
 				}';
1046
+		}
994 1047
 	}
995 1048
 
996 1049
 	echo '
@@ -1034,9 +1087,10 @@  discard block
 block discarded – undo
1034 1087
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1035 1088
 				<td>';
1036 1089
 
1037
-		foreach ($v as $i)
1038
-			echo '
1090
+		foreach ($v as $i) {
1091
+					echo '
1039 1092
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1093
+		}
1040 1094
 
1041 1095
 		echo '
1042 1096
 				</td>
@@ -1058,9 +1112,10 @@  discard block
 block discarded – undo
1058 1112
 
1059 1113
 	foreach ($context['clockicons'] as $t => $v)
1060 1114
 	{
1061
-		foreach ($v as $i)
1062
-			echo '
1115
+		foreach ($v as $i) {
1116
+					echo '
1063 1117
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1118
+		}
1064 1119
 	}
1065 1120
 
1066 1121
 	echo '
@@ -1077,13 +1132,14 @@  discard block
 block discarded – undo
1077 1132
 
1078 1133
 	foreach ($context['clockicons'] as $t => $v)
1079 1134
 	{
1080
-		foreach ($v as $i)
1081
-			echo '
1135
+		foreach ($v as $i) {
1136
+					echo '
1082 1137
 				if (', $t, ' >= ', $i, ')
1083 1138
 				{
1084 1139
 					turnon.push("', $t, '_', $i, '");
1085 1140
 					', $t, ' -= ', $i, ';
1086 1141
 				}';
1142
+		}
1087 1143
 	}
1088 1144
 
1089 1145
 	echo '
@@ -1127,9 +1183,10 @@  discard block
 block discarded – undo
1127 1183
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1128 1184
 				<td>';
1129 1185
 
1130
-		foreach ($v as $i)
1131
-			echo '
1186
+		foreach ($v as $i) {
1187
+					echo '
1132 1188
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1189
+		}
1133 1190
 
1134 1191
 		echo '
1135 1192
 				</td>
@@ -1145,9 +1202,10 @@  discard block
 block discarded – undo
1145 1202
 
1146 1203
 	foreach ($context['clockicons'] as $t => $v)
1147 1204
 	{
1148
-		foreach ($v as $i)
1149
-			echo '
1205
+		foreach ($v as $i) {
1206
+					echo '
1150 1207
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1208
+		}
1151 1209
 	}
1152 1210
 
1153 1211
 	echo '
@@ -1168,13 +1226,14 @@  discard block
 block discarded – undo
1168 1226
 
1169 1227
 	foreach ($context['clockicons'] as $t => $v)
1170 1228
 	{
1171
-		foreach ($v as $i)
1172
-		echo '
1229
+		foreach ($v as $i) {
1230
+				echo '
1173 1231
 				if (', $t, ' >= ', $i, ')
1174 1232
 				{
1175 1233
 					turnon.push("', $t, '_', $i, '");
1176 1234
 					', $t, ' -= ', $i, ';
1177 1235
 				}';
1236
+		}
1178 1237
 	}
1179 1238
 
1180 1239
 	echo '
@@ -1218,9 +1277,10 @@  discard block
 block discarded – undo
1218 1277
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1219 1278
 				<td>';
1220 1279
 
1221
-		foreach ($v as $i)
1222
-			echo '
1280
+		foreach ($v as $i) {
1281
+					echo '
1223 1282
 					<img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">';
1283
+		}
1224 1284
 
1225 1285
 		echo '
1226 1286
 				</td>
Please login to merge, or discard this patch.
Themes/default/Post.template.php 1 patch
Braces   +105 added lines, -71 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	echo '
@@ -139,14 +147,15 @@  discard block
 block discarded – undo
139 147
 	// Mod & theme authors can use the 'integrate_post_end' hook to modify or add to these (see Post.php)
140 148
 	if (!empty($context['posting_fields']) && is_array($context['posting_fields']))
141 149
 	{
142
-		foreach ($context['posting_fields'] as $pfid => $pf)
143
-			echo '
150
+		foreach ($context['posting_fields'] as $pfid => $pf) {
151
+					echo '
144 152
 						<dt class="clear', !is_numeric($pfid) ? ' pf_' . $pfid : '', '">
145 153
 							', $pf['dt'], '
146 154
 						</dt>
147 155
 						<dd', !is_numeric($pfid) ? ' class="pf_' . $pfid . '"' : '', '>
148 156
 							', preg_replace('~<(input|select|textarea|button|area|a|object)\b~', '<$1 tabindex="' . $context['tabindex']++ . '"', $pf['dd']), '
149 157
 						</dd>';
158
+		}
150 159
 	}
151 160
 
152 161
 	echo '
@@ -180,9 +189,10 @@  discard block
 block discarded – undo
180 189
 				echo '
181 190
 										<optgroup label="', $category['name'], '">';
182 191
 
183
-				foreach ($category['boards'] as $board)
184
-					echo '
192
+				foreach ($category['boards'] as $board) {
193
+									echo '
185 194
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
195
+				}
186 196
 				echo '
187 197
 										</optgroup>';
188 198
 			}
@@ -218,9 +228,10 @@  discard block
 block discarded – undo
218 228
 									<span class="label">', $txt['calendar_timezone'], '</span>
219 229
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
220 230
 
221
-		foreach ($context['all_timezones'] as $tz => $tzname)
222
-			echo '
231
+		foreach ($context['all_timezones'] as $tz => $tzname) {
232
+					echo '
223 233
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
234
+		}
224 235
 
225 236
 		echo '
226 237
 									</select>
@@ -249,14 +260,15 @@  discard block
 block discarded – undo
249 260
 								</dd>';
250 261
 
251 262
 		// Loop through all the choices and print them out.
252
-		foreach ($context['choices'] as $choice)
253
-			echo '
263
+		foreach ($context['choices'] as $choice) {
264
+					echo '
254 265
 								<dt>
255 266
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
256 267
 								</dt>
257 268
 								<dd>
258 269
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
259 270
 								</dd>';
271
+		}
260 272
 
261 273
 		echo '
262 274
 								<p id="pollMoreOptions"></p>
@@ -286,14 +298,15 @@  discard block
 block discarded – undo
286 298
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
287 299
 								</dd>';
288 300
 
289
-		if ($context['poll_options']['guest_vote_enabled'])
290
-			echo '
301
+		if ($context['poll_options']['guest_vote_enabled']) {
302
+					echo '
291 303
 								<dt>
292 304
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
293 305
 								</dt>
294 306
 								<dd>
295 307
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
296 308
 								</dd>';
309
+		}
297 310
 
298 311
 		echo '
299 312
 								<dt>
@@ -314,8 +327,8 @@  discard block
 block discarded – undo
314 327
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
315 328
 
316 329
 	// If we're editing and displaying edit details, show a box where they can say why
317
-	if (isset($context['editing']) && $modSettings['show_modify'])
318
-		echo '
330
+	if (isset($context['editing']) && $modSettings['show_modify']) {
331
+			echo '
319 332
 					<dl>
320 333
 						<dt class="clear">
321 334
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -324,20 +337,23 @@  discard block
 block discarded – undo
324 337
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
325 338
 						</dd>
326 339
 					</dl>';
340
+	}
327 341
 
328 342
 	// If this message has been edited in the past - display when it was.
329
-	if (isset($context['last_modified']))
330
-		echo '
343
+	if (isset($context['last_modified'])) {
344
+			echo '
331 345
 					<div class="padding smalltext">
332 346
 						', $context['last_modified_text'], '
333 347
 					</div>';
348
+	}
334 349
 
335 350
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
336
-	if (!empty($modSettings['additional_options_collapsable']))
337
-		echo '
351
+	if (!empty($modSettings['additional_options_collapsable'])) {
352
+			echo '
338 353
 					<div id="postAdditionalOptionsHeader">
339 354
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
340 355
 					</div>';
356
+	}
341 357
 
342 358
 	echo '
343 359
 					<div id="postAdditionalOptions">';
@@ -370,19 +386,21 @@  discard block
 block discarded – undo
370 386
 								', $txt['uncheck_unwatchd_attach'], ':
371 387
 							</dd>';
372 388
 
373
-		foreach ($context['current_attachments'] as $attachment)
374
-			echo '
389
+		foreach ($context['current_attachments'] as $attachment) {
390
+					echo '
375 391
 							<dd class="smalltext">
376 392
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
377 393
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
378 394
 							</dd>';
395
+		}
379 396
 
380 397
 		echo '
381 398
 						</dl>';
382 399
 
383
-		if (!empty($context['files_in_session_warning']))
384
-			echo '
400
+		if (!empty($context['files_in_session_warning'])) {
401
+					echo '
385 402
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
403
+		}
386 404
 	}
387 405
 
388 406
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -443,8 +461,8 @@  discard block
 block discarded – undo
443 461
 								', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">');
444 462
 
445 463
 		// Show more boxes if they aren't approaching that limit.
446
-		if ($context['num_allowed_attachments'] > 1)
447
-			echo '
464
+		if ($context['num_allowed_attachments'] > 1) {
465
+					echo '
448 466
 										<script>
449 467
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
450 468
 											var current_attachment = 1;
@@ -464,6 +482,7 @@  discard block
 block discarded – undo
464 482
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
465 483
 									</div><!-- .fallback -->
466 484
 								</div><!-- #attachUpload -->';
485
+		}
467 486
 
468 487
 		echo '
469 488
 							</dd>';
@@ -475,21 +494,25 @@  discard block
 block discarded – undo
475 494
 							<dd class="smalltext">';
476 495
 
477 496
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
478
-		if (!empty($modSettings['attachmentCheckExtensions']))
479
-			echo '
497
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
498
+					echo '
480 499
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
500
+		}
481 501
 
482
-		if (!empty($context['attachment_restrictions']))
483
-			echo '
502
+		if (!empty($context['attachment_restrictions'])) {
503
+					echo '
484 504
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
505
+		}
485 506
 
486
-		if ($context['num_allowed_attachments'] == 0)
487
-			echo '
507
+		if ($context['num_allowed_attachments'] == 0) {
508
+					echo '
488 509
 								', $txt['attach_limit_nag'], '<br>';
510
+		}
489 511
 
490
-		if (!$context['can_post_attachment_unapproved'])
491
-			echo '
512
+		if (!$context['can_post_attachment_unapproved']) {
513
+					echo '
492 514
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
515
+		}
493 516
 
494 517
 		echo '
495 518
 							</dd>
@@ -513,24 +536,26 @@  discard block
 block discarded – undo
513 536
 							<dt><strong>', $txt['subject'], '</strong></dt>
514 537
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
515 538
 
516
-		foreach ($context['drafts'] as $draft)
517
-			echo '
539
+		foreach ($context['drafts'] as $draft) {
540
+					echo '
518 541
 							<dt>', $draft['link'], '</dt>
519 542
 							<dd>', $draft['poster_time'], '</dd>';
543
+		}
520 544
 		echo '
521 545
 						</dl>
522 546
 					</div>';
523 547
 	}
524 548
 
525 549
 	// Is visual verification enabled?
526
-	if ($context['require_verification'])
527
-		echo '
550
+	if ($context['require_verification']) {
551
+			echo '
528 552
 					<div class="post_verification">
529 553
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
530 554
 							<strong>', $txt['verification'], ':</strong>
531 555
 						</span>
532 556
 						', template_control_verification($context['visual_verification_id'], 'all'), '
533 557
 					</div>';
558
+	}
534 559
 
535 560
 	// Finally, the submit buttons.
536 561
 	echo '
@@ -539,9 +564,10 @@  discard block
 block discarded – undo
539 564
 						', template_control_richedit_buttons($context['post_box_name']);
540 565
 
541 566
 	// Option to delete an event if user is editing one.
542
-	if ($context['make_event'] && !$context['event']['new'])
543
-		echo '
567
+	if ($context['make_event'] && !$context['event']['new']) {
568
+			echo '
544 569
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
570
+	}
545 571
 
546 572
 	echo '
547 573
 					</span>
@@ -550,9 +576,10 @@  discard block
 block discarded – undo
550 576
 			<br class="clear">';
551 577
 
552 578
 	// Assuming this isn't a new topic pass across the last message id.
553
-	if (isset($context['topic_last_message']))
554
-		echo '
579
+	if (isset($context['topic_last_message'])) {
580
+			echo '
555 581
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
582
+	}
556 583
 
557 584
 	echo '
558 585
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -695,9 +722,10 @@  discard block
 block discarded – undo
695 722
 
696 723
 						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
697 724
 
698
-	if ($context['can_quote'])
699
-		echo '
725
+	if ($context['can_quote']) {
726
+			echo '
700 727
 						newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';';
728
+	}
701 729
 
702 730
 	echo '
703 731
 						newPostsHTML += \'<br class="clear">\';
@@ -740,8 +768,8 @@  discard block
 block discarded – undo
740 768
 			}';
741 769
 
742 770
 	// Code for showing and hiding additional options.
743
-	if (!empty($modSettings['additional_options_collapsable']))
744
-		echo '
771
+	if (!empty($modSettings['additional_options_collapsable'])) {
772
+			echo '
745 773
 			var oSwapAdditionalOptions = new smc_Toggle({
746 774
 				bToggleEnabled: true,
747 775
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -769,10 +797,11 @@  discard block
 block discarded – undo
769 797
 					}
770 798
 				]
771 799
 			});';
800
+	}
772 801
 
773 802
 	// Code for showing and hiding drafts
774
-	if (!empty($context['drafts']))
775
-		echo '
803
+	if (!empty($context['drafts'])) {
804
+			echo '
776 805
 			var oSwapDraftOptions = new smc_Toggle({
777 806
 				bToggleEnabled: true,
778 807
 				bCurrentlyCollapsed: true,
@@ -794,6 +823,7 @@  discard block
 block discarded – undo
794 823
 					}
795 824
 				]
796 825
 			});';
826
+	}
797 827
 
798 828
 	echo '
799 829
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -814,8 +844,9 @@  discard block
 block discarded – undo
814 844
 		foreach ($context['previous_posts'] as $post)
815 845
 		{
816 846
 			$ignoring = false;
817
-			if (!empty($post['is_ignored']))
818
-				$ignored_posts[] = $ignoring = $post['id'];
847
+			if (!empty($post['is_ignored'])) {
848
+							$ignored_posts[] = $ignoring = $post['id'];
849
+			}
819 850
 
820 851
 			echo '
821 852
 			<div class="windowbg">
@@ -825,22 +856,24 @@  discard block
 block discarded – undo
825 856
 					</h5>
826 857
 					&nbsp;-&nbsp;', $post['time'];
827 858
 
828
-			if ($context['can_quote'])
829
-				echo '
859
+			if ($context['can_quote']) {
860
+							echo '
830 861
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
831 862
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
832 863
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
833 864
 					</ul>';
865
+			}
834 866
 
835 867
 			echo '
836 868
 					<br class="clear">';
837 869
 
838
-			if ($ignoring)
839
-				echo '
870
+			if ($ignoring) {
871
+							echo '
840 872
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
841 873
 						', $txt['ignoring_user'], '
842 874
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
843 875
 					</div>';
876
+			}
844 877
 
845 878
 			echo '
846 879
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -995,10 +1028,10 @@  discard block
 block discarded – undo
995 1028
 		<div id="temporary_posting_area" style="display: none;"></div>
996 1029
 		<script>';
997 1030
 
998
-	if ($context['close_window'])
999
-		echo '
1031
+	if ($context['close_window']) {
1032
+			echo '
1000 1033
 			window.close();';
1001
-	else
1034
+	} else
1002 1035
 	{
1003 1036
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
1004 1037
 		echo '
@@ -1052,11 +1085,12 @@  discard block
 block discarded – undo
1052 1085
 				</p>
1053 1086
 				<ul>';
1054 1087
 
1055
-	foreach ($context['groups'] as $group)
1056
-		echo '
1088
+	foreach ($context['groups'] as $group) {
1089
+			echo '
1057 1090
 					<li>
1058 1091
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
1059 1092
 					</li>';
1093
+	}
1060 1094
 
1061 1095
 	echo '
1062 1096
 					<li>
Please login to merge, or discard this patch.
Sources/Subs-Calendar.php 1 patch
Braces   +227 added lines, -165 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get all birthdays within the given time range.
@@ -60,8 +61,7 @@  discard block
 block discarded – undo
60 61
 				'max_year' => $year_high,
61 62
 			)
62 63
 		);
63
-	}
64
-	else
64
+	} else
65 65
 	{
66 66
 		$result = $smcFunc['db_query']('birthday_array', '
67 67
 			SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
@@ -91,10 +91,11 @@  discard block
 block discarded – undo
91 91
 	$bday = array();
92 92
 	while ($row = $smcFunc['db_fetch_assoc']($result))
93 93
 	{
94
-		if ($year_low != $year_high)
95
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
-		else
97
-			$age_year = $year_low;
94
+		if ($year_low != $year_high) {
95
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
+		} else {
97
+					$age_year = $year_low;
98
+		}
98 99
 
99 100
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
100 101
 			'id' => $row['id_member'],
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 	ksort($bday);
109 110
 
110 111
 	// Set is_last, so the themes know when to stop placing separators.
111
-	foreach ($bday as $mday => $array)
112
-		$bday[$mday][count($array) - 1]['is_last'] = true;
112
+	foreach ($bday as $mday => $array) {
113
+			$bday[$mday][count($array) - 1]['is_last'] = true;
114
+	}
113 115
 
114 116
 	return $bday;
115 117
 }
@@ -133,8 +135,9 @@  discard block
 block discarded – undo
133 135
 	static $timezone_array = array();
134 136
 	require_once($sourcedir . '/Subs.php');
135 137
 
136
-	if (empty($timezone_array['default']))
137
-		$timezone_array['default'] = timezone_open(date_default_timezone_get());
138
+	if (empty($timezone_array['default'])) {
139
+			$timezone_array['default'] = timezone_open(date_default_timezone_get());
140
+	}
138 141
 
139 142
 	$low_object = date_create($low_date);
140 143
 	$high_object = date_create($high_date);
@@ -161,8 +164,9 @@  discard block
 block discarded – undo
161 164
 	while ($row = $smcFunc['db_fetch_assoc']($result))
162 165
 	{
163 166
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
164
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
165
-			continue;
167
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
168
+					continue;
169
+		}
166 170
 
167 171
 		// Force a censor of the title - as often these are used by others.
168 172
 		censorText($row['title'], $use_permissions ? false : true);
@@ -170,12 +174,14 @@  discard block
 block discarded – undo
170 174
 		// Get the various time and date properties for this event
171 175
 		list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
172 176
 
173
-		if (empty($timezone_array[$tz]))
174
-			$timezone_array[$tz] = timezone_open($tz);
177
+		if (empty($timezone_array[$tz])) {
178
+					$timezone_array[$tz] = timezone_open($tz);
179
+		}
175 180
 
176 181
 		// Sanity check
177
-		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
178
-			continue;
182
+		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
183
+					continue;
184
+		}
179 185
 
180 186
 		// Get set up for the loop
181 187
 		$start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]);
@@ -239,8 +245,8 @@  discard block
 block discarded – undo
239 245
 			);
240 246
 
241 247
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
242
-			if ($use_permissions)
243
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
248
+			if ($use_permissions) {
249
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
244 250
 					'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
245 251
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
246 252
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
@@ -248,9 +254,10 @@  discard block
 block discarded – undo
248 254
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
249 255
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
250 256
 				));
257
+			}
251 258
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
252
-			else
253
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
259
+			else {
260
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
254 261
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
255 262
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
256 263
 					'can_edit' => false,
@@ -260,6 +267,7 @@  discard block
 block discarded – undo
260 267
 					'poster' => $row['id_member'],
261 268
 					'allowed_groups' => explode(',', $row['member_groups']),
262 269
 				));
270
+			}
263 271
 
264 272
 			date_add($cal_date, date_interval_create_from_date_string('1 day'));
265 273
 		}
@@ -269,8 +277,9 @@  discard block
 block discarded – undo
269 277
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
270 278
 	if ($use_permissions)
271 279
 	{
272
-		foreach ($events as $mday => $array)
273
-			$events[$mday][count($array) - 1]['is_last'] = true;
280
+		foreach ($events as $mday => $array) {
281
+					$events[$mday][count($array) - 1]['is_last'] = true;
282
+		}
274 283
 	}
275 284
 
276 285
 	ksort($events);
@@ -290,11 +299,12 @@  discard block
 block discarded – undo
290 299
 	global $smcFunc;
291 300
 
292 301
 	// Get the lowest and highest dates for "all years".
293
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
294
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
302
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
303
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
295 304
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
296
-	else
297
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
305
+	} else {
306
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
307
+	}
298 308
 
299 309
 	// Find some holidays... ;).
300 310
 	$result = $smcFunc['db_query']('', '
@@ -314,10 +324,11 @@  discard block
 block discarded – undo
314 324
 	$holidays = array();
315 325
 	while ($row = $smcFunc['db_fetch_assoc']($result))
316 326
 	{
317
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
318
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
319
-		else
320
-			$event_year = substr($low_date, 0, 4);
327
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
328
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
329
+		} else {
330
+					$event_year = substr($low_date, 0, 4);
331
+		}
321 332
 
322 333
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
323 334
 	}
@@ -343,10 +354,12 @@  discard block
 block discarded – undo
343 354
 	isAllowedTo('calendar_post');
344 355
 
345 356
 	// No board?  No topic?!?
346
-	if (empty($board))
347
-		fatal_lang_error('missing_board_id', false);
348
-	if (empty($topic))
349
-		fatal_lang_error('missing_topic_id', false);
357
+	if (empty($board)) {
358
+			fatal_lang_error('missing_board_id', false);
359
+	}
360
+	if (empty($topic)) {
361
+			fatal_lang_error('missing_topic_id', false);
362
+	}
350 363
 
351 364
 	// Administrator, Moderator, or owner.  Period.
352 365
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -364,12 +377,14 @@  discard block
 block discarded – undo
364 377
 		if ($row = $smcFunc['db_fetch_assoc']($result))
365 378
 		{
366 379
 			// Not the owner of the topic.
367
-			if ($row['id_member_started'] != $user_info['id'])
368
-				fatal_lang_error('not_your_topic', 'user');
380
+			if ($row['id_member_started'] != $user_info['id']) {
381
+							fatal_lang_error('not_your_topic', 'user');
382
+			}
369 383
 		}
370 384
 		// Topic/Board doesn't exist.....
371
-		else
372
-			fatal_lang_error('calendar_no_topic', 'general');
385
+		else {
386
+					fatal_lang_error('calendar_no_topic', 'general');
387
+		}
373 388
 		$smcFunc['db_free_result']($result);
374 389
 	}
375 390
 }
@@ -457,14 +472,16 @@  discard block
 block discarded – undo
457 472
 	if (!empty($calendarOptions['start_day']))
458 473
 	{
459 474
 		$nShift -= $calendarOptions['start_day'];
460
-		if ($nShift < 0)
461
-			$nShift = 7 + $nShift;
475
+		if ($nShift < 0) {
476
+					$nShift = 7 + $nShift;
477
+		}
462 478
 	}
463 479
 
464 480
 	// Number of rows required to fit the month.
465 481
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
466
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
467
-		$nRows++;
482
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
483
+			$nRows++;
484
+	}
468 485
 
469 486
 	// Fetch the arrays for birthdays, posted events, and holidays.
470 487
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -477,8 +494,9 @@  discard block
 block discarded – undo
477 494
 	{
478 495
 		$calendarGrid['week_days'][] = $count;
479 496
 		$count++;
480
-		if ($count == 7)
481
-			$count = 0;
497
+		if ($count == 7) {
498
+					$count = 0;
499
+		}
482 500
 	}
483 501
 
484 502
 	// Iterate through each week.
@@ -495,8 +513,9 @@  discard block
 block discarded – undo
495 513
 		{
496 514
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
497 515
 
498
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
499
-				$nDay = 0;
516
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
517
+							$nDay = 0;
518
+			}
500 519
 
501 520
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
502 521
 
@@ -514,8 +533,9 @@  discard block
 block discarded – undo
514 533
 	}
515 534
 
516 535
 	// What is the last day of the month?
517
-	if ($is_previous === true)
518
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
536
+	if ($is_previous === true) {
537
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
538
+	}
519 539
 
520 540
 	// We'll use the shift in the template.
521 541
 	$calendarGrid['shift'] = $nShift;
@@ -549,8 +569,9 @@  discard block
 block discarded – undo
549 569
 	{
550 570
 		// Here we offset accordingly to get things to the real start of a week.
551 571
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
552
-		if ($date_diff < 0)
553
-			$date_diff += 7;
572
+		if ($date_diff < 0) {
573
+					$date_diff += 7;
574
+		}
554 575
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
555 576
 		$day = (int) strftime('%d', $new_timestamp);
556 577
 		$month = (int) strftime('%m', $new_timestamp);
@@ -680,18 +701,20 @@  discard block
 block discarded – undo
680 701
 	{
681 702
 		foreach ($date_events as $event_key => $event_val)
682 703
 		{
683
-			if (in_array($event_val['id'], $temp))
684
-				unset($calendarGrid['events'][$date][$event_key]);
685
-			else
686
-				$temp[] = $event_val['id'];
704
+			if (in_array($event_val['id'], $temp)) {
705
+							unset($calendarGrid['events'][$date][$event_key]);
706
+			} else {
707
+							$temp[] = $event_val['id'];
708
+			}
687 709
 		}
688 710
 	}
689 711
 
690 712
 	// Give birthdays and holidays a friendly format, without the year
691
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
692
-		$date_format = '%b %d';
693
-	else
694
-		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
713
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
714
+			$date_format = '%b %d';
715
+	} else {
716
+			$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
717
+	}
695 718
 
696 719
 	foreach (array('birthdays', 'holidays') as $type)
697 720
 	{
@@ -790,8 +813,9 @@  discard block
 block discarded – undo
790 813
 		// Holidays between now and now + days.
791 814
 		for ($i = $now; $i < $now + $days_for_index; $i += 86400)
792 815
 		{
793
-			if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
794
-				$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
816
+			if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
817
+							$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
818
+			}
795 819
 		}
796 820
 	}
797 821
 
@@ -803,8 +827,9 @@  discard block
 block discarded – undo
803 827
 			$loop_date = strftime('%Y-%m-%d', $i);
804 828
 			if (isset($cached_data['birthdays'][$loop_date]))
805 829
 			{
806
-				foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
807
-					$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
830
+				foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
831
+									$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
832
+				}
808 833
 				$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
809 834
 			}
810 835
 		}
@@ -819,8 +844,9 @@  discard block
 block discarded – undo
819 844
 			$loop_date = strftime('%Y-%m-%d', $i);
820 845
 
821 846
 			// No events today? Check the next day.
822
-			if (empty($cached_data['events'][$loop_date]))
823
-				continue;
847
+			if (empty($cached_data['events'][$loop_date])) {
848
+							continue;
849
+			}
824 850
 
825 851
 			// Loop through all events to add a few last-minute values.
826 852
 			foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -833,9 +859,9 @@  discard block
 block discarded – undo
833 859
 				{
834 860
 					unset($cached_data['events'][$loop_date][$ev]);
835 861
 					continue;
862
+				} else {
863
+									$duplicates[$this_event['topic'] . $this_event['title']] = true;
836 864
 				}
837
-				else
838
-					$duplicates[$this_event['topic'] . $this_event['title']] = true;
839 865
 
840 866
 				// Might be set to true afterwards, depending on the permissions.
841 867
 				$this_event['can_edit'] = false;
@@ -843,16 +869,19 @@  discard block
 block discarded – undo
843 869
 				$this_event['date'] = $loop_date;
844 870
 			}
845 871
 
846
-			if (!empty($cached_data['events'][$loop_date]))
847
-				$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
872
+			if (!empty($cached_data['events'][$loop_date])) {
873
+							$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
874
+			}
848 875
 		}
849 876
 	}
850 877
 
851 878
 	// Mark the last item so that a list separator can be used in the template.
852
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
853
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
854
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
855
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
879
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
880
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
881
+	}
882
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
883
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
884
+	}
856 885
 
857 886
 	return array(
858 887
 		'data' => $return_data,
@@ -900,37 +929,46 @@  discard block
 block discarded – undo
900 929
 		if (isset($_POST['start_date']))
901 930
 		{
902 931
 			$d = date_parse($_POST['start_date']);
903
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
904
-				fatal_lang_error('invalid_date', false);
905
-			if (empty($d['year']))
906
-				fatal_lang_error('event_year_missing', false);
907
-			if (empty($d['month']))
908
-				fatal_lang_error('event_month_missing', false);
909
-		}
910
-		elseif (isset($_POST['start_datetime']))
932
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
933
+							fatal_lang_error('invalid_date', false);
934
+			}
935
+			if (empty($d['year'])) {
936
+							fatal_lang_error('event_year_missing', false);
937
+			}
938
+			if (empty($d['month'])) {
939
+							fatal_lang_error('event_month_missing', false);
940
+			}
941
+		} elseif (isset($_POST['start_datetime']))
911 942
 		{
912 943
 			$d = date_parse($_POST['start_datetime']);
913
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
914
-				fatal_lang_error('invalid_date', false);
915
-			if (empty($d['year']))
916
-				fatal_lang_error('event_year_missing', false);
917
-			if (empty($d['month']))
918
-				fatal_lang_error('event_month_missing', false);
944
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
945
+							fatal_lang_error('invalid_date', false);
946
+			}
947
+			if (empty($d['year'])) {
948
+							fatal_lang_error('event_year_missing', false);
949
+			}
950
+			if (empty($d['month'])) {
951
+							fatal_lang_error('event_month_missing', false);
952
+			}
919 953
 		}
920 954
 		// The 2.0 way
921 955
 		else
922 956
 		{
923 957
 			// No month?  No year?
924
-			if (!isset($_POST['month']))
925
-				fatal_lang_error('event_month_missing', false);
926
-			if (!isset($_POST['year']))
927
-				fatal_lang_error('event_year_missing', false);
958
+			if (!isset($_POST['month'])) {
959
+							fatal_lang_error('event_month_missing', false);
960
+			}
961
+			if (!isset($_POST['year'])) {
962
+							fatal_lang_error('event_year_missing', false);
963
+			}
928 964
 
929 965
 			// Check the month and year...
930
-			if ($_POST['month'] < 1 || $_POST['month'] > 12)
931
-				fatal_lang_error('invalid_month', false);
932
-			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
933
-				fatal_lang_error('invalid_year', false);
966
+			if ($_POST['month'] < 1 || $_POST['month'] > 12) {
967
+							fatal_lang_error('invalid_month', false);
968
+			}
969
+			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
970
+							fatal_lang_error('invalid_year', false);
971
+			}
934 972
 		}
935 973
 	}
936 974
 
@@ -940,8 +978,9 @@  discard block
 block discarded – undo
940 978
 	// If they want to us to calculate an end date, make sure it will fit in an acceptable range.
941 979
 	if (isset($_POST['span']))
942 980
 	{
943
-		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan']))
944
-			fatal_lang_error('invalid_days_numb', false);
981
+		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) {
982
+					fatal_lang_error('invalid_days_numb', false);
983
+		}
945 984
 	}
946 985
 
947 986
 	// There is no need to validate the following values if we are just deleting the event.
@@ -951,24 +990,29 @@  discard block
 block discarded – undo
951 990
 		if (empty($_POST['start_date']) && empty($_POST['start_datetime']))
952 991
 		{
953 992
 			// No day?
954
-			if (!isset($_POST['day']))
955
-				fatal_lang_error('event_day_missing', false);
993
+			if (!isset($_POST['day'])) {
994
+							fatal_lang_error('event_day_missing', false);
995
+			}
956 996
 
957 997
 			// Bad day?
958
-			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
959
-				fatal_lang_error('invalid_date', false);
998
+			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
999
+							fatal_lang_error('invalid_date', false);
1000
+			}
960 1001
 		}
961 1002
 
962
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
963
-			fatal_lang_error('event_title_missing', false);
964
-		elseif (!isset($_POST['evtitle']))
965
-			$_POST['evtitle'] = $_POST['subject'];
1003
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
1004
+					fatal_lang_error('event_title_missing', false);
1005
+		} elseif (!isset($_POST['evtitle'])) {
1006
+					$_POST['evtitle'] = $_POST['subject'];
1007
+		}
966 1008
 
967 1009
 		// No title?
968
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
969
-			fatal_lang_error('no_event_title', false);
970
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
971
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1010
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
1011
+					fatal_lang_error('no_event_title', false);
1012
+		}
1013
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
1014
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1015
+		}
972 1016
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
973 1017
 	}
974 1018
 }
@@ -995,8 +1039,9 @@  discard block
 block discarded – undo
995 1039
 	);
996 1040
 
997 1041
 	// No results, return false.
998
-	if ($smcFunc['db_num_rows'] === 0)
999
-		return false;
1042
+	if ($smcFunc['db_num_rows'] === 0) {
1043
+			return false;
1044
+	}
1000 1045
 
1001 1046
 	// Grab the results and return.
1002 1047
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -1130,8 +1175,9 @@  discard block
 block discarded – undo
1130 1175
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
1131 1176
 
1132 1177
 	$column_clauses = array();
1133
-	foreach ($event_columns as $col => $crit)
1134
-		$column_clauses[] = $col . ' = ' . $crit;
1178
+	foreach ($event_columns as $col => $crit) {
1179
+			$column_clauses[] = $col . ' = ' . $crit;
1180
+	}
1135 1181
 
1136 1182
 	$smcFunc['db_query']('', '
1137 1183
 		UPDATE {db_prefix}calendar
@@ -1216,8 +1262,9 @@  discard block
 block discarded – undo
1216 1262
 	);
1217 1263
 
1218 1264
 	// If nothing returned, we are in poo, poo.
1219
-	if ($smcFunc['db_num_rows']($request) === 0)
1220
-		return false;
1265
+	if ($smcFunc['db_num_rows']($request) === 0) {
1266
+			return false;
1267
+	}
1221 1268
 
1222 1269
 	$row = $smcFunc['db_fetch_assoc']($request);
1223 1270
 	$smcFunc['db_free_result']($request);
@@ -1225,8 +1272,9 @@  discard block
 block discarded – undo
1225 1272
 	list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
1226 1273
 
1227 1274
 	// Sanity check
1228
-	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
1229
-		return false;
1275
+	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
1276
+			return false;
1277
+	}
1230 1278
 
1231 1279
 	$return_value = array(
1232 1280
 		'boards' => array(),
@@ -1363,24 +1411,27 @@  discard block
 block discarded – undo
1363 1411
 
1364 1412
 	// Set $span, in case we need it
1365 1413
 	$span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0);
1366
-	if ($span > 0)
1367
-		$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1414
+	if ($span > 0) {
1415
+			$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1416
+	}
1368 1417
 
1369 1418
 	// Define the timezone for this event, falling back to the default if not provided
1370
-	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1371
-		$tz = $eventOptions['tz'];
1372
-	elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1373
-		$tz = $_POST['tz'];
1374
-	else
1375
-		$tz = getUserTimezone();
1419
+	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1420
+			$tz = $eventOptions['tz'];
1421
+	} elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1422
+			$tz = $_POST['tz'];
1423
+	} else {
1424
+			$tz = getUserTimezone();
1425
+	}
1376 1426
 
1377 1427
 	// Is this supposed to be an all day event, or should it have specific start and end times?
1378
-	if (isset($eventOptions['allday']))
1379
-		$allday = $eventOptions['allday'];
1380
-	elseif (empty($_POST['allday']))
1381
-		$allday = false;
1382
-	else
1383
-		$allday = true;
1428
+	if (isset($eventOptions['allday'])) {
1429
+			$allday = $eventOptions['allday'];
1430
+	} elseif (empty($_POST['allday'])) {
1431
+			$allday = false;
1432
+	} else {
1433
+			$allday = true;
1434
+	}
1384 1435
 
1385 1436
 	// Input might come as individual parameters...
1386 1437
 	$start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null);
@@ -1407,10 +1458,12 @@  discard block
 block discarded – undo
1407 1458
 	$end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null);
1408 1459
 
1409 1460
 	// If the date and time were given in separate strings, combine them
1410
-	if (empty($start_string) && isset($start_date_string))
1411
-		$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1412
-	if (empty($end_string) && isset($end_date_string))
1413
-		$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1461
+	if (empty($start_string) && isset($start_date_string)) {
1462
+			$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1463
+	}
1464
+	if (empty($end_string) && isset($end_date_string)) {
1465
+			$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1466
+	}
1414 1467
 
1415 1468
 	// If some form of string input was given, override individually defined options with it
1416 1469
 	if (isset($start_string))
@@ -1501,10 +1554,11 @@  discard block
 block discarded – undo
1501 1554
 	if ($start_object >= $end_object)
1502 1555
 	{
1503 1556
 		$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1504
-		if ($span > 0)
1505
-			date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1506
-		else
1507
-			date_add($end_object, date_interval_create_from_date_string('1 hour'));
1557
+		if ($span > 0) {
1558
+					date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1559
+		} else {
1560
+					date_add($end_object, date_interval_create_from_date_string('1 hour'));
1561
+		}
1508 1562
 	}
1509 1563
 
1510 1564
 	// Is $end_object too late?
@@ -1517,9 +1571,9 @@  discard block
 block discarded – undo
1517 1571
 			{
1518 1572
 				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1519 1573
 				date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days'));
1574
+			} else {
1575
+							$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1520 1576
 			}
1521
-			else
1522
-				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1523 1577
 		}
1524 1578
 	}
1525 1579
 
@@ -1532,8 +1586,7 @@  discard block
 block discarded – undo
1532 1586
 		$start_time = null;
1533 1587
 		$end_time = null;
1534 1588
 		$tz = null;
1535
-	}
1536
-	else
1589
+	} else
1537 1590
 	{
1538 1591
 		$start_time = date_format($start_object, 'H:i:s');
1539 1592
 		$end_time = date_format($end_object, 'H:i:s');
@@ -1561,19 +1614,21 @@  discard block
 block discarded – undo
1561 1614
 	// First, try to create a better date format, ignoring the "time" elements.
1562 1615
 	if (empty($date_format))
1563 1616
 	{
1564
-		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1565
-			$date_format = '%F';
1566
-		else
1567
-			$date_format = $matches[0];
1617
+		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1618
+					$date_format = '%F';
1619
+		} else {
1620
+					$date_format = $matches[0];
1621
+		}
1568 1622
 	}
1569 1623
 
1570 1624
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1571 1625
 	if (empty($time_format))
1572 1626
 	{
1573
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1574
-			$time_format = '%k:%M';
1575
-		else
1576
-			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1627
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1628
+					$time_format = '%k:%M';
1629
+		} else {
1630
+					$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1631
+		}
1577 1632
 	}
1578 1633
 
1579 1634
 	// Should this be an all day event?
@@ -1583,11 +1638,13 @@  discard block
 block discarded – undo
1583 1638
 	$span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d');
1584 1639
 
1585 1640
 	// We need to have a defined timezone in the steps below
1586
-	if (empty($row['timezone']))
1587
-		$row['timezone'] = getUserTimezone();
1641
+	if (empty($row['timezone'])) {
1642
+			$row['timezone'] = getUserTimezone();
1643
+	}
1588 1644
 
1589
-	if (empty($timezone_array[$row['timezone']]))
1590
-		$timezone_array[$row['timezone']] = timezone_open($row['timezone']);
1645
+	if (empty($timezone_array[$row['timezone']])) {
1646
+			$timezone_array[$row['timezone']] = timezone_open($row['timezone']);
1647
+	}
1591 1648
 
1592 1649
 	// Get most of the standard date information for the start and end datetimes
1593 1650
 	$start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''));
@@ -1622,8 +1679,9 @@  discard block
 block discarded – undo
1622 1679
 	$tz_abbrev = date_format($start_object, 'T');
1623 1680
 
1624 1681
 	// If the abbreviation is just a numerical offset from UTC, make that clear.
1625
-	if (strspn($tz_abbrev, '+-') > 0)
1626
-		$tz_abbrev = 'UTC' . $tz_abbrev;
1682
+	if (strspn($tz_abbrev, '+-') > 0) {
1683
+			$tz_abbrev = 'UTC' . $tz_abbrev;
1684
+	}
1627 1685
 
1628 1686
 	return array($start, $end, $allday, $span, $tz, $tz_abbrev);
1629 1687
 }
@@ -1639,8 +1697,9 @@  discard block
 block discarded – undo
1639 1697
 	global $smcFunc, $context, $user_info, $modSettings, $user_settings;
1640 1698
 	static $member_cache = array();
1641 1699
 
1642
-	if (is_null($id_member) && $user_info['is_guest'] == false)
1643
-		$id_member = $context['user']['id'];
1700
+	if (is_null($id_member) && $user_info['is_guest'] == false) {
1701
+			$id_member = $context['user']['id'];
1702
+	}
1644 1703
 
1645 1704
 	//check if the cache got the data
1646 1705
 	if (isset($id_member) && isset($member_cache[$id_member]))
@@ -1669,11 +1728,13 @@  discard block
 block discarded – undo
1669 1728
 		$smcFunc['db_free_result']($request);
1670 1729
 	}
1671 1730
 
1672
-	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1673
-		$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1731
+	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1732
+			$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1733
+	}
1674 1734
 
1675
-	if (isset($id_member))
1676
-		$member_cache[$id_member] = $timezone;
1735
+	if (isset($id_member)) {
1736
+			$member_cache[$id_member] = $timezone;
1737
+	}
1677 1738
 
1678 1739
 	return $timezone;
1679 1740
 }
@@ -1702,8 +1763,9 @@  discard block
 block discarded – undo
1702 1763
 		)
1703 1764
 	);
1704 1765
 	$holidays = array();
1705
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1706
-		$holidays[] = $row;
1766
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1767
+			$holidays[] = $row;
1768
+	}
1707 1769
 	$smcFunc['db_free_result']($request);
1708 1770
 
1709 1771
 	return $holidays;
Please login to merge, or discard this patch.
Sources/MessageIndex.php 1 patch
Braces   +266 added lines, -199 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the list of topics in this board, along with any child boards.
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 	$context['name'] = $board_info['name'];
58 59
 	$context['description'] = $board_info['description'];
59
-	if (!empty($board_info['description']))
60
-		$context['meta_description'] = strip_tags($board_info['description']);
60
+	if (!empty($board_info['description'])) {
61
+			$context['meta_description'] = strip_tags($board_info['description']);
62
+	}
61 63
 
62 64
 	// How many topics do we have in total?
63 65
 	$board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
 		$session_name = session_name();
74 76
 		foreach ($_GET as $k => $v)
75 77
 		{
76
-			if (!in_array($k, array('board', 'start', $session_name)))
77
-				$context['robot_no_index'] = true;
78
+			if (!in_array($k, array('board', 'start', $session_name))) {
79
+							$context['robot_no_index'] = true;
80
+			}
78 81
 		}
79 82
 	}
80
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
81
-		$context['robot_no_index'] = true;
83
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
84
+			$context['robot_no_index'] = true;
85
+	}
82 86
 
83 87
 	// If we can view unapproved messages and there are some build up a list.
84 88
 	if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts']))
@@ -89,14 +93,16 @@  discard block
 block discarded – undo
89 93
 	}
90 94
 
91 95
 	// We only know these.
92
-	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
93
-		$_REQUEST['sort'] = 'last_post';
96
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) {
97
+			$_REQUEST['sort'] = 'last_post';
98
+	}
94 99
 
95 100
 	// Make sure the starting place makes sense and construct the page index.
96
-	if (isset($_REQUEST['sort']))
97
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
98
-	else
99
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
101
+	if (isset($_REQUEST['sort'])) {
102
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
103
+	} else {
104
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
105
+	}
100 106
 	$context['start'] = &$_REQUEST['start'];
101 107
 
102 108
 	// Set a canonical URL for this page.
@@ -132,14 +138,16 @@  discard block
 block discarded – undo
132 138
 	$context['link_moderators'] = array();
133 139
 	if (!empty($board_info['moderators']))
134 140
 	{
135
-		foreach ($board_info['moderators'] as $mod)
136
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
141
+		foreach ($board_info['moderators'] as $mod) {
142
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
143
+		}
137 144
 	}
138 145
 	if (!empty($board_info['moderator_groups']))
139 146
 	{
140 147
 		// By default just tack the moderator groups onto the end of the members
141
-		foreach ($board_info['moderator_groups'] as $mod_group)
142
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
148
+		foreach ($board_info['moderator_groups'] as $mod_group) {
149
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
150
+		}
143 151
 	}
144 152
 
145 153
 	// Now we tack the info onto the end of the linktree
@@ -191,20 +199,24 @@  discard block
 block discarded – undo
191 199
 		);
192 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
193 201
 		{
194
-			if (empty($row['id_member']))
195
-				continue;
202
+			if (empty($row['id_member'])) {
203
+							continue;
204
+			}
196 205
 
197
-			if (!empty($row['online_color']))
198
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
199
-			else
200
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
206
+			if (!empty($row['online_color'])) {
207
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
208
+			} else {
209
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
210
+			}
201 211
 
202 212
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
203
-			if ($is_buddy)
204
-				$link = '<strong>' . $link . '</strong>';
213
+			if ($is_buddy) {
214
+							$link = '<strong>' . $link . '</strong>';
215
+			}
205 216
 
206
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
207
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
217
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
218
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
219
+			}
208 220
 			// @todo why are we filling this array of data that are just counted (twice) and discarded? ???
209 221
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
210 222
 				'id' => $row['id_member'],
@@ -217,8 +229,9 @@  discard block
 block discarded – undo
217 229
 				'hidden' => empty($row['show_online']),
218 230
 			);
219 231
 
220
-			if (empty($row['show_online']))
221
-				$context['view_num_hidden']++;
232
+			if (empty($row['show_online'])) {
233
+							$context['view_num_hidden']++;
234
+			}
222 235
 		}
223 236
 		$context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
224 237
 		$smcFunc['db_free_result']($request);
@@ -260,8 +273,9 @@  discard block
 block discarded – undo
260 273
 	// Bring in any changes we want to make before the query.
261 274
 	call_integration_hook('integrate_pre_messageindex', array(&$sort_methods));
262 275
 
263
-	foreach ($sort_methods as $key => $val)
264
-		$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
276
+	foreach ($sort_methods as $key => $val) {
277
+			$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
278
+	}
265 279
 
266 280
 	// Calculate the fastest way to get the topics.
267 281
 	$start = (int) $_REQUEST['start'];
@@ -271,14 +285,15 @@  discard block
 block discarded – undo
271 285
 		$fake_ascending = true;
272 286
 		$context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex'];
273 287
 		$start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex'];
288
+	} else {
289
+			$fake_ascending = false;
274 290
 	}
275
-	else
276
-		$fake_ascending = false;
277 291
 
278 292
 	// Setup the default topic icons...
279 293
 	$context['icon_sources'] = array();
280
-	foreach ($context['stable_icons'] as $icon)
281
-		$context['icon_sources'][$icon] = 'images_url';
294
+	foreach ($context['stable_icons'] as $icon) {
295
+			$context['icon_sources'][$icon] = 'images_url';
296
+	}
282 297
 
283 298
 	$topic_ids = array();
284 299
 	$context['topics'] = array();
@@ -316,8 +331,9 @@  discard block
 block discarded – undo
316 331
 			$message_pre_index_parameters
317 332
 		);
318 333
 		$topic_ids = array();
319
-		while ($row = $smcFunc['db_fetch_assoc']($request))
320
-			$topic_ids[] = $row['id_topic'];
334
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
335
+					$topic_ids[] = $row['id_topic'];
336
+		}
321 337
 	}
322 338
 
323 339
 	// Grab the appropriate topic information...
@@ -340,10 +356,11 @@  discard block
 block discarded – undo
340 356
 		$message_index_wheres = array();
341 357
 		call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids));
342 358
 
343
-		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
344
-			$enableParticipation = true;
345
-		else
346
-			$enableParticipation = false;
359
+		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) {
360
+					$enableParticipation = true;
361
+		} else {
362
+					$enableParticipation = false;
363
+		}
347 364
 
348 365
 		$result = $smcFunc['db_query']('substring', '
349 366
 			SELECT
@@ -382,11 +399,13 @@  discard block
 block discarded – undo
382 399
 		// Begin 'printing' the message index for current board.
383 400
 		while ($row = $smcFunc['db_fetch_assoc']($result))
384 401
 		{
385
-			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
386
-				continue;
402
+			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
403
+							continue;
404
+			}
387 405
 
388
-			if (!$pre_query)
389
-				$topic_ids[] = $row['id_topic'];
406
+			if (!$pre_query) {
407
+							$topic_ids[] = $row['id_topic'];
408
+			}
390 409
 
391 410
 			// Reference the main color class.
392 411
 			$colorClass = 'windowbg';
@@ -396,8 +415,9 @@  discard block
 block discarded – undo
396 415
 			{
397 416
 				// Limit them to $modSettings['preview_characters'] characters
398 417
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
399
-				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
400
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
418
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
419
+									$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
420
+				}
401 421
 
402 422
 				// Censor the subject and message preview.
403 423
 				censorText($row['first_subject']);
@@ -408,27 +428,27 @@  discard block
 block discarded – undo
408 428
 				{
409 429
 					$row['last_subject'] = $row['first_subject'];
410 430
 					$row['last_body'] = $row['first_body'];
411
-				}
412
-				else
431
+				} else
413 432
 				{
414 433
 					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
415
-					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
416
-						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
434
+					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
435
+											$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
436
+					}
417 437
 
418 438
 					censorText($row['last_subject']);
419 439
 					censorText($row['last_body']);
420 440
 				}
421
-			}
422
-			else
441
+			} else
423 442
 			{
424 443
 				$row['first_body'] = '';
425 444
 				$row['last_body'] = '';
426 445
 				censorText($row['first_subject']);
427 446
 
428
-				if ($row['id_first_msg'] == $row['id_last_msg'])
429
-					$row['last_subject'] = $row['first_subject'];
430
-				else
431
-					censorText($row['last_subject']);
447
+				if ($row['id_first_msg'] == $row['id_last_msg']) {
448
+									$row['last_subject'] = $row['first_subject'];
449
+				} else {
450
+									censorText($row['last_subject']);
451
+				}
432 452
 			}
433 453
 
434 454
 			// Decide how many pages the topic should have.
@@ -439,42 +459,50 @@  discard block
 block discarded – undo
439 459
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
440 460
 
441 461
 				// If we can use all, show all.
442
-				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages'])
443
-					$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
462
+				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
463
+									$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
464
+				}
465
+			} else {
466
+							$pages = '';
444 467
 			}
445
-			else
446
-				$pages = '';
447 468
 
448 469
 			// We need to check the topic icons exist...
449 470
 			if (!empty($modSettings['messageIconChecks_enable']))
450 471
 			{
451
-				if (!isset($context['icon_sources'][$row['first_icon']]))
452
-					$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
453
-				if (!isset($context['icon_sources'][$row['last_icon']]))
454
-					$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
455
-			}
456
-			else
472
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
473
+									$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
474
+				}
475
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
476
+									$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
477
+				}
478
+			} else
457 479
 			{
458
-				if (!isset($context['icon_sources'][$row['first_icon']]))
459
-					$context['icon_sources'][$row['first_icon']] = 'images_url';
460
-				if (!isset($context['icon_sources'][$row['last_icon']]))
461
-					$context['icon_sources'][$row['last_icon']] = 'images_url';
480
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
481
+									$context['icon_sources'][$row['first_icon']] = 'images_url';
482
+				}
483
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
484
+									$context['icon_sources'][$row['last_icon']] = 'images_url';
485
+				}
462 486
 			}
463 487
 
464
-			if (!empty($board_info['recycle']))
465
-				$row['first_icon'] = 'recycled';
488
+			if (!empty($board_info['recycle'])) {
489
+							$row['first_icon'] = 'recycled';
490
+			}
466 491
 
467 492
 			// Is this topic pending approval, or does it have any posts pending approval?
468
-			if ($context['can_approve_posts'] && $row['unapproved_posts'])
469
-				$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
493
+			if ($context['can_approve_posts'] && $row['unapproved_posts']) {
494
+							$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
495
+			}
470 496
 
471 497
 			// Sticky topics should get a different color, too.
472
-			if ($row['is_sticky'])
473
-				$colorClass .= ' sticky';
498
+			if ($row['is_sticky']) {
499
+							$colorClass .= ' sticky';
500
+			}
474 501
 
475 502
 			// Locked topics get special treatment as well.
476
-			if ($row['locked'])
477
-				$colorClass .= ' locked';
503
+			if ($row['locked']) {
504
+							$colorClass .= ' locked';
505
+			}
478 506
 
479 507
 			// 'Print' the topic info.
480 508
 			$context['topics'][$row['id_topic']] = array_merge($row, array(
@@ -555,8 +583,9 @@  discard block
 block discarded – undo
555 583
 		$smcFunc['db_free_result']($result);
556 584
 
557 585
 		// Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
558
-		if ($fake_ascending)
559
-			$context['topics'] = array_reverse($context['topics'], true);
586
+		if ($fake_ascending) {
587
+					$context['topics'] = array_reverse($context['topics'], true);
588
+		}
560 589
 	}
561 590
 
562 591
 	$context['jump_to'] = array(
@@ -579,9 +608,9 @@  discard block
 block discarded – undo
579 608
 		// Can we restore topics?
580 609
 		$context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']);
581 610
 
582
-		if ($user_info['is_admin'] || $modSettings['topic_move_any'])
583
-			$context['can_move_any'] = true;
584
-		else
611
+		if ($user_info['is_admin'] || $modSettings['topic_move_any']) {
612
+					$context['can_move_any'] = true;
613
+		} else
585 614
 		{
586 615
 			// We'll use this in a minute
587 616
 			$boards_allowed = boardsAllowedTo('post_new');
@@ -608,11 +637,13 @@  discard block
 block discarded – undo
608 637
 		}
609 638
 
610 639
 		// Can we use quick moderation checkboxes?
611
-		if ($options['display_quick_mod'] == 1)
612
-			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
640
+		if ($options['display_quick_mod'] == 1) {
641
+					$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
642
+		}
613 643
 		// Or the icons?
614
-		else
615
-			$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
644
+		else {
645
+					$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
646
+		}
616 647
 	}
617 648
 
618 649
 	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
@@ -646,13 +677,15 @@  discard block
 block discarded – undo
646 677
 			);
647 678
 
648 679
 			// We've seen all these boards now!
649
-			foreach ($board_info['parent_boards'] as $k => $dummy)
650
-				if (isset($_SESSION['topicseen_cache'][$k]))
680
+			foreach ($board_info['parent_boards'] as $k => $dummy) {
681
+							if (isset($_SESSION['topicseen_cache'][$k]))
651 682
 					unset($_SESSION['topicseen_cache'][$k]);
683
+			}
652 684
 		}
653 685
 
654
-		if (isset($_SESSION['topicseen_cache'][$board]))
655
-			unset($_SESSION['topicseen_cache'][$board]);
686
+		if (isset($_SESSION['topicseen_cache'][$board])) {
687
+					unset($_SESSION['topicseen_cache'][$board]);
688
+		}
656 689
 
657 690
 		$request = $smcFunc['db_query']('', '
658 691
 			SELECT id_topic, id_board, sent
@@ -673,8 +706,9 @@  discard block
 block discarded – undo
673 706
 				$context['is_marked_notify'] = true;
674 707
 				$board_sent = $row['sent'];
675 708
 			}
676
-			if (!empty($row['id_topic']))
677
-				$context['topics'][$row['id_topic']]['is_watched'] = true;
709
+			if (!empty($row['id_topic'])) {
710
+							$context['topics'][$row['id_topic']]['is_watched'] = true;
711
+			}
678 712
 		}
679 713
 		$smcFunc['db_free_result']($request);
680 714
 
@@ -698,8 +732,7 @@  discard block
 block discarded – undo
698 732
 		$pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array();
699 733
 		$pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0);
700 734
 		$context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1));
701
-	}
702
-	else
735
+	} else
703 736
 	{
704 737
 		$context['is_marked_notify'] = false;
705 738
 		$context['board_notification_mode'] = 1;
@@ -712,23 +745,27 @@  discard block
 block discarded – undo
712 745
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
713 746
 
714 747
 	// Don't want to show this forever...
715
-	if ($context['becomesUnapproved'])
716
-		unset($_SESSION['becomesUnapproved']);
748
+	if ($context['becomesUnapproved']) {
749
+			unset($_SESSION['becomesUnapproved']);
750
+	}
717 751
 
718 752
 	// Build the message index button array.
719 753
 	$context['normal_buttons'] = array();
720 754
 
721
-	if ($context['can_post_new'])
722
-		$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
755
+	if ($context['can_post_new']) {
756
+			$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
757
+	}
723 758
 
724
-	if ($context['can_post_poll'])
725
-		$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
759
+	if ($context['can_post_poll']) {
760
+			$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
761
+	}
726 762
 
727
-	if ($context['user']['is_logged'])
728
-		$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
763
+	if ($context['user']['is_logged']) {
764
+			$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
765
+	}
729 766
 
730
-	if ($context['can_mark_notify'])
731
-		$context['normal_buttons']['notify'] = array(
767
+	if ($context['can_mark_notify']) {
768
+			$context['normal_buttons']['notify'] = array(
732 769
 			'lang' => true,
733 770
 			'text' => 'notify_board_' . $context['board_notification_mode'],
734 771
 			'sub_buttons' => array(
@@ -746,6 +783,7 @@  discard block
 block discarded – undo
746 783
 				),
747 784
 			),
748 785
 		);
786
+	}
749 787
 
750 788
 	// Javascript for inline editing.
751 789
 	loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic');
@@ -767,18 +805,21 @@  discard block
 block discarded – undo
767 805
 	checkSession('request');
768 806
 
769 807
 	// Lets go straight to the restore area.
770
-	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics']))
771
-		redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
808
+	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) {
809
+			redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
810
+	}
772 811
 
773
-	if (isset($_SESSION['topicseen_cache']))
774
-		$_SESSION['topicseen_cache'] = array();
812
+	if (isset($_SESSION['topicseen_cache'])) {
813
+			$_SESSION['topicseen_cache'] = array();
814
+	}
775 815
 
776 816
 	// This is going to be needed to send off the notifications and for updateLastMessages().
777 817
 	require_once($sourcedir . '/Subs-Post.php');
778 818
 
779 819
 	// Remember the last board they moved things to.
780
-	if (isset($_REQUEST['move_to']))
781
-		$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
820
+	if (isset($_REQUEST['move_to'])) {
821
+			$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
822
+	}
782 823
 
783 824
 	// Only a few possible actions.
784 825
 	$possibleActions = array();
@@ -798,8 +839,7 @@  discard block
 block discarded – undo
798 839
 		);
799 840
 
800 841
 		$redirect_url = 'board=' . $board . '.' . $_REQUEST['start'];
801
-	}
802
-	else
842
+	} else
803 843
 	{
804 844
 		/**
805 845
 		 * @todo Ugly. There's no getting around this, is there?
@@ -817,8 +857,7 @@  discard block
 block discarded – undo
817 857
 		if (!empty($board))
818 858
 		{
819 859
 			$boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board));
820
-		}
821
-		else
860
+		} else
822 861
 		{
823 862
 			$boards_can['post_new'] = boardsAllowedTo('post_new');
824 863
 		}
@@ -829,55 +868,67 @@  discard block
 block discarded – undo
829 868
 		}
830 869
 	}
831 870
 
832
-	if (!$user_info['is_guest'])
833
-		$possibleActions[] = 'markread';
834
-	if (!empty($boards_can['make_sticky']))
835
-		$possibleActions[] = 'sticky';
836
-	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own']))
837
-		$possibleActions[] = 'move';
838
-	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own']))
839
-		$possibleActions[] = 'remove';
840
-	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own']))
841
-		$possibleActions[] = 'lock';
842
-	if (!empty($boards_can['merge_any']))
843
-		$possibleActions[] = 'merge';
844
-	if (!empty($boards_can['approve_posts']))
845
-		$possibleActions[] = 'approve';
871
+	if (!$user_info['is_guest']) {
872
+			$possibleActions[] = 'markread';
873
+	}
874
+	if (!empty($boards_can['make_sticky'])) {
875
+			$possibleActions[] = 'sticky';
876
+	}
877
+	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) {
878
+			$possibleActions[] = 'move';
879
+	}
880
+	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) {
881
+			$possibleActions[] = 'remove';
882
+	}
883
+	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) {
884
+			$possibleActions[] = 'lock';
885
+	}
886
+	if (!empty($boards_can['merge_any'])) {
887
+			$possibleActions[] = 'merge';
888
+	}
889
+	if (!empty($boards_can['approve_posts'])) {
890
+			$possibleActions[] = 'approve';
891
+	}
846 892
 
847 893
 	// Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction'].
848 894
 	// (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.)
849 895
 	if (!empty($_REQUEST['topics']))
850 896
 	{
851 897
 		// If the action isn't valid, just quit now.
852
-		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions))
853
-			redirectexit($redirect_url);
898
+		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) {
899
+					redirectexit($redirect_url);
900
+		}
854 901
 
855 902
 		// Merge requires all topics as one parameter and can be done at once.
856 903
 		if ($_REQUEST['qaction'] == 'merge')
857 904
 		{
858 905
 			// Merge requires at least two topics.
859
-			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2)
860
-				redirectexit($redirect_url);
906
+			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) {
907
+							redirectexit($redirect_url);
908
+			}
861 909
 
862 910
 			require_once($sourcedir . '/SplitTopics.php');
863 911
 			return MergeExecute($_REQUEST['topics']);
864 912
 		}
865 913
 
866 914
 		// Just convert to the other method, to make it easier.
867
-		foreach ($_REQUEST['topics'] as $topic)
868
-			$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
915
+		foreach ($_REQUEST['topics'] as $topic) {
916
+					$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
917
+		}
869 918
 	}
870 919
 
871 920
 	// Weird... how'd you get here?
872
-	if (empty($_REQUEST['actions']))
873
-		redirectexit($redirect_url);
921
+	if (empty($_REQUEST['actions'])) {
922
+			redirectexit($redirect_url);
923
+	}
874 924
 
875 925
 	// Validate each action.
876 926
 	$temp = array();
877 927
 	foreach ($_REQUEST['actions'] as $topic => $action)
878 928
 	{
879
-		if (in_array($action, $possibleActions))
880
-			$temp[(int) $topic] = $action;
929
+		if (in_array($action, $possibleActions)) {
930
+					$temp[(int) $topic] = $action;
931
+		}
881 932
 	}
882 933
 	$_REQUEST['actions'] = $temp;
883 934
 
@@ -898,27 +949,31 @@  discard block
 block discarded – undo
898 949
 		{
899 950
 			if (!empty($board))
900 951
 			{
901
-				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts')))
902
-					unset($_REQUEST['actions'][$row['id_topic']]);
903
-			}
904
-			else
952
+				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) {
953
+									unset($_REQUEST['actions'][$row['id_topic']]);
954
+				}
955
+			} else
905 956
 			{
906 957
 				// Don't allow them to act on unapproved posts they can't see...
907
-				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))
908
-					unset($_REQUEST['actions'][$row['id_topic']]);
958
+				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) {
959
+									unset($_REQUEST['actions'][$row['id_topic']]);
960
+				}
909 961
 				// Goodness, this is fun.  We need to validate the action.
910
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky']))
911
-					unset($_REQUEST['actions'][$row['id_topic']]);
912
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own']))))
913
-					unset($_REQUEST['actions'][$row['id_topic']]);
914
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own']))))
915
-					unset($_REQUEST['actions'][$row['id_topic']]);
962
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) {
963
+									unset($_REQUEST['actions'][$row['id_topic']]);
964
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) {
965
+									unset($_REQUEST['actions'][$row['id_topic']]);
966
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) {
967
+									unset($_REQUEST['actions'][$row['id_topic']]);
968
+				}
916 969
 				// @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked'])
917
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own']))))
918
-					unset($_REQUEST['actions'][$row['id_topic']]);
970
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) {
971
+									unset($_REQUEST['actions'][$row['id_topic']]);
972
+				}
919 973
 				// If the topic is approved then you need permission to approve the posts within.
920
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))))
921
-					unset($_REQUEST['actions'][$row['id_topic']]);
974
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) {
975
+									unset($_REQUEST['actions'][$row['id_topic']]);
976
+				}
922 977
 			}
923 978
 		}
924 979
 		$smcFunc['db_free_result']($request);
@@ -936,11 +991,11 @@  discard block
 block discarded – undo
936 991
 	{
937 992
 		$topic = (int) $topic;
938 993
 
939
-		if ($action == 'markread')
940
-			$markCache[] = $topic;
941
-		elseif ($action == 'sticky')
942
-			$stickyCache[] = $topic;
943
-		elseif ($action == 'move')
994
+		if ($action == 'markread') {
995
+					$markCache[] = $topic;
996
+		} elseif ($action == 'sticky') {
997
+					$stickyCache[] = $topic;
998
+		} elseif ($action == 'move')
944 999
 		{
945 1000
 			require_once($sourcedir . '/MoveTopic.php');
946 1001
 			moveTopicConcurrence();
@@ -948,23 +1003,25 @@  discard block
 block discarded – undo
948 1003
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
949 1004
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
950 1005
 
951
-			if (empty($moveCache[1][$topic]))
952
-				continue;
1006
+			if (empty($moveCache[1][$topic])) {
1007
+							continue;
1008
+			}
953 1009
 
954 1010
 			$moveCache[0][] = $topic;
1011
+		} elseif ($action == 'remove') {
1012
+					$removeCache[] = $topic;
1013
+		} elseif ($action == 'lock') {
1014
+					$lockCache[] = $topic;
1015
+		} elseif ($action == 'approve') {
1016
+					$approveCache[] = $topic;
955 1017
 		}
956
-		elseif ($action == 'remove')
957
-			$removeCache[] = $topic;
958
-		elseif ($action == 'lock')
959
-			$lockCache[] = $topic;
960
-		elseif ($action == 'approve')
961
-			$approveCache[] = $topic;
962 1018
 	}
963 1019
 
964
-	if (empty($board))
965
-		$affectedBoards = array();
966
-	else
967
-		$affectedBoards = array($board => array(0, 0));
1020
+	if (empty($board)) {
1021
+			$affectedBoards = array();
1022
+	} else {
1023
+			$affectedBoards = array($board => array(0, 0));
1024
+	}
968 1025
 
969 1026
 	// Do all the stickies...
970 1027
 	if (!empty($stickyCache))
@@ -1024,14 +1081,16 @@  discard block
 block discarded – undo
1024 1081
 		{
1025 1082
 			$to = $moveCache[1][$row['id_topic']];
1026 1083
 
1027
-			if (empty($to))
1028
-				continue;
1084
+			if (empty($to)) {
1085
+							continue;
1086
+			}
1029 1087
 
1030 1088
 			// Does this topic's board count the posts or not?
1031 1089
 			$countPosts[$row['id_topic']] = empty($row['count_posts']);
1032 1090
 
1033
-			if (!isset($moveTos[$to]))
1034
-				$moveTos[$to] = array();
1091
+			if (!isset($moveTos[$to])) {
1092
+							$moveTos[$to] = array();
1093
+			}
1035 1094
 
1036 1095
 			$moveTos[$to][] = $row['id_topic'];
1037 1096
 
@@ -1045,8 +1104,9 @@  discard block
 block discarded – undo
1045 1104
 		require_once($sourcedir . '/MoveTopic.php');
1046 1105
 
1047 1106
 		// Do the actual moves...
1048
-		foreach ($moveTos as $to => $topics)
1049
-			moveTopics($topics, $to);
1107
+		foreach ($moveTos as $to => $topics) {
1108
+					moveTopics($topics, $to);
1109
+		}
1050 1110
 
1051 1111
 		// Does the post counts need to be updated?
1052 1112
 		if (!empty($moveTos))
@@ -1095,20 +1155,23 @@  discard block
 block discarded – undo
1095 1155
 
1096 1156
 				while ($row = $smcFunc['db_fetch_assoc']($request))
1097 1157
 				{
1098
-					if (!isset($members[$row['id_member']]))
1099
-						$members[$row['id_member']] = 0;
1158
+					if (!isset($members[$row['id_member']])) {
1159
+											$members[$row['id_member']] = 0;
1160
+					}
1100 1161
 
1101
-					if ($topicRecounts[$row['id_topic']] === '+')
1102
-						$members[$row['id_member']] += 1;
1103
-					else
1104
-						$members[$row['id_member']] -= 1;
1162
+					if ($topicRecounts[$row['id_topic']] === '+') {
1163
+											$members[$row['id_member']] += 1;
1164
+					} else {
1165
+											$members[$row['id_member']] -= 1;
1166
+					}
1105 1167
 				}
1106 1168
 
1107 1169
 				$smcFunc['db_free_result']($request);
1108 1170
 
1109 1171
 				// And now update them member's post counts
1110
-				foreach ($members as $id_member => $post_adj)
1111
-					updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1172
+				foreach ($members as $id_member => $post_adj) {
1173
+									updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1174
+				}
1112 1175
 			}
1113 1176
 		}
1114 1177
 	}
@@ -1187,8 +1250,9 @@  discard block
 block discarded – undo
1187 1250
 			approveTopics($approveCache);
1188 1251
 
1189 1252
 			// Time for some logging!
1190
-			foreach ($approveCache as $topic)
1191
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1253
+			foreach ($approveCache as $topic) {
1254
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1255
+			}
1192 1256
 		}
1193 1257
 	}
1194 1258
 
@@ -1223,8 +1287,7 @@  discard block
 block discarded – undo
1223 1287
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1224 1288
 			}
1225 1289
 			$smcFunc['db_free_result']($result);
1226
-		}
1227
-		else
1290
+		} else
1228 1291
 		{
1229 1292
 			$result = $smcFunc['db_query']('', '
1230 1293
 				SELECT id_topic, locked, id_board
@@ -1274,13 +1337,15 @@  discard block
 block discarded – undo
1274 1337
 			)
1275 1338
 		);
1276 1339
 		$logged_topics = array();
1277
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1278
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1340
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1341
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1342
+		}
1279 1343
 		$smcFunc['db_free_result']($request);
1280 1344
 
1281 1345
 		$markArray = array();
1282
-		foreach ($markCache as $topic)
1283
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1346
+		foreach ($markCache as $topic) {
1347
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1348
+		}
1284 1349
 
1285 1350
 		$smcFunc['db_insert']('replace',
1286 1351
 			'{db_prefix}log_topics',
@@ -1293,8 +1358,9 @@  discard block
 block discarded – undo
1293 1358
 	foreach ($moveCache as $topic)
1294 1359
 	{
1295 1360
 		// Didn't actually move anything!
1296
-		if (!isset($topic[0]))
1297
-			break;
1361
+		if (!isset($topic[0])) {
1362
+					break;
1363
+		}
1298 1364
 
1299 1365
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1300 1366
 		sendNotifications($topic[0], 'move');
@@ -1316,8 +1382,9 @@  discard block
 block discarded – undo
1316 1382
 		'calendar_updated' => time(),
1317 1383
 	));
1318 1384
 
1319
-	if (!empty($affectedBoards))
1320
-		updateLastMessages(array_keys($affectedBoards));
1385
+	if (!empty($affectedBoards)) {
1386
+			updateLastMessages(array_keys($affectedBoards));
1387
+	}
1321 1388
 
1322 1389
 	redirectexit($redirect_url);
1323 1390
 }
Please login to merge, or discard this patch.
Themes/default/MessageIndex.template.php 1 patch
Braces   +97 added lines, -68 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $settings, $options, $scripturl, $modSettings, $txt;
19 19
 
20 20
 	// Let them know why their message became unapproved.
21
-	if ($context['becomesUnapproved'])
22
-		echo '
21
+	if ($context['becomesUnapproved']) {
22
+			echo '
23 23
 	<div class="noticebox">
24 24
 		', $txt['post_becomesUnapproved'], '
25 25
 	</div>';
26
+	}
26 27
 
27 28
 	if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
28 29
 	{
@@ -46,17 +47,19 @@  discard block
 block discarded – undo
46 47
 				</a>';
47 48
 
48 49
 			// Has it outstanding posts for approval?
49
-			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
50
-				echo '
50
+			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) {
51
+							echo '
51 52
 				<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
53
+			}
52 54
 
53 55
 			echo '
54 56
 				<p class="board_description">', $board['description'], '</p>';
55 57
 
56 58
 			// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
57
-			if (!empty($board['moderators']) || !empty($board['moderator_groups']))
58
-				echo '
59
+			if (!empty($board['moderators']) || !empty($board['moderator_groups'])) {
60
+							echo '
59 61
 				<p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
62
+			}
60 63
 
61 64
 			// Show some basic information about the number of posts, etc.
62 65
 			echo '
@@ -68,9 +71,10 @@  discard block
 block discarded – undo
68 71
 			</div>
69 72
 			<div class="lastpost lpr_border">';
70 73
 
71
-			if (!empty($board['last_post']['id']))
72
-				echo '
74
+			if (!empty($board['last_post']['id'])) {
75
+							echo '
73 76
 				<p>', $board['last_post']['last_post_message'], '</p>';
77
+			}
74 78
 
75 79
 			echo '
76 80
 			</div>';
@@ -84,14 +88,16 @@  discard block
 block discarded – undo
84 88
 					id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
85 89
 				foreach ($board['children'] as $child)
86 90
 				{
87
-					if (!$child['is_redirect'])
88
-						$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
89
-					else
90
-						$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
91
+					if (!$child['is_redirect']) {
92
+											$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
93
+					} else {
94
+											$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
95
+					}
91 96
 
92 97
 					// Has it posts awaiting approval?
93
-					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics']))
94
-						$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
98
+					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) {
99
+											$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
100
+					}
95 101
 
96 102
 					$children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>';
97 103
 				}
@@ -135,13 +141,15 @@  discard block
 block discarded – undo
135 141
 		<h3>', $context['name'], '</h3>
136 142
 		<p>';
137 143
 
138
-			if ($context['description'] != '')
139
-				echo '
144
+			if ($context['description'] != '') {
145
+							echo '
140 146
 			', $context['description'];
147
+			}
141 148
 
142
-			if (!empty($context['moderators']))
143
-				echo '
149
+			if (!empty($context['moderators'])) {
150
+							echo '
144 151
 			', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.';
152
+			}
145 153
 
146 154
 			echo '
147 155
 		</p>
@@ -149,9 +157,10 @@  discard block
 block discarded – undo
149 157
 		}
150 158
 
151 159
 		// If Quick Moderation is enabled start the form.
152
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
153
-			echo '
160
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
161
+					echo '
154 162
 	<form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">';
163
+		}
155 164
 
156 165
 		echo '
157 166
 		<div id="messageindex">';
@@ -161,11 +170,11 @@  discard block
 block discarded – undo
161 170
 			echo '
162 171
 			<div class="information">';
163 172
 
164
-			if ($settings['display_who_viewing'] == 1)
165
-				echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
166
-
167
-			else
168
-				echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
173
+			if ($settings['display_who_viewing'] == 1) {
174
+							echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
175
+			} else {
176
+							echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
177
+			}
169 178
 			echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'];
170 179
 
171 180
 		echo '
@@ -185,32 +194,36 @@  discard block
 block discarded – undo
185 194
 				<div class="lastpost">', $context['topics_headers']['last_post'], '</div>';
186 195
 
187 196
 			// Show a "select all" box for quick moderation?
188
-			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
189
-				echo '
197
+			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) {
198
+							echo '
190 199
 				<div class="moderation">
191 200
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
192 201
 				</div>';
202
+			}
193 203
 
194 204
 			// If it's on in "image" mode, don't show anything but the column.
195
-			elseif (!empty($context['can_quick_mod']))
196
-				echo '
205
+			elseif (!empty($context['can_quick_mod'])) {
206
+							echo '
197 207
 				<div class="moderation"></div>';
208
+			}
198 209
 		}
199 210
 
200 211
 		// No topics... just say, "sorry bub".
201
-		else
202
-			echo '
212
+		else {
213
+					echo '
203 214
 				<h3 class="titlebg">', $txt['topic_alert_none'], '</h3>';
215
+		}
204 216
 
205 217
 		echo '
206 218
 			</div><!-- #topic_header -->';
207 219
 
208 220
 		// If this person can approve items and we have some awaiting approval tell them.
209
-		if (!empty($context['unapproved_posts_message']))
210
-			echo '
221
+		if (!empty($context['unapproved_posts_message'])) {
222
+					echo '
211 223
 			<div class="information">
212 224
 				<span class="alert">!</span> ', $context['unapproved_posts_message'], '
213 225
 			</div>';
226
+		}
214 227
 
215 228
 		// Contain the topic list
216 229
 		echo '
@@ -231,25 +244,30 @@  discard block
 block discarded – undo
231 244
 			echo '
232 245
 							<div class="icons floatright">';
233 246
 
234
-			if ($topic['is_watched'])
235
-				echo '
247
+			if ($topic['is_watched']) {
248
+							echo '
236 249
 								<span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>';
250
+			}
237 251
 
238
-			if ($topic['is_locked'])
239
-				echo '
252
+			if ($topic['is_locked']) {
253
+							echo '
240 254
 								<span class="generic_icons lock"></span>';
255
+			}
241 256
 
242
-			if ($topic['is_sticky'])
243
-				echo '
257
+			if ($topic['is_sticky']) {
258
+							echo '
244 259
 								<span class="generic_icons sticky"></span>';
260
+			}
245 261
 
246
-			if ($topic['is_redirect'])
247
-				echo '
262
+			if ($topic['is_redirect']) {
263
+							echo '
248 264
 								<span class="generic_icons move"></span>';
265
+			}
249 266
 
250
-			if ($topic['is_poll'])
251
-				echo '
267
+			if ($topic['is_poll']) {
268
+							echo '
252 269
 								<span class="generic_icons poll"></span>';
270
+			}
253 271
 
254 272
 			echo '
255 273
 							</div>';
@@ -281,26 +299,31 @@  discard block
 block discarded – undo
281 299
 				echo '
282 300
 					<div class="moderation">';
283 301
 
284
-				if ($options['display_quick_mod'] == 1)
285
-					echo '
302
+				if ($options['display_quick_mod'] == 1) {
303
+									echo '
286 304
 						<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
287
-				else
305
+				} else
288 306
 				{
289 307
 					// Check permissions on each and show only the ones they are allowed to use.
290
-					if ($topic['quick_mod']['remove'])
291
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
308
+					if ($topic['quick_mod']['remove']) {
309
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
310
+					}
292 311
 
293
-					if ($topic['quick_mod']['lock'])
294
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
312
+					if ($topic['quick_mod']['lock']) {
313
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
314
+					}
295 315
 
296
-					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
297
-						echo '<br>';
316
+					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
317
+											echo '<br>';
318
+					}
298 319
 
299
-					if ($topic['quick_mod']['sticky'])
300
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
320
+					if ($topic['quick_mod']['sticky']) {
321
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
322
+					}
301 323
 
302
-					if ($topic['quick_mod']['move'])
303
-						echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
324
+					if ($topic['quick_mod']['move']) {
325
+											echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
326
+					}
304 327
 				}
305 328
 				echo '
306 329
 					</div><!-- .moderation -->';
@@ -318,18 +341,20 @@  discard block
 block discarded – undo
318 341
 				<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
319 342
 					<option value="">--------</option>';
320 343
 
321
-			foreach ($context['qmod_actions'] as $qmod_action)
322
-				if ($context['can_' . $qmod_action])
344
+			foreach ($context['qmod_actions'] as $qmod_action) {
345
+							if ($context['can_' . $qmod_action])
323 346
 					echo '
324 347
 					<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
348
+			}
325 349
 
326 350
 			echo '
327 351
 				</select>';
328 352
 
329 353
 			// Show a list of boards they can move the topic to.
330
-			if ($context['can_move'])
331
-				echo '
354
+			if ($context['can_move']) {
355
+							echo '
332 356
 				<span id="quick_mod_jump_to"></span>';
357
+			}
333 358
 
334 359
 			echo '
335 360
 				<input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction">
@@ -340,10 +365,11 @@  discard block
 block discarded – undo
340 365
 		</div><!-- #messageindex -->';
341 366
 
342 367
 		// Finish off the form - again.
343
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
344
-			echo '
368
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
369
+					echo '
345 370
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
346 371
 	</form>';
372
+		}
347 373
 
348 374
 		// Mobile action buttons (bottom)
349 375
 		echo '
@@ -365,8 +391,8 @@  discard block
 block discarded – undo
365 391
 	// Show breadcrumbs at the bottom too.
366 392
 	theme_linktree();
367 393
 
368
-	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
369
-		echo '
394
+	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
395
+			echo '
370 396
 	<script>
371 397
 		if (typeof(window.XMLHttpRequest) != "undefined")
372 398
 			aJumpTo[aJumpTo.length] = new JumpTo({
@@ -385,6 +411,7 @@  discard block
 block discarded – undo
385 411
 				sCustomName: "move_to"
386 412
 			});
387 413
 	</script>';
414
+	}
388 415
 
389 416
 	// Javascript for inline editing.
390 417
 	echo '
@@ -421,8 +448,8 @@  discard block
 block discarded – undo
421 448
 		<div class="information">
422 449
 			<p class="floatright" id="message_index_jump_to"></p>';
423 450
 
424
-	if (empty($context['no_topic_listing']))
425
-		echo '
451
+	if (empty($context['no_topic_listing'])) {
452
+			echo '
426 453
 			<p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? '
427 454
 				<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', '
428 455
 				'. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br>
@@ -432,9 +459,10 @@  discard block
 block discarded – undo
432 459
 				<span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br>
433 460
 				<span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br>
434 461
 			</p>';
462
+	}
435 463
 
436
-	if (!empty($context['jump_to']))
437
-		echo '
464
+	if (!empty($context['jump_to'])) {
465
+			echo '
438 466
 			<script>
439 467
 				if (typeof(window.XMLHttpRequest) != "undefined")
440 468
 					aJumpTo[aJumpTo.length] = new JumpTo({
@@ -450,6 +478,7 @@  discard block
 block discarded – undo
450 478
 						sGoButtonLabel: "', $txt['quick_mod_go'], '"
451 479
 					});
452 480
 			</script>';
481
+	}
453 482
 
454 483
 	echo '
455 484
 			<br class="clear">
Please login to merge, or discard this patch.
Sources/Load.php 1 patch
Braces   +792 added lines, -597 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Load the $modSettings array.
@@ -25,13 +26,14 @@  discard block
 block discarded – undo
25 26
 	global $cache_enable, $sourcedir, $context;
26 27
 
27 28
 	// Most database systems have not set UTF-8 as their default input charset.
28
-	if (!empty($db_character_set))
29
-		$smcFunc['db_query']('', '
29
+	if (!empty($db_character_set)) {
30
+			$smcFunc['db_query']('', '
30 31
 			SET NAMES {string:db_character_set}',
31 32
 			array(
32 33
 				'db_character_set' => $db_character_set,
33 34
 			)
34 35
 		);
36
+	}
35 37
 
36 38
 	// We need some caching support, maybe.
37 39
 	loadCacheAccelerator();
@@ -46,28 +48,36 @@  discard block
 block discarded – undo
46 48
 			)
47 49
 		);
48 50
 		$modSettings = array();
49
-		if (!$request)
50
-			display_db_error();
51
-		while ($row = $smcFunc['db_fetch_row']($request))
52
-			$modSettings[$row[0]] = $row[1];
51
+		if (!$request) {
52
+					display_db_error();
53
+		}
54
+		while ($row = $smcFunc['db_fetch_row']($request)) {
55
+					$modSettings[$row[0]] = $row[1];
56
+		}
53 57
 		$smcFunc['db_free_result']($request);
54 58
 
55 59
 		// Do a few things to protect against missing settings or settings with invalid values...
56
-		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
57
-			$modSettings['defaultMaxTopics'] = 20;
58
-		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
59
-			$modSettings['defaultMaxMessages'] = 15;
60
-		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
61
-			$modSettings['defaultMaxMembers'] = 30;
62
-		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
63
-			$modSettings['defaultMaxListItems'] = 15;
60
+		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
61
+					$modSettings['defaultMaxTopics'] = 20;
62
+		}
63
+		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
64
+					$modSettings['defaultMaxMessages'] = 15;
65
+		}
66
+		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
67
+					$modSettings['defaultMaxMembers'] = 30;
68
+		}
69
+		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) {
70
+					$modSettings['defaultMaxListItems'] = 15;
71
+		}
64 72
 
65 73
 		// We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded.
66
-		if (!is_array($modSettings['attachmentUploadDir']))
67
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
74
+		if (!is_array($modSettings['attachmentUploadDir'])) {
75
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
76
+		}
68 77
 
69
-		if (!empty($cache_enable))
70
-			cache_put_data('modSettings', $modSettings, 90);
78
+		if (!empty($cache_enable)) {
79
+					cache_put_data('modSettings', $modSettings, 90);
80
+		}
71 81
 	}
72 82
 
73 83
 	$modSettings['cache_enable'] = $cache_enable;
@@ -87,8 +97,9 @@  discard block
 block discarded – undo
87 97
 		};
88 98
 	$fix_utf8mb4 = function($string) use ($utf8, $smcFunc)
89 99
 	{
90
-		if (!$utf8 || $smcFunc['db_mb4'])
91
-			return $string;
100
+		if (!$utf8 || $smcFunc['db_mb4']) {
101
+					return $string;
102
+		}
92 103
 
93 104
 		$i = 0;
94 105
 		$len = strlen($string);
@@ -100,18 +111,15 @@  discard block
 block discarded – undo
100 111
 			{
101 112
 				$new_string .= $string[$i];
102 113
 				$i++;
103
-			}
104
-			elseif ($ord < 224)
114
+			} elseif ($ord < 224)
105 115
 			{
106 116
 				$new_string .= $string[$i] . $string[$i + 1];
107 117
 				$i += 2;
108
-			}
109
-			elseif ($ord < 240)
118
+			} elseif ($ord < 240)
110 119
 			{
111 120
 				$new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2];
112 121
 				$i += 3;
113
-			}
114
-			elseif ($ord < 248)
122
+			} elseif ($ord < 248)
115 123
 			{
116 124
 				// Magic happens.
117 125
 				$val = (ord($string[$i]) & 0x07) << 18;
@@ -155,8 +163,7 @@  discard block
 block discarded – undo
155 163
 			{
156 164
 				$result = array_search($needle, array_slice($haystack_arr, $offset));
157 165
 				return is_int($result) ? $result + $offset : false;
158
-			}
159
-			else
166
+			} else
160 167
 			{
161 168
 				$needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
162 169
 				$needle_size = count($needle_arr);
@@ -165,8 +172,9 @@  discard block
 block discarded – undo
165 172
 				while ((int) $result === $result)
166 173
 				{
167 174
 					$offset += $result;
168
-					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
169
-						return $offset;
175
+					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) {
176
+											return $offset;
177
+					}
170 178
 					$result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset));
171 179
 				}
172 180
 				return false;
@@ -204,8 +212,9 @@  discard block
 block discarded – undo
204 212
 			$string = $ent_check($string);
205 213
 			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches);
206 214
 			$string = $matches[0];
207
-			while (strlen($string) > $length)
208
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
215
+			while (strlen($string) > $length) {
216
+							$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
217
+			}
209 218
 			return $string;
210 219
 		},
211 220
 		'ucfirst' => $utf8 ? function($string) use (&$smcFunc)
@@ -215,8 +224,9 @@  discard block
 block discarded – undo
215 224
 		'ucwords' => $utf8 ? function($string) use (&$smcFunc)
216 225
 		{
217 226
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
218
-			for ($i = 0, $n = count($words); $i < $n; $i += 2)
219
-				$words[$i] = $smcFunc['ucfirst']($words[$i]);
227
+			for ($i = 0, $n = count($words); $i < $n; $i += 2) {
228
+							$words[$i] = $smcFunc['ucfirst']($words[$i]);
229
+			}
220 230
 			return implode('', $words);
221 231
 		} : 'ucwords',
222 232
 		'json_decode' => 'smf_json_decode',
@@ -224,16 +234,17 @@  discard block
 block discarded – undo
224 234
 	);
225 235
 
226 236
 	// Setting the timezone is a requirement for some functions.
227
-	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list()))
228
-		date_default_timezone_set($modSettings['default_timezone']);
229
-	else
237
+	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) {
238
+			date_default_timezone_set($modSettings['default_timezone']);
239
+	} else
230 240
 	{
231 241
 		// Get PHP's default timezone, if set
232 242
 		$ini_tz = ini_get('date.timezone');
233
-		if (!empty($ini_tz))
234
-			$modSettings['default_timezone'] = $ini_tz;
235
-		else
236
-			$modSettings['default_timezone'] = '';
243
+		if (!empty($ini_tz)) {
244
+					$modSettings['default_timezone'] = $ini_tz;
245
+		} else {
246
+					$modSettings['default_timezone'] = '';
247
+		}
237 248
 
238 249
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
239 250
 		if (!in_array($modSettings['default_timezone'], timezone_identifiers_list()))
@@ -251,22 +262,26 @@  discard block
 block discarded – undo
251 262
 		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
252 263
 		{
253 264
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
254
-			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
255
-				$modSettings['load_average'] = (float) $matches[1];
256
-			elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0)
257
-				$modSettings['load_average'] = (float) $matches[1];
258
-			else
259
-				unset($modSettings['load_average']);
265
+			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
266
+							$modSettings['load_average'] = (float) $matches[1];
267
+			} elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) {
268
+							$modSettings['load_average'] = (float) $matches[1];
269
+			} else {
270
+							unset($modSettings['load_average']);
271
+			}
260 272
 
261
-			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
262
-				cache_put_data('loadavg', $modSettings['load_average'], 90);
273
+			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
274
+							cache_put_data('loadavg', $modSettings['load_average'], 90);
275
+			}
263 276
 		}
264 277
 
265
-		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
266
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
278
+		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
279
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
280
+		}
267 281
 
268
-		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum'])
269
-			display_loadavg_error();
282
+		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
283
+					display_loadavg_error();
284
+		}
270 285
 	}
271 286
 
272 287
 	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
@@ -287,8 +302,9 @@  discard block
 block discarded – undo
287 302
 	if (defined('SMF_INTEGRATION_SETTINGS'))
288 303
 	{
289 304
 		$integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true);
290
-		foreach ($integration_settings as $hook => $function)
291
-			add_integration_function($hook, $function, '', false);
305
+		foreach ($integration_settings as $hook => $function) {
306
+					add_integration_function($hook, $function, '', false);
307
+		}
292 308
 	}
293 309
 
294 310
 	// Any files to pre include?
@@ -298,8 +314,9 @@  discard block
 block discarded – undo
298 314
 		foreach ($pre_includes as $include)
299 315
 		{
300 316
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
301
-			if (file_exists($include))
302
-				require_once($include);
317
+			if (file_exists($include)) {
318
+							require_once($include);
319
+			}
303 320
 		}
304 321
 	}
305 322
 
@@ -392,9 +409,9 @@  discard block
 block discarded – undo
392 409
 				break;
393 410
 			}
394 411
 		}
412
+	} else {
413
+			$id_member = 0;
395 414
 	}
396
-	else
397
-		$id_member = 0;
398 415
 
399 416
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
400 417
 	{
@@ -402,8 +419,9 @@  discard block
 block discarded – undo
402 419
 		$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
403 420
 
404 421
 		// Legacy format (for recent 2.0 --> 2.1 upgrades)
405
-		if (empty($cookie_data))
406
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
422
+		if (empty($cookie_data)) {
423
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
424
+		}
407 425
 
408 426
 		list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, '');
409 427
 
@@ -411,16 +429,17 @@  discard block
 block discarded – undo
411 429
 
412 430
 		// Make sure the cookie is set to the correct domain and path
413 431
 		require_once($sourcedir . '/Subs-Auth.php');
414
-		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])))
415
-			setLoginCookie((int) $login_span - time(), $id_member);
416
-	}
417
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
432
+		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) {
433
+					setLoginCookie((int) $login_span - time(), $id_member);
434
+		}
435
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
418 436
 	{
419 437
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
420 438
 		$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true);
421 439
 
422
-		if (empty($cookie_data))
423
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
440
+		if (empty($cookie_data)) {
441
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
442
+		}
424 443
 
425 444
 		list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, '');
426 445
 		$id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0;
@@ -445,30 +464,34 @@  discard block
 block discarded – undo
445 464
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
446 465
 			$smcFunc['db_free_result']($request);
447 466
 
448
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
449
-				$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
467
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
468
+							$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
469
+			}
450 470
 
451
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
452
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
471
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
472
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
473
+			}
453 474
 		}
454 475
 
455 476
 		// Did we find 'im?  If not, junk it.
456 477
 		if (!empty($user_settings))
457 478
 		{
458 479
 			// As much as the password should be right, we can assume the integration set things up.
459
-			if (!empty($already_verified) && $already_verified === true)
460
-				$check = true;
480
+			if (!empty($already_verified) && $already_verified === true) {
481
+							$check = true;
482
+			}
461 483
 			// SHA-512 hash should be 128 characters long.
462
-			elseif (strlen($password) == 128)
463
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
464
-			else
465
-				$check = false;
484
+			elseif (strlen($password) == 128) {
485
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
486
+			} else {
487
+							$check = false;
488
+			}
466 489
 
467 490
 			// Wrong password or not activated - either way, you're going nowhere.
468 491
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
492
+		} else {
493
+					$id_member = 0;
469 494
 		}
470
-		else
471
-			$id_member = 0;
472 495
 
473 496
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
474 497
 		if (!$id_member)
@@ -497,8 +520,9 @@  discard block
 block discarded – undo
497 520
 
498 521
 					list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, '');
499 522
 
500
-					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member)
501
-						$tfasecret = null;
523
+					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) {
524
+											$tfasecret = null;
525
+					}
502 526
 				}
503 527
 
504 528
 				// They didn't finish logging in before coming here? Then they're no one to us.
@@ -520,10 +544,12 @@  discard block
 block discarded – undo
520 544
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
521 545
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
522 546
 		{
523
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
547
+			if ($modSettings['tfa_mode'] == 2) {
548
+				//only do this if we are just forcing SOME membergroups
524 549
 			{
525 550
 				//Build an array of ALL user membergroups.
526 551
 				$full_groups = array($user_settings['id_group']);
552
+			}
527 553
 				if (!empty($user_settings['additional_groups']))
528 554
 				{
529 555
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -543,15 +569,17 @@  discard block
 block discarded – undo
543 569
 				);
544 570
 				$row = $smcFunc['db_fetch_assoc']($request);
545 571
 				$smcFunc['db_free_result']($request);
572
+			} else {
573
+							$row['total'] = 1;
546 574
 			}
547
-			else
548
-				$row['total'] = 1; //simplifies logics in the next "if"
575
+			//simplifies logics in the next "if"
549 576
 
550 577
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
551 578
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
552 579
 
553
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
554
-				redirectexit('action=profile;area=tfasetup;forced');
580
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
581
+							redirectexit('action=profile;area=tfasetup;forced');
582
+			}
555 583
 		}
556 584
 	}
557 585
 
@@ -588,33 +616,37 @@  discard block
 block discarded – undo
588 616
 				updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
589 617
 				$user_settings['last_login'] = time();
590 618
 
591
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
592
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
619
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
620
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
621
+				}
593 622
 
594
-				if (!empty($modSettings['cache_enable']))
595
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
623
+				if (!empty($modSettings['cache_enable'])) {
624
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
625
+				}
596 626
 			}
627
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
628
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
597 629
 		}
598
-		elseif (empty($_SESSION['id_msg_last_visit']))
599
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
600 630
 
601 631
 		$username = $user_settings['member_name'];
602 632
 
603
-		if (empty($user_settings['additional_groups']))
604
-			$user_info = array(
633
+		if (empty($user_settings['additional_groups'])) {
634
+					$user_info = array(
605 635
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
606 636
 			);
607
-		else
608
-			$user_info = array(
637
+		} else {
638
+					$user_info = array(
609 639
 				'groups' => array_merge(
610 640
 					array($user_settings['id_group'], $user_settings['id_post_group']),
611 641
 					explode(',', $user_settings['additional_groups'])
612 642
 				)
613 643
 			);
644
+		}
614 645
 
615 646
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
616
-		foreach ($user_info['groups'] as $k => $v)
617
-			$user_info['groups'][$k] = (int) $v;
647
+		foreach ($user_info['groups'] as $k => $v) {
648
+					$user_info['groups'][$k] = (int) $v;
649
+		}
618 650
 
619 651
 		// This is a logged in user, so definitely not a spider.
620 652
 		$user_info['possibly_robot'] = false;
@@ -628,8 +660,7 @@  discard block
 block discarded – undo
628 660
 			$time_system = new DateTime('now', $tz_system);
629 661
 			$time_user = new DateTime('now', $tz_user);
630 662
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
631
-		}
632
-		else
663
+		} else
633 664
 		{
634 665
 			// !!! Compatibility.
635 666
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
@@ -643,8 +674,9 @@  discard block
 block discarded – undo
643 674
 		$user_info = array('groups' => array(-1));
644 675
 		$user_settings = array();
645 676
 
646
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
647
-			$_COOKIE[$cookiename] = '';
677
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
678
+					$_COOKIE[$cookiename] = '';
679
+		}
648 680
 
649 681
 		// Expire the 2FA cookie
650 682
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
@@ -661,19 +693,20 @@  discard block
 block discarded – undo
661 693
 		}
662 694
 
663 695
 		// Create a login token if it doesn't exist yet.
664
-		if (!isset($_SESSION['token']['post-login']))
665
-			createToken('login');
666
-		else
667
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
696
+		if (!isset($_SESSION['token']['post-login'])) {
697
+					createToken('login');
698
+		} else {
699
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
700
+		}
668 701
 
669 702
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
670 703
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
671 704
 		{
672 705
 			require_once($sourcedir . '/ManageSearchEngines.php');
673 706
 			$user_info['possibly_robot'] = SpiderCheck();
707
+		} elseif (!empty($modSettings['spider_mode'])) {
708
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
674 709
 		}
675
-		elseif (!empty($modSettings['spider_mode']))
676
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
677 710
 		// If we haven't turned on proper spider hunts then have a guess!
678 711
 		else
679 712
 		{
@@ -721,8 +754,9 @@  discard block
 block discarded – undo
721 754
 	$user_info['groups'] = array_unique($user_info['groups']);
722 755
 
723 756
 	// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
724
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
725
-		unset($user_info['ignoreboards'][$tmp]);
757
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
758
+			unset($user_info['ignoreboards'][$tmp]);
759
+	}
726 760
 
727 761
 	// Allow the user to change their language.
728 762
 	if (!empty($modSettings['userLanguage']))
@@ -735,13 +769,14 @@  discard block
 block discarded – undo
735 769
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
736 770
 
737 771
 			// Make it permanent for members.
738
-			if (!empty($user_info['id']))
739
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
740
-			else
741
-				$_SESSION['language'] = $user_info['language'];
772
+			if (!empty($user_info['id'])) {
773
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
774
+			} else {
775
+							$_SESSION['language'] = $user_info['language'];
776
+			}
777
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
778
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
742 779
 		}
743
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
744
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
745 780
 	}
746 781
 
747 782
 	$temp = build_query_board($user_info['id']);
@@ -804,9 +839,9 @@  discard block
 block discarded – undo
804 839
 		}
805 840
 
806 841
 		// Remember redirection is the key to avoiding fallout from your bosses.
807
-		if (!empty($topic))
808
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
809
-		else
842
+		if (!empty($topic)) {
843
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
844
+		} else
810 845
 		{
811 846
 			loadPermissions();
812 847
 			loadTheme();
@@ -824,10 +859,11 @@  discard block
 block discarded – undo
824 859
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
825 860
 	{
826 861
 		// @todo SLOW?
827
-		if (!empty($topic))
828
-			$temp = cache_get_data('topic_board-' . $topic, 120);
829
-		else
830
-			$temp = cache_get_data('board-' . $board, 120);
862
+		if (!empty($topic)) {
863
+					$temp = cache_get_data('topic_board-' . $topic, 120);
864
+		} else {
865
+					$temp = cache_get_data('board-' . $board, 120);
866
+		}
831 867
 
832 868
 		if (!empty($temp))
833 869
 		{
@@ -865,8 +901,9 @@  discard block
 block discarded – undo
865 901
 			$row = $smcFunc['db_fetch_assoc']($request);
866 902
 
867 903
 			// Set the current board.
868
-			if (!empty($row['id_board']))
869
-				$board = $row['id_board'];
904
+			if (!empty($row['id_board'])) {
905
+							$board = $row['id_board'];
906
+			}
870 907
 
871 908
 			// Basic operating information. (globals... :/)
872 909
 			$board_info = array(
@@ -902,21 +939,23 @@  discard block
 block discarded – undo
902 939
 
903 940
 			do
904 941
 			{
905
-				if (!empty($row['id_moderator']))
906
-					$board_info['moderators'][$row['id_moderator']] = array(
942
+				if (!empty($row['id_moderator'])) {
943
+									$board_info['moderators'][$row['id_moderator']] = array(
907 944
 						'id' => $row['id_moderator'],
908 945
 						'name' => $row['real_name'],
909 946
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
910 947
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
911 948
 					);
949
+				}
912 950
 
913
-				if (!empty($row['id_moderator_group']))
914
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
951
+				if (!empty($row['id_moderator_group'])) {
952
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
915 953
 						'id' => $row['id_moderator_group'],
916 954
 						'name' => $row['group_name'],
917 955
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
918 956
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
919 957
 					);
958
+				}
920 959
 			}
921 960
 			while ($row = $smcFunc['db_fetch_assoc']($request));
922 961
 
@@ -948,12 +987,12 @@  discard block
 block discarded – undo
948 987
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
949 988
 			{
950 989
 				// @todo SLOW?
951
-				if (!empty($topic))
952
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
990
+				if (!empty($topic)) {
991
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
992
+				}
953 993
 				cache_put_data('board-' . $board, $board_info, 120);
954 994
 			}
955
-		}
956
-		else
995
+		} else
957 996
 		{
958 997
 			// Otherwise the topic is invalid, there are no moderators, etc.
959 998
 			$board_info = array(
@@ -967,8 +1006,9 @@  discard block
 block discarded – undo
967 1006
 		$smcFunc['db_free_result']($request);
968 1007
 	}
969 1008
 
970
-	if (!empty($topic))
971
-		$_GET['board'] = (int) $board;
1009
+	if (!empty($topic)) {
1010
+			$_GET['board'] = (int) $board;
1011
+	}
972 1012
 
973 1013
 	if (!empty($board))
974 1014
 	{
@@ -978,10 +1018,12 @@  discard block
 block discarded – undo
978 1018
 		// Now check if the user is a moderator.
979 1019
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
980 1020
 
981
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
982
-			$board_info['error'] = 'access';
983
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
984
-			$board_info['error'] = 'access';
1021
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1022
+					$board_info['error'] = 'access';
1023
+		}
1024
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1025
+					$board_info['error'] = 'access';
1026
+		}
985 1027
 
986 1028
 		// Build up the linktree.
987 1029
 		$context['linktree'] = array_merge(
@@ -1004,8 +1046,9 @@  discard block
 block discarded – undo
1004 1046
 	$context['current_board'] = $board;
1005 1047
 
1006 1048
 	// No posting in redirection boards!
1007
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
1008
-		$board_info['error'] == 'post_in_redirect';
1049
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1050
+			$board_info['error'] == 'post_in_redirect';
1051
+	}
1009 1052
 
1010 1053
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1011 1054
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1031,24 +1074,23 @@  discard block
 block discarded – undo
1031 1074
 			ob_end_clean();
1032 1075
 			header('HTTP/1.1 403 Forbidden');
1033 1076
 			die;
1034
-		}
1035
-		elseif ($board_info['error'] == 'post_in_redirect')
1077
+		} elseif ($board_info['error'] == 'post_in_redirect')
1036 1078
 		{
1037 1079
 			// Slightly different error message here...
1038 1080
 			fatal_lang_error('cannot_post_redirect', false);
1039
-		}
1040
-		elseif ($user_info['is_guest'])
1081
+		} elseif ($user_info['is_guest'])
1041 1082
 		{
1042 1083
 			loadLanguage('Errors');
1043 1084
 			is_not_guest($txt['topic_gone']);
1085
+		} else {
1086
+					fatal_lang_error('topic_gone', false);
1044 1087
 		}
1045
-		else
1046
-			fatal_lang_error('topic_gone', false);
1047 1088
 	}
1048 1089
 
1049
-	if ($user_info['is_mod'])
1050
-		$user_info['groups'][] = 3;
1051
-}
1090
+	if ($user_info['is_mod']) {
1091
+			$user_info['groups'][] = 3;
1092
+	}
1093
+	}
1052 1094
 
1053 1095
 /**
1054 1096
  * Load this user's permissions.
@@ -1069,8 +1111,9 @@  discard block
 block discarded – undo
1069 1111
 		asort($cache_groups);
1070 1112
 		$cache_groups = implode(',', $cache_groups);
1071 1113
 		// If it's a spider then cache it different.
1072
-		if ($user_info['possibly_robot'])
1073
-			$cache_groups .= '-spider';
1114
+		if ($user_info['possibly_robot']) {
1115
+					$cache_groups .= '-spider';
1116
+		}
1074 1117
 
1075 1118
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1076 1119
 		{
@@ -1078,9 +1121,9 @@  discard block
 block discarded – undo
1078 1121
 			banPermissions();
1079 1122
 
1080 1123
 			return;
1124
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1125
+					list ($user_info['permissions'], $removals) = $temp;
1081 1126
 		}
1082
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1083
-			list ($user_info['permissions'], $removals) = $temp;
1084 1127
 	}
1085 1128
 
1086 1129
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1102,23 +1145,26 @@  discard block
 block discarded – undo
1102 1145
 		$removals = array();
1103 1146
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1104 1147
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$removals[] = $row['permission'];
1107
-			else
1108
-				$user_info['permissions'][] = $row['permission'];
1148
+			if (empty($row['add_deny'])) {
1149
+							$removals[] = $row['permission'];
1150
+			} else {
1151
+							$user_info['permissions'][] = $row['permission'];
1152
+			}
1109 1153
 		}
1110 1154
 		$smcFunc['db_free_result']($request);
1111 1155
 
1112
-		if (isset($cache_groups))
1113
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1156
+		if (isset($cache_groups)) {
1157
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1158
+		}
1114 1159
 	}
1115 1160
 
1116 1161
 	// Get the board permissions.
1117 1162
 	if (!empty($board))
1118 1163
 	{
1119 1164
 		// Make sure the board (if any) has been loaded by loadBoard().
1120
-		if (!isset($board_info['profile']))
1121
-			fatal_lang_error('no_board');
1165
+		if (!isset($board_info['profile'])) {
1166
+					fatal_lang_error('no_board');
1167
+		}
1122 1168
 
1123 1169
 		$request = $smcFunc['db_query']('', '
1124 1170
 			SELECT permission, add_deny
@@ -1134,20 +1180,23 @@  discard block
 block discarded – undo
1134 1180
 		);
1135 1181
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1136 1182
 		{
1137
-			if (empty($row['add_deny']))
1138
-				$removals[] = $row['permission'];
1139
-			else
1140
-				$user_info['permissions'][] = $row['permission'];
1183
+			if (empty($row['add_deny'])) {
1184
+							$removals[] = $row['permission'];
1185
+			} else {
1186
+							$user_info['permissions'][] = $row['permission'];
1187
+			}
1141 1188
 		}
1142 1189
 		$smcFunc['db_free_result']($request);
1143 1190
 	}
1144 1191
 
1145 1192
 	// Remove all the permissions they shouldn't have ;).
1146
-	if (!empty($modSettings['permission_enable_deny']))
1147
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1193
+	if (!empty($modSettings['permission_enable_deny'])) {
1194
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1195
+	}
1148 1196
 
1149
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1150
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1197
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1198
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1199
+	}
1151 1200
 
1152 1201
 	// Banned?  Watch, don't touch..
1153 1202
 	banPermissions();
@@ -1159,17 +1208,18 @@  discard block
 block discarded – undo
1159 1208
 		{
1160 1209
 			require_once($sourcedir . '/Subs-Auth.php');
1161 1210
 			rebuildModCache();
1211
+		} else {
1212
+					$user_info['mod_cache'] = $_SESSION['mc'];
1162 1213
 		}
1163
-		else
1164
-			$user_info['mod_cache'] = $_SESSION['mc'];
1165 1214
 
1166 1215
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1167 1216
 		// For example this drastically simplifies certain changes to the profile area.
1168 1217
 		$user_info['permissions'][] = 'is_not_guest';
1169 1218
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1170 1219
 		$user_info['permissions'][] = 'profile_view_own';
1171
-		if (in_array('profile_view', $user_info['permissions']))
1172
-			$user_info['permissions'][] = 'profile_view_any';
1220
+		if (in_array('profile_view', $user_info['permissions'])) {
1221
+					$user_info['permissions'][] = 'profile_view_any';
1222
+		}
1173 1223
 	}
1174 1224
 }
1175 1225
 
@@ -1187,8 +1237,9 @@  discard block
 block discarded – undo
1187 1237
 	global $image_proxy_enabled, $boardurl, $user_info;
1188 1238
 
1189 1239
 	// Can't just look for no users :P.
1190
-	if (empty($users))
1191
-		return array();
1240
+	if (empty($users)) {
1241
+			return array();
1242
+	}
1192 1243
 
1193 1244
 	// Pass the set value
1194 1245
 	$context['loadMemberContext_set'] = $set;
@@ -1203,8 +1254,9 @@  discard block
 block discarded – undo
1203 1254
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1204 1255
 		{
1205 1256
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1206
-			if ($data == null)
1207
-				continue;
1257
+			if ($data == null) {
1258
+							continue;
1259
+			}
1208 1260
 
1209 1261
 			$loaded_ids[] = $data['id_member'];
1210 1262
 			$user_profile[$data['id_member']] = $data;
@@ -1271,16 +1323,19 @@  discard block
 block discarded – undo
1271 1323
 			$row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : '';
1272 1324
 
1273 1325
 			// Take care of proxying avatar if required, do this here for maximum reach
1274
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
1275
-				$row['avatar'] = get_proxied_url($row['avatar']);
1326
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
1327
+							$row['avatar'] = get_proxied_url($row['avatar']);
1328
+			}
1276 1329
 
1277 1330
 			// Keep track of the member's normal member group
1278 1331
 			$row['primary_group'] = $row['member_group'];
1279 1332
 
1280
-			if (isset($row['member_ip']))
1281
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1282
-			if (isset($row['member_ip2']))
1283
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1333
+			if (isset($row['member_ip'])) {
1334
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1335
+			}
1336
+			if (isset($row['member_ip2'])) {
1337
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1338
+			}
1284 1339
 			$new_loaded_ids[] = $row['id_member'];
1285 1340
 			$loaded_ids[] = $row['id_member'];
1286 1341
 			$row['options'] = array();
@@ -1299,8 +1354,9 @@  discard block
 block discarded – undo
1299 1354
 				'loaded_ids' => $new_loaded_ids,
1300 1355
 			)
1301 1356
 		);
1302
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1303
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1357
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1358
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1359
+		}
1304 1360
 		$smcFunc['db_free_result']($request);
1305 1361
 	}
1306 1362
 
@@ -1311,10 +1367,11 @@  discard block
 block discarded – undo
1311 1367
 	{
1312 1368
 		foreach ($loaded_ids as $a_member)
1313 1369
 		{
1314
-			if (!empty($user_profile[$a_member]['additional_groups']))
1315
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1316
-			else
1317
-				$groups = array($user_profile[$a_member]['id_group']);
1370
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1371
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1372
+			} else {
1373
+							$groups = array($user_profile[$a_member]['id_group']);
1374
+			}
1318 1375
 
1319 1376
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1320 1377
 
@@ -1327,8 +1384,9 @@  discard block
 block discarded – undo
1327 1384
 
1328 1385
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1329 1386
 	{
1330
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1331
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1387
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1388
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1389
+		}
1332 1390
 	}
1333 1391
 
1334 1392
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1354,14 +1412,17 @@  discard block
 block discarded – undo
1354 1412
 		foreach ($temp_mods as $id)
1355 1413
 		{
1356 1414
 			// By popular demand, don't show admins or global moderators as moderators.
1357
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1358
-				$user_profile[$id]['member_group'] = $row['member_group'];
1415
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1416
+							$user_profile[$id]['member_group'] = $row['member_group'];
1417
+			}
1359 1418
 
1360 1419
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1361
-			if (!empty($row['icons']))
1362
-				$user_profile[$id]['icons'] = $row['icons'];
1363
-			if (!empty($row['member_group_color']))
1364
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1420
+			if (!empty($row['icons'])) {
1421
+							$user_profile[$id]['icons'] = $row['icons'];
1422
+			}
1423
+			if (!empty($row['member_group_color'])) {
1424
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1425
+			}
1365 1426
 		}
1366 1427
 	}
1367 1428
 
@@ -1383,12 +1444,14 @@  discard block
 block discarded – undo
1383 1444
 	static $loadedLanguages = array();
1384 1445
 
1385 1446
 	// If this person's data is already loaded, skip it.
1386
-	if (isset($dataLoaded[$user]))
1387
-		return true;
1447
+	if (isset($dataLoaded[$user])) {
1448
+			return true;
1449
+	}
1388 1450
 
1389 1451
 	// We can't load guests or members not loaded by loadMemberData()!
1390
-	if ($user == 0)
1391
-		return false;
1452
+	if ($user == 0) {
1453
+			return false;
1454
+	}
1392 1455
 	if (!isset($user_profile[$user]))
1393 1456
 	{
1394 1457
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1414,12 +1477,16 @@  discard block
 block discarded – undo
1414 1477
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1415 1478
 
1416 1479
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1417
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1480
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1481
+		//icon is set and exists
1418 1482
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1419
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1483
+	} elseif (isset($profile['icons'][1])) {
1484
+		//icon is set and doesn't exist, fallback to default
1420 1485
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1421
-	else //not set, bye bye
1486
+	} else {
1487
+		//not set, bye bye
1422 1488
 		$group_icon_url = '';
1489
+	}
1423 1490
 
1424 1491
 	// These minimal values are always loaded
1425 1492
 	$memberContext[$user] = array(
@@ -1438,8 +1505,9 @@  discard block
 block discarded – undo
1438 1505
 	if ($context['loadMemberContext_set'] != 'minimal')
1439 1506
 	{
1440 1507
 		// Go the extra mile and load the user's native language name.
1441
-		if (empty($loadedLanguages))
1442
-			$loadedLanguages = getLanguages();
1508
+		if (empty($loadedLanguages)) {
1509
+					$loadedLanguages = getLanguages();
1510
+		}
1443 1511
 
1444 1512
 		$memberContext[$user] += array(
1445 1513
 			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
@@ -1494,31 +1562,33 @@  discard block
 block discarded – undo
1494 1562
 	{
1495 1563
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1496 1564
 		{
1497
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1498
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1499
-			else
1500
-				$image = get_gravatar_url($profile['email_address']);
1501
-		}
1502
-		else
1565
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1566
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1567
+			} else {
1568
+							$image = get_gravatar_url($profile['email_address']);
1569
+			}
1570
+		} else
1503 1571
 		{
1504 1572
 			// So it's stored in the member table?
1505 1573
 			if (!empty($profile['avatar']))
1506 1574
 			{
1507 1575
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1576
+			} elseif (!empty($profile['filename'])) {
1577
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1508 1578
 			}
1509
-			elseif (!empty($profile['filename']))
1510
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1511 1579
 			// Right... no avatar...use the default one
1512
-			else
1513
-				$image = $modSettings['avatar_url'] . '/default.png';
1580
+			else {
1581
+							$image = $modSettings['avatar_url'] . '/default.png';
1582
+			}
1514 1583
 		}
1515
-		if (!empty($image))
1516
-			$memberContext[$user]['avatar'] = array(
1584
+		if (!empty($image)) {
1585
+					$memberContext[$user]['avatar'] = array(
1517 1586
 				'name' => $profile['avatar'],
1518 1587
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1519 1588
 				'href' => $image,
1520 1589
 				'url' => $image,
1521 1590
 			);
1591
+		}
1522 1592
 	}
1523 1593
 
1524 1594
 	// Are we also loading the members custom fields into context?
@@ -1526,13 +1596,15 @@  discard block
 block discarded – undo
1526 1596
 	{
1527 1597
 		$memberContext[$user]['custom_fields'] = array();
1528 1598
 
1529
-		if (!isset($context['display_fields']))
1530
-			$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1599
+		if (!isset($context['display_fields'])) {
1600
+					$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1601
+		}
1531 1602
 
1532 1603
 		foreach ($context['display_fields'] as $custom)
1533 1604
 		{
1534
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1535
-				continue;
1605
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1606
+							continue;
1607
+			}
1536 1608
 
1537 1609
 			$value = $profile['options'][$custom['col_name']];
1538 1610
 
@@ -1540,31 +1612,36 @@  discard block
 block discarded – undo
1540 1612
 			$currentKey = 0;
1541 1613
 
1542 1614
 			// Create a key => value array for multiple options fields
1543
-			if (!empty($custom['options']))
1544
-				foreach ($custom['options'] as $k => $v)
1615
+			if (!empty($custom['options'])) {
1616
+							foreach ($custom['options'] as $k => $v)
1545 1617
 				{
1546 1618
 					$fieldOptions[] = $v;
1547
-					if (empty($currentKey))
1548
-						$currentKey = $v == $value ? $k : 0;
1619
+			}
1620
+					if (empty($currentKey)) {
1621
+											$currentKey = $v == $value ? $k : 0;
1622
+					}
1549 1623
 				}
1550 1624
 
1551 1625
 			// BBC?
1552
-			if ($custom['bbc'])
1553
-				$value = parse_bbc($value);
1626
+			if ($custom['bbc']) {
1627
+							$value = parse_bbc($value);
1628
+			}
1554 1629
 
1555 1630
 			// ... or checkbox?
1556
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1557
-				$value = $value ? $txt['yes'] : $txt['no'];
1631
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1632
+							$value = $value ? $txt['yes'] : $txt['no'];
1633
+			}
1558 1634
 
1559 1635
 			// Enclosing the user input within some other text?
1560
-			if (!empty($custom['enclose']))
1561
-				$value = strtr($custom['enclose'], array(
1636
+			if (!empty($custom['enclose'])) {
1637
+							$value = strtr($custom['enclose'], array(
1562 1638
 					'{SCRIPTURL}' => $scripturl,
1563 1639
 					'{IMAGES_URL}' => $settings['images_url'],
1564 1640
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1565 1641
 					'{INPUT}' => $value,
1566 1642
 					'{KEY}' => $currentKey,
1567 1643
 				));
1644
+			}
1568 1645
 
1569 1646
 			$memberContext[$user]['custom_fields'][] = array(
1570 1647
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1591,8 +1668,9 @@  discard block
 block discarded – undo
1591 1668
 	global $smcFunc, $txt, $scripturl, $settings;
1592 1669
 
1593 1670
 	// Do not waste my time...
1594
-	if (empty($users) || empty($params))
1595
-		return false;
1671
+	if (empty($users) || empty($params)) {
1672
+			return false;
1673
+	}
1596 1674
 
1597 1675
 	// Make sure it's an array.
1598 1676
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1619,41 +1697,48 @@  discard block
 block discarded – undo
1619 1697
 		$currentKey = 0;
1620 1698
 
1621 1699
 		// Create a key => value array for multiple options fields
1622
-		if (!empty($row['field_options']))
1623
-			foreach (explode(',', $row['field_options']) as $k => $v)
1700
+		if (!empty($row['field_options'])) {
1701
+					foreach (explode(',', $row['field_options']) as $k => $v)
1624 1702
 			{
1625 1703
 				$fieldOptions[] = $v;
1626
-				if (empty($currentKey))
1627
-					$currentKey = $v == $row['value'] ? $k : 0;
1704
+		}
1705
+				if (empty($currentKey)) {
1706
+									$currentKey = $v == $row['value'] ? $k : 0;
1707
+				}
1628 1708
 			}
1629 1709
 
1630 1710
 		// BBC?
1631
-		if (!empty($row['bbc']))
1632
-			$row['value'] = parse_bbc($row['value']);
1711
+		if (!empty($row['bbc'])) {
1712
+					$row['value'] = parse_bbc($row['value']);
1713
+		}
1633 1714
 
1634 1715
 		// ... or checkbox?
1635
-		elseif (isset($row['type']) && $row['type'] == 'check')
1636
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1716
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1717
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1718
+		}
1637 1719
 
1638 1720
 		// Enclosing the user input within some other text?
1639
-		if (!empty($row['enclose']))
1640
-			$row['value'] = strtr($row['enclose'], array(
1721
+		if (!empty($row['enclose'])) {
1722
+					$row['value'] = strtr($row['enclose'], array(
1641 1723
 				'{SCRIPTURL}' => $scripturl,
1642 1724
 				'{IMAGES_URL}' => $settings['images_url'],
1643 1725
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1644 1726
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1645 1727
 				'{KEY}' => $currentKey,
1646 1728
 			));
1729
+		}
1647 1730
 
1648 1731
 		// Send a simple array if there is just 1 param
1649
-		if (count($params) == 1)
1650
-			$return[$row['id_member']] = $row;
1732
+		if (count($params) == 1) {
1733
+					$return[$row['id_member']] = $row;
1734
+		}
1651 1735
 
1652 1736
 		// More than 1? knock yourself out...
1653 1737
 		else
1654 1738
 		{
1655
-			if (!isset($return[$row['id_member']]))
1656
-				$return[$row['id_member']] = array();
1739
+			if (!isset($return[$row['id_member']])) {
1740
+							$return[$row['id_member']] = array();
1741
+			}
1657 1742
 
1658 1743
 			$return[$row['id_member']][$row['variable']] = $row;
1659 1744
 		}
@@ -1687,8 +1772,9 @@  discard block
 block discarded – undo
1687 1772
 	global $context;
1688 1773
 
1689 1774
 	// Don't know any browser!
1690
-	if (empty($context['browser']))
1691
-		detectBrowser();
1775
+	if (empty($context['browser'])) {
1776
+			detectBrowser();
1777
+	}
1692 1778
 
1693 1779
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1694 1780
 }
@@ -1706,8 +1792,9 @@  discard block
 block discarded – undo
1706 1792
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1707 1793
 
1708 1794
 	// The theme was specified by parameter.
1709
-	if (!empty($id_theme))
1710
-		$id_theme = (int) $id_theme;
1795
+	if (!empty($id_theme)) {
1796
+			$id_theme = (int) $id_theme;
1797
+	}
1711 1798
 	// The theme was specified by REQUEST.
1712 1799
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1713 1800
 	{
@@ -1715,32 +1802,38 @@  discard block
 block discarded – undo
1715 1802
 		$_SESSION['id_theme'] = $id_theme;
1716 1803
 	}
1717 1804
 	// The theme was specified by REQUEST... previously.
1718
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1719
-		$id_theme = (int) $_SESSION['id_theme'];
1805
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1806
+			$id_theme = (int) $_SESSION['id_theme'];
1807
+	}
1720 1808
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1721
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1722
-		$id_theme = $user_info['theme'];
1809
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1810
+			$id_theme = $user_info['theme'];
1811
+	}
1723 1812
 	// The theme was specified by the board.
1724
-	elseif (!empty($board_info['theme']))
1725
-		$id_theme = $board_info['theme'];
1813
+	elseif (!empty($board_info['theme'])) {
1814
+			$id_theme = $board_info['theme'];
1815
+	}
1726 1816
 	// The theme is the forum's default.
1727
-	else
1728
-		$id_theme = $modSettings['theme_guests'];
1817
+	else {
1818
+			$id_theme = $modSettings['theme_guests'];
1819
+	}
1729 1820
 
1730 1821
 	// Verify the id_theme... no foul play.
1731 1822
 	// Always allow the board specific theme, if they are overriding.
1732
-	if (!empty($board_info['theme']) && $board_info['override_theme'])
1733
-		$id_theme = $board_info['theme'];
1823
+	if (!empty($board_info['theme']) && $board_info['override_theme']) {
1824
+			$id_theme = $board_info['theme'];
1825
+	}
1734 1826
 	// If they have specified a particular theme to use with SSI allow it to be used.
1735
-	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1736
-		$id_theme = (int) $id_theme;
1737
-	elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1827
+	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1828
+			$id_theme = (int) $id_theme;
1829
+	} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1738 1830
 	{
1739 1831
 		$themes = explode(',', $modSettings['enableThemes']);
1740
-		if (!in_array($id_theme, $themes))
1741
-			$id_theme = $modSettings['theme_guests'];
1742
-		else
1743
-			$id_theme = (int) $id_theme;
1832
+		if (!in_array($id_theme, $themes)) {
1833
+					$id_theme = $modSettings['theme_guests'];
1834
+		} else {
1835
+					$id_theme = (int) $id_theme;
1836
+		}
1744 1837
 	}
1745 1838
 		
1746 1839
 	// We already load the basic stuff?
@@ -1749,18 +1842,19 @@  discard block
 block discarded – undo
1749 1842
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1750 1843
 
1751 1844
 		// Disable image proxy if we don't have SSL enabled
1752
-		if (empty($modSettings['force_ssl']))
1753
-			$image_proxy_enabled = false;
1845
+		if (empty($modSettings['force_ssl'])) {
1846
+					$image_proxy_enabled = false;
1847
+		}
1754 1848
 
1755 1849
 		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated'])
1756 1850
 		{
1757 1851
 			$themeData = $temp;
1758 1852
 			$flag = true;
1853
+		} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1854
+					$themeData = $temp + array($member => array());
1855
+		} else {
1856
+					$themeData = array(-1 => array(), 0 => array(), $member => array());
1759 1857
 		}
1760
-		elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1761
-			$themeData = $temp + array($member => array());
1762
-		else
1763
-			$themeData = array(-1 => array(), 0 => array(), $member => array());
1764 1858
 
1765 1859
 		if (empty($flag))
1766 1860
 		{
@@ -1780,31 +1874,37 @@  discard block
 block discarded – undo
1780 1874
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1781 1875
 			{
1782 1876
 				// There are just things we shouldn't be able to change as members.
1783
-				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url')))
1784
-					continue;
1877
+				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
1878
+									continue;
1879
+				}
1785 1880
 
1786 1881
 				// If this is the theme_dir of the default theme, store it.
1787
-				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1788
-					$themeData[0]['default_' . $row['variable']] = $row['value'];
1882
+				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1883
+									$themeData[0]['default_' . $row['variable']] = $row['value'];
1884
+				}
1789 1885
 
1790 1886
 				// If this isn't set yet, is a theme option, or is not the default theme..
1791
-				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1792
-					$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1887
+				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1888
+									$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1889
+				}
1793 1890
 			}
1794 1891
 			$smcFunc['db_free_result']($result);
1795 1892
 
1796
-			if (!empty($themeData[-1]))
1797
-				foreach ($themeData[-1] as $k => $v)
1893
+			if (!empty($themeData[-1])) {
1894
+							foreach ($themeData[-1] as $k => $v)
1798 1895
 				{
1799 1896
 					if (!isset($themeData[$member][$k]))
1800 1897
 						$themeData[$member][$k] = $v;
1898
+			}
1801 1899
 				}
1802 1900
 
1803
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1804
-				cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1901
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1902
+							cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1903
+			}
1805 1904
 			// Only if we didn't already load that part of the cache...
1806
-			elseif (!isset($temp))
1807
-				cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1905
+			elseif (!isset($temp)) {
1906
+							cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1907
+			}
1808 1908
 		}
1809 1909
 
1810 1910
 		$settings = $themeData[0];
@@ -1821,17 +1921,20 @@  discard block
 block discarded – undo
1821 1921
 		$settings['template_dirs'][] = $settings['theme_dir'];
1822 1922
 
1823 1923
 		// Based on theme (if there is one).
1824
-		if (!empty($settings['base_theme_dir']))
1825
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1924
+		if (!empty($settings['base_theme_dir'])) {
1925
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1926
+		}
1826 1927
 
1827 1928
 		// Lastly the default theme.
1828
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1829
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1929
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1930
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1931
+		}
1830 1932
 	}
1831 1933
 
1832 1934
 
1833
-	if (!$initialize)
1834
-		return;
1935
+	if (!$initialize) {
1936
+			return;
1937
+	}
1835 1938
 
1836 1939
 	// Check to see if we're forcing SSL
1837 1940
 	if (!empty($modSettings['force_ssl']) && empty($maintenance) &&
@@ -1852,8 +1955,9 @@  discard block
 block discarded – undo
1852 1955
 		$detected_url = httpsOn() ? 'https://' : 'http://';
1853 1956
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1854 1957
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1855
-		if ($temp != '/')
1856
-			$detected_url .= $temp;
1958
+		if ($temp != '/') {
1959
+					$detected_url .= $temp;
1960
+		}
1857 1961
 	}
1858 1962
 	if (isset($detected_url) && $detected_url != $boardurl)
1859 1963
 	{
@@ -1865,8 +1969,9 @@  discard block
 block discarded – undo
1865 1969
 			foreach ($aliases as $alias)
1866 1970
 			{
1867 1971
 				// Rip off all the boring parts, spaces, etc.
1868
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1869
-					$do_fix = true;
1972
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1973
+									$do_fix = true;
1974
+				}
1870 1975
 			}
1871 1976
 		}
1872 1977
 
@@ -1874,21 +1979,23 @@  discard block
 block discarded – undo
1874 1979
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1875 1980
 		{
1876 1981
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1877
-			if (empty($_GET))
1878
-				redirectexit('wwwRedirect');
1879
-			else
1982
+			if (empty($_GET)) {
1983
+							redirectexit('wwwRedirect');
1984
+			} else
1880 1985
 			{
1881 1986
 				$k = key($_GET);
1882 1987
 				$v = current($_GET);
1883 1988
 
1884
-				if ($k != 'wwwRedirect')
1885
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1989
+				if ($k != 'wwwRedirect') {
1990
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1991
+				}
1886 1992
 			}
1887 1993
 		}
1888 1994
 
1889 1995
 		// #3 is just a check for SSL...
1890
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1891
-			$do_fix = true;
1996
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1997
+					$do_fix = true;
1998
+		}
1892 1999
 
1893 2000
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1894 2001
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1923,8 +2030,9 @@  discard block
 block discarded – undo
1923 2030
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1924 2031
 				}
1925 2032
 			}
1926
-			foreach ($context['linktree'] as $k => $dummy)
1927
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2033
+			foreach ($context['linktree'] as $k => $dummy) {
2034
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2035
+			}
1928 2036
 		}
1929 2037
 	}
1930 2038
 	// Set up the contextual user array.
@@ -1943,16 +2051,16 @@  discard block
 block discarded – undo
1943 2051
 			'email' => $user_info['email'],
1944 2052
 			'ignoreusers' => $user_info['ignoreusers'],
1945 2053
 		);
1946
-		if (!$context['user']['is_guest'])
1947
-			$context['user']['name'] = $user_info['name'];
1948
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1949
-			$context['user']['name'] = $txt['guest_title'];
2054
+		if (!$context['user']['is_guest']) {
2055
+					$context['user']['name'] = $user_info['name'];
2056
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2057
+					$context['user']['name'] = $txt['guest_title'];
2058
+		}
1950 2059
 
1951 2060
 		// Determine the current smiley set.
1952 2061
 		$user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];
1953 2062
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1954
-	}
1955
-	else
2063
+	} else
1956 2064
 	{
1957 2065
 		// What to do when there is no $user_info (e.g., an error very early in the login process)
1958 2066
 		$context['user'] = array(
@@ -1986,18 +2094,24 @@  discard block
 block discarded – undo
1986 2094
 	}
1987 2095
 
1988 2096
 	// Some basic information...
1989
-	if (!isset($context['html_headers']))
1990
-		$context['html_headers'] = '';
1991
-	if (!isset($context['javascript_files']))
1992
-		$context['javascript_files'] = array();
1993
-	if (!isset($context['css_files']))
1994
-		$context['css_files'] = array();
1995
-	if (!isset($context['css_header']))
1996
-		$context['css_header'] = array();
1997
-	if (!isset($context['javascript_inline']))
1998
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1999
-	if (!isset($context['javascript_vars']))
2000
-		$context['javascript_vars'] = array();
2097
+	if (!isset($context['html_headers'])) {
2098
+			$context['html_headers'] = '';
2099
+	}
2100
+	if (!isset($context['javascript_files'])) {
2101
+			$context['javascript_files'] = array();
2102
+	}
2103
+	if (!isset($context['css_files'])) {
2104
+			$context['css_files'] = array();
2105
+	}
2106
+	if (!isset($context['css_header'])) {
2107
+			$context['css_header'] = array();
2108
+	}
2109
+	if (!isset($context['javascript_inline'])) {
2110
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2111
+	}
2112
+	if (!isset($context['javascript_vars'])) {
2113
+			$context['javascript_vars'] = array();
2114
+	}
2001 2115
 
2002 2116
 	$context['login_url'] =  $scripturl . '?action=login2';
2003 2117
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -2009,16 +2123,18 @@  discard block
 block discarded – undo
2009 2123
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
2010 2124
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
2011 2125
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
2012
-	if (isset($modSettings['load_average']))
2013
-		$context['load_average'] = $modSettings['load_average'];
2126
+	if (isset($modSettings['load_average'])) {
2127
+			$context['load_average'] = $modSettings['load_average'];
2128
+	}
2014 2129
 
2015 2130
 	// Detect the browser. This is separated out because it's also used in attachment downloads
2016 2131
 	detectBrowser();
2017 2132
 
2018 2133
 	// Set the top level linktree up.
2019 2134
 	// Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet...
2020
-	if (empty($context['linktree']))
2021
-		$context['linktree'] = array();
2135
+	if (empty($context['linktree'])) {
2136
+			$context['linktree'] = array();
2137
+	}
2022 2138
 	array_unshift($context['linktree'], array(
2023 2139
 		'url' => $scripturl,
2024 2140
 		'name' => $context['forum_name_html_safe']
@@ -2027,8 +2143,9 @@  discard block
 block discarded – undo
2027 2143
 	// This allows sticking some HTML on the page output - useful for controls.
2028 2144
 	$context['insert_after_template'] = '';
2029 2145
 
2030
-	if (!isset($txt))
2031
-		$txt = array();
2146
+	if (!isset($txt)) {
2147
+			$txt = array();
2148
+	}
2032 2149
 
2033 2150
 	$simpleActions = array(
2034 2151
 		'findmember',
@@ -2074,9 +2191,10 @@  discard block
 block discarded – undo
2074 2191
 
2075 2192
 	// See if theres any extra param to check.
2076 2193
 	$requiresXML = false;
2077
-	foreach ($extraParams as $key => $extra)
2078
-		if (isset($_REQUEST[$extra]))
2194
+	foreach ($extraParams as $key => $extra) {
2195
+			if (isset($_REQUEST[$extra]))
2079 2196
 			$requiresXML = true;
2197
+	}
2080 2198
 
2081 2199
 	// Output is fully XML, so no need for the index template.
2082 2200
 	if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML))
@@ -2091,37 +2209,39 @@  discard block
 block discarded – undo
2091 2209
 	{
2092 2210
 		loadLanguage('index+Modifications');
2093 2211
 		$context['template_layers'] = array();
2094
-	}
2095
-
2096
-	else
2212
+	} else
2097 2213
 	{
2098 2214
 		// Custom templates to load, or just default?
2099
-		if (isset($settings['theme_templates']))
2100
-			$templates = explode(',', $settings['theme_templates']);
2101
-		else
2102
-			$templates = array('index');
2215
+		if (isset($settings['theme_templates'])) {
2216
+					$templates = explode(',', $settings['theme_templates']);
2217
+		} else {
2218
+					$templates = array('index');
2219
+		}
2103 2220
 
2104 2221
 		// Load each template...
2105
-		foreach ($templates as $template)
2106
-			loadTemplate($template);
2222
+		foreach ($templates as $template) {
2223
+					loadTemplate($template);
2224
+		}
2107 2225
 
2108 2226
 		// ...and attempt to load their associated language files.
2109 2227
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2110 2228
 		loadLanguage($required_files, '', false);
2111 2229
 
2112 2230
 		// Custom template layers?
2113
-		if (isset($settings['theme_layers']))
2114
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2115
-		else
2116
-			$context['template_layers'] = array('html', 'body');
2231
+		if (isset($settings['theme_layers'])) {
2232
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2233
+		} else {
2234
+					$context['template_layers'] = array('html', 'body');
2235
+		}
2117 2236
 	}
2118 2237
 
2119 2238
 	// Initialize the theme.
2120 2239
 	loadSubTemplate('init', 'ignore');
2121 2240
 
2122 2241
 	// Allow overriding the board wide time/number formats.
2123
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2124
-		$user_info['time_format'] = $txt['time_format'];
2242
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2243
+			$user_info['time_format'] = $txt['time_format'];
2244
+	}
2125 2245
 
2126 2246
 	// Set the character set from the template.
2127 2247
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2129,12 +2249,14 @@  discard block
 block discarded – undo
2129 2249
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2130 2250
 
2131 2251
 	// Guests may still need a name.
2132
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2133
-		$context['user']['name'] = $txt['guest_title'];
2252
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2253
+			$context['user']['name'] = $txt['guest_title'];
2254
+	}
2134 2255
 
2135 2256
 	// Any theme-related strings that need to be loaded?
2136
-	if (!empty($settings['require_theme_strings']))
2137
-		loadLanguage('ThemeStrings', '', false);
2257
+	if (!empty($settings['require_theme_strings'])) {
2258
+			loadLanguage('ThemeStrings', '', false);
2259
+	}
2138 2260
 
2139 2261
 	// Make a special URL for the language.
2140 2262
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2145,8 +2267,9 @@  discard block
 block discarded – undo
2145 2267
 	// Here is my luvly Responsive CSS
2146 2268
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive');
2147 2269
 
2148
-	if ($context['right_to_left'])
2149
-		loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2270
+	if ($context['right_to_left']) {
2271
+			loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2272
+	}
2150 2273
 
2151 2274
 	// We allow theme variants, because we're cool.
2152 2275
 	$context['theme_variant'] = '';
@@ -2154,14 +2277,17 @@  discard block
 block discarded – undo
2154 2277
 	if (!empty($settings['theme_variants']))
2155 2278
 	{
2156 2279
 		// Overriding - for previews and that ilk.
2157
-		if (!empty($_REQUEST['variant']))
2158
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2280
+		if (!empty($_REQUEST['variant'])) {
2281
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2282
+		}
2159 2283
 		// User selection?
2160
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2161
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2284
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2285
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2286
+		}
2162 2287
 		// If not a user variant, select the default.
2163
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2164
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2288
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2289
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2290
+		}
2165 2291
 
2166 2292
 		// Do this to keep things easier in the templates.
2167 2293
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2170,20 +2296,23 @@  discard block
 block discarded – undo
2170 2296
 		if (!empty($context['theme_variant']))
2171 2297
 		{
2172 2298
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']);
2173
-			if ($context['right_to_left'])
2174
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2299
+			if ($context['right_to_left']) {
2300
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2301
+			}
2175 2302
 		}
2176 2303
 	}
2177 2304
 
2178 2305
 	// Let's be compatible with old themes!
2179
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2180
-		$context['template_layers'] = array('main');
2306
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2307
+			$context['template_layers'] = array('main');
2308
+	}
2181 2309
 
2182 2310
 	$context['tabindex'] = 1;
2183 2311
 
2184 2312
 	// Compatibility.
2185
-	if (!isset($settings['theme_version']))
2186
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2313
+	if (!isset($settings['theme_version'])) {
2314
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2315
+	}
2187 2316
 
2188 2317
 	// Default JS variables for use in every theme
2189 2318
 	$context['javascript_vars'] = array(
@@ -2202,18 +2331,18 @@  discard block
 block discarded – undo
2202 2331
 	);
2203 2332
 
2204 2333
 	// Add the JQuery library to the list of files to load.
2205
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2206
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2207
-
2208
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2209
-		loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2210
-
2211
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2212
-		loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2334
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2335
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2336
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2337
+			loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2338
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2339
+			loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2340
+	}
2213 2341
 
2214 2342
 	// Auto loading? template_javascript() will take care of the local half of this.
2215
-	else
2216
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2343
+	else {
2344
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2345
+	}
2217 2346
 
2218 2347
 	// Queue our JQuery plugins!
2219 2348
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2236,12 +2365,12 @@  discard block
 block discarded – undo
2236 2365
 			require_once($sourcedir . '/ScheduledTasks.php');
2237 2366
 
2238 2367
 			// What to do, what to do?!
2239
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2240
-				AutoTask();
2241
-			else
2242
-				ReduceMailQueue();
2243
-		}
2244
-		else
2368
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2369
+							AutoTask();
2370
+			} else {
2371
+							ReduceMailQueue();
2372
+			}
2373
+		} else
2245 2374
 		{
2246 2375
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2247 2376
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2292,8 +2421,9 @@  discard block
 block discarded – undo
2292 2421
 		foreach ($theme_includes as $include)
2293 2422
 		{
2294 2423
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2295
-			if (file_exists($include))
2296
-				require_once($include);
2424
+			if (file_exists($include)) {
2425
+							require_once($include);
2426
+			}
2297 2427
 		}
2298 2428
 	}
2299 2429
 
@@ -2323,16 +2453,19 @@  discard block
 block discarded – undo
2323 2453
 	// Do any style sheets first, cause we're easy with those.
2324 2454
 	if (!empty($style_sheets))
2325 2455
 	{
2326
-		if (!is_array($style_sheets))
2327
-			$style_sheets = array($style_sheets);
2456
+		if (!is_array($style_sheets)) {
2457
+					$style_sheets = array($style_sheets);
2458
+		}
2328 2459
 
2329
-		foreach ($style_sheets as $sheet)
2330
-			loadCSSFile($sheet . '.css', array(), $sheet);
2460
+		foreach ($style_sheets as $sheet) {
2461
+					loadCSSFile($sheet . '.css', array(), $sheet);
2462
+		}
2331 2463
 	}
2332 2464
 
2333 2465
 	// No template to load?
2334
-	if ($template_name === false)
2335
-		return true;
2466
+	if ($template_name === false) {
2467
+			return true;
2468
+	}
2336 2469
 
2337 2470
 	$loaded = false;
2338 2471
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2347,12 +2480,14 @@  discard block
 block discarded – undo
2347 2480
 
2348 2481
 	if ($loaded)
2349 2482
 	{
2350
-		if ($db_show_debug === true)
2351
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2483
+		if ($db_show_debug === true) {
2484
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2485
+		}
2352 2486
 
2353 2487
 		// If they have specified an initialization function for this template, go ahead and call it now.
2354
-		if (function_exists('template_' . $template_name . '_init'))
2355
-			call_user_func('template_' . $template_name . '_init');
2488
+		if (function_exists('template_' . $template_name . '_init')) {
2489
+					call_user_func('template_' . $template_name . '_init');
2490
+		}
2356 2491
 	}
2357 2492
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2358 2493
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2372,13 +2507,14 @@  discard block
 block discarded – undo
2372 2507
 		loadTemplate($template_name);
2373 2508
 	}
2374 2509
 	// Cause an error otherwise.
2375
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2376
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2377
-	elseif ($fatal)
2378
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2379
-	else
2380
-		return false;
2381
-}
2510
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2511
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2512
+	} elseif ($fatal) {
2513
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2514
+	} else {
2515
+			return false;
2516
+	}
2517
+	}
2382 2518
 
2383 2519
 /**
2384 2520
  * Load a sub-template.
@@ -2396,17 +2532,19 @@  discard block
 block discarded – undo
2396 2532
 {
2397 2533
 	global $context, $txt, $db_show_debug;
2398 2534
 
2399
-	if ($db_show_debug === true)
2400
-		$context['debug']['sub_templates'][] = $sub_template_name;
2535
+	if ($db_show_debug === true) {
2536
+			$context['debug']['sub_templates'][] = $sub_template_name;
2537
+	}
2401 2538
 
2402 2539
 	// Figure out what the template function is named.
2403 2540
 	$theme_function = 'template_' . $sub_template_name;
2404
-	if (function_exists($theme_function))
2405
-		$theme_function();
2406
-	elseif ($fatal === false)
2407
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2408
-	elseif ($fatal !== 'ignore')
2409
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2541
+	if (function_exists($theme_function)) {
2542
+			$theme_function();
2543
+	} elseif ($fatal === false) {
2544
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2545
+	} elseif ($fatal !== 'ignore') {
2546
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2547
+	}
2410 2548
 
2411 2549
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2412 2550
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2436,8 +2574,9 @@  discard block
 block discarded – undo
2436 2574
 {
2437 2575
 	global $settings, $context, $modSettings;
2438 2576
 
2439
-	if (empty($context['css_files_order']))
2440
-		$context['css_files_order'] = array();
2577
+	if (empty($context['css_files_order'])) {
2578
+			$context['css_files_order'] = array();
2579
+	}
2441 2580
 
2442 2581
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : '');
2443 2582
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
@@ -2448,8 +2587,9 @@  discard block
 block discarded – undo
2448 2587
 	$params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000;
2449 2588
 
2450 2589
 	// If this is an external file, automatically set this to false.
2451
-	if (!empty($params['external']))
2452
-		$params['minimize'] = false;
2590
+	if (!empty($params['external'])) {
2591
+			$params['minimize'] = false;
2592
+	}
2453 2593
 
2454 2594
 	// Account for shorthand like admin.css?alp21 filenames
2455 2595
 	$has_seed = strpos($fileName, '.css?');
@@ -2466,16 +2606,12 @@  discard block
 block discarded – undo
2466 2606
 			{
2467 2607
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2468 2608
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2469
-			}
2470
-
2471
-			else
2609
+			} else
2472 2610
 			{
2473 2611
 				$fileUrl = false;
2474 2612
 				$filePath = false;
2475 2613
 			}
2476
-		}
2477
-
2478
-		else
2614
+		} else
2479 2615
 		{
2480 2616
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2481 2617
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2493,16 +2629,18 @@  discard block
 block discarded – undo
2493 2629
 	if (!empty($fileName))
2494 2630
 	{
2495 2631
 		// find a free number/position
2496
-		while (isset($context['css_files_order'][$params['order_pos']]))
2497
-			$params['order_pos']++;
2632
+		while (isset($context['css_files_order'][$params['order_pos']])) {
2633
+					$params['order_pos']++;
2634
+		}
2498 2635
 		$context['css_files_order'][$params['order_pos']] = $id;
2499 2636
 
2500 2637
 		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2501 2638
 	}
2502 2639
 
2503
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2504
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2505
-}
2640
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2641
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2642
+	}
2643
+	}
2506 2644
 
2507 2645
 /**
2508 2646
  * Add a block of inline css code to be executed later
@@ -2519,8 +2657,9 @@  discard block
 block discarded – undo
2519 2657
 	global $context;
2520 2658
 
2521 2659
 	// Gotta add something...
2522
-	if (empty($css))
2523
-		return false;
2660
+	if (empty($css)) {
2661
+			return false;
2662
+	}
2524 2663
 
2525 2664
 	$context['css_header'][] = $css;
2526 2665
 }
@@ -2556,8 +2695,9 @@  discard block
 block discarded – undo
2556 2695
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2557 2696
 
2558 2697
 	// If this is an external file, automatically set this to false.
2559
-	if (!empty($params['external']))
2560
-		$params['minimize'] = false;
2698
+	if (!empty($params['external'])) {
2699
+			$params['minimize'] = false;
2700
+	}
2561 2701
 
2562 2702
 	// Account for shorthand like admin.js?alp21 filenames
2563 2703
 	$has_seed = strpos($fileName, '.js?');
@@ -2574,16 +2714,12 @@  discard block
 block discarded – undo
2574 2714
 			{
2575 2715
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2576 2716
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2577
-			}
2578
-
2579
-			else
2717
+			} else
2580 2718
 			{
2581 2719
 				$fileUrl = false;
2582 2720
 				$filePath = false;
2583 2721
 			}
2584
-		}
2585
-
2586
-		else
2722
+		} else
2587 2723
 		{
2588 2724
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2589 2725
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2598,9 +2734,10 @@  discard block
 block discarded – undo
2598 2734
 	}
2599 2735
 
2600 2736
 	// Add it to the array for use in the template
2601
-	if (!empty($fileName))
2602
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2603
-}
2737
+	if (!empty($fileName)) {
2738
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2739
+	}
2740
+	}
2604 2741
 
2605 2742
 /**
2606 2743
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2614,9 +2751,10 @@  discard block
 block discarded – undo
2614 2751
 {
2615 2752
 	global $context;
2616 2753
 
2617
-	if (!empty($key) && (!empty($value) || $value === '0'))
2618
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2619
-}
2754
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2755
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2756
+	}
2757
+	}
2620 2758
 
2621 2759
 /**
2622 2760
  * Add a block of inline Javascript code to be executed later
@@ -2633,8 +2771,9 @@  discard block
 block discarded – undo
2633 2771
 {
2634 2772
 	global $context;
2635 2773
 
2636
-	if (empty($javascript))
2637
-		return false;
2774
+	if (empty($javascript)) {
2775
+			return false;
2776
+	}
2638 2777
 
2639 2778
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2640 2779
 }
@@ -2655,15 +2794,18 @@  discard block
 block discarded – undo
2655 2794
 	static $already_loaded = array();
2656 2795
 
2657 2796
 	// Default to the user's language.
2658
-	if ($lang == '')
2659
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2797
+	if ($lang == '') {
2798
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2799
+	}
2660 2800
 
2661 2801
 	// Do we want the English version of language file as fallback?
2662
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2663
-		loadLanguage($template_name, 'english', false);
2802
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2803
+			loadLanguage($template_name, 'english', false);
2804
+	}
2664 2805
 
2665
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2666
-		return $lang;
2806
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2807
+			return $lang;
2808
+	}
2667 2809
 
2668 2810
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2669 2811
 	if (empty($settings['default_theme_dir']))
@@ -2674,8 +2816,9 @@  discard block
 block discarded – undo
2674 2816
 
2675 2817
 	// What theme are we in?
2676 2818
 	$theme_name = basename($settings['theme_url']);
2677
-	if (empty($theme_name))
2678
-		$theme_name = 'unknown';
2819
+	if (empty($theme_name)) {
2820
+			$theme_name = 'unknown';
2821
+	}
2679 2822
 
2680 2823
 	// For each file open it up and write it out!
2681 2824
 	foreach (explode('+', $template_name) as $template)
@@ -2717,8 +2860,9 @@  discard block
 block discarded – undo
2717 2860
 				$found = true;
2718 2861
 
2719 2862
 				// setlocale is required for basename() & pathinfo() to work properly on the selected language
2720
-				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set']))
2721
-					setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2863
+				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) {
2864
+									setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2865
+				}
2722 2866
 
2723 2867
 				break;
2724 2868
 			}
@@ -2758,8 +2902,9 @@  discard block
 block discarded – undo
2758 2902
 	}
2759 2903
 
2760 2904
 	// Keep track of what we're up to soldier.
2761
-	if ($db_show_debug === true)
2762
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2905
+	if ($db_show_debug === true) {
2906
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2907
+	}
2763 2908
 
2764 2909
 	// Remember what we have loaded, and in which language.
2765 2910
 	$already_loaded[$template_name] = $lang;
@@ -2805,8 +2950,9 @@  discard block
 block discarded – undo
2805 2950
 				)
2806 2951
 			);
2807 2952
 			// In the EXTREMELY unlikely event this happens, give an error message.
2808
-			if ($smcFunc['db_num_rows']($result) == 0)
2809
-				fatal_lang_error('parent_not_found', 'critical');
2953
+			if ($smcFunc['db_num_rows']($result) == 0) {
2954
+							fatal_lang_error('parent_not_found', 'critical');
2955
+			}
2810 2956
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2811 2957
 			{
2812 2958
 				if (!isset($boards[$row['id_board']]))
@@ -2823,8 +2969,8 @@  discard block
 block discarded – undo
2823 2969
 					);
2824 2970
 				}
2825 2971
 				// If a moderator exists for this board, add that moderator for all children too.
2826
-				if (!empty($row['id_moderator']))
2827
-					foreach ($boards as $id => $dummy)
2972
+				if (!empty($row['id_moderator'])) {
2973
+									foreach ($boards as $id => $dummy)
2828 2974
 					{
2829 2975
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2830 2976
 							'id' => $row['id_moderator'],
@@ -2832,11 +2978,12 @@  discard block
 block discarded – undo
2832 2978
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2833 2979
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2834 2980
 						);
2981
+				}
2835 2982
 					}
2836 2983
 
2837 2984
 				// If a moderator group exists for this board, add that moderator group for all children too
2838
-				if (!empty($row['id_moderator_group']))
2839
-					foreach ($boards as $id => $dummy)
2985
+				if (!empty($row['id_moderator_group'])) {
2986
+									foreach ($boards as $id => $dummy)
2840 2987
 					{
2841 2988
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2842 2989
 							'id' => $row['id_moderator_group'],
@@ -2844,6 +2991,7 @@  discard block
 block discarded – undo
2844 2991
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2845 2992
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2846 2993
 						);
2994
+				}
2847 2995
 					}
2848 2996
 			}
2849 2997
 			$smcFunc['db_free_result']($result);
@@ -2870,23 +3018,27 @@  discard block
 block discarded – undo
2870 3018
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2871 3019
 	{
2872 3020
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2873
-		if (empty($smcFunc['ucwords']))
2874
-			reloadSettings();
3021
+		if (empty($smcFunc['ucwords'])) {
3022
+					reloadSettings();
3023
+		}
2875 3024
 
2876 3025
 		// If we don't have our theme information yet, let's get it.
2877
-		if (empty($settings['default_theme_dir']))
2878
-			loadTheme(0, false);
3026
+		if (empty($settings['default_theme_dir'])) {
3027
+					loadTheme(0, false);
3028
+		}
2879 3029
 
2880 3030
 		// Default language directories to try.
2881 3031
 		$language_directories = array(
2882 3032
 			$settings['default_theme_dir'] . '/languages',
2883 3033
 		);
2884
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2885
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3034
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
3035
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3036
+		}
2886 3037
 
2887 3038
 		// We possibly have a base theme directory.
2888
-		if (!empty($settings['base_theme_dir']))
2889
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
3039
+		if (!empty($settings['base_theme_dir'])) {
3040
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
3041
+		}
2890 3042
 
2891 3043
 		// Remove any duplicates.
2892 3044
 		$language_directories = array_unique($language_directories);
@@ -2900,20 +3052,21 @@  discard block
 block discarded – undo
2900 3052
 		foreach ($language_directories as $language_dir)
2901 3053
 		{
2902 3054
 			// Can't look in here... doesn't exist!
2903
-			if (!file_exists($language_dir))
2904
-				continue;
3055
+			if (!file_exists($language_dir)) {
3056
+							continue;
3057
+			}
2905 3058
 
2906 3059
 			$dir = dir($language_dir);
2907 3060
 			while ($entry = $dir->read())
2908 3061
 			{
2909 3062
 				// Look for the index language file... For good measure skip any "index.language-utf8.php" files
2910
-				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches))
2911
-					continue;
2912
-
2913
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2914
-					$langName = $langList[$matches[1]];
3063
+				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) {
3064
+									continue;
3065
+				}
2915 3066
 
2916
-				else
3067
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
3068
+									$langName = $langList[$matches[1]];
3069
+				} else
2917 3070
 				{
2918 3071
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2919 3072
 
@@ -2954,12 +3107,14 @@  discard block
 block discarded – undo
2954 3107
 		}
2955 3108
 
2956 3109
 		// Do we need to store the lang list?
2957
-		if (empty($langList))
2958
-			updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3110
+		if (empty($langList)) {
3111
+					updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3112
+		}
2959 3113
 
2960 3114
 		// Let's cash in on this deal.
2961
-		if (!empty($modSettings['cache_enable']))
2962
-			cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3115
+		if (!empty($modSettings['cache_enable'])) {
3116
+					cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3117
+		}
2963 3118
 	}
2964 3119
 
2965 3120
 	return $context['languages'];
@@ -2982,8 +3137,9 @@  discard block
 block discarded – undo
2982 3137
 	global $modSettings, $options, $txt;
2983 3138
 	static $censor_vulgar = null, $censor_proper;
2984 3139
 
2985
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2986
-		return $text;
3140
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3141
+			return $text;
3142
+	}
2987 3143
 
2988 3144
 	// If they haven't yet been loaded, load them.
2989 3145
 	if ($censor_vulgar == null)
@@ -3014,9 +3170,9 @@  discard block
 block discarded – undo
3014 3170
 	{
3015 3171
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
3016 3172
 		$text = $func($censor_vulgar, $censor_proper, $text);
3173
+	} else {
3174
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
3017 3175
 	}
3018
-	else
3019
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
3020 3176
 
3021 3177
 	return $text;
3022 3178
 }
@@ -3042,30 +3198,35 @@  discard block
 block discarded – undo
3042 3198
 	@ini_set('track_errors', '1');
3043 3199
 
3044 3200
 	// Don't include the file more than once, if $once is true.
3045
-	if ($once && in_array($filename, $templates))
3046
-		return;
3201
+	if ($once && in_array($filename, $templates)) {
3202
+			return;
3203
+	}
3047 3204
 	// Add this file to the include list, whether $once is true or not.
3048
-	else
3049
-		$templates[] = $filename;
3205
+	else {
3206
+			$templates[] = $filename;
3207
+	}
3050 3208
 
3051 3209
 
3052 3210
 	$file_found = file_exists($filename);
3053 3211
 
3054
-	if ($once && $file_found)
3055
-		require_once($filename);
3056
-	elseif ($file_found)
3057
-		require($filename);
3212
+	if ($once && $file_found) {
3213
+			require_once($filename);
3214
+	} elseif ($file_found) {
3215
+			require($filename);
3216
+	}
3058 3217
 
3059 3218
 	if ($file_found !== true)
3060 3219
 	{
3061 3220
 		ob_end_clean();
3062
-		if (!empty($modSettings['enableCompressedOutput']))
3063
-			@ob_start('ob_gzhandler');
3064
-		else
3065
-			ob_start();
3221
+		if (!empty($modSettings['enableCompressedOutput'])) {
3222
+					@ob_start('ob_gzhandler');
3223
+		} else {
3224
+					ob_start();
3225
+		}
3066 3226
 
3067
-		if (isset($_GET['debug']))
3068
-			header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3227
+		if (isset($_GET['debug'])) {
3228
+					header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3229
+		}
3069 3230
 
3070 3231
 		// Don't cache error pages!!
3071 3232
 		header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -3084,12 +3245,13 @@  discard block
 block discarded – undo
3084 3245
 		echo '<!DOCTYPE html>
3085 3246
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
3086 3247
 	<head>';
3087
-		if (isset($context['character_set']))
3088
-			echo '
3248
+		if (isset($context['character_set'])) {
3249
+					echo '
3089 3250
 		<meta charset="', $context['character_set'], '">';
3251
+		}
3090 3252
 
3091
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3092
-			echo '
3253
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3254
+					echo '
3093 3255
 		<title>', $mtitle, '</title>
3094 3256
 	</head>
3095 3257
 	<body>
@@ -3097,8 +3259,8 @@  discard block
 block discarded – undo
3097 3259
 		', $mmessage, '
3098 3260
 	</body>
3099 3261
 </html>';
3100
-		elseif (!allowedTo('admin_forum'))
3101
-			echo '
3262
+		} elseif (!allowedTo('admin_forum')) {
3263
+					echo '
3102 3264
 		<title>', $txt['template_parse_error'], '</title>
3103 3265
 	</head>
3104 3266
 	<body>
@@ -3106,14 +3268,16 @@  discard block
 block discarded – undo
3106 3268
 		', $txt['template_parse_error_message'], '
3107 3269
 	</body>
3108 3270
 </html>';
3109
-		else
3271
+		} else
3110 3272
 		{
3111 3273
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3112 3274
 			$error_array = error_get_last();
3113
-			if (empty($error) && ini_get('track_errors') && !empty($error_array))
3114
-				$error = $error_array['message'];
3115
-			if (empty($error))
3116
-				$error = $txt['template_parse_errmsg'];
3275
+			if (empty($error) && ini_get('track_errors') && !empty($error_array)) {
3276
+							$error = $error_array['message'];
3277
+			}
3278
+			if (empty($error)) {
3279
+							$error = $txt['template_parse_errmsg'];
3280
+			}
3117 3281
 
3118 3282
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3119 3283
 
@@ -3124,11 +3288,12 @@  discard block
 block discarded – undo
3124 3288
 		<h3>', $txt['template_parse_error'], '</h3>
3125 3289
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3126 3290
 
3127
-			if (!empty($error))
3128
-				echo '
3291
+			if (!empty($error)) {
3292
+							echo '
3129 3293
 		<hr>
3130 3294
 
3131 3295
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3296
+			}
3132 3297
 
3133 3298
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3134 3299
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3138,10 +3303,11 @@  discard block
 block discarded – undo
3138 3303
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3139 3304
 
3140 3305
 				// Fix the PHP code stuff...
3141
-				if (!isBrowser('gecko'))
3142
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3143
-				else
3144
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3306
+				if (!isBrowser('gecko')) {
3307
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3308
+				} else {
3309
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3310
+				}
3145 3311
 
3146 3312
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3147 3313
 				$j = -1;
@@ -3149,8 +3315,9 @@  discard block
 block discarded – undo
3149 3315
 				{
3150 3316
 					$j++;
3151 3317
 
3152
-					if (substr_count($line, '<br>') == 0)
3153
-						continue;
3318
+					if (substr_count($line, '<br>') == 0) {
3319
+											continue;
3320
+					}
3154 3321
 
3155 3322
 					$n = substr_count($line, '<br>');
3156 3323
 					for ($i = 0; $i < $n; $i++)
@@ -3169,38 +3336,42 @@  discard block
 block discarded – undo
3169 3336
 				// Figure out what the color coding was before...
3170 3337
 				$line = max($match[1] - 9, 1);
3171 3338
 				$last_line = '';
3172
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3173
-					if (strpos($data2[$line2], '<') !== false)
3339
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3340
+									if (strpos($data2[$line2], '<') !== false)
3174 3341
 					{
3175 3342
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3176 3343
 							$last_line = $color_match[1];
3344
+				}
3177 3345
 						break;
3178 3346
 					}
3179 3347
 
3180 3348
 				// Show the relevant lines...
3181 3349
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3182 3350
 				{
3183
-					if ($line == $match[1])
3184
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3351
+					if ($line == $match[1]) {
3352
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3353
+					}
3185 3354
 
3186 3355
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3187
-					if (isset($data2[$line]) && $data2[$line] != '')
3188
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3356
+					if (isset($data2[$line]) && $data2[$line] != '') {
3357
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3358
+					}
3189 3359
 
3190 3360
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3191 3361
 					{
3192 3362
 						$last_line = $color_match[1];
3193 3363
 						echo '</', substr($last_line, 1, 4), '>';
3364
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3365
+											$last_line = '';
3366
+					} elseif ($last_line != '' && $data2[$line] != '') {
3367
+											echo '</', substr($last_line, 1, 4), '>';
3194 3368
 					}
3195
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3196
-						$last_line = '';
3197
-					elseif ($last_line != '' && $data2[$line] != '')
3198
-						echo '</', substr($last_line, 1, 4), '>';
3199 3369
 
3200
-					if ($line == $match[1])
3201
-						echo '</pre></div><pre style="margin: 0;">';
3202
-					else
3203
-						echo "\n";
3370
+					if ($line == $match[1]) {
3371
+											echo '</pre></div><pre style="margin: 0;">';
3372
+					} else {
3373
+											echo "\n";
3374
+					}
3204 3375
 				}
3205 3376
 
3206 3377
 				echo '</pre></div>';
@@ -3224,8 +3395,9 @@  discard block
 block discarded – undo
3224 3395
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port;
3225 3396
 
3226 3397
 	// Figure out what type of database we are using.
3227
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3228
-		$db_type = 'mysql';
3398
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3399
+			$db_type = 'mysql';
3400
+	}
3229 3401
 
3230 3402
 	// Load the file for the database.
3231 3403
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3233,8 +3405,9 @@  discard block
 block discarded – undo
3233 3405
 	$db_options = array();
3234 3406
 
3235 3407
 	// Add in the port if needed
3236
-	if (!empty($db_port))
3237
-		$db_options['port'] = $db_port;
3408
+	if (!empty($db_port)) {
3409
+			$db_options['port'] = $db_port;
3410
+	}
3238 3411
 
3239 3412
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
3240 3413
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3253,13 +3426,15 @@  discard block
 block discarded – undo
3253 3426
 	}
3254 3427
 
3255 3428
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3256
-	if (!$db_connection)
3257
-		display_db_error();
3429
+	if (!$db_connection) {
3430
+			display_db_error();
3431
+	}
3258 3432
 
3259 3433
 	// If in SSI mode fix up the prefix.
3260
-	if (SMF == 'SSI')
3261
-		db_fix_prefix($db_prefix, $db_name);
3262
-}
3434
+	if (SMF == 'SSI') {
3435
+			db_fix_prefix($db_prefix, $db_name);
3436
+	}
3437
+	}
3263 3438
 
3264 3439
 /**
3265 3440
  * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it.
@@ -3273,10 +3448,11 @@  discard block
 block discarded – undo
3273 3448
 	global $sourcedir, $cacheAPI, $cache_accelerator;
3274 3449
 
3275 3450
 	// Not overriding this and we have a cacheAPI, send it back.
3276
-	if (empty($overrideCache) && is_object($cacheAPI))
3277
-		return $cacheAPI;
3278
-	elseif (is_null($cacheAPI))
3279
-		$cacheAPI = false;
3451
+	if (empty($overrideCache) && is_object($cacheAPI)) {
3452
+			return $cacheAPI;
3453
+	} elseif (is_null($cacheAPI)) {
3454
+			$cacheAPI = false;
3455
+	}
3280 3456
 
3281 3457
 	// Make sure our class is in session.
3282 3458
 	require_once($sourcedir . '/Class-CacheAPI.php');
@@ -3297,8 +3473,9 @@  discard block
 block discarded – undo
3297 3473
 		if (!$testAPI->isSupported())
3298 3474
 		{
3299 3475
 			// Can we save ourselves?
3300
-			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf')
3301
-				return loadCacheAccelerator(null, false);
3476
+			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') {
3477
+							return loadCacheAccelerator(null, false);
3478
+			}
3302 3479
 			return false;
3303 3480
 		}
3304 3481
 
@@ -3310,9 +3487,9 @@  discard block
 block discarded – undo
3310 3487
 		{
3311 3488
 			$cacheAPI = $testAPI;
3312 3489
 			return $cacheAPI;
3490
+		} else {
3491
+					return $testAPI;
3313 3492
 		}
3314
-		else
3315
-			return $testAPI;
3316 3493
 	}
3317 3494
 }
3318 3495
 
@@ -3332,8 +3509,9 @@  discard block
 block discarded – undo
3332 3509
 
3333 3510
 	// @todo Why are we doing this if caching is disabled?
3334 3511
 
3335
-	if (function_exists('call_integration_hook'))
3336
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3512
+	if (function_exists('call_integration_hook')) {
3513
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3514
+	}
3337 3515
 
3338 3516
 	/* Refresh the cache if either:
3339 3517
 		1. Caching is disabled.
@@ -3347,16 +3525,19 @@  discard block
 block discarded – undo
3347 3525
 		require_once($sourcedir . '/' . $file);
3348 3526
 		$cache_block = call_user_func_array($function, $params);
3349 3527
 
3350
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3351
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3528
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3529
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3530
+		}
3352 3531
 	}
3353 3532
 
3354 3533
 	// Some cached data may need a freshening up after retrieval.
3355
-	if (!empty($cache_block['post_retri_eval']))
3356
-		eval($cache_block['post_retri_eval']);
3534
+	if (!empty($cache_block['post_retri_eval'])) {
3535
+			eval($cache_block['post_retri_eval']);
3536
+	}
3357 3537
 
3358
-	if (function_exists('call_integration_hook'))
3359
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3538
+	if (function_exists('call_integration_hook')) {
3539
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3540
+	}
3360 3541
 
3361 3542
 	return $cache_block['data'];
3362 3543
 }
@@ -3383,8 +3564,9 @@  discard block
 block discarded – undo
3383 3564
 	global $smcFunc, $cache_enable, $cacheAPI;
3384 3565
 	global $cache_hits, $cache_count, $db_show_debug;
3385 3566
 
3386
-	if (empty($cache_enable) || empty($cacheAPI))
3387
-		return;
3567
+	if (empty($cache_enable) || empty($cacheAPI)) {
3568
+			return;
3569
+	}
3388 3570
 
3389 3571
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3390 3572
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3397,12 +3579,14 @@  discard block
 block discarded – undo
3397 3579
 	$value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value));
3398 3580
 	$cacheAPI->putData($key, $value, $ttl);
3399 3581
 
3400
-	if (function_exists('call_integration_hook'))
3401
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3582
+	if (function_exists('call_integration_hook')) {
3583
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3584
+	}
3402 3585
 
3403
-	if (isset($db_show_debug) && $db_show_debug === true)
3404
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3405
-}
3586
+	if (isset($db_show_debug) && $db_show_debug === true) {
3587
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3588
+	}
3589
+	}
3406 3590
 
3407 3591
 /**
3408 3592
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3418,8 +3602,9 @@  discard block
 block discarded – undo
3418 3602
 	global $smcFunc, $cache_enable, $cacheAPI;
3419 3603
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
3420 3604
 
3421
-	if (empty($cache_enable) || empty($cacheAPI))
3422
-		return;
3605
+	if (empty($cache_enable) || empty($cacheAPI)) {
3606
+			return;
3607
+	}
3423 3608
 
3424 3609
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3425 3610
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3439,16 +3624,18 @@  discard block
 block discarded – undo
3439 3624
 
3440 3625
 		if (empty($value))
3441 3626
 		{
3442
-			if (!is_array($cache_misses))
3443
-				$cache_misses = array();
3627
+			if (!is_array($cache_misses)) {
3628
+							$cache_misses = array();
3629
+			}
3444 3630
 
3445 3631
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3446 3632
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3447 3633
 		}
3448 3634
 	}
3449 3635
 
3450
-	if (function_exists('call_integration_hook') && isset($value))
3451
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3636
+	if (function_exists('call_integration_hook') && isset($value)) {
3637
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3638
+	}
3452 3639
 
3453 3640
 	return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true));
3454 3641
 }
@@ -3470,8 +3657,9 @@  discard block
 block discarded – undo
3470 3657
 	global $cacheAPI;
3471 3658
 
3472 3659
 	// If we can't get to the API, can't do this.
3473
-	if (empty($cacheAPI))
3474
-		return;
3660
+	if (empty($cacheAPI)) {
3661
+			return;
3662
+	}
3475 3663
 
3476 3664
 	// Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure.
3477 3665
 	$cacheAPI->cleanCache($type);
@@ -3496,8 +3684,9 @@  discard block
 block discarded – undo
3496 3684
 	global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $user_info;
3497 3685
 
3498 3686
 	// Come on!
3499
-	if (empty($data))
3500
-		return array();
3687
+	if (empty($data)) {
3688
+			return array();
3689
+	}
3501 3690
 
3502 3691
 	// Set a nice default var.
3503 3692
 	$image = '';
@@ -3505,11 +3694,11 @@  discard block
 block discarded – undo
3505 3694
 	// Gravatar has been set as mandatory!
3506 3695
 	if (!empty($modSettings['gravatarOverride']))
3507 3696
 	{
3508
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3509
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3510
-
3511
-		else if (!empty($data['email']))
3512
-			$image = get_gravatar_url($data['email']);
3697
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3698
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3699
+		} else if (!empty($data['email'])) {
3700
+					$image = get_gravatar_url($data['email']);
3701
+		}
3513 3702
 	}
3514 3703
 
3515 3704
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3521,54 +3710,60 @@  discard block
 block discarded – undo
3521 3710
 			// Gravatar.
3522 3711
 			if (stristr($data['avatar'], 'gravatar://'))
3523 3712
 			{
3524
-				if ($data['avatar'] == 'gravatar://')
3525
-					$image = get_gravatar_url($data['email']);
3526
-
3527
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3528
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3713
+				if ($data['avatar'] == 'gravatar://') {
3714
+									$image = get_gravatar_url($data['email']);
3715
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3716
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3717
+				}
3529 3718
 			}
3530 3719
 
3531 3720
 			// External url.
3532 3721
 			else
3533 3722
 			{
3534 3723
 				// Using ssl?
3535
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
3536
-					$image = get_proxied_url($data['avatar']);
3724
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
3725
+									$image = get_proxied_url($data['avatar']);
3726
+				}
3537 3727
 
3538 3728
 				// Just a plain external url.
3539
-				else
3540
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3729
+				else {
3730
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3731
+				}
3541 3732
 			}
3542 3733
 		}
3543 3734
 
3544 3735
 		// Perhaps this user has an attachment as avatar...
3545
-		else if (!empty($data['filename']))
3546
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3736
+		else if (!empty($data['filename'])) {
3737
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3738
+		}
3547 3739
 
3548 3740
 		// Right... no avatar... use our default image.
3549
-		else
3550
-			$image = $modSettings['avatar_url'] . '/default.png';
3741
+		else {
3742
+					$image = $modSettings['avatar_url'] . '/default.png';
3743
+		}
3551 3744
 	}
3552 3745
 
3553 3746
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3554 3747
 
3555 3748
 	// At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed.
3556
-	if (!empty($image))
3557
-		return array(
3749
+	if (!empty($image)) {
3750
+			return array(
3558 3751
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3559 3752
 			'image' => '<img class="avatar" src="' . $image . '" />',
3560 3753
 			'href' => $image,
3561 3754
 			'url' => $image,
3562 3755
 		);
3756
+	}
3563 3757
 
3564 3758
 	// Fallback to make life easier for everyone...
3565
-	else
3566
-		return array(
3759
+	else {
3760
+			return array(
3567 3761
 			'name' => '',
3568 3762
 			'image' => '',
3569 3763
 			'href' => '',
3570 3764
 			'url' => '',
3571 3765
 		);
3572
-}
3766
+	}
3767
+	}
3573 3768
 
3574 3769
 ?>
3575 3770
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Post.php 1 patch
Braces   +674 added lines, -521 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 block discarded – undo
35 36
 	global $sourcedir, $smcFunc, $language;
36 37
 
37 38
 	loadLanguage('Post');
38
-	if (!empty($modSettings['drafts_post_enabled']))
39
-		loadLanguage('Drafts');
39
+	if (!empty($modSettings['drafts_post_enabled'])) {
40
+			loadLanguage('Drafts');
41
+	}
40 42
 
41 43
 	// You can't reply with a poll... hacker.
42
-	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
43
-		unset($_REQUEST['poll']);
44
+	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) {
45
+			unset($_REQUEST['poll']);
46
+	}
44 47
 
45 48
 	// Posting an event?
46 49
 	$context['make_event'] = isset($_REQUEST['calendar']);
@@ -58,12 +61,14 @@  discard block
 block discarded – undo
58 61
 	{
59 62
 		// Get ids of all the boards they can post in.
60 63
 		$post_permissions = array('post_new');
61
-		if ($modSettings['postmod_active'])
62
-			$post_permissions[] = 'post_unapproved_topics';
64
+		if ($modSettings['postmod_active']) {
65
+					$post_permissions[] = 'post_unapproved_topics';
66
+		}
63 67
 
64 68
 		$boards = boardsAllowedTo($post_permissions);
65
-		if (empty($boards))
66
-			fatal_lang_error('cannot_post_new', false);
69
+		if (empty($boards)) {
70
+					fatal_lang_error('cannot_post_new', false);
71
+		}
67 72
 
68 73
 		// Get a list of boards for the select menu
69 74
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -76,8 +81,9 @@  discard block
 block discarded – undo
76 81
 		$board_list = getBoardList($boardListOptions);
77 82
 	}
78 83
 	// Let's keep things simple for ourselves below
79
-	else
80
-		$boards = array($board);
84
+	else {
85
+			$boards = array($board);
86
+	}
81 87
 
82 88
 	require_once($sourcedir . '/Subs-Post.php');
83 89
 
@@ -100,10 +106,11 @@  discard block
 block discarded – undo
100 106
 			array(
101 107
 				'msg' => (int) $_REQUEST['msg'],
102 108
 		));
103
-		if ($smcFunc['db_num_rows']($request) != 1)
104
-			unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
105
-		else
106
-			list ($topic) = $smcFunc['db_fetch_row']($request);
109
+		if ($smcFunc['db_num_rows']($request) != 1) {
110
+					unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
111
+		} else {
112
+					list ($topic) = $smcFunc['db_fetch_row']($request);
113
+		}
107 114
 		$smcFunc['db_free_result']($request);
108 115
 	}
109 116
 
@@ -130,33 +137,36 @@  discard block
 block discarded – undo
130 137
 		$smcFunc['db_free_result']($request);
131 138
 
132 139
 		// If this topic already has a poll, they sure can't add another.
133
-		if (isset($_REQUEST['poll']) && $pollID > 0)
134
-			unset($_REQUEST['poll']);
140
+		if (isset($_REQUEST['poll']) && $pollID > 0) {
141
+					unset($_REQUEST['poll']);
142
+		}
135 143
 
136 144
 		if (empty($_REQUEST['msg']))
137 145
 		{
138
-			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
139
-				is_not_guest();
146
+			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) {
147
+							is_not_guest();
148
+			}
140 149
 
141 150
 			// By default the reply will be approved...
142 151
 			$context['becomes_approved'] = true;
143 152
 			if ($id_member_poster != $user_info['id'] || $user_info['is_guest'])
144 153
 			{
145
-				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
146
-					$context['becomes_approved'] = false;
147
-				else
148
-					isAllowedTo('post_reply_any');
149
-			}
150
-			elseif (!allowedTo('post_reply_any'))
154
+				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
155
+									$context['becomes_approved'] = false;
156
+				} else {
157
+									isAllowedTo('post_reply_any');
158
+				}
159
+			} elseif (!allowedTo('post_reply_any'))
151 160
 			{
152
-				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any')))
153
-					$context['becomes_approved'] = false;
154
-				else
155
-					isAllowedTo('post_reply_own');
161
+				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) {
162
+									$context['becomes_approved'] = false;
163
+				} else {
164
+									isAllowedTo('post_reply_own');
165
+				}
156 166
 			}
167
+		} else {
168
+					$context['becomes_approved'] = true;
157 169
 		}
158
-		else
159
-			$context['becomes_approved'] = true;
160 170
 
161 171
 		$context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
162 172
 		$context['can_sticky'] = allowedTo('make_sticky');
@@ -171,17 +181,18 @@  discard block
 block discarded – undo
171 181
 		$context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
172 182
 
173 183
 		// Check whether this is a really old post being bumped...
174
-		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
175
-			$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
176
-	}
177
-	else
184
+		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) {
185
+					$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
186
+		}
187
+	} else
178 188
 	{
179 189
 		// @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu
180 190
 		$context['becomes_approved'] = true;
181
-		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true))
182
-			$context['becomes_approved'] = false;
183
-		else
184
-			isAllowedTo('post_new', $boards, true);
191
+		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) {
192
+					$context['becomes_approved'] = false;
193
+		} else {
194
+					isAllowedTo('post_new', $boards, true);
195
+		}
185 196
 
186 197
 		$locked = 0;
187 198
 		$context['already_locked'] = 0;
@@ -211,27 +222,32 @@  discard block
 block discarded – undo
211 222
 	if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached']))
212 223
 	{
213 224
 		require_once($sourcedir . '/ManageAttachments.php');
214
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
215
-			removeAttachments(array('id_attach' => $attachID));
225
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
226
+					removeAttachments(array('id_attach' => $attachID));
227
+		}
216 228
 
217 229
 		unset($_SESSION['already_attached']);
218 230
 	}
219 231
 
220 232
 	// Don't allow a post if it's locked and you aren't all powerful.
221
-	if ($locked && !allowedTo('moderate_board'))
222
-		fatal_lang_error('topic_locked', false);
233
+	if ($locked && !allowedTo('moderate_board')) {
234
+			fatal_lang_error('topic_locked', false);
235
+	}
223 236
 	// Check the users permissions - is the user allowed to add or post a poll?
224 237
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
225 238
 	{
226 239
 		// New topic, new poll.
227
-		if (empty($topic))
228
-			isAllowedTo('poll_post');
240
+		if (empty($topic)) {
241
+					isAllowedTo('poll_post');
242
+		}
229 243
 		// This is an old topic - but it is yours!  Can you add to it?
230
-		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
231
-			isAllowedTo('poll_add_own');
244
+		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) {
245
+					isAllowedTo('poll_add_own');
246
+		}
232 247
 		// If you're not the owner, can you add to any poll?
233
-		else
234
-			isAllowedTo('poll_add_any');
248
+		else {
249
+					isAllowedTo('poll_add_any');
250
+		}
235 251
 
236 252
 		if (!empty($board))
237 253
 		{
@@ -240,8 +256,9 @@  discard block
 block discarded – undo
240 256
 			$guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']);
241 257
 		}
242 258
 		// No board, so we'll have to check this again in Post2
243
-		else
244
-			$guest_vote_enabled = true;
259
+		else {
260
+					$guest_vote_enabled = true;
261
+		}
245 262
 
246 263
 		// Set up the poll options.
247 264
 		$context['poll_options'] = array(
@@ -267,8 +284,9 @@  discard block
 block discarded – undo
267 284
 	if ($context['make_event'])
268 285
 	{
269 286
 		// They might want to pick a board.
270
-		if (!isset($context['current_board']))
271
-			$context['current_board'] = 0;
287
+		if (!isset($context['current_board'])) {
288
+					$context['current_board'] = 0;
289
+		}
272 290
 
273 291
 		// Start loading up the event info.
274 292
 		$context['event'] = array();
@@ -282,10 +300,11 @@  discard block
 block discarded – undo
282 300
 		isAllowedTo('calendar_post');
283 301
 
284 302
 		// We want a fairly compact version of the time, but as close as possible to the user's settings.
285
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
286
-			$time_string = '%k:%M';
287
-		else
288
-			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
303
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
304
+					$time_string = '%k:%M';
305
+		} else {
306
+					$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
307
+		}
289 308
 
290 309
 		$js_time_string = str_replace(
291 310
 			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -307,8 +326,7 @@  discard block
 block discarded – undo
307 326
 			require_once($sourcedir . '/Subs-Calendar.php');
308 327
 			$eventProperties = getEventProperties($context['event']['id']);
309 328
 			$context['event'] = array_merge($context['event'], $eventProperties);
310
-		}
311
-		else
329
+		} else
312 330
 		{
313 331
 			// Get the current event information.
314 332
 			require_once($sourcedir . '/Subs-Calendar.php');
@@ -316,10 +334,12 @@  discard block
 block discarded – undo
316 334
 			$context['event'] = array_merge($context['event'], $eventProperties);
317 335
 
318 336
 			// Make sure the year and month are in the valid range.
319
-			if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
320
-				fatal_lang_error('invalid_month', false);
321
-			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
322
-				fatal_lang_error('invalid_year', false);
337
+			if ($context['event']['month'] < 1 || $context['event']['month'] > 12) {
338
+							fatal_lang_error('invalid_month', false);
339
+			}
340
+			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) {
341
+							fatal_lang_error('invalid_year', false);
342
+			}
323 343
 
324 344
 			$context['event']['categories'] = $board_list;
325 345
 		}
@@ -430,10 +450,11 @@  discard block
 block discarded – undo
430 450
 
431 451
 			if (!empty($context['new_replies']))
432 452
 			{
433
-				if ($context['new_replies'] == 1)
434
-					$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
435
-				else
436
-					$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
453
+				if ($context['new_replies'] == 1) {
454
+									$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
455
+				} else {
456
+									$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
457
+				}
437 458
 
438 459
 				$post_errors[] = 'new_replies';
439 460
 
@@ -445,9 +466,9 @@  discard block
 block discarded – undo
445 466
 	// Get a response prefix (like 'Re:') in the default forum language.
446 467
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
447 468
 	{
448
-		if ($language === $user_info['language'])
449
-			$context['response_prefix'] = $txt['response_prefix'];
450
-		else
469
+		if ($language === $user_info['language']) {
470
+					$context['response_prefix'] = $txt['response_prefix'];
471
+		} else
451 472
 		{
452 473
 			loadLanguage('index', $language, false);
453 474
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -460,23 +481,26 @@  discard block
 block discarded – undo
460 481
 	// Do we have a body, but an error happened.
461 482
 	if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error']))
462 483
 	{
463
-		if (isset($_REQUEST['quickReply']))
464
-			$_REQUEST['message'] = $_REQUEST['quickReply'];
484
+		if (isset($_REQUEST['quickReply'])) {
485
+					$_REQUEST['message'] = $_REQUEST['quickReply'];
486
+		}
465 487
 
466 488
 		// Validate inputs.
467 489
 		if (empty($context['post_error']))
468 490
 		{
469 491
 			// This means they didn't click Post and get an error.
470 492
 			$really_previewing = true;
471
-		}
472
-		else
493
+		} else
473 494
 		{
474
-			if (!isset($_REQUEST['subject']))
475
-				$_REQUEST['subject'] = '';
476
-			if (!isset($_REQUEST['message']))
477
-				$_REQUEST['message'] = '';
478
-			if (!isset($_REQUEST['icon']))
479
-				$_REQUEST['icon'] = 'xx';
495
+			if (!isset($_REQUEST['subject'])) {
496
+							$_REQUEST['subject'] = '';
497
+			}
498
+			if (!isset($_REQUEST['message'])) {
499
+							$_REQUEST['message'] = '';
500
+			}
501
+			if (!isset($_REQUEST['icon'])) {
502
+							$_REQUEST['icon'] = 'xx';
503
+			}
480 504
 
481 505
 			// They are previewing if they asked to preview (i.e. came from quick reply).
482 506
 			$really_previewing = !empty($_POST['preview']);
@@ -492,8 +516,9 @@  discard block
 block discarded – undo
492 516
 		$form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
493 517
 
494 518
 		// Make sure the subject isn't too long - taking into account special characters.
495
-		if ($smcFunc['strlen']($form_subject) > 100)
496
-			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
519
+		if ($smcFunc['strlen']($form_subject) > 100) {
520
+					$form_subject = $smcFunc['substr']($form_subject, 0, 100);
521
+		}
497 522
 
498 523
 		if (isset($_REQUEST['poll']))
499 524
 		{
@@ -505,8 +530,9 @@  discard block
 block discarded – undo
505 530
 			$_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
506 531
 			foreach ($_POST['options'] as $option)
507 532
 			{
508
-				if (trim($option) == '')
509
-					continue;
533
+				if (trim($option) == '') {
534
+									continue;
535
+				}
510 536
 
511 537
 				$context['choices'][] = array(
512 538
 					'id' => $choice_id++,
@@ -568,13 +594,14 @@  discard block
 block discarded – undo
568 594
 				$context['preview_subject'] = $form_subject;
569 595
 
570 596
 				censorText($context['preview_subject']);
597
+			} else {
598
+							$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
571 599
 			}
572
-			else
573
-				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
574 600
 
575 601
 			// Protect any CDATA blocks.
576
-			if (isset($_REQUEST['xml']))
577
-				$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
602
+			if (isset($_REQUEST['xml'])) {
603
+							$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
604
+			}
578 605
 		}
579 606
 
580 607
 		// Set up the checkboxes.
@@ -613,29 +640,32 @@  discard block
 block discarded – undo
613 640
 			);
614 641
 			// The message they were trying to edit was most likely deleted.
615 642
 			// @todo Change this error message?
616
-			if ($smcFunc['db_num_rows']($request) == 0)
617
-				fatal_lang_error('no_board', false);
643
+			if ($smcFunc['db_num_rows']($request) == 0) {
644
+							fatal_lang_error('no_board', false);
645
+			}
618 646
 			$row = $smcFunc['db_fetch_assoc']($request);
619 647
 
620 648
 			$attachment_stuff = array($row);
621
-			while ($row2 = $smcFunc['db_fetch_assoc']($request))
622
-				$attachment_stuff[] = $row2;
649
+			while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
650
+							$attachment_stuff[] = $row2;
651
+			}
623 652
 			$smcFunc['db_free_result']($request);
624 653
 
625 654
 			if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
626 655
 			{
627 656
 				// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
628
-				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
629
-					fatal_lang_error('modify_post_time_passed', false);
630
-				elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
631
-					isAllowedTo('modify_replies');
632
-				else
633
-					isAllowedTo('modify_own');
657
+				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
658
+									fatal_lang_error('modify_post_time_passed', false);
659
+				} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
660
+									isAllowedTo('modify_replies');
661
+				} else {
662
+									isAllowedTo('modify_own');
663
+				}
664
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
665
+							isAllowedTo('modify_replies');
666
+			} else {
667
+							isAllowedTo('modify_any');
634 668
 			}
635
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
636
-				isAllowedTo('modify_replies');
637
-			else
638
-				isAllowedTo('modify_any');
639 669
 
640 670
 			if ($context['can_announce'] && !empty($row['id_action']))
641 671
 			{
@@ -659,8 +689,9 @@  discard block
 block discarded – undo
659 689
 
660 690
 				while ($row = $smcFunc['db_fetch_assoc']($request))
661 691
 				{
662
-					if ($row['filesize'] <= 0)
663
-						continue;
692
+					if ($row['filesize'] <= 0) {
693
+											continue;
694
+					}
664 695
 					$context['current_attachments'][$row['id_attach']] = array(
665 696
 						'name' => $smcFunc['htmlspecialchars']($row['filename']),
666 697
 						'size' => $row['filesize'],
@@ -730,29 +761,32 @@  discard block
 block discarded – undo
730 761
 			)
731 762
 		);
732 763
 		// The message they were trying to edit was most likely deleted.
733
-		if ($smcFunc['db_num_rows']($request) == 0)
734
-			fatal_lang_error('no_message', false);
764
+		if ($smcFunc['db_num_rows']($request) == 0) {
765
+					fatal_lang_error('no_message', false);
766
+		}
735 767
 		$row = $smcFunc['db_fetch_assoc']($request);
736 768
 
737 769
 		$attachment_stuff = array($row);
738
-		while ($row2 = $smcFunc['db_fetch_assoc']($request))
739
-			$attachment_stuff[] = $row2;
770
+		while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
771
+					$attachment_stuff[] = $row2;
772
+		}
740 773
 		$smcFunc['db_free_result']($request);
741 774
 
742 775
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
743 776
 		{
744 777
 			// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
745
-			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
746
-				fatal_lang_error('modify_post_time_passed', false);
747
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
748
-				isAllowedTo('modify_replies');
749
-			else
750
-				isAllowedTo('modify_own');
778
+			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
779
+							fatal_lang_error('modify_post_time_passed', false);
780
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
781
+							isAllowedTo('modify_replies');
782
+			} else {
783
+							isAllowedTo('modify_own');
784
+			}
785
+		} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
786
+					isAllowedTo('modify_replies');
787
+		} else {
788
+					isAllowedTo('modify_any');
751 789
 		}
752
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
753
-			isAllowedTo('modify_replies');
754
-		else
755
-			isAllowedTo('modify_any');
756 790
 
757 791
 		if ($context['can_announce'] && !empty($row['id_action']))
758 792
 		{
@@ -779,15 +813,17 @@  discard block
 block discarded – undo
779 813
 		$context['icon'] = $row['icon'];
780 814
 
781 815
 		// Show an "approve" box if the user can approve it, and the message isn't approved.
782
-		if (!$row['approved'] && !$context['show_approval'])
783
-			$context['show_approval'] = allowedTo('approve_posts');
816
+		if (!$row['approved'] && !$context['show_approval']) {
817
+					$context['show_approval'] = allowedTo('approve_posts');
818
+		}
784 819
 
785 820
 		// Sort the attachments so they are in the order saved
786 821
 		$temp = array();
787 822
 		foreach ($attachment_stuff as $attachment)
788 823
 		{
789
-			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
790
-				$temp[$attachment['id_attach']] = $attachment;
824
+			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) {
825
+							$temp[$attachment['id_attach']] = $attachment;
826
+			}
791 827
 		}
792 828
 		ksort($temp);
793 829
 
@@ -848,14 +884,16 @@  discard block
 block discarded – undo
848 884
 					'is_approved' => 1,
849 885
 				)
850 886
 			);
851
-			if ($smcFunc['db_num_rows']($request) == 0)
852
-				fatal_lang_error('quoted_post_deleted', false);
887
+			if ($smcFunc['db_num_rows']($request) == 0) {
888
+							fatal_lang_error('quoted_post_deleted', false);
889
+			}
853 890
 			list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
854 891
 			$smcFunc['db_free_result']($request);
855 892
 
856 893
 			// Add 'Re: ' to the front of the quoted subject.
857
-			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
858
-				$form_subject = $context['response_prefix'] . $form_subject;
894
+			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
895
+							$form_subject = $context['response_prefix'] . $form_subject;
896
+			}
859 897
 
860 898
 			// Censor the message and subject.
861 899
 			censorText($form_message);
@@ -868,10 +906,11 @@  discard block
 block discarded – undo
868 906
 				for ($i = 0, $n = count($parts); $i < $n; $i++)
869 907
 				{
870 908
 					// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
871
-					if ($i % 4 == 0)
872
-						$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
909
+					if ($i % 4 == 0) {
910
+											$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
873 911
 						{
874 912
 							return '[html]' . preg_replace('~<br\s?/?' . '>~i', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
913
+					}
875 914
 						}, $parts[$i]);
876 915
 				}
877 916
 				$form_message = implode('', $parts);
@@ -880,8 +919,9 @@  discard block
 block discarded – undo
880 919
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
881 920
 
882 921
 			// Remove any nested quotes, if necessary.
883
-			if (!empty($modSettings['removeNestedQuotes']))
884
-				$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
922
+			if (!empty($modSettings['removeNestedQuotes'])) {
923
+							$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
924
+			}
885 925
 
886 926
 			// Add a quote string on the front and end.
887 927
 			$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
@@ -893,15 +933,15 @@  discard block
 block discarded – undo
893 933
 			$form_subject = $first_subject;
894 934
 
895 935
 			// Add 'Re: ' to the front of the subject.
896
-			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
897
-				$form_subject = $context['response_prefix'] . $form_subject;
936
+			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
937
+							$form_subject = $context['response_prefix'] . $form_subject;
938
+			}
898 939
 
899 940
 			// Censor the subject.
900 941
 			censorText($form_subject);
901 942
 
902 943
 			$form_message = '';
903
-		}
904
-		else
944
+		} else
905 945
 		{
906 946
 			$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
907 947
 			$form_message = '';
@@ -920,13 +960,15 @@  discard block
 block discarded – undo
920 960
 		if (isset($_REQUEST['msg']))
921 961
 		{
922 962
 			$context['attachments']['quantity'] = count($context['current_attachments']);
923
-			foreach ($context['current_attachments'] as $attachment)
924
-				$context['attachments']['total_size'] += $attachment['size'];
963
+			foreach ($context['current_attachments'] as $attachment) {
964
+							$context['attachments']['total_size'] += $attachment['size'];
965
+			}
925 966
 		}
926 967
 
927 968
 		// A bit of house keeping first.
928
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
929
-			unset($_SESSION['temp_attachments']);
969
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
970
+					unset($_SESSION['temp_attachments']);
971
+		}
930 972
 
931 973
 		if (!empty($_SESSION['temp_attachments']))
932 974
 		{
@@ -935,9 +977,10 @@  discard block
 block discarded – undo
935 977
 			{
936 978
 				foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
937 979
 				{
938
-					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
939
-						if (file_exists($attachment['tmp_name']))
980
+					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) {
981
+											if (file_exists($attachment['tmp_name']))
940 982
 							unlink($attachment['tmp_name']);
983
+					}
941 984
 				}
942 985
 				$post_errors[] = 'temp_attachments_gone';
943 986
 				$_SESSION['temp_attachments'] = array();
@@ -951,8 +994,9 @@  discard block
 block discarded – undo
951 994
 					// See if any files still exist before showing the warning message and the files attached.
952 995
 					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
953 996
 					{
954
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
955
-							continue;
997
+						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
998
+													continue;
999
+						}
956 1000
 
957 1001
 						if (file_exists($attachment['tmp_name']))
958 1002
 						{
@@ -962,20 +1006,21 @@  discard block
 block discarded – undo
962 1006
 							break;
963 1007
 						}
964 1008
 					}
965
-				}
966
-				else
1009
+				} else
967 1010
 				{
968 1011
 					// Since, they don't belong here. Let's inform the user that they exist..
969
-					if (!empty($topic))
970
-						$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
971
-					else
972
-						$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1012
+					if (!empty($topic)) {
1013
+											$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
1014
+					} else {
1015
+											$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1016
+					}
973 1017
 
974 1018
 					// Compile a list of the files to show the user.
975 1019
 					$file_list = array();
976
-					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
977
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
1020
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
1021
+											if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
978 1022
 							$file_list[] = $attachment['name'];
1023
+					}
979 1024
 
980 1025
 					$_SESSION['temp_attachments']['post']['files'] = $file_list;
981 1026
 					$file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>';
@@ -987,8 +1032,7 @@  discard block
 block discarded – undo
987 1032
 
988 1033
 						$post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list));
989 1034
 						$context['ignore_temp_attachments'] = true;
990
-					}
991
-					else
1035
+					} else
992 1036
 					{
993 1037
 						$post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list));
994 1038
 						$context['ignore_temp_attachments'] = true;
@@ -996,16 +1040,19 @@  discard block
 block discarded – undo
996 1040
 				}
997 1041
 			}
998 1042
 
999
-			if (!empty($context['we_are_history']))
1000
-				$post_errors[] = $context['we_are_history'];
1043
+			if (!empty($context['we_are_history'])) {
1044
+							$post_errors[] = $context['we_are_history'];
1045
+			}
1001 1046
 
1002 1047
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1003 1048
 			{
1004
-				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files']))
1005
-					break;
1049
+				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) {
1050
+									break;
1051
+				}
1006 1052
 
1007
-				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1008
-					continue;
1053
+				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1054
+									continue;
1055
+				}
1009 1056
 
1010 1057
 				if ($attachID == 'initial_error')
1011 1058
 				{
@@ -1020,15 +1067,17 @@  discard block
 block discarded – undo
1020 1067
 				{
1021 1068
 					$txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : '';
1022 1069
 					$txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">';
1023
-					foreach ($attachment['errors'] as $error)
1024
-						$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1070
+					foreach ($attachment['errors'] as $error) {
1071
+											$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1072
+					}
1025 1073
 					$txt['error_attach_errors'] .= '</div>';
1026 1074
 					$post_errors[] = 'attach_errors';
1027 1075
 
1028 1076
 					// Take out the trash.
1029 1077
 					unset($_SESSION['temp_attachments'][$attachID]);
1030
-					if (file_exists($attachment['tmp_name']))
1031
-						unlink($attachment['tmp_name']);
1078
+					if (file_exists($attachment['tmp_name'])) {
1079
+											unlink($attachment['tmp_name']);
1080
+					}
1032 1081
 					continue;
1033 1082
 				}
1034 1083
 
@@ -1041,8 +1090,9 @@  discard block
 block discarded – undo
1041 1090
 
1042 1091
 				$context['attachments']['quantity']++;
1043 1092
 				$context['attachments']['total_size'] += $attachment['size'];
1044
-				if (!isset($context['files_in_session_warning']))
1045
-					$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1093
+				if (!isset($context['files_in_session_warning'])) {
1094
+									$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1095
+				}
1046 1096
 
1047 1097
 				$context['current_attachments'][$attachID] = array(
1048 1098
 					'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>',
@@ -1070,8 +1120,9 @@  discard block
 block discarded – undo
1070 1120
 	}
1071 1121
 
1072 1122
 	// If they came from quick reply, and have to enter verification details, give them some notice.
1073
-	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
1074
-		$post_errors[] = 'need_qr_verification';
1123
+	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) {
1124
+			$post_errors[] = 'need_qr_verification';
1125
+	}
1075 1126
 
1076 1127
 	/*
1077 1128
 	 * There are two error types: serious and minor. Serious errors
@@ -1088,52 +1139,56 @@  discard block
 block discarded – undo
1088 1139
 	{
1089 1140
 		loadLanguage('Errors');
1090 1141
 		$context['error_type'] = 'minor';
1091
-		foreach ($post_errors as $post_error)
1092
-			if (is_array($post_error))
1142
+		foreach ($post_errors as $post_error) {
1143
+					if (is_array($post_error))
1093 1144
 			{
1094 1145
 				$post_error_id = $post_error[0];
1146
+		}
1095 1147
 				$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
1096 1148
 
1097 1149
 				// If it's not a minor error flag it as such.
1098
-				if (!in_array($post_error_id, $minor_errors))
1099
-					$context['error_type'] = 'serious';
1100
-			}
1101
-			else
1150
+				if (!in_array($post_error_id, $minor_errors)) {
1151
+									$context['error_type'] = 'serious';
1152
+				}
1153
+			} else
1102 1154
 			{
1103 1155
 				$context['post_error'][$post_error] = $txt['error_' . $post_error];
1104 1156
 
1105 1157
 				// If it's not a minor error flag it as such.
1106
-				if (!in_array($post_error, $minor_errors))
1107
-					$context['error_type'] = 'serious';
1158
+				if (!in_array($post_error, $minor_errors)) {
1159
+									$context['error_type'] = 'serious';
1160
+				}
1108 1161
 			}
1109 1162
 	}
1110 1163
 
1111 1164
 	// What are you doing? Posting a poll, modifying, previewing, new post, or reply...
1112
-	if (isset($_REQUEST['poll']))
1113
-		$context['page_title'] = $txt['new_poll'];
1114
-	elseif ($context['make_event'])
1115
-		$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1116
-	elseif (isset($_REQUEST['msg']))
1117
-		$context['page_title'] = $txt['modify_msg'];
1118
-	elseif (isset($_REQUEST['subject'], $context['preview_subject']))
1119
-		$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1120
-	elseif (empty($topic))
1121
-		$context['page_title'] = $txt['start_new_topic'];
1122
-	else
1123
-		$context['page_title'] = $txt['post_reply'];
1165
+	if (isset($_REQUEST['poll'])) {
1166
+			$context['page_title'] = $txt['new_poll'];
1167
+	} elseif ($context['make_event']) {
1168
+			$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1169
+	} elseif (isset($_REQUEST['msg'])) {
1170
+			$context['page_title'] = $txt['modify_msg'];
1171
+	} elseif (isset($_REQUEST['subject'], $context['preview_subject'])) {
1172
+			$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1173
+	} elseif (empty($topic)) {
1174
+			$context['page_title'] = $txt['start_new_topic'];
1175
+	} else {
1176
+			$context['page_title'] = $txt['post_reply'];
1177
+	}
1124 1178
 
1125 1179
 	// Build the link tree.
1126
-	if (empty($topic))
1127
-		$context['linktree'][] = array(
1180
+	if (empty($topic)) {
1181
+			$context['linktree'][] = array(
1128 1182
 			'name' => '<em>' . $txt['start_new_topic'] . '</em>'
1129 1183
 		);
1130
-	else
1131
-		$context['linktree'][] = array(
1184
+	} else {
1185
+			$context['linktree'][] = array(
1132 1186
 			'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
1133 1187
 			'name' => $form_subject,
1134 1188
 			'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>',
1135 1189
 			'extra_after' => '<span><strong class="nav">)</strong></span>'
1136 1190
 		);
1191
+	}
1137 1192
 
1138 1193
 	$context['subject'] = addcslashes($form_subject, '"');
1139 1194
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1177,8 +1232,9 @@  discard block
 block discarded – undo
1177 1232
 	// Message icons - customized icons are off?
1178 1233
 	$context['icons'] = getMessageIcons(!empty($board) ? $board : 0);
1179 1234
 
1180
-	if (!empty($context['icons']))
1181
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1235
+	if (!empty($context['icons'])) {
1236
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1237
+	}
1182 1238
 
1183 1239
 	// Are we starting a poll? if set the poll icon as selected if its available
1184 1240
 	if (isset($_REQUEST['poll']))
@@ -1198,8 +1254,9 @@  discard block
 block discarded – undo
1198 1254
 	for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
1199 1255
 	{
1200 1256
 		$context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
1201
-		if ($context['icons'][$i]['selected'])
1202
-			$context['icon_url'] = $context['icons'][$i]['url'];
1257
+		if ($context['icons'][$i]['selected']) {
1258
+					$context['icon_url'] = $context['icons'][$i]['url'];
1259
+		}
1203 1260
 	}
1204 1261
 	if (empty($context['icon_url']))
1205 1262
 	{
@@ -1213,8 +1270,9 @@  discard block
 block discarded – undo
1213 1270
 		));
1214 1271
 	}
1215 1272
 
1216
-	if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
1217
-		getTopic();
1273
+	if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) {
1274
+			getTopic();
1275
+	}
1218 1276
 
1219 1277
 	// If the user can post attachments prepare the warning labels.
1220 1278
 	if ($context['can_post_attachment'])
@@ -1225,12 +1283,13 @@  discard block
 block discarded – undo
1225 1283
 		$context['attachment_restrictions'] = array();
1226 1284
 		$context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', '));
1227 1285
 		$attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
1228
-		foreach ($attachmentRestrictionTypes as $type)
1229
-			if (!empty($modSettings[$type]))
1286
+		foreach ($attachmentRestrictionTypes as $type) {
1287
+					if (!empty($modSettings[$type]))
1230 1288
 			{
1231 1289
 				// Show the max number of attachments if not 0.
1232 1290
 				if ($type == 'attachmentNumPerPostLimit')
1233 1291
 					$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']);
1292
+		}
1234 1293
 			}
1235 1294
 	}
1236 1295
 
@@ -1264,8 +1323,8 @@  discard block
 block discarded – undo
1264 1323
 
1265 1324
 	if (!empty($context['current_attachments']))
1266 1325
 	{
1267
-		foreach ($context['current_attachments'] as $key => $mock)
1268
-			addInlineJavaScript('
1326
+		foreach ($context['current_attachments'] as $key => $mock) {
1327
+					addInlineJavaScript('
1269 1328
 	current_attachments.push({
1270 1329
 		name: '. JavaScriptEscape($mock['name']) . ',
1271 1330
 		size: '. $mock['size'] . ',
@@ -1274,6 +1333,7 @@  discard block
 block discarded – undo
1274 1333
 		type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ',
1275 1334
 		thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . '
1276 1335
 	});');
1336
+		}
1277 1337
 	}
1278 1338
 
1279 1339
 	// File Upload.
@@ -1348,9 +1408,10 @@  discard block
 block discarded – undo
1348 1408
 			$context['posting_fields']['board']['dd'] .= '
1349 1409
 							<optgroup label="' . $category['name'] . '">';
1350 1410
 
1351
-			foreach ($category['boards'] as $brd)
1352
-				$context['posting_fields']['board']['dd'] .= '
1411
+			foreach ($category['boards'] as $brd) {
1412
+							$context['posting_fields']['board']['dd'] .= '
1353 1413
 								<option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=&gt;' : '') . ' ' . $brd['name'] . '</option>';
1414
+			}
1354 1415
 
1355 1416
 			$context['posting_fields']['board']['dd'] .= '
1356 1417
 							</optgroup>';
@@ -1381,8 +1442,9 @@  discard block
 block discarded – undo
1381 1442
 
1382 1443
 
1383 1444
 	// Finally, load the template.
1384
-	if (!isset($_REQUEST['xml']))
1385
-		loadTemplate('Post');
1445
+	if (!isset($_REQUEST['xml'])) {
1446
+			loadTemplate('Post');
1447
+	}
1386 1448
 
1387 1449
 	call_integration_hook('integrate_post_end');
1388 1450
 }
@@ -1403,13 +1465,14 @@  discard block
 block discarded – undo
1403 1465
 	// Sneaking off, are we?
1404 1466
 	if (empty($_POST) && empty($topic))
1405 1467
 	{
1406
-		if (empty($_SERVER['CONTENT_LENGTH']))
1407
-			redirectexit('action=post;board=' . $board . '.0');
1408
-		else
1409
-			fatal_lang_error('post_upload_error', false);
1468
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1469
+					redirectexit('action=post;board=' . $board . '.0');
1470
+		} else {
1471
+					fatal_lang_error('post_upload_error', false);
1472
+		}
1473
+	} elseif (empty($_POST) && !empty($topic)) {
1474
+			redirectexit('action=post;topic=' . $topic . '.0');
1410 1475
 	}
1411
-	elseif (empty($_POST) && !empty($topic))
1412
-		redirectexit('action=post;topic=' . $topic . '.0');
1413 1476
 
1414 1477
 	// No need!
1415 1478
 	$context['robot_no_index'] = true;
@@ -1421,8 +1484,9 @@  discard block
 block discarded – undo
1421 1484
 	$post_errors = array();
1422 1485
 
1423 1486
 	// If the session has timed out, let the user re-submit their form.
1424
-	if (checkSession('post', '', false) != '')
1425
-		$post_errors[] = 'session_timeout';
1487
+	if (checkSession('post', '', false) != '') {
1488
+			$post_errors[] = 'session_timeout';
1489
+	}
1426 1490
 
1427 1491
 	// Wrong verification code?
1428 1492
 	if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
@@ -1432,33 +1496,38 @@  discard block
 block discarded – undo
1432 1496
 			'id' => 'post',
1433 1497
 		);
1434 1498
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1435
-		if (is_array($context['require_verification']))
1436
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1499
+		if (is_array($context['require_verification'])) {
1500
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1501
+		}
1437 1502
 	}
1438 1503
 
1439 1504
 	require_once($sourcedir . '/Subs-Post.php');
1440 1505
 	loadLanguage('Post');
1441 1506
 
1442 1507
 	// Drafts enabled and needed?
1443
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1444
-		require_once($sourcedir . '/Drafts.php');
1508
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1509
+			require_once($sourcedir . '/Drafts.php');
1510
+	}
1445 1511
 
1446 1512
 	// First check to see if they are trying to delete any current attachments.
1447 1513
 	if (isset($_POST['attach_del']))
1448 1514
 	{
1449 1515
 		$keep_temp = array();
1450 1516
 		$keep_ids = array();
1451
-		foreach ($_POST['attach_del'] as $dummy)
1452
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1517
+		foreach ($_POST['attach_del'] as $dummy) {
1518
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1453 1519
 				$keep_temp[] = $dummy;
1454
-			else
1455
-				$keep_ids[] = (int) $dummy;
1520
+		}
1521
+			else {
1522
+							$keep_ids[] = (int) $dummy;
1523
+			}
1456 1524
 
1457
-		if (isset($_SESSION['temp_attachments']))
1458
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1525
+		if (isset($_SESSION['temp_attachments'])) {
1526
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1459 1527
 			{
1460 1528
 				if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1461 1529
 					continue;
1530
+		}
1462 1531
 
1463 1532
 				unset($_SESSION['temp_attachments'][$attachID]);
1464 1533
 				unlink($attachment['tmp_name']);
@@ -1490,8 +1559,9 @@  discard block
 block discarded – undo
1490 1559
 	{
1491 1560
 		require_once($sourcedir . '/ManageAttachments.php');
1492 1561
 
1493
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
1494
-			removeAttachments(array('id_attach' => $attachID));
1562
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
1563
+					removeAttachments(array('id_attach' => $attachID));
1564
+		}
1495 1565
 
1496 1566
 		unset($_SESSION['already_attached']);
1497 1567
 
@@ -1514,12 +1584,14 @@  discard block
 block discarded – undo
1514 1584
 		$smcFunc['db_free_result']($request);
1515 1585
 
1516 1586
 		// Though the topic should be there, it might have vanished.
1517
-		if (!is_array($topic_info))
1518
-			fatal_lang_error('topic_doesnt_exist', 404);
1587
+		if (!is_array($topic_info)) {
1588
+					fatal_lang_error('topic_doesnt_exist', 404);
1589
+		}
1519 1590
 
1520 1591
 		// Did this topic suddenly move? Just checking...
1521
-		if ($topic_info['id_board'] != $board)
1522
-			fatal_lang_error('not_a_topic');
1592
+		if ($topic_info['id_board'] != $board) {
1593
+					fatal_lang_error('not_a_topic');
1594
+		}
1523 1595
 
1524 1596
 		// Do the permissions and approval stuff...
1525 1597
 		$becomesApproved = true;
@@ -1542,49 +1614,50 @@  discard block
 block discarded – undo
1542 1614
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1543 1615
 	{
1544 1616
 		// Don't allow a post if it's locked.
1545
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1546
-			fatal_lang_error('topic_locked', false);
1617
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1618
+					fatal_lang_error('topic_locked', false);
1619
+		}
1547 1620
 
1548 1621
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1549
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1550
-			unset($_REQUEST['poll']);
1551
-
1552
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1553
-		{
1554
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1555
-				$becomesApproved = false;
1556
-
1557
-			else
1558
-				isAllowedTo('post_reply_any');
1559
-		}
1560
-		elseif (!allowedTo('post_reply_any'))
1622
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1623
+					unset($_REQUEST['poll']);
1624
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1625
+		{
1626
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1627
+							$becomesApproved = false;
1628
+			} else {
1629
+							isAllowedTo('post_reply_any');
1630
+			}
1631
+		} elseif (!allowedTo('post_reply_any'))
1561 1632
 		{
1562
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1563
-				$becomesApproved = false;
1564
-
1565
-			else
1566
-				isAllowedTo('post_reply_own');
1633
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1634
+							$becomesApproved = false;
1635
+			} else {
1636
+							isAllowedTo('post_reply_own');
1637
+			}
1567 1638
 		}
1568 1639
 
1569 1640
 		if (isset($_POST['lock']))
1570 1641
 		{
1571 1642
 			// Nothing is changed to the lock.
1572
-			if (empty($topic_info['locked']) == empty($_POST['lock']))
1573
-				unset($_POST['lock']);
1643
+			if (empty($topic_info['locked']) == empty($_POST['lock'])) {
1644
+							unset($_POST['lock']);
1645
+			}
1574 1646
 
1575 1647
 			// You're have no permission to lock this topic.
1576
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1577
-				unset($_POST['lock']);
1648
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1649
+							unset($_POST['lock']);
1650
+			}
1578 1651
 
1579 1652
 			// You are allowed to (un)lock your own topic only.
1580 1653
 			elseif (!allowedTo('lock_any'))
1581 1654
 			{
1582 1655
 				// You cannot override a moderator lock.
1583
-				if ($topic_info['locked'] == 1)
1584
-					unset($_POST['lock']);
1585
-
1586
-				else
1587
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1656
+				if ($topic_info['locked'] == 1) {
1657
+									unset($_POST['lock']);
1658
+				} else {
1659
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1660
+				}
1588 1661
 			}
1589 1662
 			// Hail mighty moderator, (un)lock this topic immediately.
1590 1663
 			else
@@ -1592,19 +1665,21 @@  discard block
 block discarded – undo
1592 1665
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1593 1666
 
1594 1667
 				// Did someone (un)lock this while you were posting?
1595
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1596
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1668
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1669
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1670
+				}
1597 1671
 			}
1598 1672
 		}
1599 1673
 
1600 1674
 		// So you wanna (un)sticky this...let's see.
1601
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1602
-			unset($_POST['sticky']);
1603
-		elseif (isset($_POST['sticky']))
1675
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1676
+					unset($_POST['sticky']);
1677
+		} elseif (isset($_POST['sticky']))
1604 1678
 		{
1605 1679
 			// Did someone (un)sticky this while you were posting?
1606
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1607
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1680
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1681
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1682
+			}
1608 1683
 		}
1609 1684
 
1610 1685
 		// If drafts are enabled, then pass this off
@@ -1631,26 +1706,31 @@  discard block
 block discarded – undo
1631 1706
 
1632 1707
 		// Do like, the permissions, for safety and stuff...
1633 1708
 		$becomesApproved = true;
1634
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1635
-			$becomesApproved = false;
1636
-		else
1637
-			isAllowedTo('post_new');
1709
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1710
+					$becomesApproved = false;
1711
+		} else {
1712
+					isAllowedTo('post_new');
1713
+		}
1638 1714
 
1639 1715
 		if (isset($_POST['lock']))
1640 1716
 		{
1641 1717
 			// New topics are by default not locked.
1642
-			if (empty($_POST['lock']))
1643
-				unset($_POST['lock']);
1718
+			if (empty($_POST['lock'])) {
1719
+							unset($_POST['lock']);
1720
+			}
1644 1721
 			// Besides, you need permission.
1645
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1646
-				unset($_POST['lock']);
1722
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1723
+							unset($_POST['lock']);
1724
+			}
1647 1725
 			// A moderator-lock (1) can override a user-lock (2).
1648
-			else
1649
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1726
+			else {
1727
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1728
+			}
1650 1729
 		}
1651 1730
 
1652
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1653
-			unset($_POST['sticky']);
1731
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1732
+					unset($_POST['sticky']);
1733
+		}
1654 1734
 
1655 1735
 		// Saving your new topic as a draft first?
1656 1736
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1675,31 +1755,37 @@  discard block
 block discarded – undo
1675 1755
 				'id_msg' => $_REQUEST['msg'],
1676 1756
 			)
1677 1757
 		);
1678
-		if ($smcFunc['db_num_rows']($request) == 0)
1679
-			fatal_lang_error('cant_find_messages', false);
1758
+		if ($smcFunc['db_num_rows']($request) == 0) {
1759
+					fatal_lang_error('cant_find_messages', false);
1760
+		}
1680 1761
 		$row = $smcFunc['db_fetch_assoc']($request);
1681 1762
 		$smcFunc['db_free_result']($request);
1682 1763
 
1683
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1684
-			fatal_lang_error('topic_locked', false);
1764
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1765
+					fatal_lang_error('topic_locked', false);
1766
+		}
1685 1767
 
1686 1768
 		if (isset($_POST['lock']))
1687 1769
 		{
1688 1770
 			// Nothing changes to the lock status.
1689
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1690
-				unset($_POST['lock']);
1771
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1772
+							unset($_POST['lock']);
1773
+			}
1691 1774
 			// You're simply not allowed to (un)lock this.
1692
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1693
-				unset($_POST['lock']);
1775
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1776
+							unset($_POST['lock']);
1777
+			}
1694 1778
 			// You're only allowed to lock your own topics.
1695 1779
 			elseif (!allowedTo('lock_any'))
1696 1780
 			{
1697 1781
 				// You're not allowed to break a moderator's lock.
1698
-				if ($topic_info['locked'] == 1)
1699
-					unset($_POST['lock']);
1782
+				if ($topic_info['locked'] == 1) {
1783
+									unset($_POST['lock']);
1784
+				}
1700 1785
 				// Lock it with a soft lock or unlock it.
1701
-				else
1702
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1786
+				else {
1787
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1788
+				}
1703 1789
 			}
1704 1790
 			// You must be the moderator.
1705 1791
 			else
@@ -1707,44 +1793,46 @@  discard block
 block discarded – undo
1707 1793
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1708 1794
 
1709 1795
 				// Did someone (un)lock this while you were posting?
1710
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1711
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1796
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1797
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1798
+				}
1712 1799
 			}
1713 1800
 		}
1714 1801
 
1715 1802
 		// Change the sticky status of this topic?
1716
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1717
-			unset($_POST['sticky']);
1718
-		elseif (isset($_POST['sticky']))
1803
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1804
+					unset($_POST['sticky']);
1805
+		} elseif (isset($_POST['sticky']))
1719 1806
 		{
1720 1807
 			// Did someone (un)sticky this while you were posting?
1721
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1722
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1808
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1809
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1810
+			}
1723 1811
 		}
1724 1812
 
1725 1813
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1726 1814
 		{
1727
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1728
-				fatal_lang_error('modify_post_time_passed', false);
1729
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1730
-				isAllowedTo('modify_replies');
1731
-			else
1732
-				isAllowedTo('modify_own');
1733
-		}
1734
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1815
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1816
+							fatal_lang_error('modify_post_time_passed', false);
1817
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1818
+							isAllowedTo('modify_replies');
1819
+			} else {
1820
+							isAllowedTo('modify_own');
1821
+			}
1822
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1735 1823
 		{
1736 1824
 			isAllowedTo('modify_replies');
1737 1825
 
1738 1826
 			// If you're modifying a reply, I say it better be logged...
1739 1827
 			$moderationAction = true;
1740
-		}
1741
-		else
1828
+		} else
1742 1829
 		{
1743 1830
 			isAllowedTo('modify_any');
1744 1831
 
1745 1832
 			// Log it, assuming you're not modifying your own post.
1746
-			if ($row['id_member'] != $user_info['id'])
1747
-				$moderationAction = true;
1833
+			if ($row['id_member'] != $user_info['id']) {
1834
+							$moderationAction = true;
1835
+			}
1748 1836
 		}
1749 1837
 
1750 1838
 		// If drafts are enabled, then lets send this off to save
@@ -1783,20 +1871,24 @@  discard block
 block discarded – undo
1783 1871
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1784 1872
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1785 1873
 
1786
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1787
-			$post_errors[] = 'no_name';
1788
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1789
-			$post_errors[] = 'long_name';
1874
+		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') {
1875
+					$post_errors[] = 'no_name';
1876
+		}
1877
+		if ($smcFunc['strlen']($_POST['guestname']) > 25) {
1878
+					$post_errors[] = 'long_name';
1879
+		}
1790 1880
 
1791 1881
 		if (empty($modSettings['guest_post_no_email']))
1792 1882
 		{
1793 1883
 			// Only check if they changed it!
1794 1884
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1795 1885
 			{
1796
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1797
-					$post_errors[] = 'no_email';
1798
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1799
-					$post_errors[] = 'bad_email';
1886
+				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) {
1887
+									$post_errors[] = 'no_email';
1888
+				}
1889
+				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1890
+									$post_errors[] = 'bad_email';
1891
+				}
1800 1892
 			}
1801 1893
 
1802 1894
 			// Now make sure this email address is not banned from posting.
@@ -1812,81 +1904,95 @@  discard block
 block discarded – undo
1812 1904
 	}
1813 1905
 
1814 1906
 	// Coming from the quickReply?
1815
-	if (isset($_POST['quickReply']))
1816
-		$_POST['message'] = $_POST['quickReply'];
1907
+	if (isset($_POST['quickReply'])) {
1908
+			$_POST['message'] = $_POST['quickReply'];
1909
+	}
1817 1910
 
1818 1911
 	// Check the subject and message.
1819
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1820
-		$post_errors[] = 'no_subject';
1821
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1822
-		$post_errors[] = 'no_message';
1823
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1824
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1825
-	else
1912
+	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') {
1913
+			$post_errors[] = 'no_subject';
1914
+	}
1915
+	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') {
1916
+			$post_errors[] = 'no_message';
1917
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
1918
+			$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1919
+	} else
1826 1920
 	{
1827 1921
 		// Prepare the message a bit for some additional testing.
1828 1922
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1829 1923
 
1830 1924
 		// Preparse code. (Zef)
1831
-		if ($user_info['is_guest'])
1832
-			$user_info['name'] = $_POST['guestname'];
1925
+		if ($user_info['is_guest']) {
1926
+					$user_info['name'] = $_POST['guestname'];
1927
+		}
1833 1928
 		preparsecode($_POST['message']);
1834 1929
 
1835 1930
 		// Youtube BBC would be stripped out in the next check without this
1836 1931
 		$context['allowed_html_tags'][] = '<iframe>';
1837 1932
 
1838 1933
 		// Let's see if there's still some content left without the tags.
1839
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1840
-			$post_errors[] = 'no_message';
1934
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) {
1935
+					$post_errors[] = 'no_message';
1936
+		}
1841 1937
 
1842 1938
 		// Remove iframe from the list
1843 1939
 		array_pop($context['allowed_html_tags']);
1844 1940
 	}
1845
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1846
-		$post_errors[] = 'no_event';
1941
+	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') {
1942
+			$post_errors[] = 'no_event';
1943
+	}
1847 1944
 	// You are not!
1848
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1849
-		fatal_error('Knave! Masquerader! Charlatan!', false);
1945
+	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) {
1946
+			fatal_error('Knave! Masquerader! Charlatan!', false);
1947
+	}
1850 1948
 
1851 1949
 	// Validate the poll...
1852 1950
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1853 1951
 	{
1854
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1855
-			fatal_lang_error('no_access', false);
1952
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
1953
+					fatal_lang_error('no_access', false);
1954
+		}
1856 1955
 
1857 1956
 		// This is a new topic... so it's a new poll.
1858
-		if (empty($topic))
1859
-			isAllowedTo('poll_post');
1957
+		if (empty($topic)) {
1958
+					isAllowedTo('poll_post');
1959
+		}
1860 1960
 		// Can you add to your own topics?
1861
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1862
-			isAllowedTo('poll_add_own');
1961
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
1962
+					isAllowedTo('poll_add_own');
1963
+		}
1863 1964
 		// Can you add polls to any topic, then?
1864
-		else
1865
-			isAllowedTo('poll_add_any');
1965
+		else {
1966
+					isAllowedTo('poll_add_any');
1967
+		}
1866 1968
 
1867
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1868
-			$post_errors[] = 'no_question';
1969
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
1970
+					$post_errors[] = 'no_question';
1971
+		}
1869 1972
 
1870 1973
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1871 1974
 
1872 1975
 		// Get rid of empty ones.
1873
-		foreach ($_POST['options'] as $k => $option)
1874
-			if ($option == '')
1976
+		foreach ($_POST['options'] as $k => $option) {
1977
+					if ($option == '')
1875 1978
 				unset($_POST['options'][$k], $_POST['options'][$k]);
1979
+		}
1876 1980
 
1877 1981
 		// What are you going to vote between with one choice?!?
1878
-		if (count($_POST['options']) < 2)
1879
-			$post_errors[] = 'poll_few';
1880
-		elseif (count($_POST['options']) > 256)
1881
-			$post_errors[] = 'poll_many';
1982
+		if (count($_POST['options']) < 2) {
1983
+					$post_errors[] = 'poll_few';
1984
+		} elseif (count($_POST['options']) > 256) {
1985
+					$post_errors[] = 'poll_many';
1986
+		}
1882 1987
 	}
1883 1988
 
1884 1989
 	if ($posterIsGuest)
1885 1990
 	{
1886 1991
 		// If user is a guest, make sure the chosen name isn't taken.
1887 1992
 		require_once($sourcedir . '/Subs-Members.php');
1888
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1889
-			$post_errors[] = 'bad_name';
1993
+		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) {
1994
+					$post_errors[] = 'bad_name';
1995
+		}
1890 1996
 	}
1891 1997
 	// If the user isn't a guest, get his or her name and email.
1892 1998
 	elseif (!isset($_REQUEST['msg']))
@@ -1917,8 +2023,9 @@  discard block
 block discarded – undo
1917 2023
 	}
1918 2024
 
1919 2025
 	// Make sure the user isn't spamming the board.
1920
-	if (!isset($_REQUEST['msg']))
1921
-		spamProtection('post');
2026
+	if (!isset($_REQUEST['msg'])) {
2027
+			spamProtection('post');
2028
+	}
1922 2029
 
1923 2030
 	// At about this point, we're posting and that's that.
1924 2031
 	ignore_user_abort(true);
@@ -1931,32 +2038,36 @@  discard block
 block discarded – undo
1931 2038
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1932 2039
 
1933 2040
 	// At this point, we want to make sure the subject isn't too long.
1934
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1935
-		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2041
+	if ($smcFunc['strlen']($_POST['subject']) > 100) {
2042
+			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2043
+	}
1936 2044
 
1937 2045
 	// Same with the "why did you edit this" text.
1938
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1939
-		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2046
+	if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
2047
+			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2048
+	}
1940 2049
 
1941 2050
 	// Make the poll...
1942 2051
 	if (isset($_REQUEST['poll']))
1943 2052
 	{
1944 2053
 		// Make sure that the user has not entered a ridiculous number of options..
1945
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1946
-			$_POST['poll_max_votes'] = 1;
1947
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1948
-			$_POST['poll_max_votes'] = count($_POST['options']);
1949
-		else
1950
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2054
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
2055
+					$_POST['poll_max_votes'] = 1;
2056
+		} elseif ($_POST['poll_max_votes'] > count($_POST['options'])) {
2057
+					$_POST['poll_max_votes'] = count($_POST['options']);
2058
+		} else {
2059
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2060
+		}
1951 2061
 
1952 2062
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
1953 2063
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
1954 2064
 
1955 2065
 		// Just set it to zero if it's not there..
1956
-		if (!isset($_POST['poll_hide']))
1957
-			$_POST['poll_hide'] = 0;
1958
-		else
1959
-			$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2066
+		if (!isset($_POST['poll_hide'])) {
2067
+					$_POST['poll_hide'] = 0;
2068
+		} else {
2069
+					$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2070
+		}
1960 2071
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
1961 2072
 
1962 2073
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -1965,16 +2076,19 @@  discard block
 block discarded – undo
1965 2076
 		{
1966 2077
 			require_once($sourcedir . '/Subs-Members.php');
1967 2078
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
1968
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
1969
-				$_POST['poll_guest_vote'] = 0;
2079
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2080
+							$_POST['poll_guest_vote'] = 0;
2081
+			}
1970 2082
 		}
1971 2083
 
1972 2084
 		// If the user tries to set the poll too far in advance, don't let them.
1973
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
1974
-			fatal_lang_error('poll_range_error', false);
2085
+		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
2086
+					fatal_lang_error('poll_range_error', false);
2087
+		}
1975 2088
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
1976
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
1977
-			$_POST['poll_hide'] = 1;
2089
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2090
+					$_POST['poll_hide'] = 1;
2091
+		}
1978 2092
 
1979 2093
 		// Clean up the question and answers.
1980 2094
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -1988,13 +2102,15 @@  discard block
 block discarded – undo
1988 2102
 	{
1989 2103
 		$attachIDs = array();
1990 2104
 		$attach_errors = array();
1991
-		if (!empty($context['we_are_history']))
1992
-			$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2105
+		if (!empty($context['we_are_history'])) {
2106
+					$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2107
+		}
1993 2108
 
1994 2109
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
1995 2110
 		{
1996
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1997
-				continue;
2111
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2112
+							continue;
2113
+			}
1998 2114
 
1999 2115
 			// If there was an initial error just show that message.
2000 2116
 			if ($attachID == 'initial_error')
@@ -2023,12 +2139,13 @@  discard block
 block discarded – undo
2023 2139
 				if (createAttachment($attachmentOptions))
2024 2140
 				{
2025 2141
 					$attachIDs[] = $attachmentOptions['id'];
2026
-					if (!empty($attachmentOptions['thumb']))
2027
-						$attachIDs[] = $attachmentOptions['thumb'];
2142
+					if (!empty($attachmentOptions['thumb'])) {
2143
+											$attachIDs[] = $attachmentOptions['thumb'];
2144
+					}
2028 2145
 				}
2146
+			} else {
2147
+							$attach_errors[] = '<dt>&nbsp;</dt>';
2029 2148
 			}
2030
-			else
2031
-				$attach_errors[] = '<dt>&nbsp;</dt>';
2032 2149
 
2033 2150
 			if (!empty($attachmentOptions['errors']))
2034 2151
 			{
@@ -2040,14 +2157,16 @@  discard block
 block discarded – undo
2040 2157
 					if (!is_array($error))
2041 2158
 					{
2042 2159
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
2043
-						if (in_array($error, $log_these))
2044
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2160
+						if (in_array($error, $log_these)) {
2161
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2162
+						}
2163
+					} else {
2164
+											$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2045 2165
 					}
2046
-					else
2047
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2048 2166
 				}
2049
-				if (file_exists($attachment['tmp_name']))
2050
-					unlink($attachment['tmp_name']);
2167
+				if (file_exists($attachment['tmp_name'])) {
2168
+									unlink($attachment['tmp_name']);
2169
+				}
2051 2170
 			}
2052 2171
 		}
2053 2172
 		unset($_SESSION['temp_attachments']);
@@ -2088,24 +2207,24 @@  discard block
 block discarded – undo
2088 2207
 		);
2089 2208
 
2090 2209
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2210
+	} else {
2211
+			$id_poll = 0;
2091 2212
 	}
2092
-	else
2093
-		$id_poll = 0;
2094 2213
 
2095 2214
 	// Creating a new topic?
2096 2215
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2097 2216
 
2098 2217
 	// Check the icon.
2099
-	if (!isset($_POST['icon']))
2100
-		$_POST['icon'] = 'xx';
2101
-
2102
-	else
2218
+	if (!isset($_POST['icon'])) {
2219
+			$_POST['icon'] = 'xx';
2220
+	} else
2103 2221
 	{
2104 2222
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2105 2223
 
2106 2224
 		// Need to figure it out if this is a valid icon name.
2107
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2108
-			$_POST['icon'] = 'xx';
2225
+		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) {
2226
+					$_POST['icon'] = 'xx';
2227
+		}
2109 2228
 	}
2110 2229
 
2111 2230
 	// Collect all parameters for the creation or modification of a post.
@@ -2146,8 +2265,9 @@  discard block
 block discarded – undo
2146 2265
 		}
2147 2266
 
2148 2267
 		// This will save some time...
2149
-		if (empty($approve_has_changed))
2150
-			unset($msgOptions['approved']);
2268
+		if (empty($approve_has_changed)) {
2269
+					unset($msgOptions['approved']);
2270
+		}
2151 2271
 
2152 2272
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2153 2273
 	}
@@ -2156,8 +2276,9 @@  discard block
 block discarded – undo
2156 2276
 	{
2157 2277
 		createPost($msgOptions, $topicOptions, $posterOptions);
2158 2278
 
2159
-		if (isset($topicOptions['id']))
2160
-			$topic = $topicOptions['id'];
2279
+		if (isset($topicOptions['id'])) {
2280
+					$topic = $topicOptions['id'];
2281
+		}
2161 2282
 	}
2162 2283
 
2163 2284
 	// Are there attachments already uploaded and waiting to be assigned?
@@ -2169,8 +2290,9 @@  discard block
 block discarded – undo
2169 2290
 	}
2170 2291
 
2171 2292
 	// If we had a draft for this, its time to remove it since it was just posted
2172
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2173
-		DeleteDraft($_POST['id_draft']);
2293
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2294
+			DeleteDraft($_POST['id_draft']);
2295
+	}
2174 2296
 
2175 2297
 	// Editing or posting an event?
2176 2298
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2189,8 +2311,7 @@  discard block
 block discarded – undo
2189 2311
 			'member' => $user_info['id'],
2190 2312
 		);
2191 2313
 		insertEvent($eventOptions);
2192
-	}
2193
-	elseif (isset($_POST['calendar']))
2314
+	} elseif (isset($_POST['calendar']))
2194 2315
 	{
2195 2316
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2196 2317
 
@@ -2218,14 +2339,15 @@  discard block
 block discarded – undo
2218 2339
 		}
2219 2340
 
2220 2341
 		// Delete it?
2221
-		if (isset($_REQUEST['deleteevent']))
2222
-			$smcFunc['db_query']('', '
2342
+		if (isset($_REQUEST['deleteevent'])) {
2343
+					$smcFunc['db_query']('', '
2223 2344
 				DELETE FROM {db_prefix}calendar
2224 2345
 				WHERE id_event = {int:id_event}',
2225 2346
 				array(
2226 2347
 					'id_event' => $_REQUEST['eventid'],
2227 2348
 				)
2228 2349
 			);
2350
+		}
2229 2351
 		// ... or just update it?
2230 2352
 		else
2231 2353
 		{
@@ -2267,9 +2389,8 @@  discard block
 block discarded – undo
2267 2389
 			array($user_info['id'], $topic, 0),
2268 2390
 			array('id_member', 'id_topic', 'id_board')
2269 2391
 		);
2270
-	}
2271
-	elseif (!$newTopic)
2272
-		$smcFunc['db_query']('', '
2392
+	} elseif (!$newTopic) {
2393
+			$smcFunc['db_query']('', '
2273 2394
 			DELETE FROM {db_prefix}log_notify
2274 2395
 			WHERE id_member = {int:current_member}
2275 2396
 				AND id_topic = {int:current_topic}',
@@ -2278,16 +2399,20 @@  discard block
 block discarded – undo
2278 2399
 				'current_topic' => $topic,
2279 2400
 			)
2280 2401
 		);
2402
+	}
2281 2403
 
2282 2404
 	// Log an act of moderation - modifying.
2283
-	if (!empty($moderationAction))
2284
-		logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2405
+	if (!empty($moderationAction)) {
2406
+			logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2407
+	}
2285 2408
 
2286
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2287
-		logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2409
+	if (isset($_POST['lock']) && $_POST['lock'] != 2) {
2410
+			logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2411
+	}
2288 2412
 
2289
-	if (isset($_POST['sticky']))
2290
-		logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2413
+	if (isset($_POST['sticky'])) {
2414
+			logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2415
+	}
2291 2416
 
2292 2417
 	// Returning to the topic?
2293 2418
 	if (!empty($_REQUEST['goback']))
@@ -2306,26 +2431,31 @@  discard block
 block discarded – undo
2306 2431
 		);
2307 2432
 	}
2308 2433
 
2309
-	if ($board_info['num_topics'] == 0)
2310
-		cache_put_data('board-' . $board, null, 120);
2434
+	if ($board_info['num_topics'] == 0) {
2435
+			cache_put_data('board-' . $board, null, 120);
2436
+	}
2311 2437
 
2312 2438
 	call_integration_hook('integrate_post2_end');
2313 2439
 
2314
-	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic'))
2315
-		redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2440
+	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) {
2441
+			redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2442
+	}
2316 2443
 
2317
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2318
-		redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2444
+	if (!empty($_POST['move']) && allowedTo('move_any')) {
2445
+			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2446
+	}
2319 2447
 
2320 2448
 	// Return to post if the mod is on.
2321
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2322
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2323
-	elseif (!empty($_REQUEST['goback']))
2324
-		redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2449
+	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
2450
+			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2451
+	} elseif (!empty($_REQUEST['goback'])) {
2452
+			redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2453
+	}
2325 2454
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2326
-	else
2327
-		redirectexit('board=' . $board . '.0');
2328
-}
2455
+	else {
2456
+			redirectexit('board=' . $board . '.0');
2457
+	}
2458
+	}
2329 2459
 
2330 2460
 /**
2331 2461
  * Handle the announce topic function (action=announce).
@@ -2343,8 +2473,9 @@  discard block
 block discarded – undo
2343 2473
 
2344 2474
 	validateSession();
2345 2475
 
2346
-	if (empty($topic))
2347
-		fatal_lang_error('topic_gone', false);
2476
+	if (empty($topic)) {
2477
+			fatal_lang_error('topic_gone', false);
2478
+	}
2348 2479
 
2349 2480
 	loadLanguage('Post');
2350 2481
 	loadTemplate('Post');
@@ -2371,8 +2502,9 @@  discard block
 block discarded – undo
2371 2502
 	global $txt, $context, $topic, $board_info, $smcFunc;
2372 2503
 
2373 2504
 	$groups = array_merge($board_info['groups'], array(1));
2374
-	foreach ($groups as $id => $group)
2375
-		$groups[$id] = (int) $group;
2505
+	foreach ($groups as $id => $group) {
2506
+			$groups[$id] = (int) $group;
2507
+	}
2376 2508
 
2377 2509
 	$context['groups'] = array();
2378 2510
 	if (in_array(0, $groups))
@@ -2415,8 +2547,9 @@  discard block
 block discarded – undo
2415 2547
 			'group_list' => $groups,
2416 2548
 		)
2417 2549
 	);
2418
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2419
-		$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2550
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2551
+			$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2552
+	}
2420 2553
 	$smcFunc['db_free_result']($request);
2421 2554
 
2422 2555
 	// Get the subject of the topic we're about to announce.
@@ -2458,16 +2591,19 @@  discard block
 block discarded – undo
2458 2591
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2459 2592
 	$groups = array_merge($board_info['groups'], array(1));
2460 2593
 
2461
-	if (isset($_POST['membergroups']))
2462
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2594
+	if (isset($_POST['membergroups'])) {
2595
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2596
+	}
2463 2597
 
2464 2598
 	// Check whether at least one membergroup was selected.
2465
-	if (empty($_POST['who']))
2466
-		fatal_lang_error('no_membergroup_selected');
2599
+	if (empty($_POST['who'])) {
2600
+			fatal_lang_error('no_membergroup_selected');
2601
+	}
2467 2602
 
2468 2603
 	// Make sure all membergroups are integers and can access the board of the announcement.
2469
-	foreach ($_POST['who'] as $id => $mg)
2470
-		$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2604
+	foreach ($_POST['who'] as $id => $mg) {
2605
+			$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2606
+	}
2471 2607
 
2472 2608
 	// Get the topic subject and censor it.
2473 2609
 	$request = $smcFunc['db_query']('', '
@@ -2513,12 +2649,13 @@  discard block
 block discarded – undo
2513 2649
 	if ($smcFunc['db_num_rows']($request) == 0)
2514 2650
 	{
2515 2651
 		logAction('announce_topic', array('topic' => $topic), 'user');
2516
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2517
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2518
-		elseif (!empty($_REQUEST['goback']))
2519
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2520
-		else
2521
-			redirectexit('board=' . $board . '.0');
2652
+		if (!empty($_REQUEST['move']) && allowedTo('move_any')) {
2653
+					redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2654
+		} elseif (!empty($_REQUEST['goback'])) {
2655
+					redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2656
+		} else {
2657
+					redirectexit('board=' . $board . '.0');
2658
+		}
2522 2659
 	}
2523 2660
 
2524 2661
 	$announcements = array();
@@ -2537,8 +2674,9 @@  discard block
 block discarded – undo
2537 2674
 	foreach ($rows as $row)
2538 2675
 	{
2539 2676
 		// Force them to have it?
2540
-		if (empty($prefs[$row['id_member']]['announcements']))
2541
-			continue;
2677
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2678
+					continue;
2679
+		}
2542 2680
 
2543 2681
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2544 2682
 
@@ -2566,8 +2704,9 @@  discard block
 block discarded – undo
2566 2704
 	}
2567 2705
 
2568 2706
 	// For each language send a different mail - low priority...
2569
-	foreach ($announcements as $lang => $mail)
2570
-		sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2707
+	foreach ($announcements as $lang => $mail) {
2708
+			sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2709
+	}
2571 2710
 
2572 2711
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2573 2712
 
@@ -2577,9 +2716,10 @@  discard block
 block discarded – undo
2577 2716
 	$context['sub_template'] = 'announcement_send';
2578 2717
 
2579 2718
 	// Go back to the correct language for the user ;).
2580
-	if (!empty($modSettings['userLanguage']))
2581
-		loadLanguage('Post');
2582
-}
2719
+	if (!empty($modSettings['userLanguage'])) {
2720
+			loadLanguage('Post');
2721
+	}
2722
+	}
2583 2723
 
2584 2724
 /**
2585 2725
  * Get the topic for display purposes.
@@ -2592,12 +2732,13 @@  discard block
 block discarded – undo
2592 2732
 {
2593 2733
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2594 2734
 
2595
-	if (isset($_REQUEST['xml']))
2596
-		$limit = '
2735
+	if (isset($_REQUEST['xml'])) {
2736
+			$limit = '
2597 2737
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2598
-	else
2599
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2738
+	} else {
2739
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2600 2740
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2741
+	}
2601 2742
 
2602 2743
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2603 2744
 	$request = $smcFunc['db_query']('', '
@@ -2635,8 +2776,9 @@  discard block
 block discarded – undo
2635 2776
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2636 2777
 		);
2637 2778
 
2638
-		if (!empty($context['new_replies']))
2639
-			$context['new_replies']--;
2779
+		if (!empty($context['new_replies'])) {
2780
+					$context['new_replies']--;
2781
+		}
2640 2782
 	}
2641 2783
 	$smcFunc['db_free_result']($request);
2642 2784
 }
@@ -2653,8 +2795,9 @@  discard block
 block discarded – undo
2653 2795
 	global $sourcedir, $smcFunc;
2654 2796
 
2655 2797
 	loadLanguage('Post');
2656
-	if (!isset($_REQUEST['xml']))
2657
-		loadTemplate('Post');
2798
+	if (!isset($_REQUEST['xml'])) {
2799
+			loadTemplate('Post');
2800
+	}
2658 2801
 
2659 2802
 	include_once($sourcedir . '/Subs-Post.php');
2660 2803
 
@@ -2685,8 +2828,9 @@  discard block
 block discarded – undo
2685 2828
 	$smcFunc['db_free_result']($request);
2686 2829
 
2687 2830
 	$context['sub_template'] = 'quotefast';
2688
-	if (!empty($row))
2689
-		$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2831
+	if (!empty($row)) {
2832
+			$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2833
+	}
2690 2834
 
2691 2835
 	if (!empty($can_view_post))
2692 2836
 	{
@@ -2719,8 +2863,9 @@  discard block
 block discarded – undo
2719 2863
 		}
2720 2864
 
2721 2865
 		// Remove any nested quotes.
2722
-		if (!empty($modSettings['removeNestedQuotes']))
2723
-			$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2866
+		if (!empty($modSettings['removeNestedQuotes'])) {
2867
+					$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2868
+		}
2724 2869
 
2725 2870
 		$lb = "\n";
2726 2871
 
@@ -2746,14 +2891,14 @@  discard block
 block discarded – undo
2746 2891
 				'time' => '',
2747 2892
 			),
2748 2893
 		);
2749
-	}
2750
-	else
2751
-		$context['quote'] = array(
2894
+	} else {
2895
+			$context['quote'] = array(
2752 2896
 			'xml' => '',
2753 2897
 			'mozilla' => '',
2754 2898
 			'text' => '',
2755 2899
 		);
2756
-}
2900
+	}
2901
+	}
2757 2902
 
2758 2903
 /**
2759 2904
  * Used to edit the body or subject of a message inline
@@ -2765,8 +2910,9 @@  discard block
 block discarded – undo
2765 2910
 	global $user_info, $context, $smcFunc, $language, $board_info;
2766 2911
 
2767 2912
 	// We have to have a topic!
2768
-	if (empty($topic))
2769
-		obExit(false);
2913
+	if (empty($topic)) {
2914
+			obExit(false);
2915
+	}
2770 2916
 
2771 2917
 	checkSession('get');
2772 2918
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2792,31 +2938,35 @@  discard block
 block discarded – undo
2792 2938
 			'guest_id' => 0,
2793 2939
 		)
2794 2940
 	);
2795
-	if ($smcFunc['db_num_rows']($request) == 0)
2796
-		fatal_lang_error('no_board', false);
2941
+	if ($smcFunc['db_num_rows']($request) == 0) {
2942
+			fatal_lang_error('no_board', false);
2943
+	}
2797 2944
 	$row = $smcFunc['db_fetch_assoc']($request);
2798 2945
 	$smcFunc['db_free_result']($request);
2799 2946
 
2800 2947
 	// Change either body or subject requires permissions to modify messages.
2801 2948
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2802 2949
 	{
2803
-		if (!empty($row['locked']))
2804
-			isAllowedTo('moderate_board');
2950
+		if (!empty($row['locked'])) {
2951
+					isAllowedTo('moderate_board');
2952
+		}
2805 2953
 
2806 2954
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2807 2955
 		{
2808
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2809
-				fatal_lang_error('modify_post_time_passed', false);
2810
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2811
-				isAllowedTo('modify_replies');
2812
-			else
2813
-				isAllowedTo('modify_own');
2956
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
2957
+							fatal_lang_error('modify_post_time_passed', false);
2958
+			} elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
2959
+							isAllowedTo('modify_replies');
2960
+			} else {
2961
+							isAllowedTo('modify_own');
2962
+			}
2814 2963
 		}
2815 2964
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2816
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2817
-			isAllowedTo('modify_replies');
2818
-		else
2819
-			isAllowedTo('modify_any');
2965
+		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
2966
+					isAllowedTo('modify_replies');
2967
+		} else {
2968
+					isAllowedTo('modify_any');
2969
+		}
2820 2970
 
2821 2971
 		// Only log this action if it wasn't your message.
2822 2972
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2828,10 +2978,10 @@  discard block
 block discarded – undo
2828 2978
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2829 2979
 
2830 2980
 		// Maximum number of characters.
2831
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2832
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2833
-	}
2834
-	elseif (isset($_POST['subject']))
2981
+		if ($smcFunc['strlen']($_POST['subject']) > 100) {
2982
+					$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2983
+		}
2984
+	} elseif (isset($_POST['subject']))
2835 2985
 	{
2836 2986
 		$post_errors[] = 'no_subject';
2837 2987
 		unset($_POST['subject']);
@@ -2843,13 +2993,11 @@  discard block
 block discarded – undo
2843 2993
 		{
2844 2994
 			$post_errors[] = 'no_message';
2845 2995
 			unset($_POST['message']);
2846
-		}
2847
-		elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2996
+		} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2848 2997
 		{
2849 2998
 			$post_errors[] = 'long_message';
2850 2999
 			unset($_POST['message']);
2851
-		}
2852
-		else
3000
+		} else
2853 3001
 		{
2854 3002
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2855 3003
 
@@ -2865,31 +3013,34 @@  discard block
 block discarded – undo
2865 3013
 
2866 3014
 	if (isset($_POST['lock']))
2867 3015
 	{
2868
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2869
-			unset($_POST['lock']);
2870
-		elseif (!allowedTo('lock_any'))
3016
+		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) {
3017
+					unset($_POST['lock']);
3018
+		} elseif (!allowedTo('lock_any'))
2871 3019
 		{
2872
-			if ($row['locked'] == 1)
2873
-				unset($_POST['lock']);
2874
-			else
2875
-				$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3020
+			if ($row['locked'] == 1) {
3021
+							unset($_POST['lock']);
3022
+			} else {
3023
+							$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3024
+			}
3025
+		} elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
3026
+					unset($_POST['lock']);
3027
+		} else {
3028
+					$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2876 3029
 		}
2877
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2878
-			unset($_POST['lock']);
2879
-		else
2880
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2881 3030
 	}
2882 3031
 
2883
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2884
-		unset($_POST['sticky']);
3032
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
3033
+			unset($_POST['sticky']);
3034
+	}
2885 3035
 
2886 3036
 	if (isset($_POST['modify_reason']))
2887 3037
 	{
2888 3038
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2889 3039
 
2890 3040
 		// Maximum number of characters.
2891
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2892
-			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3041
+		if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
3042
+					$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3043
+		}
2893 3044
 	}
2894 3045
 
2895 3046
 	if (empty($post_errors))
@@ -2926,8 +3077,9 @@  discard block
 block discarded – undo
2926 3077
 			}
2927 3078
 		}
2928 3079
 		// If nothing was changed there's no need to add an entry to the moderation log.
2929
-		else
2930
-			$moderationAction = false;
3080
+		else {
3081
+					$moderationAction = false;
3082
+		}
2931 3083
 
2932 3084
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2933 3085
 
@@ -2945,9 +3097,9 @@  discard block
 block discarded – undo
2945 3097
 			// Get the proper (default language) response prefix first.
2946 3098
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2947 3099
 			{
2948
-				if ($language === $user_info['language'])
2949
-					$context['response_prefix'] = $txt['response_prefix'];
2950
-				else
3100
+				if ($language === $user_info['language']) {
3101
+									$context['response_prefix'] = $txt['response_prefix'];
3102
+				} else
2951 3103
 				{
2952 3104
 					loadLanguage('index', $language, false);
2953 3105
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -2969,8 +3121,9 @@  discard block
 block discarded – undo
2969 3121
 			);
2970 3122
 		}
2971 3123
 
2972
-		if (!empty($moderationAction))
2973
-			logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3124
+		if (!empty($moderationAction)) {
3125
+					logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3126
+		}
2974 3127
 	}
2975 3128
 
2976 3129
 	if (isset($_REQUEST['xml']))
@@ -3011,8 +3164,7 @@  discard block
 block discarded – undo
3011 3164
 			);
3012 3165
 
3013 3166
 			censorText($context['message']['subject']);
3014
-		}
3015
-		else
3167
+		} else
3016 3168
 		{
3017 3169
 			$context['message'] = array(
3018 3170
 				'id' => $row['id_msg'],
@@ -3024,15 +3176,16 @@  discard block
 block discarded – undo
3024 3176
 			loadLanguage('Errors');
3025 3177
 			foreach ($post_errors as $post_error)
3026 3178
 			{
3027
-				if ($post_error == 'long_message')
3028
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3029
-				else
3030
-					$context['message']['errors'][] = $txt['error_' . $post_error];
3179
+				if ($post_error == 'long_message') {
3180
+									$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3181
+				} else {
3182
+									$context['message']['errors'][] = $txt['error_' . $post_error];
3183
+				}
3031 3184
 			}
3032 3185
 		}
3186
+	} else {
3187
+			obExit(false);
3188
+	}
3033 3189
 	}
3034
-	else
3035
-		obExit(false);
3036
-}
3037 3190
 
3038 3191
 ?>
3039 3192
\ No newline at end of file
Please login to merge, or discard this patch.