Completed
Pull Request — release-2.1 (#4597)
by Michael
08:14
created
Themes/default/ManagePermissions.template.php 1 patch
Braces   +170 added lines, -128 removed lines patch added patch discarded remove patch
@@ -19,26 +19,28 @@  discard block
 block discarded – undo
19 19
 	global $context, $settings, $scripturl, $txt, $modSettings;
20 20
 
21 21
 	// Not allowed to edit?
22
-	if (!$context['can_modify'])
23
-		echo '
22
+	if (!$context['can_modify']) {
23
+			echo '
24 24
 	<div class="errorbox">
25 25
 		', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
26 26
 	</div>';
27
+	}
27 28
 
28 29
 	echo '
29 30
 	<div id="admin_form_wrapper">
30 31
 		<form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">';
31 32
 
32
-	if (!empty($context['profile']))
33
-		echo '
33
+	if (!empty($context['profile'])) {
34
+			echo '
34 35
 			<div class="cat_bar">
35 36
 				<h3 class="catbg">', $txt['permissions_for_profile'], ': &quot;', $context['profile']['name'], '&quot;</h3>
36 37
 			</div>';
37
-	else
38
-		echo '
38
+	} else {
39
+			echo '
39 40
 			<div class="cat_bar">
40 41
 				<h3 class="catbg">', $txt['permissions_title'], '</h3>
41 42
 			</div>';
43
+	}
42 44
 
43 45
 	echo '
44 46
 			<table class="table_grid">
@@ -47,13 +49,14 @@  discard block
 block discarded – undo
47 49
 						<th>', $txt['membergroups_name'], '</th>
48 50
 						<th class="small_table">', $txt['membergroups_members_top'], '</th>';
49 51
 
50
-	if (empty($modSettings['permission_enable_deny']))
51
-		echo '
52
+	if (empty($modSettings['permission_enable_deny'])) {
53
+			echo '
52 54
 						<th class="small_table">', $txt['membergroups_permissions'], '</th>';
53
-	else
54
-		echo '
55
+	} else {
56
+			echo '
55 57
 						<th class="small_table">', $txt['permissions_allowed'], '</th>
56 58
 						<th class="small_table">', $txt['permissions_denied'], '</th>';
59
+	}
57 60
 
58 61
 	echo '
59 62
 						<th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th>
@@ -71,26 +74,28 @@  discard block
 block discarded – undo
71 74
 						<td>
72 75
 							', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a> ' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '<span>', $group['name'], '</span>';
73 76
 
74
-		if (!empty($group['children']))
75
-			echo '
77
+		if (!empty($group['children'])) {
78
+					echo '
76 79
 							<br>
77 80
 							<span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
81
+		}
78 82
 
79 83
 		echo '
80 84
 						</td>
81 85
 						<td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>';
82 86
 
83
-		if (empty($modSettings['permission_enable_deny']))
84
-			echo '
87
+		if (empty($modSettings['permission_enable_deny'])) {
88
+					echo '
85 89
 						<td>', $group['num_permissions']['allowed'], '</td>';
86
-		else
87
-			echo '
90
+		} else {
91
+					echo '
88 92
 						<td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>
89 93
 							', $group['num_permissions']['allowed'], '
90 94
 						</td>
91 95
 						<td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '>
92 96
 							', $group['num_permissions']['denied'], '
93 97
 						</td>';
98
+		}
94 99
 
95 100
 		echo '
96 101
 						<td>
@@ -141,10 +146,11 @@  discard block
 block discarded – undo
141 146
 							<select name="copy_from">
142 147
 								<option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
143 148
 
144
-		foreach ($context['groups'] as $group)
145
-			if ($group['id'] != 1)
149
+		foreach ($context['groups'] as $group) {
150
+					if ($group['id'] != 1)
146 151
 				echo '
147 152
 								<option value="', $group['id'], '">', $group['name'], '</option>';
153
+		}
148 154
 
149 155
 		echo '
150 156
 							</select>
@@ -154,9 +160,10 @@  discard block
 block discarded – undo
154 160
 								<option value="add">', $txt['permissions_add'], '...</option>
155 161
 								<option value="clear">', $txt['permissions_remove'], '...</option>';
156 162
 
157
-		if (!empty($modSettings['permission_enable_deny']))
158
-			echo '
163
+		if (!empty($modSettings['permission_enable_deny'])) {
164
+					echo '
159 165
 								<option value="deny">', $txt['permissions_deny'], '...</option>';
166
+		}
160 167
 
161 168
 		echo '
162 169
 							</select>
@@ -167,31 +174,35 @@  discard block
 block discarded – undo
167 174
 
168 175
 		foreach ($context['permissions'] as $permissionType)
169 176
 		{
170
-			if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
171
-				continue;
177
+			if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) {
178
+							continue;
179
+			}
172 180
 
173 181
 			foreach ($permissionType['columns'] as $column)
174 182
 			{
175 183
 				foreach ($column as $permissionGroup)
176 184
 				{
177
-					if ($permissionGroup['hidden'])
178
-						continue;
185
+					if ($permissionGroup['hidden']) {
186
+											continue;
187
+					}
179 188
 
180 189
 					echo '
181 190
 								<option value="" disabled>[', $permissionGroup['name'], ']</option>';
182 191
 
183 192
 					foreach ($permissionGroup['permissions'] as $perm)
184 193
 					{
185
-						if ($perm['hidden'])
186
-							continue;
194
+						if ($perm['hidden']) {
195
+													continue;
196
+						}
187 197
 
188
-						if ($perm['has_own_any'])
189
-							echo '
198
+						if ($perm['has_own_any']) {
199
+													echo '
190 200
 								<option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
191 201
 								<option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
192
-						else
193
-							echo '
202
+						} else {
203
+													echo '
194 204
 								<option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
205
+						}
195 206
 					}
196 207
 				}
197 208
 			}
@@ -256,9 +267,10 @@  discard block
 block discarded – undo
256 267
 				}
257 268
 			</script>';
258 269
 
259
-		if (!empty($context['profile']))
260
-			echo '
270
+		if (!empty($context['profile'])) {
271
+					echo '
261 272
 			<input type="hidden" name="pid" value="', $context['profile']['id'], '">';
273
+		}
262 274
 
263 275
 		echo '
264 276
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -303,9 +315,10 @@  discard block
 block discarded – undo
303 315
 					<h3 class="subbg">', $category['name'], '</h3>
304 316
 				</div>';
305 317
 
306
-		if (!empty($category['boards']))
307
-			echo '
318
+		if (!empty($category['boards'])) {
319
+					echo '
308 320
 				<ul class="perm_boards flow_hidden">';
321
+		}
309 322
 
310 323
 		foreach ($category['boards'] as $board)
311 324
 		{
@@ -321,33 +334,36 @@  discard block
 block discarded – undo
321 334
 				echo '
322 335
 							<select name="boardprofile[', $board['id'], ']">';
323 336
 
324
-				foreach ($context['profiles'] as $id => $profile)
325
-					echo '
337
+				foreach ($context['profiles'] as $id => $profile) {
338
+									echo '
326 339
 								<option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
340
+				}
327 341
 
328 342
 				echo '
329 343
 							</select>';
330
-			}
331
-			else
332
-				echo '
344
+			} else {
345
+							echo '
333 346
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>';
347
+			}
334 348
 
335 349
 			echo '
336 350
 						</span>
337 351
 					</li>';
338 352
 		}
339 353
 
340
-		if (!empty($category['boards']))
341
-			echo '
354
+		if (!empty($category['boards'])) {
355
+					echo '
342 356
 				</ul>';
357
+		}
343 358
 	}
344 359
 
345
-	if ($context['edit_all'])
346
-		echo '
360
+	if ($context['edit_all']) {
361
+			echo '
347 362
 				<input type="submit" name="save_changes" value="', $txt['save'], '" class="button">';
348
-	else
349
-		echo '
363
+	} else {
364
+			echo '
350 365
 				<a class="button" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>';
366
+	}
351 367
 
352 368
 	echo '
353 369
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -387,12 +403,13 @@  discard block
 block discarded – undo
387 403
 					<tr class="windowbg">
388 404
 						<td>';
389 405
 
390
-		if (!empty($context['show_rename_boxes']) && $profile['can_edit'])
391
-			echo '
406
+		if (!empty($context['show_rename_boxes']) && $profile['can_edit']) {
407
+					echo '
392 408
 							<input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '">';
393
-		else
394
-			echo '
409
+		} else {
410
+					echo '
395 411
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>';
412
+		}
396 413
 
397 414
 		echo '
398 415
 						</td>
@@ -412,9 +429,10 @@  discard block
 block discarded – undo
412 429
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
413 430
 				<input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">';
414 431
 
415
-	if ($context['can_edit_something'])
416
-		echo '
432
+	if ($context['can_edit_something']) {
433
+			echo '
417 434
 				<input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button">';
435
+	}
418 436
 
419 437
 	echo '
420 438
 				<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '>
@@ -439,9 +457,10 @@  discard block
 block discarded – undo
439 457
 					<dd>
440 458
 						<select name="copy_from">';
441 459
 
442
-	foreach ($context['profiles'] as $id => $profile)
443
-		echo '
460
+	foreach ($context['profiles'] as $id => $profile) {
461
+			echo '
444 462
 							<option value="', $id, '">', $profile['name'], '</option>';
463
+	}
445 464
 
446 465
 	echo '
447 466
 						</select>
@@ -463,13 +482,13 @@  discard block
 block discarded – undo
463 482
 	global $context, $scripturl, $txt, $modSettings;
464 483
 
465 484
 	// Cannot be edited?
466
-	if (!$context['profile']['can_modify'])
467
-		echo '
485
+	if (!$context['profile']['can_modify']) {
486
+			echo '
468 487
 	<div class="errorbox">
469 488
 		', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
470 489
 	</div>';
471
-	else
472
-		echo '
490
+	} else {
491
+			echo '
473 492
 	<script>
474 493
 		window.smf_usedDeny = false;
475 494
 
@@ -481,27 +500,30 @@  discard block
 block discarded – undo
481 500
 				return true;
482 501
 		}
483 502
 	</script>';
503
+	}
484 504
 
485 505
 	echo '
486 506
 	<div id="admincenter">
487 507
 		<form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">';
488 508
 
489
-	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
490
-		echo '
509
+	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) {
510
+			echo '
491 511
 			<div class="information">
492 512
 				', $txt['permissions_option_desc'], '
493 513
 			</div>';
514
+	}
494 515
 
495 516
 	echo '
496 517
 			<div class="cat_bar">
497 518
 				<h3 class="catbg">';
498 519
 
499
-	if ($context['permission_type'] == 'board')
500
-		echo '
520
+	if ($context['permission_type'] == 'board') {
521
+			echo '
501 522
 				', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
502
-	else
503
-		echo '
523
+	} else {
524
+			echo '
504 525
 				', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
526
+	}
505 527
 	echo '
506 528
 				</h3>
507 529
 			</div>';
@@ -524,15 +546,17 @@  discard block
 block discarded – undo
524 546
 		template_modify_group_display('board');
525 547
 	}
526 548
 
527
-	if ($context['profile']['can_modify'])
528
-		echo '
549
+	if ($context['profile']['can_modify']) {
550
+			echo '
529 551
 			<div class="padding">
530 552
 				<input type="submit" value="', $txt['permissions_commit'], '" class="button">
531 553
 			</div>';
554
+	}
532 555
 
533
-	foreach ($context['hidden_perms'] as $hidden_perm)
534
-		echo '
556
+	foreach ($context['hidden_perms'] as $hidden_perm) {
557
+			echo '
535 558
 			<input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">';
559
+	}
536 560
 
537 561
 	echo '
538 562
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -560,17 +584,19 @@  discard block
 block discarded – undo
560 584
 
561 585
 		foreach ($column as $permissionGroup)
562 586
 		{
563
-			if (empty($permissionGroup['permissions']))
564
-				continue;
587
+			if (empty($permissionGroup['permissions'])) {
588
+							continue;
589
+			}
565 590
 
566 591
 			// Are we likely to have something in this group to display or is it all hidden?
567 592
 			$has_display_content = false;
568 593
 			if (!$permissionGroup['hidden'])
569 594
 			{
570 595
 				// Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
571
-				foreach ($permissionGroup['permissions'] as $permission)
572
-					if (!$permission['hidden'])
596
+				foreach ($permissionGroup['permissions'] as $permission) {
597
+									if (!$permission['hidden'])
573 598
 						$has_display_content = true;
599
+				}
574 600
 
575 601
 				if ($has_display_content)
576 602
 				{
@@ -579,10 +605,11 @@  discard block
 block discarded – undo
579 605
 							<th></th>
580 606
 							<th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>';
581 607
 
582
-					if ($context['group']['id'] != -1)
583
-						echo '
608
+					if ($context['group']['id'] != -1) {
609
+											echo '
584 610
 							<th>', $txt['permissions_option_own'], '</th>
585 611
 							<th>', $txt['permissions_option_any'], '</th>';
612
+					}
586 613
 
587 614
 					echo '
588 615
 						</tr>';
@@ -605,17 +632,18 @@  discard block
 block discarded – undo
605 632
 						// Guests can't do their own thing.
606 633
 						if ($context['group']['id'] != -1)
607 634
 						{
608
-							if (empty($modSettings['permission_enable_deny']))
609
-								echo '
635
+							if (empty($modSettings['permission_enable_deny'])) {
636
+															echo '
610 637
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" ', $disable_field, '>';
611
-							else
638
+							} else
612 639
 							{
613 640
 								echo '
614 641
 								<select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>';
615 642
 
616
-								foreach (array('on', 'off', 'deny') as $c)
617
-									echo '
643
+								foreach (array('on', 'off', 'deny') as $c) {
644
+																	echo '
618 645
 									<option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
646
+								}
619 647
 								echo '
620 648
 								</select>';
621 649
 							}
@@ -625,39 +653,41 @@  discard block
 block discarded – undo
625 653
 							<td>';
626 654
 						}
627 655
 
628
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
629
-							echo '
656
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
657
+													echo '
630 658
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>';
631
-						else
659
+						} else
632 660
 						{
633 661
 							echo '
634 662
 								<select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>';
635 663
 
636
-							foreach (array('on', 'off', 'deny') as $c)
637
-								echo '
664
+							foreach (array('on', 'off', 'deny') as $c) {
665
+															echo '
638 666
 									<option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
667
+							}
639 668
 							echo '
640 669
 								</select>';
641 670
 						}
642
-					}
643
-					else
671
+					} else
644 672
 					{
645
-						if ($context['group']['id'] != -1)
646
-							echo '
673
+						if ($context['group']['id'] != -1) {
674
+													echo '
647 675
 							</td>
648 676
 							<td>';
677
+						}
649 678
 
650
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
651
-							echo '
679
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
680
+													echo '
652 681
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>';
653
-						else
682
+						} else
654 683
 						{
655 684
 							echo '
656 685
 								<select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>';
657 686
 
658
-							foreach (array('on', 'off', 'deny') as $c)
659
-								echo '
687
+							foreach (array('on', 'off', 'deny') as $c) {
688
+															echo '
660 689
 									<option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
690
+							}
661 691
 							echo '
662 692
 								</select>';
663 693
 						}
@@ -689,11 +719,11 @@  discard block
 block discarded – undo
689 719
 											<fieldset id="', $context['current_permission'], '">
690 720
 												<legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>';
691 721
 
692
-	if (empty($modSettings['permission_enable_deny']))
693
-		echo '
722
+	if (empty($modSettings['permission_enable_deny'])) {
723
+			echo '
694 724
 												<ul>';
695
-	else
696
-		echo '
725
+	} else {
726
+			echo '
697 727
 												<div class="information">', $txt['permissions_option_desc'], '</div>
698 728
 												<dl class="settings">
699 729
 													<dt>
@@ -703,47 +733,52 @@  discard block
 block discarded – undo
703 733
 													</dt>
704 734
 													<dd>
705 735
 													</dd>';
736
+	}
706 737
 
707 738
 	foreach ($context['member_groups'] as $group)
708 739
 	{
709
-		if (!empty($modSettings['permission_enable_deny']))
710
-			echo '
740
+		if (!empty($modSettings['permission_enable_deny'])) {
741
+					echo '
711 742
 													<dt>';
712
-		else
713
-			echo '
743
+		} else {
744
+					echo '
714 745
 													<li>';
746
+		}
715 747
 
716
-		if (empty($modSettings['permission_enable_deny']))
717
-			echo '
748
+		if (empty($modSettings['permission_enable_deny'])) {
749
+					echo '
718 750
 														<input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '>';
719
-		else
720
-			echo '
751
+		} else {
752
+					echo '
721 753
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '></span>
722 754
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', '></span>
723 755
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', '></span>';
756
+		}
724 757
 
725
-		if (!empty($modSettings['permission_enable_deny']))
726
-			echo '
758
+		if (!empty($modSettings['permission_enable_deny'])) {
759
+					echo '
727 760
 													</dt>
728 761
 													<dd>
729 762
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
730 763
 													</dd>';
731
-		else
732
-			echo '
764
+		} else {
765
+					echo '
733 766
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
734 767
 													</li>';
768
+		}
735 769
 	}
736 770
 
737
-	if (empty($modSettings['permission_enable_deny']))
738
-		echo '
771
+	if (empty($modSettings['permission_enable_deny'])) {
772
+			echo '
739 773
 													<li>
740 774
 														<input type="checkbox" onclick="invertAll(this, this.form, \''. $context['current_permission'] . '[\');">
741 775
 														<span>', $txt['check_all'], '</span>
742 776
 													</li>
743 777
 												</ul>';
744
-	else
745
-		echo '
778
+	} else {
779
+			echo '
746 780
 												</dl>';
781
+	}
747 782
 
748 783
 	echo '
749 784
 											</fieldset>
@@ -783,9 +818,10 @@  discard block
 block discarded – undo
783 818
 	if (!empty($modSettings['postmod_active']))
784 819
 	{
785 820
 		// Got advanced permissions - if so warn!
786
-		if (!empty($modSettings['permission_enable_deny']))
787
-			echo '
821
+		if (!empty($modSettings['permission_enable_deny'])) {
822
+					echo '
788 823
 							<div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
824
+		}
789 825
 
790 826
 		echo '
791 827
 							<div class="padding">
@@ -800,10 +836,11 @@  discard block
 block discarded – undo
800 836
 									', $txt['permissions_post_moderation_select'], ':
801 837
 									<select name="pid" onchange="document.forms.postmodForm.submit();">';
802 838
 
803
-		foreach ($context['profiles'] as $profile)
804
-			if ($profile['can_modify'])
839
+		foreach ($context['profiles'] as $profile) {
840
+					if ($profile['can_modify'])
805 841
 				echo '
806 842
 										<option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
843
+		}
807 844
 
808 845
 		echo '
809 846
 									</select>
@@ -824,11 +861,12 @@  discard block
 block discarded – undo
824 861
 											', $txt['permissions_post_moderation_replies_any'], '
825 862
 										</th>';
826 863
 
827
-		if ($modSettings['attachmentEnable'] == 1)
828
-			echo '
864
+		if ($modSettings['attachmentEnable'] == 1) {
865
+					echo '
829 866
 										<th class="centercol" colspan="3">
830 867
 											', $txt['permissions_post_moderation_attachments'], '
831 868
 										</th>';
869
+		}
832 870
 
833 871
 		echo '
834 872
 									</tr>
@@ -846,11 +884,12 @@  discard block
 block discarded – undo
846 884
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
847 885
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
848 886
 
849
-		if ($modSettings['attachmentEnable'] == 1)
850
-			echo '
887
+		if ($modSettings['attachmentEnable'] == 1) {
888
+					echo '
851 889
 										<th><span class="generic_icons post_moderation_allow"></span></th>
852 890
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
853 891
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
892
+		}
854 893
 
855 894
 		echo '
856 895
 									</tr>
@@ -864,10 +903,11 @@  discard block
 block discarded – undo
864 903
 										<td class="half_table">
865 904
 											<span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
866 905
 
867
-				if (!empty($group['children']))
868
-					echo '
906
+				if (!empty($group['children'])) {
907
+									echo '
869 908
 											<br>
870 909
 											<span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
910
+				}
871 911
 
872 912
 				echo '
873 913
 										</td>
@@ -882,11 +922,11 @@  discard block
 block discarded – undo
882 922
 										</td>';
883 923
 
884 924
 				// Guests can't have "own" permissions
885
-				if ($group['id'] == '-1')
886
-					echo '
925
+				if ($group['id'] == '-1') {
926
+									echo '
887 927
 										<td colspan="3"></td>';
888
-				else
889
-					echo '
928
+				} else {
929
+									echo '
890 930
 										<td class="centercol">
891 931
 											<input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', '>
892 932
 										</td>
@@ -896,6 +936,7 @@  discard block
 block discarded – undo
896 936
 										<td class="centercol">
897 937
 											<input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', '>
898 938
 										</td>';
939
+				}
899 940
 
900 941
 				echo '
901 942
 										<td class="centercol">
@@ -908,8 +949,8 @@  discard block
 block discarded – undo
908 949
 											<input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', '>
909 950
 										</td>';
910 951
 
911
-				if ($modSettings['attachmentEnable'] == 1)
912
-					echo '
952
+				if ($modSettings['attachmentEnable'] == 1) {
953
+									echo '
913 954
 										<td class="centercol">
914 955
 											<input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', '>
915 956
 										</td>
@@ -919,6 +960,7 @@  discard block
 block discarded – undo
919 960
 										<td class="centercol">
920 961
 											<input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', '>
921 962
 										</td>';
963
+				}
922 964
 
923 965
 				echo '
924 966
 									</tr>';
Please login to merge, or discard this patch.
Themes/default/ManageCalendar.template.php 1 patch
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,9 +40,10 @@  discard block
 block discarded – undo
40 40
 							<option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>';
41 41
 
42 42
 	// Show a list of all the years we allow...
43
-	for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
44
-		echo '
43
+	for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) {
44
+			echo '
45 45
 							<option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>';
46
+	}
46 47
 
47 48
 	echo '
48 49
 						</select>
@@ -50,9 +51,10 @@  discard block
 block discarded – undo
50 51
 						<select name="month" id="month" onchange="generateDays();">';
51 52
 
52 53
 	// There are 12 months per year - ensure that they all get listed.
53
-	for ($month = 1; $month <= 12; $month++)
54
-		echo '
54
+	for ($month = 1; $month <= 12; $month++) {
55
+			echo '
55 56
 							<option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
57
+	}
56 58
 
57 59
 	echo '
58 60
 						</select>
@@ -60,23 +62,25 @@  discard block
 block discarded – undo
60 62
 						<select name="day" id="day" onchange="generateDays();">';
61 63
 
62 64
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
63
-	for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
64
-		echo '
65
+	for ($day = 1; $day <= $context['holiday']['last_day']; $day++) {
66
+			echo '
65 67
 							<option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>';
68
+	}
66 69
 
67 70
 	echo '
68 71
 						</select>
69 72
 					</dd>
70 73
 				</dl>';
71 74
 
72
-	if ($context['is_new'])
73
-		echo '
75
+	if ($context['is_new']) {
76
+			echo '
74 77
 				<input type="submit" value="', $txt['holidays_button_add'], '" class="button">';
75
-	else
76
-		echo '
78
+	} else {
79
+			echo '
77 80
 				<input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button">
78 81
 				<input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button">
79 82
 				<input type="hidden" name="holiday" value="', $context['holiday']['id'], '">';
83
+	}
80 84
 	echo '
81 85
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
82 86
 			</div><!-- .windowbg2 -->
Please login to merge, or discard this patch.
Themes/default/ManagePaid.template.php 1 patch
Braces   +66 added lines, -47 removed lines patch added patch discarded remove patch
@@ -24,11 +24,12 @@  discard block
 block discarded – undo
24 24
 				<h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3>
25 25
 			</div>';
26 26
 
27
-	if (!empty($context['disable_groups']))
28
-		echo '
27
+	if (!empty($context['disable_groups'])) {
28
+			echo '
29 29
 			<div class="information">
30 30
 				<span class="alert">', $txt['paid_mod_edit_note'], '</span>
31 31
 			</div>';
32
+	}
32 33
 
33 34
 	echo '
34 35
 			<div class="windowbg2">
@@ -69,9 +70,10 @@  discard block
 block discarded – undo
69 70
 							<option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>';
70 71
 
71 72
 	// Put each group into the box.
72
-	foreach ($context['groups'] as $id => $name)
73
-		echo '
73
+	foreach ($context['groups'] as $id => $name) {
74
+			echo '
74 75
 							<option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>';
76
+	}
75 77
 
76 78
 	echo '
77 79
 						</select>
@@ -83,12 +85,13 @@  discard block
 block discarded – undo
83 85
 					<dd>';
84 86
 
85 87
 	// Put a checkbox in for each group
86
-	foreach ($context['groups'] as $id => $name)
87
-		echo '
88
+	foreach ($context['groups'] as $id => $name) {
89
+			echo '
88 90
 						<label for="addgroup_', $id, '">
89 91
 							<input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '>
90 92
 							<span class="smalltext">', $name, '</span>
91 93
 						</label><br>';
94
+	}
92 95
 
93 96
 	echo '
94 97
 					</dd>
@@ -142,8 +145,8 @@  discard block
 block discarded – undo
142 145
 					<fieldset>';
143 146
 
144 147
 	//!! Removed until implemented
145
-	if (!empty($sdflsdhglsdjgs))
146
-		echo '
148
+	if (!empty($sdflsdhglsdjgs)) {
149
+			echo '
147 150
 						<dl class="settings">
148 151
 							<dt>
149 152
 								<label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span>
@@ -152,6 +155,7 @@  discard block
 block discarded – undo
152 155
 								<input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '>
153 156
 							</dd>
154 157
 						</dl>';
158
+	}
155 159
 
156 160
 	echo '
157 161
 						<div class="information">
@@ -250,8 +254,8 @@  discard block
 block discarded – undo
250 254
 				<dl class="settings">';
251 255
 
252 256
 	// Do we need a username?
253
-	if ($context['action_type'] == 'add')
254
-		echo '
257
+	if ($context['action_type'] == 'add') {
258
+			echo '
255 259
 					<dt>
256 260
 						<strong>', $txt['paid_username'], ':</strong><br>
257 261
 						<span class="smalltext">', $txt['one_username'], '</span>
@@ -259,6 +263,7 @@  discard block
 block discarded – undo
259 263
 					<dd>
260 264
 						<input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30">
261 265
 					</dd>';
266
+	}
262 267
 
263 268
 	echo '
264 269
 					<dt>
@@ -276,9 +281,10 @@  discard block
 block discarded – undo
276 281
 					<select name="year" id="year" onchange="generateDays();">';
277 282
 
278 283
 	// Show a list of all the years we allow...
279
-	for ($year = 2005; $year <= 2030; $year++)
280
-		echo '
284
+	for ($year = 2005; $year <= 2030; $year++) {
285
+			echo '
281 286
 						<option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>';
287
+	}
282 288
 
283 289
 	echo '
284 290
 					</select>&nbsp;
@@ -286,9 +292,10 @@  discard block
 block discarded – undo
286 292
 					<select name="month" id="month" onchange="generateDays();">';
287 293
 
288 294
 	// There are 12 months per year - ensure that they all get listed.
289
-	for ($month = 1; $month <= 12; $month++)
290
-		echo '
295
+	for ($month = 1; $month <= 12; $month++) {
296
+			echo '
291 297
 						<option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
298
+	}
292 299
 
293 300
 	echo '
294 301
 					</select>&nbsp;
@@ -296,9 +303,10 @@  discard block
 block discarded – undo
296 303
 					<select name="day" id="day">';
297 304
 
298 305
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
299
-	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++)
300
-		echo '
306
+	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) {
307
+			echo '
301 308
 						<option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>';
309
+	}
302 310
 
303 311
 	echo '
304 312
 					</select>
@@ -310,9 +318,10 @@  discard block
 block discarded – undo
310 318
 					<select name="yearend" id="yearend" onchange="generateDays(\'end\');">';
311 319
 
312 320
 	// Show a list of all the years we allow...
313
-	for ($year = 2005; $year <= 2030; $year++)
314
-		echo '
321
+	for ($year = 2005; $year <= 2030; $year++) {
322
+			echo '
315 323
 						<option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>';
324
+	}
316 325
 
317 326
 	echo '
318 327
 					</select>&nbsp;
@@ -320,9 +329,10 @@  discard block
 block discarded – undo
320 329
 					<select name="monthend" id="monthend" onchange="generateDays(\'end\');">';
321 330
 
322 331
 	// There are 12 months per year - ensure that they all get listed.
323
-	for ($month = 1; $month <= 12; $month++)
324
-		echo '
332
+	for ($month = 1; $month <= 12; $month++) {
333
+			echo '
325 334
 						<option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
335
+	}
326 336
 
327 337
 	echo '
328 338
 					</select>&nbsp;
@@ -330,9 +340,10 @@  discard block
 block discarded – undo
330 340
 					<select name="dayend" id="dayend">';
331 341
 
332 342
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
333
-	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++)
334
-		echo '
343
+	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) {
344
+			echo '
335 345
 						<option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>';
346
+	}
336 347
 
337 348
 	echo '
338 349
 					</select>
@@ -371,8 +382,8 @@  discard block
 block discarded – undo
371 382
 		<div class="windowbg">
372 383
 			<ul>';
373 384
 
374
-		foreach ($context['pending_payments'] as $id => $payment)
375
-			echo '
385
+		foreach ($context['pending_payments'] as $id => $payment) {
386
+					echo '
376 387
 				<li>
377 388
 					', $payment['desc'], '
378 389
 					<span class="floatleft">
@@ -382,6 +393,7 @@  discard block
 block discarded – undo
382 393
 						<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a>
383 394
 					</span>
384 395
 				</li>';
396
+		}
385 397
 
386 398
 		echo '
387 399
 			</ul>
@@ -406,12 +418,12 @@  discard block
 block discarded – undo
406 418
 				<h3 class="catbg">', $txt['subscriptions'], '</h3>
407 419
 			</div>';
408 420
 
409
-	if (empty($context['subscriptions']))
410
-		echo '
421
+	if (empty($context['subscriptions'])) {
422
+			echo '
411 423
 			<div class="information">
412 424
 				', $txt['paid_subs_none'], '
413 425
 			</div>';
414
-	else
426
+	} else
415 427
 	{
416 428
 		echo '
417 429
 			<div class="information">
@@ -423,8 +435,9 @@  discard block
 block discarded – undo
423 435
 		{
424 436
 
425 437
 			// Ignore the inactive ones...
426
-			if (empty($subscription['active']))
427
-				continue;
438
+			if (empty($subscription['active'])) {
439
+							continue;
440
+			}
428 441
 
429 442
 			echo '
430 443
 			<div class="cat_bar">
@@ -434,9 +447,10 @@  discard block
 block discarded – undo
434 447
 				<p><strong>', $subscription['name'], '</strong></p>
435 448
 				<p class="smalltext">', $subscription['desc'], '</p>';
436 449
 
437
-			if (!$subscription['flexible'])
438
-				echo '
450
+			if (!$subscription['flexible']) {
451
+							echo '
439 452
 				<div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>';
453
+			}
440 454
 
441 455
 			if ($context['user']['is_owner'])
442 456
 			{
@@ -449,24 +463,25 @@  discard block
 block discarded – undo
449 463
 				<select name="cur[', $subscription['id'], ']">';
450 464
 
451 465
 					// Print out the costs for this one.
452
-					foreach ($subscription['costs'] as $duration => $value)
453
-						echo '
466
+					foreach ($subscription['costs'] as $duration => $value) {
467
+											echo '
454 468
 					<option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>';
469
+					}
455 470
 
456 471
 					echo '
457 472
 				</select>';
458
-				}
459
-				else
460
-					echo '
473
+				} else {
474
+									echo '
461 475
 				', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']);
476
+				}
462 477
 
463 478
 				echo '
464 479
 				<hr>
465 480
 				<input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">';
466
-			}
467
-			else
468
-				echo '
481
+			} else {
482
+							echo '
469 483
 				<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>';
484
+			}
470 485
 
471 486
 			echo '
472 487
 			</div><!-- .windowbg -->';
@@ -493,19 +508,20 @@  discard block
 block discarded – undo
493 508
 			</thead>
494 509
 			<tbody>';
495 510
 
496
-	if (empty($context['current']))
497
-		echo '
511
+	if (empty($context['current'])) {
512
+			echo '
498 513
 				<tr class="windowbg">
499 514
 					<td colspan="4">
500 515
 						', $txt['paid_none_yet'], '
501 516
 					</td>
502 517
 				</tr>';
518
+	}
503 519
 
504 520
 	foreach ($context['current'] as $sub)
505 521
 	{
506 522
 
507
-		if (!$sub['hide'])
508
-			echo '
523
+		if (!$sub['hide']) {
524
+					echo '
509 525
 				<tr class="windowbg">
510 526
 					<td>
511 527
 						', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), '
@@ -516,6 +532,7 @@  discard block
 block discarded – undo
516 532
 					<td>', $sub['start'], '</td>
517 533
 					<td>', $sub['end'], '</td>
518 534
 				</tr>';
535
+		}
519 536
 	}
520 537
 
521 538
 	echo '
@@ -567,15 +584,17 @@  discard block
 block discarded – undo
567 584
 			', $gateway['desc'], '<br>
568 585
 			<form action="', $gateway['form'], '" method="post">';
569 586
 
570
-		if (!empty($gateway['javascript']))
571
-			echo '
587
+		if (!empty($gateway['javascript'])) {
588
+					echo '
572 589
 				<script>
573 590
 					', $gateway['javascript'], '
574 591
 				</script>';
592
+		}
575 593
 
576
-		foreach ($gateway['hidden'] as $name => $value)
577
-			echo '
594
+		foreach ($gateway['hidden'] as $name => $value) {
595
+					echo '
578 596
 				<input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">';
597
+		}
579 598
 
580 599
 		echo '
581 600
 				<br>
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 1 patch
Braces   +60 added lines, -47 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
  * Fetches a list of boards and (optional) categories including
@@ -37,11 +38,12 @@  discard block
 block discarded – undo
37 38
 	require_once($sourcedir . '/Subs-Boards.php');
38 39
 
39 40
 	// For performance, track the latest post while going through the boards.
40
-	if (!empty($boardIndexOptions['set_latest_post']))
41
-		$latest_post = array(
41
+	if (!empty($boardIndexOptions['set_latest_post'])) {
42
+			$latest_post = array(
42 43
 			'timestamp' => 0,
43 44
 			'ref' => 0,
44 45
 		);
46
+	}
45 47
 
46 48
 	// Find all boards and categories, as well as related information.  This will be sorted by the natural order of boards and categories, which we control.
47 49
 	$result_boards = $smcFunc['db_query']('', '
@@ -74,10 +76,11 @@  discard block
 block discarded – undo
74 76
 	);
75 77
 
76 78
 	// Start with an empty array.
77
-	if ($boardIndexOptions['include_categories'])
78
-		$categories = array();
79
-	else
80
-		$this_category = array();
79
+	if ($boardIndexOptions['include_categories']) {
80
+			$categories = array();
81
+	} else {
82
+			$this_category = array();
83
+	}
81 84
 	$boards = array();
82 85
 
83 86
 	// Run through the categories and boards (or only boards)....
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 		$row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0';
89 92
 
90 93
 		// Add parent boards to the $boards list later used to fetch moderators
91
-		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'])
92
-			$boards[] = $row_board['id_board'];
94
+		if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) {
95
+					$boards[] = $row_board['id_board'];
96
+		}
93 97
 
94 98
 		if ($boardIndexOptions['include_categories'])
95 99
 		{
@@ -111,8 +115,9 @@  discard block
 block discarded – undo
111 115
 			}
112 116
 
113 117
 			// If this board has new posts in it (and isn't the recycle bin!) then the category is new.
114
-			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board'])
115
-				$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != '';
118
+			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) {
119
+							$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != '';
120
+			}
116 121
 
117 122
 			// Avoid showing category unread link where it only has redirection boards.
118 123
 			$categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect'];
@@ -161,14 +166,12 @@  discard block
 block discarded – undo
161 166
 				{
162 167
 					$this_category[$row_board['id_board']]['board_class'] = 'redirect';
163 168
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board'];
164
-				}
165
-				elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
169
+				} elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
166 170
 				{
167 171
 					// If we're showing to guests, we want to give them the idea that something interesting is going on!
168 172
 					$this_category[$row_board['id_board']]['board_class'] = 'on';
169 173
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts'];
170
-				}
171
-				else
174
+				} else
172 175
 				{
173 176
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts'];
174 177
 				}
@@ -219,14 +222,16 @@  discard block
 block discarded – undo
219 222
 		// Child of a child... just add it on...
220 223
 		elseif (!empty($boardIndexOptions['countChildPosts']))
221 224
 		{
222
-			if (!isset($parent_map))
223
-				$parent_map = array();
225
+			if (!isset($parent_map)) {
226
+							$parent_map = array();
227
+			}
224 228
 
225
-			if (!isset($parent_map[$row_board['id_parent']]))
226
-				foreach ($this_category as $id => $board)
229
+			if (!isset($parent_map[$row_board['id_parent']])) {
230
+							foreach ($this_category as $id => $board)
227 231
 				{
228 232
 					if (!isset($board['children'][$row_board['id_parent']]))
229 233
 						continue;
234
+			}
230 235
 
231 236
 					$parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
232 237
 					$parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
@@ -247,8 +252,9 @@  discard block
 block discarded – undo
247 252
 			continue;
248 253
 		}
249 254
 		// Found a child of a child - skip.
250
-		else
251
-			continue;
255
+		else {
256
+					continue;
257
+		}
252 258
 
253 259
 		// Prepare the subject, and make sure it's not too long.
254 260
 		censorText($row_board['subject']);
@@ -269,12 +275,13 @@  discard block
 block discarded – undo
269 275
 			'topic' => $row_board['id_topic']
270 276
 		);
271 277
 
272
-		if (!empty($settings['avatars_on_boardIndex']))
273
-			$this_last_post['member']['avatar'] = set_avatar_data(array(
278
+		if (!empty($settings['avatars_on_boardIndex'])) {
279
+					$this_last_post['member']['avatar'] = set_avatar_data(array(
274 280
 				'avatar' => $row_board['avatar'],
275 281
 				'email' => $row_board['email_address'],
276 282
 				'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '',
277 283
 			));
284
+		}
278 285
 
279 286
 		// Provide the href and link.
280 287
 		if ($row_board['subject'] != '')
@@ -286,8 +293,7 @@  discard block
 block discarded – undo
286 293
 			link, href, subject, start (where they should go for the first unread post.),
287 294
 			and member. (which has id, name, link, href, username in it.) */
288 295
 			$this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']);
289
-		}
290
-		else
296
+		} else
291 297
 		{
292 298
 			$this_last_post['href'] = '';
293 299
 			$this_last_post['link'] = $txt['not_applicable'];
@@ -295,8 +301,9 @@  discard block
 block discarded – undo
295 301
 		}
296 302
 
297 303
 		// Set the last post in the parent board.
298
-		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])))
299
-			$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
304
+		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) {
305
+					$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
306
+		}
300 307
 		// Just in the child...?
301 308
 		if ($isChild)
302 309
 		{
@@ -306,15 +313,17 @@  discard block
 block discarded – undo
306 313
 			$this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != '';
307 314
 		}
308 315
 		// No last post for this board?  It's not new then, is it..?
309
-		elseif ($row_board['poster_name'] == '')
310
-			$this_category[$row_board['id_board']]['new'] = false;
316
+		elseif ($row_board['poster_name'] == '') {
317
+					$this_category[$row_board['id_board']]['new'] = false;
318
+		}
311 319
 
312 320
 		// Determine a global most recent topic.
313
-		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard)
314
-			$latest_post = array(
321
+		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) {
322
+					$latest_post = array(
315 323
 				'timestamp' => $row_board['poster_time'],
316 324
 				'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'],
317 325
 			);
326
+		}
318 327
 	}
319 328
 	$smcFunc['db_free_result']($result_boards);
320 329
 
@@ -331,8 +340,9 @@  discard block
 block discarded – undo
331 340
 				if (!empty($moderators[$board['id']]))
332 341
 				{
333 342
 					$categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']];
334
-					foreach ($moderators[$board['id']] as $moderator)
335
-						$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
343
+					foreach ($moderators[$board['id']] as $moderator) {
344
+											$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
345
+					}
336 346
 				}
337 347
 				if (!empty($groups[$board['id']]))
338 348
 				{
@@ -345,16 +355,16 @@  discard block
 block discarded – undo
345 355
 				}
346 356
 			}
347 357
 		}
348
-	}
349
-	else
358
+	} else
350 359
 	{
351 360
 		foreach ($this_category as $k => $board)
352 361
 		{
353 362
 			if (!empty($moderators[$board['id']]))
354 363
 			{
355 364
 				$this_category[$k]['moderators'] = $moderators[$board['id']];
356
-				foreach ($moderators[$board['id']] as $moderator)
357
-					$this_category[$k]['link_moderators'][] = $moderator['link'];
365
+				foreach ($moderators[$board['id']] as $moderator) {
366
+									$this_category[$k]['link_moderators'][] = $moderator['link'];
367
+				}
358 368
 			}
359 369
 			if (!empty($groups[$board['id']]))
360 370
 			{
@@ -368,20 +378,23 @@  discard block
 block discarded – undo
368 378
 		}
369 379
 	}
370 380
 
371
-	if ($boardIndexOptions['include_categories'])
372
-		sortCategories($categories);
373
-	else
374
-		sortBoards($this_category);
381
+	if ($boardIndexOptions['include_categories']) {
382
+			sortCategories($categories);
383
+	} else {
384
+			sortBoards($this_category);
385
+	}
375 386
 
376 387
 	// By now we should know the most recent post...if we wanna know it that is.
377
-	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref']))
378
-		$context['latest_post'] = $latest_post['ref'];
388
+	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) {
389
+			$context['latest_post'] = $latest_post['ref'];
390
+	}
379 391
 
380 392
 	// I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea.
381
-	if ($boardIndexOptions['include_categories'])
382
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
383
-	else
384
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
393
+	if ($boardIndexOptions['include_categories']) {
394
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
395
+	} else {
396
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
397
+	}
385 398
 
386 399
 	return $boardIndexOptions['include_categories'] ? $categories : $this_category;
387 400
 }
Please login to merge, or discard this patch.
Sources/ManageSearch.php 1 patch
Braces   +109 added lines, -90 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
  * Main entry point for the admin search settings screen.
@@ -107,11 +108,13 @@  discard block
 block discarded – undo
107 108
 	// Perhaps the search method wants to add some settings?
108 109
 	require_once($sourcedir . '/Search.php');
109 110
 	$searchAPI = findSearchAPI();
110
-	if (is_callable(array($searchAPI, 'searchSettings')))
111
-		call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars));
111
+	if (is_callable(array($searchAPI, 'searchSettings'))) {
112
+			call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars));
113
+	}
112 114
 
113
-	if ($return_config)
114
-		return $config_vars;
115
+	if ($return_config) {
116
+			return $config_vars;
117
+	}
115 118
 
116 119
 	$context['page_title'] = $txt['search_settings_title'];
117 120
 	$context['sub_template'] = 'show_settings';
@@ -126,8 +129,9 @@  discard block
 block discarded – undo
126 129
 
127 130
 		call_integration_hook('integrate_save_search_settings');
128 131
 
129
-		if (empty($_POST['search_results_per_page']))
130
-			$_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages'];
132
+		if (empty($_POST['search_results_per_page'])) {
133
+					$_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages'];
134
+		}
131 135
 		saveDBSettings($config_vars);
132 136
 		$_SESSION['adm-save'] = true;
133 137
 		redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']);
@@ -177,17 +181,20 @@  discard block
 block discarded – undo
177 181
 		call_integration_hook('integrate_save_search_weights');
178 182
 
179 183
 		$changes = array();
180
-		foreach ($factors as $factor)
181
-			$changes[$factor] = (int) $_POST[$factor];
184
+		foreach ($factors as $factor) {
185
+					$changes[$factor] = (int) $_POST[$factor];
186
+		}
182 187
 		updateSettings($changes);
183 188
 	}
184 189
 
185 190
 	$context['relative_weights'] = array('total' => 0);
186
-	foreach ($factors as $factor)
187
-		$context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0;
191
+	foreach ($factors as $factor) {
192
+			$context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0;
193
+	}
188 194
 
189
-	foreach ($factors as $factor)
190
-		$context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1);
195
+	foreach ($factors as $factor) {
196
+			$context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1);
197
+	}
191 198
 
192 199
 	createToken('admin-msw');
193 200
 }
@@ -215,8 +222,9 @@  discard block
 block discarded – undo
215 222
 	$context['search_apis'] = loadSearchAPIs();
216 223
 
217 224
 	// Detect whether a fulltext index is set.
218
-	if ($context['supports_fulltext'])
219
-		detectFulltextIndex();
225
+	if ($context['supports_fulltext']) {
226
+			detectFulltextIndex();
227
+	}
220 228
 
221 229
 	if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext')
222 230
 	{
@@ -240,8 +248,7 @@  discard block
 block discarded – undo
240 248
 					'language' => $language_ftx
241 249
 				)
242 250
 			);
243
-		}
244
-		else
251
+		} else
245 252
 		{
246 253
 			// Make sure it's gone before creating it.
247 254
 			$smcFunc['db_query']('', '
@@ -259,8 +266,7 @@  discard block
 block discarded – undo
259 266
 				)
260 267
 			);
261 268
 		}
262
-	}
263
-	elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index']))
269
+	} elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index']))
264 270
 	{
265 271
 		checkSession('get');
266 272
 		validateToken('admin-msm', 'get');
@@ -277,12 +283,12 @@  discard block
 block discarded – undo
277 283
 		$context['fulltext_index'] = array();
278 284
 
279 285
 		// Go back to the default search method.
280
-		if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext')
281
-			updateSettings(array(
286
+		if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') {
287
+					updateSettings(array(
282 288
 				'search_index' => '',
283 289
 			));
284
-	}
285
-	elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom')
290
+		}
291
+	} elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom')
286 292
 	{
287 293
 		checkSession('get');
288 294
 		validateToken('admin-msm', 'get');
@@ -304,12 +310,12 @@  discard block
 block discarded – undo
304 310
 		));
305 311
 
306 312
 		// Go back to the default search method.
307
-		if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom')
308
-			updateSettings(array(
313
+		if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') {
314
+					updateSettings(array(
309 315
 				'search_index' => '',
310 316
 			));
311
-	}
312
-	elseif (isset($_POST['save']))
317
+		}
318
+	} elseif (isset($_POST['save']))
313 319
 	{
314 320
 		checkSession();
315 321
 		validateToken('admin-msmpost');
@@ -331,8 +337,8 @@  discard block
 block discarded – undo
331 337
 	// Get some info about the messages table, to show its size and index size.
332 338
 	if ($db_type == 'mysql')
333 339
 	{
334
-		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0)
335
-			$request = $smcFunc['db_query']('', '
340
+		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) {
341
+					$request = $smcFunc['db_query']('', '
336 342
 				SHOW TABLE STATUS
337 343
 				FROM {string:database_name}
338 344
 				LIKE {string:table_name}',
@@ -341,14 +347,15 @@  discard block
 block discarded – undo
341 347
 					'table_name' => str_replace('_', '\_', $match[2]) . 'messages',
342 348
 				)
343 349
 			);
344
-		else
345
-			$request = $smcFunc['db_query']('', '
350
+		} else {
351
+					$request = $smcFunc['db_query']('', '
346 352
 				SHOW TABLE STATUS
347 353
 				LIKE {string:table_name}',
348 354
 				array(
349 355
 					'table_name' => str_replace('_', '\_', $db_prefix) . 'messages',
350 356
 				)
351 357
 			);
358
+		}
352 359
 		if ($request !== false && $smcFunc['db_num_rows']($request) == 1)
353 360
 		{
354 361
 			// Only do this if the user has permission to execute this query.
@@ -360,8 +367,8 @@  discard block
 block discarded – undo
360 367
 		}
361 368
 
362 369
 		// Now check the custom index table, if it exists at all.
363
-		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0)
364
-			$request = $smcFunc['db_query']('', '
370
+		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) {
371
+					$request = $smcFunc['db_query']('', '
365 372
 				SHOW TABLE STATUS
366 373
 				FROM {string:database_name}
367 374
 				LIKE {string:table_name}',
@@ -370,14 +377,15 @@  discard block
 block discarded – undo
370 377
 					'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words',
371 378
 				)
372 379
 			);
373
-		else
374
-			$request = $smcFunc['db_query']('', '
380
+		} else {
381
+					$request = $smcFunc['db_query']('', '
375 382
 				SHOW TABLE STATUS
376 383
 				LIKE {string:table_name}',
377 384
 				array(
378 385
 					'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words',
379 386
 				)
380 387
 			);
388
+		}
381 389
 		if ($request !== false && $smcFunc['db_num_rows']($request) == 1)
382 390
 		{
383 391
 			// Only do this if the user has permission to execute this query.
@@ -386,8 +394,7 @@  discard block
 block discarded – undo
386 394
 			$context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length'];
387 395
 			$smcFunc['db_free_result']($request);
388 396
 		}
389
-	}
390
-	elseif ($db_type == 'postgresql')
397
+	} elseif ($db_type == 'postgresql')
391 398
 	{
392 399
 		// In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using.
393 400
 		//db_extend();
@@ -429,38 +436,38 @@  discard block
 block discarded – undo
429 436
 					$context['table_info']['data_length'] = (int) $row['table_size'];
430 437
 					$context['table_info']['index_length'] = (int) $row['index_size'];
431 438
 					$context['table_info']['fulltext_length'] = (int) $row['index_size'];
432
-				}
433
-				elseif ($row['indexname'] == $db_prefix . 'log_search_words')
439
+				} elseif ($row['indexname'] == $db_prefix . 'log_search_words')
434 440
 				{
435 441
 					$context['table_info']['index_length'] = (int) $row['index_size'];
436 442
 					$context['table_info']['custom_index_length'] = (int) $row['index_size'];
437 443
 				}
438 444
 			}
439 445
 			$smcFunc['db_free_result']($request);
440
-		}
441
-		else
442
-			// Didn't work for some reason...
446
+		} else {
447
+					// Didn't work for some reason...
443 448
 			$context['table_info'] = array(
444 449
 				'data_length' => $txt['not_applicable'],
445 450
 				'index_length' => $txt['not_applicable'],
446 451
 				'fulltext_length' => $txt['not_applicable'],
447 452
 				'custom_index_length' => $txt['not_applicable'],
448 453
 			);
449
-	}
450
-	else
451
-		$context['table_info'] = array(
454
+		}
455
+	} else {
456
+			$context['table_info'] = array(
452 457
 			'data_length' => $txt['not_applicable'],
453 458
 			'index_length' => $txt['not_applicable'],
454 459
 			'fulltext_length' => $txt['not_applicable'],
455 460
 			'custom_index_length' => $txt['not_applicable'],
456 461
 		);
462
+	}
457 463
 
458 464
 	// Format the data and index length in kilobytes.
459 465
 	foreach ($context['table_info'] as $type => $size)
460 466
 	{
461 467
 		// If it's not numeric then just break.  This database engine doesn't support size.
462
-		if (!is_numeric($size))
463
-			break;
468
+		if (!is_numeric($size)) {
469
+					break;
470
+		}
464 471
 
465 472
 		$context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes'];
466 473
 	}
@@ -489,8 +496,9 @@  discard block
 block discarded – undo
489 496
 
490 497
 	// Scotty, we need more time...
491 498
 	@set_time_limit(600);
492
-	if (function_exists('apache_reset_timeout'))
493
-		@apache_reset_timeout();
499
+	if (function_exists('apache_reset_timeout')) {
500
+			@apache_reset_timeout();
501
+	}
494 502
 
495 503
 	$context[$context['admin_menu_name']]['current_subsection'] = 'method';
496 504
 	$context['page_title'] = $txt['search_index_custom'];
@@ -520,8 +528,7 @@  discard block
 block discarded – undo
520 528
 		$context['start'] = (int) $context['index_settings']['resume_at'];
521 529
 		unset($context['index_settings']['resume_at']);
522 530
 		$context['step'] = 1;
523
-	}
524
-	else
531
+	} else
525 532
 	{
526 533
 		$context['index_settings'] = array(
527 534
 			'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2,
@@ -530,12 +537,14 @@  discard block
 block discarded – undo
530 537
 		$context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0;
531 538
 
532 539
 		// admin timeouts are painful when building these long indexes - but only if we actually have such things enabled
533
-		if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1)
534
-			$_SESSION['admin_time'] = time();
540
+		if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) {
541
+					$_SESSION['admin_time'] = time();
542
+		}
535 543
 	}
536 544
 
537
-	if ($context['step'] !== 0)
538
-		checkSession('request');
545
+	if ($context['step'] !== 0) {
546
+			checkSession('request');
547
+	}
539 548
 
540 549
 	// Step 0: let the user determine how they like their index.
541 550
 	if ($context['step'] === 0)
@@ -564,12 +573,14 @@  discard block
 block discarded – undo
564 573
 			$smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']);
565 574
 
566 575
 			// Temporarily switch back to not using a search index.
567
-			if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom')
568
-				updateSettings(array('search_index' => ''));
576
+			if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') {
577
+							updateSettings(array('search_index' => ''));
578
+			}
569 579
 
570 580
 			// Don't let simultanious processes be updating the search index.
571
-			if (!empty($modSettings['search_custom_index_config']))
572
-				updateSettings(array('search_custom_index_config' => ''));
581
+			if (!empty($modSettings['search_custom_index_config'])) {
582
+							updateSettings(array('search_custom_index_config' => ''));
583
+			}
573 584
 		}
574 585
 
575 586
 		$num_messages = array(
@@ -585,16 +596,16 @@  discard block
 block discarded – undo
585 596
 				'starting_id' => $context['start'],
586 597
 			)
587 598
 		);
588
-		while ($row = $smcFunc['db_fetch_assoc']($request))
589
-			$num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages'];
599
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
600
+					$num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages'];
601
+		}
590 602
 
591 603
 		if (empty($num_messages['todo']))
592 604
 		{
593 605
 			$context['step'] = 2;
594 606
 			$context['percentage'] = 80;
595 607
 			$context['start'] = 0;
596
-		}
597
-		else
608
+		} else
598 609
 		{
599 610
 			// Number of seconds before the next step.
600 611
 			$stop = time() + 3;
@@ -635,21 +646,22 @@  discard block
 block discarded – undo
635 646
 
636 647
 				$context['start'] += $forced_break ? $number_processed : $messages_per_batch;
637 648
 
638
-				if (!empty($inserts))
639
-					$smcFunc['db_insert']('ignore',
649
+				if (!empty($inserts)) {
650
+									$smcFunc['db_insert']('ignore',
640 651
 						'{db_prefix}log_search_words',
641 652
 						array('id_word' => 'int', 'id_msg' => 'int'),
642 653
 						$inserts,
643 654
 						array('id_word', 'id_msg')
644 655
 					);
656
+				}
645 657
 				if ($num_messages['todo'] === 0)
646 658
 				{
647 659
 					$context['step'] = 2;
648 660
 					$context['start'] = 0;
649 661
 					break;
662
+				} else {
663
+									updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start'])))));
650 664
 				}
651
-				else
652
-					updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start'])))));
653 665
 			}
654 666
 
655 667
 			// Since there are still two steps to go, 80% is the maximum here.
@@ -660,9 +672,9 @@  discard block
 block discarded – undo
660 672
 	// Step 2: removing the words that occur too often and are of no use.
661 673
 	elseif ($context['step'] === 2)
662 674
 	{
663
-		if ($context['index_settings']['bytes_per_word'] < 4)
664
-			$context['step'] = 3;
665
-		else
675
+		if ($context['index_settings']['bytes_per_word'] < 4) {
676
+					$context['step'] = 3;
677
+		} else
666 678
 		{
667 679
 			$stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']);
668 680
 			$stop = time() + 3;
@@ -683,20 +695,22 @@  discard block
 block discarded – undo
683 695
 						'minimum_messages' => $max_messages,
684 696
 					)
685 697
 				);
686
-				while ($row = $smcFunc['db_fetch_assoc']($request))
687
-					$stop_words[] = $row['id_word'];
698
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
699
+									$stop_words[] = $row['id_word'];
700
+				}
688 701
 				$smcFunc['db_free_result']($request);
689 702
 
690 703
 				updateSettings(array('search_stopwords' => implode(',', $stop_words)));
691 704
 
692
-				if (!empty($stop_words))
693
-					$smcFunc['db_query']('', '
705
+				if (!empty($stop_words)) {
706
+									$smcFunc['db_query']('', '
694 707
 						DELETE FROM {db_prefix}log_search_words
695 708
 						WHERE id_word in ({array_int:stop_words})',
696 709
 						array(
697 710
 							'stop_words' => $stop_words,
698 711
 						)
699 712
 					);
713
+				}
700 714
 
701 715
 				$context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size'];
702 716
 				if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size'])
@@ -757,8 +771,9 @@  discard block
 block discarded – undo
757 771
 					$searchAPI = new $search_class_name();
758 772
 
759 773
 					// No Support?  NEXT!
760
-					if (!$searchAPI->is_supported)
761
-						continue;
774
+					if (!$searchAPI->is_supported) {
775
+											continue;
776
+					}
762 777
 
763 778
 					$apis[$index_name] = array(
764 779
 						'filename' => $file,
@@ -805,10 +820,10 @@  discard block
 block discarded – undo
805 820
 				'messages_ftx' => $db_prefix . 'messages_ftx',
806 821
 			)
807 822
 		);
808
-		while ($row = $smcFunc['db_fetch_assoc']($request))
809
-			$context['fulltext_index'][] = $row['indexname'];
810
-	}
811
-	else
823
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
824
+					$context['fulltext_index'][] = $row['indexname'];
825
+		}
826
+	} else
812 827
 	{
813 828
 		$request = $smcFunc['db_query']('', '
814 829
 			SHOW INDEX
@@ -819,17 +834,19 @@  discard block
 block discarded – undo
819 834
 		$context['fulltext_index'] = array();
820 835
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
821 836
 		{
822
-			while ($row = $smcFunc['db_fetch_assoc']($request))
823
-			if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
837
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
838
+						if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
824 839
 				$context['fulltext_index'][] = $row['Key_name'];
840
+			}
825 841
 			$smcFunc['db_free_result']($request);
826 842
 
827
-			if (is_array($context['fulltext_index']))
828
-				$context['fulltext_index'] = array_unique($context['fulltext_index']);
843
+			if (is_array($context['fulltext_index'])) {
844
+							$context['fulltext_index'] = array_unique($context['fulltext_index']);
845
+			}
829 846
 		}
830 847
 
831
-		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0)
832
-			$request = $smcFunc['db_query']('', '
848
+		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) {
849
+					$request = $smcFunc['db_query']('', '
833 850
 			SHOW TABLE STATUS
834 851
 			FROM {string:database_name}
835 852
 			LIKE {string:table_name}',
@@ -838,20 +855,22 @@  discard block
 block discarded – undo
838 855
 				'table_name' => str_replace('_', '\_', $match[2]) . 'messages',
839 856
 			)
840 857
 			);
841
-		else
842
-			$request = $smcFunc['db_query']('', '
858
+		} else {
859
+					$request = $smcFunc['db_query']('', '
843 860
 			SHOW TABLE STATUS
844 861
 			LIKE {string:table_name}',
845 862
 			array(
846 863
 				'table_name' => str_replace('_', '\_', $db_prefix) . 'messages',
847 864
 			)
848 865
 			);
866
+		}
849 867
 
850 868
 		if ($request !== false)
851 869
 		{
852
-			while ($row = $smcFunc['db_fetch_assoc']($request))
853
-			if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>=')))
870
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
871
+						if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>=')))
854 872
 				$context['cannot_create_fulltext'] = true;
873
+			}
855 874
 			$smcFunc['db_free_result']($request);
856 875
 		}
857 876
 	}
Please login to merge, or discard this patch.
Sources/MessageIndex.php 2 patches
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), '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
 		}
@@ -1188,8 +1251,9 @@  discard block
 block discarded – undo
1188 1251
 			approveTopics($approveCache);
1189 1252
 
1190 1253
 			// Time for some logging!
1191
-			foreach ($approveCache as $topic)
1192
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1254
+			foreach ($approveCache as $topic) {
1255
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1256
+			}
1193 1257
 		}
1194 1258
 	}
1195 1259
 
@@ -1224,8 +1288,7 @@  discard block
 block discarded – undo
1224 1288
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1225 1289
 			}
1226 1290
 			$smcFunc['db_free_result']($result);
1227
-		}
1228
-		else
1291
+		} else
1229 1292
 		{
1230 1293
 			$result = $smcFunc['db_query']('', '
1231 1294
 				SELECT id_topic, locked, id_board
@@ -1275,13 +1338,15 @@  discard block
 block discarded – undo
1275 1338
 			)
1276 1339
 		);
1277 1340
 		$logged_topics = array();
1278
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1279
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1341
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1342
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1343
+		}
1280 1344
 		$smcFunc['db_free_result']($request);
1281 1345
 
1282 1346
 		$markArray = array();
1283
-		foreach ($markCache as $topic)
1284
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1347
+		foreach ($markCache as $topic) {
1348
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1349
+		}
1285 1350
 
1286 1351
 		$smcFunc['db_insert']('replace',
1287 1352
 			'{db_prefix}log_topics',
@@ -1294,8 +1359,9 @@  discard block
 block discarded – undo
1294 1359
 	foreach ($moveCache as $topic)
1295 1360
 	{
1296 1361
 		// Didn't actually move anything!
1297
-		if (!isset($topic[0]))
1298
-			break;
1362
+		if (!isset($topic[0])) {
1363
+					break;
1364
+		}
1299 1365
 
1300 1366
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1301 1367
 		sendNotifications($topic[0], 'move');
@@ -1317,8 +1383,9 @@  discard block
 block discarded – undo
1317 1383
 		'calendar_updated' => time(),
1318 1384
 	));
1319 1385
 
1320
-	if (!empty($affectedBoards))
1321
-		updateLastMessages(array_keys($affectedBoards));
1386
+	if (!empty($affectedBoards)) {
1387
+			updateLastMessages(array_keys($affectedBoards));
1388
+	}
1322 1389
 
1323 1390
 	redirectexit($redirect_url);
1324 1391
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -349,7 +349,7 @@
 block discarded – undo
349 349
 			SELECT
350 350
 				t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board,
351 351
 				' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from,
352
-				' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in,
352
+				' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in,
353 353
 				'	: '') . '
354 354
 				t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic,
355 355
 				ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon,
Please login to merge, or discard this patch.
Sources/ManageNews.php 1 patch
Braces   +140 added lines, -102 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The news dispatcher; doesn't do anything, just delegates.
@@ -67,8 +68,9 @@  discard block
 block discarded – undo
67 68
 	);
68 69
 
69 70
 	// Force the right area...
70
-	if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
71
-		$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
71
+	if (substr($_REQUEST['sa'], 0, 7) == 'mailing') {
72
+			$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
73
+	}
72 74
 
73 75
 	call_helper($subActions[$_REQUEST['sa']][0]);
74 76
 }
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		$temp_news = explode("\n", $modSettings['news']);
100 102
 
101 103
 		// Remove the items that were selected.
102
-		foreach ($temp_news as $i => $news)
103
-			if (in_array($i, $_POST['remove']))
104
+		foreach ($temp_news as $i => $news) {
105
+					if (in_array($i, $_POST['remove']))
104 106
 				unset($temp_news[$i]);
107
+		}
105 108
 
106 109
 		// Update the database.
107 110
 		updateSettings(array('news' => implode("\n", $temp_news)));
@@ -117,9 +120,9 @@  discard block
 block discarded – undo
117 120
 
118 121
 		foreach ($_POST['news'] as $i => $news)
119 122
 		{
120
-			if (trim($news) == '')
121
-				unset($_POST['news'][$i]);
122
-			else
123
+			if (trim($news) == '') {
124
+							unset($_POST['news'][$i]);
125
+			} else
123 126
 			{
124 127
 				$_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES);
125 128
 				preparsecode($_POST['news'][$i]);
@@ -155,12 +158,13 @@  discard block
 block discarded – undo
155 158
 				'data' => array(
156 159
 					'function' => function($news)
157 160
 					{
158
-						if (is_numeric($news['id']))
159
-							return '
161
+						if (is_numeric($news['id'])) {
162
+													return '
160 163
 								<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
161 164
 								<div class="floatleft" id="preview_' . $news['id'] . '"></div>';
162
-						else
163
-							return $news['unparsed'];
165
+						} else {
166
+													return $news['unparsed'];
167
+						}
164 168
 					},
165 169
 					'class' => 'half_table',
166 170
 				),
@@ -186,10 +190,11 @@  discard block
 block discarded – undo
186 190
 				'data' => array(
187 191
 					'function' => function($news)
188 192
 					{
189
-						if (is_numeric($news['id']))
190
-							return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">';
191
-						else
192
-							return '';
193
+						if (is_numeric($news['id'])) {
194
+													return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">';
195
+						} else {
196
+													return '';
197
+						}
193 198
 					},
194 199
 					'class' => 'centercol icon',
195 200
 				),
@@ -283,12 +288,13 @@  discard block
 block discarded – undo
283 288
 
284 289
 	$admin_current_news = array();
285 290
 	// Ready the current news.
286
-	foreach (explode("\n", $modSettings['news']) as $id => $line)
287
-		$admin_current_news[$id] = array(
291
+	foreach (explode("\n", $modSettings['news']) as $id => $line) {
292
+			$admin_current_news[$id] = array(
288 293
 			'id' => $id,
289 294
 			'unparsed' => un_preparsecode($line),
290 295
 			'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext">&lt;$1form&gt;</em>', parse_bbc($line)),
291 296
 		);
297
+	}
292 298
 
293 299
 	$admin_current_news['last'] = array(
294 300
 		'id' => 'last',
@@ -355,10 +361,11 @@  discard block
 block discarded – undo
355 361
 			'member_count' => 0,
356 362
 		);
357 363
 
358
-		if ($row['min_posts'] == -1)
359
-			$normalGroups[$row['id_group']] = $row['id_group'];
360
-		else
361
-			$postGroups[$row['id_group']] = $row['id_group'];
364
+		if ($row['min_posts'] == -1) {
365
+					$normalGroups[$row['id_group']] = $row['id_group'];
366
+		} else {
367
+					$postGroups[$row['id_group']] = $row['id_group'];
368
+		}
362 369
 	}
363 370
 	$smcFunc['db_free_result']($request);
364 371
 
@@ -374,8 +381,9 @@  discard block
 block discarded – undo
374 381
 				'post_group_list' => $postGroups,
375 382
 			)
376 383
 		);
377
-		while ($row = $smcFunc['db_fetch_assoc']($query))
378
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
384
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
385
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
386
+		}
379 387
 		$smcFunc['db_free_result']($query);
380 388
 	}
381 389
 
@@ -391,8 +399,9 @@  discard block
 block discarded – undo
391 399
 				'normal_group_list' => $normalGroups,
392 400
 			)
393 401
 		);
394
-		while ($row = $smcFunc['db_fetch_assoc']($query))
395
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
402
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
403
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
404
+		}
396 405
 		$smcFunc['db_free_result']($query);
397 406
 
398 407
 		// Also do those who have it as an additional membergroup - this ones more yucky...
@@ -409,8 +418,9 @@  discard block
 block discarded – undo
409 418
 				'blank_string' => '',
410 419
 			)
411 420
 		);
412
-		while ($row = $smcFunc['db_fetch_assoc']($query))
413
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
421
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
422
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
423
+		}
414 424
 		$smcFunc['db_free_result']($query);
415 425
 	}
416 426
 
@@ -461,10 +471,11 @@  discard block
 block discarded – undo
461 471
 	{
462 472
 		$context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : '';
463 473
 
464
-		if (empty($context[$key]) && empty($_REQUEST['xml']))
465
-			$context['post_error']['messages'][] = $txt['error_no_' . $post];
466
-		elseif (!empty($_REQUEST['xml']))
467
-			continue;
474
+		if (empty($context[$key]) && empty($_REQUEST['xml'])) {
475
+					$context['post_error']['messages'][] = $txt['error_no_' . $post];
476
+		} elseif (!empty($_REQUEST['xml'])) {
477
+					continue;
478
+		}
468 479
 
469 480
 		preparsecode($context[$key]);
470 481
 		if ($html)
@@ -543,10 +554,12 @@  discard block
 block discarded – undo
543 554
 
544 555
 	// Start by finding any members!
545 556
 	$toClean = array();
546
-	if (!empty($_POST['members']))
547
-		$toClean[] = 'members';
548
-	if (!empty($_POST['exclude_members']))
549
-		$toClean[] = 'exclude_members';
557
+	if (!empty($_POST['members'])) {
558
+			$toClean[] = 'members';
559
+	}
560
+	if (!empty($_POST['exclude_members'])) {
561
+			$toClean[] = 'exclude_members';
562
+	}
550 563
 	if (!empty($toClean))
551 564
 	{
552 565
 		require_once($sourcedir . '/Subs-Auth.php');
@@ -558,11 +571,13 @@  discard block
 block discarded – undo
558 571
 			preg_match_all('~"([^"]+)"~', $_POST[$type], $matches);
559 572
 			$_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type]))));
560 573
 
561
-			foreach ($_POST[$type] as $index => $member)
562
-				if (strlen(trim($member)) > 0)
574
+			foreach ($_POST[$type] as $index => $member) {
575
+							if (strlen(trim($member)) > 0)
563 576
 					$_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member)));
564
-				else
565
-					unset($_POST[$type][$index]);
577
+			}
578
+				else {
579
+									unset($_POST[$type][$index]);
580
+				}
566 581
 
567 582
 			// Find the members
568 583
 			$_POST[$type] = implode(',', array_keys(findMembers($_POST[$type])));
@@ -572,16 +587,18 @@  discard block
 block discarded – undo
572 587
 	if (isset($_POST['member_list']) && is_array($_POST['member_list']))
573 588
 	{
574 589
 		$members = array();
575
-		foreach ($_POST['member_list'] as $member_id)
576
-			$members[] = (int) $member_id;
590
+		foreach ($_POST['member_list'] as $member_id) {
591
+					$members[] = (int) $member_id;
592
+		}
577 593
 		$_POST['members'] = implode(',', $members);
578 594
 	}
579 595
 
580 596
 	if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list']))
581 597
 	{
582 598
 		$members = array();
583
-		foreach ($_POST['exclude_member_list'] as $member_id)
584
-			$members[] = (int) $member_id;
599
+		foreach ($_POST['exclude_member_list'] as $member_id) {
600
+					$members[] = (int) $member_id;
601
+		}
585 602
 		$_POST['exclude_members'] = implode(',', $members);
586 603
 	}
587 604
 
@@ -605,8 +622,9 @@  discard block
 block discarded – undo
605 622
 			'current_time' => time(),
606 623
 		)
607 624
 	);
608
-	while ($row = $smcFunc['db_fetch_assoc']($request))
609
-		$context['recipients']['exclude_members'][] = $row['id_member'];
625
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
626
+			$context['recipients']['exclude_members'][] = $row['id_member'];
627
+	}
610 628
 	$smcFunc['db_free_result']($request);
611 629
 
612 630
 	$request = $smcFunc['db_query']('', '
@@ -641,8 +659,9 @@  discard block
 block discarded – undo
641 659
 			WHERE email_address IN(' . implode(', ', $condition_array) . ')',
642 660
 			$condition_array_params
643 661
 		);
644
-		while ($row = $smcFunc['db_fetch_assoc']($request))
645
-			$context['recipients']['exclude_members'][] = $row['id_member'];
662
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
663
+					$context['recipients']['exclude_members'][] = $row['id_member'];
664
+		}
646 665
 		$smcFunc['db_free_result']($request);
647 666
 	}
648 667
 
@@ -660,10 +679,11 @@  discard block
 block discarded – undo
660 679
 		);
661 680
 		while ($row = $smcFunc['db_fetch_assoc']($request))
662 681
 		{
663
-			if (in_array(3, $context['recipients']))
664
-				$context['recipients']['exclude_members'][] = $row['identifier'];
665
-			else
666
-				$context['recipients']['members'][] = $row['identifier'];
682
+			if (in_array(3, $context['recipients'])) {
683
+							$context['recipients']['exclude_members'][] = $row['identifier'];
684
+			} else {
685
+							$context['recipients']['members'][] = $row['identifier'];
686
+			}
667 687
 		}
668 688
 		$smcFunc['db_free_result']($request);
669 689
 	}
@@ -710,8 +730,9 @@  discard block
 block discarded – undo
710 730
 	$num_at_once = 1000;
711 731
 
712 732
 	// If by PM's I suggest we half the above number.
713
-	if (!empty($_POST['send_pm']))
714
-		$num_at_once /= 2;
733
+	if (!empty($_POST['send_pm'])) {
734
+			$num_at_once /= 2;
735
+	}
715 736
 
716 737
 	checkSession();
717 738
 
@@ -734,8 +755,7 @@  discard block
 block discarded – undo
734 755
 		);
735 756
 		list ($context['total_members']) = $smcFunc['db_fetch_row']($request);
736 757
 		$smcFunc['db_free_result']($request);
737
-	}
738
-	else
758
+	} else
739 759
 	{
740 760
 		$context['total_members'] = (int) $_REQUEST['total_members'];
741 761
 	}
@@ -753,32 +773,35 @@  discard block
 block discarded – undo
753 773
 	if (!empty($_POST['exclude_members']))
754 774
 	{
755 775
 		$members = explode(',', $_POST['exclude_members']);
756
-		foreach ($members as $member)
757
-			if ($member >= $context['start'])
776
+		foreach ($members as $member) {
777
+					if ($member >= $context['start'])
758 778
 				$context['recipients']['exclude_members'][] = (int) $member;
779
+		}
759 780
 	}
760 781
 
761 782
 	// What about members we *must* do?
762 783
 	if (!empty($_POST['members']))
763 784
 	{
764 785
 		$members = explode(',', $_POST['members']);
765
-		foreach ($members as $member)
766
-			if ($member >= $context['start'])
786
+		foreach ($members as $member) {
787
+					if ($member >= $context['start'])
767 788
 				$context['recipients']['members'][] = (int) $member;
789
+		}
768 790
 	}
769 791
 	// Cleaning groups is simple - although deal with both checkbox and commas.
770 792
 	if (isset($_POST['groups']))
771 793
 	{
772 794
 		if (is_array($_POST['groups']))
773 795
 		{
774
-			foreach ($_POST['groups'] as $group => $dummy)
775
-				$context['recipients']['groups'][] = (int) $group;
776
-		}
777
-		else
796
+			foreach ($_POST['groups'] as $group => $dummy) {
797
+							$context['recipients']['groups'][] = (int) $group;
798
+			}
799
+		} else
778 800
 		{
779 801
 			$groups = explode(',', $_POST['groups']);
780
-			foreach ($groups as $group)
781
-				$context['recipients']['groups'][] = (int) $group;
802
+			foreach ($groups as $group) {
803
+							$context['recipients']['groups'][] = (int) $group;
804
+			}
782 805
 		}
783 806
 	}
784 807
 	// Same for excluded groups
@@ -786,15 +809,17 @@  discard block
 block discarded – undo
786 809
 	{
787 810
 		if (is_array($_POST['exclude_groups']))
788 811
 		{
789
-			foreach ($_POST['exclude_groups'] as $group => $dummy)
790
-				$context['recipients']['exclude_groups'][] = (int) $group;
812
+			foreach ($_POST['exclude_groups'] as $group => $dummy) {
813
+							$context['recipients']['exclude_groups'][] = (int) $group;
814
+			}
791 815
 		}
792 816
 		// Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected
793 817
 		elseif ($_POST['exclude_groups'] != '')
794 818
 		{
795 819
 			$groups = explode(',', $_POST['exclude_groups']);
796
-			foreach ($groups as $group)
797
-				$context['recipients']['exclude_groups'][] = (int) $group;
820
+			foreach ($groups as $group) {
821
+							$context['recipients']['exclude_groups'][] = (int) $group;
822
+			}
798 823
 		}
799 824
 	}
800 825
 	// Finally - emails!
@@ -804,14 +829,16 @@  discard block
 block discarded – undo
804 829
 		foreach ($addressed as $curmem)
805 830
 		{
806 831
 			$curmem = trim($curmem);
807
-			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL))
808
-				$context['recipients']['emails'][$curmem] = $curmem;
832
+			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) {
833
+							$context['recipients']['emails'][$curmem] = $curmem;
834
+			}
809 835
 		}
810 836
 	}
811 837
 
812 838
 	// If we're only cleaning drop out here.
813
-	if ($clean_only)
814
-		return;
839
+	if ($clean_only) {
840
+			return;
841
+	}
815 842
 
816 843
 	require_once($sourcedir . '/Subs-Post.php');
817 844
 
@@ -827,16 +854,18 @@  discard block
 block discarded – undo
827 854
 	if (!$context['send_pm'] && !empty($_POST['send_html']))
828 855
 	{
829 856
 		// Prepare the message for HTML.
830
-		if (!empty($_POST['parse_html']))
831
-			$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
857
+		if (!empty($_POST['parse_html'])) {
858
+					$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
859
+		}
832 860
 
833 861
 		// This is here to prevent spam filters from tagging this as spam.
834 862
 		if (preg_match('~\<html~i', $_POST['message']) == 0)
835 863
 		{
836
-			if (preg_match('~\<body~i', $_POST['message']) == 0)
837
-				$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
838
-			else
839
-				$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
864
+			if (preg_match('~\<body~i', $_POST['message']) == 0) {
865
+							$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
866
+			} else {
867
+							$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
868
+			}
840 869
 		}
841 870
 	}
842 871
 
@@ -890,15 +919,17 @@  discard block
 block discarded – undo
890 919
 	foreach ($context['recipients']['emails'] as $k => $email)
891 920
 	{
892 921
 		// Done as many as we can?
893
-		if ($i >= $num_at_once)
894
-			break;
922
+		if ($i >= $num_at_once) {
923
+					break;
924
+		}
895 925
 
896 926
 		// Don't sent it twice!
897 927
 		unset($context['recipients']['emails'][$k]);
898 928
 
899 929
 		// Dammit - can't PM emails!
900
-		if ($context['send_pm'])
901
-			continue;
930
+		if ($context['send_pm']) {
931
+					continue;
932
+		}
902 933
 
903 934
 		$to_member = array(
904 935
 			$email,
@@ -932,8 +963,9 @@  discard block
 block discarded – undo
932 963
 					$queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}';
933 964
 				}
934 965
 			}
935
-			if (!empty($queryBuild))
936
-			$sendQuery .= implode(' OR ', $queryBuild);
966
+			if (!empty($queryBuild)) {
967
+						$sendQuery .= implode(' OR ', $queryBuild);
968
+			}
937 969
 		}
938 970
 		if (!empty($context['recipients']['members']))
939 971
 		{
@@ -952,8 +984,9 @@  discard block
 block discarded – undo
952 984
 		}
953 985
 
954 986
 		// Anything to exclude?
955
-		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups']))
956
-			$sendQuery .= ' AND mem.id_group != {int:regular_group}';
987
+		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) {
988
+					$sendQuery .= ' AND mem.id_group != {int:regular_group}';
989
+		}
957 990
 		if (!empty($context['recipients']['exclude_members']))
958 991
 		{
959 992
 			$sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})';
@@ -989,21 +1022,24 @@  discard block
 block discarded – undo
989 1022
 		foreach ($rows as $row)
990 1023
 		{
991 1024
 			// Force them to have it?
992
-			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements']))
993
-				continue;
1025
+			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) {
1026
+							continue;
1027
+			}
994 1028
 
995 1029
 			// What groups are we looking at here?
996
-			if (empty($row['additional_groups']))
997
-				$groups = array($row['id_group'], $row['id_post_group']);
998
-			else
999
-				$groups = array_merge(
1030
+			if (empty($row['additional_groups'])) {
1031
+							$groups = array($row['id_group'], $row['id_post_group']);
1032
+			} else {
1033
+							$groups = array_merge(
1000 1034
 					array($row['id_group'], $row['id_post_group']),
1001 1035
 					explode(',', $row['additional_groups'])
1002 1036
 				);
1037
+			}
1003 1038
 
1004 1039
 			// Excluded groups?
1005
-			if (array_intersect($groups, $context['recipients']['exclude_groups']))
1006
-				continue;
1040
+			if (array_intersect($groups, $context['recipients']['exclude_groups'])) {
1041
+							continue;
1042
+			}
1007 1043
 
1008 1044
 			// We might need this
1009 1045
 			$cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name'];
@@ -1026,10 +1062,11 @@  discard block
 block discarded – undo
1026 1062
 				), $_POST['subject']);
1027 1063
 
1028 1064
 			// Send the actual email - or a PM!
1029
-			if (!$context['send_pm'])
1030
-				sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1031
-			else
1032
-				sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1065
+			if (!$context['send_pm']) {
1066
+							sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1067
+			} else {
1068
+							sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1069
+			}
1033 1070
 		}
1034 1071
 	}
1035 1072
 
@@ -1079,8 +1116,9 @@  discard block
 block discarded – undo
1079 1116
 
1080 1117
 	call_integration_hook('integrate_modify_news_settings', array(&$config_vars));
1081 1118
 
1082
-	if ($return_config)
1083
-		return $config_vars;
1119
+	if ($return_config) {
1120
+			return $config_vars;
1121
+	}
1084 1122
 
1085 1123
 	$context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
1086 1124
 	$context['sub_template'] = 'show_settings';
Please login to merge, or discard this patch.
Sources/Subs.php 4 patches
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5495,7 +5495,6 @@  discard block
 block discarded – undo
5495 5495
 
5496 5496
 /**
5497 5497
  * Tries different modes to make file/dirs writable. Wrapper function for chmod()
5498
-
5499 5498
  * @param string $file The file/dir full path.
5500 5499
  * @param int $value Not needed, added for legacy reasons.
5501 5500
  * @return boolean  true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable.
@@ -5535,7 +5534,6 @@  discard block
 block discarded – undo
5535 5534
 
5536 5535
 /**
5537 5536
  * Wrapper function for json_decode() with error handling.
5538
-
5539 5537
  * @param string $json The string to decode.
5540 5538
  * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default.
5541 5539
  * @param bool $logIt To specify if the error will be logged if theres any.
@@ -6029,7 +6027,7 @@  discard block
 block discarded – undo
6029 6027
 		$params = stream_context_get_params($stream);
6030 6028
 		$result = isset($params["options"]["ssl"]["peer_certificate"]) ? true : false;
6031 6029
 	}
6032
-    return $result;
6030
+	return $result;
6033 6031
 }
6034 6032
 
6035 6033
 /**
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  * - caches the formatting data from the setting for optimization.
694 694
  *
695 695
  * @param float $number A number
696
- * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
696
+ * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined
697 697
  * @return string A formatted number
698 698
  */
699 699
 function comma_format($number, $override_decimal_count = false)
@@ -5646,7 +5646,7 @@  discard block
 block discarded – undo
5646 5646
  * It assumes the data is already a string.
5647 5647
  * @param string $data The data to print
5648 5648
  * @param string $type The content type. Defaults to Json.
5649
- * @return void
5649
+ * @return false|null
5650 5650
  */
5651 5651
 function smf_serverResponse($data = '', $type = 'content-type: application/json')
5652 5652
 {
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			{
387 387
 				$val = 'CASE ';
388 388
 				foreach ($members as $k => $v)
389
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
389
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' ';
390 390
 				$val = $val . ' END';
391 391
 				$type = 'raw';
392 392
 			}
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
818 818
 		if (empty($unsupportedFormats))
819 819
 		{
820
-			foreach($strftimeFormatSubstitutions as $format => $substitution)
820
+			foreach ($strftimeFormatSubstitutions as $format => $substitution)
821 821
 			{
822 822
 				$value = @strftime('%' . $format);
823 823
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1183 1183
 				),
1184 1184
 				'content' => '$1',
1185
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1185
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1186 1186
 				{
1187 1187
 					$returnContext = '';
1188 1188
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 						}
1218 1218
 
1219 1219
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1220
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1220
+							$returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>';
1221 1221
 						else
1222 1222
 							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1223 1223
 					}
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				'type' => 'unparsed_content',
1247 1247
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1248 1248
 				// @todo Maybe this can be simplified?
1249
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1249
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1250 1250
 				{
1251 1251
 					if (!isset($disabled['code']))
1252 1252
 					{
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 				'type' => 'unparsed_equals_content',
1284 1284
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1285 1285
 				// @todo Maybe this can be simplified?
1286
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1286
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1287 1287
 				{
1288 1288
 					if (!isset($disabled['code']))
1289 1289
 					{
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 				'type' => 'unparsed_content',
1328 1328
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1329 1329
 				// @todo Should this respect guest_hideContacts?
1330
-				'validate' => function (&$tag, &$data, $disabled)
1330
+				'validate' => function(&$tag, &$data, $disabled)
1331 1331
 				{
1332 1332
 					$data = strtr($data, array('<br>' => ''));
1333 1333
 				},
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 				'type' => 'unparsed_commas_content',
1347 1347
 				'test' => '\d+,\d+\]',
1348 1348
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1349
-				'validate' => function (&$tag, &$data, $disabled)
1349
+				'validate' => function(&$tag, &$data, $disabled)
1350 1350
 				{
1351 1351
 					if (isset($disabled['url']))
1352 1352
 						$tag['content'] = '$1';
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 				'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]',
1363 1363
 				'before' => '<div $1>',
1364 1364
 				'after' => '</div>',
1365
-				'validate' => function (&$tag, &$data, $disabled)
1365
+				'validate' => function(&$tag, &$data, $disabled)
1366 1366
 				{
1367 1367
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1368 1368
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1412 1412
 				),
1413 1413
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1414
-				'validate' => function (&$tag, &$data, $disabled)
1414
+				'validate' => function(&$tag, &$data, $disabled)
1415 1415
 				{
1416 1416
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info, $image_proxy_url;
1417 1417
 
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 				'tag' => 'img',
1441 1441
 				'type' => 'unparsed_content',
1442 1442
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1443
-				'validate' => function (&$tag, &$data, $disabled)
1443
+				'validate' => function(&$tag, &$data, $disabled)
1444 1444
 				{
1445 1445
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl, $image_proxy_url, $user_info;
1446 1446
 
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 				'tag' => 'iurl',
1470 1470
 				'type' => 'unparsed_content',
1471 1471
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1472
-				'validate' => function (&$tag, &$data, $disabled)
1472
+				'validate' => function(&$tag, &$data, $disabled)
1473 1473
 				{
1474 1474
 					$data = strtr($data, array('<br>' => ''));
1475 1475
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
 				'quoted' => 'optional',
1484 1484
 				'before' => '<a href="$1" class="bbc_link">',
1485 1485
 				'after' => '</a>',
1486
-				'validate' => function (&$tag, &$data, $disabled)
1486
+				'validate' => function(&$tag, &$data, $disabled)
1487 1487
 				{
1488 1488
 					if (substr($data, 0, 1) == '#')
1489 1489
 						$data = '#post_' . substr($data, 1);
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 				'tag' => 'php',
1564 1564
 				'type' => 'unparsed_content',
1565 1565
 				'content' => '<span class="phpcode">$1</span>',
1566
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1566
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1567 1567
 				{
1568 1568
 					if (!isset($disabled['php']))
1569 1569
 					{
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 				'test' => '[1-7]\]',
1662 1662
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1663 1663
 				'after' => '</span>',
1664
-				'validate' => function (&$tag, &$data, $disabled)
1664
+				'validate' => function(&$tag, &$data, $disabled)
1665 1665
 				{
1666 1666
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1667 1667
 					$data = $sizes[$data] . 'em';
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 				'tag' => 'time',
1700 1700
 				'type' => 'unparsed_content',
1701 1701
 				'content' => '$1',
1702
-				'validate' => function (&$tag, &$data, $disabled)
1702
+				'validate' => function(&$tag, &$data, $disabled)
1703 1703
 				{
1704 1704
 					if (is_numeric($data))
1705 1705
 						$data = timeformat($data);
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 				'tag' => 'url',
1728 1728
 				'type' => 'unparsed_content',
1729 1729
 				'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>',
1730
-				'validate' => function (&$tag, &$data, $disabled)
1730
+				'validate' => function(&$tag, &$data, $disabled)
1731 1731
 				{
1732 1732
 					$data = strtr($data, array('<br>' => ''));
1733 1733
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 				'quoted' => 'optional',
1742 1742
 				'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">',
1743 1743
 				'after' => '</a>',
1744
-				'validate' => function (&$tag, &$data, $disabled)
1744
+				'validate' => function(&$tag, &$data, $disabled)
1745 1745
 				{
1746 1746
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1747 1747
 					if (empty($scheme))
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
 		{
1768 1768
 			if (isset($temp_bbc))
1769 1769
 				$bbc_codes = $temp_bbc;
1770
-			usort($codes, function ($a, $b) {
1770
+			usort($codes, function($a, $b) {
1771 1771
 				return strcmp($a['tag'], $b['tag']);
1772 1772
 			});
1773 1773
 			return $codes;
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 										# a run of Unicode domain name characters and a dot
2005 2005
 										[\p{L}\p{M}\p{N}\-.:@]+\.
2006 2006
 										# and then a TLD valid in the DNS or the reserved "local" TLD
2007
-										(?:'. $modSettings['tld_regex'] .'|local)
2007
+										(?:'. $modSettings['tld_regex'] . '|local)
2008 2008
 									)
2009 2009
 									# followed by a non-domain character or end of line
2010 2010
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 						)?
2073 2073
 						';
2074 2074
 
2075
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
2075
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
2076 2076
 							$url = array_shift($matches);
2077 2077
 
2078 2078
 							$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2154 2154
 
2155 2155
 			// A closing tag that doesn't match any open tags? Skip it.
2156
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2156
+			if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags)))
2157 2157
 				continue;
2158 2158
 
2159 2159
 			$to_close = array();
@@ -2820,7 +2820,7 @@  discard block
 block discarded – undo
2820 2820
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2821 2821
 		{
2822 2822
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2823
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2823
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2824 2824
 
2825 2825
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2826 2826
 
@@ -2837,7 +2837,7 @@  discard block
 block discarded – undo
2837 2837
 
2838 2838
 	// Replace away!
2839 2839
 	$message = preg_replace_callback($smileyPregSearch,
2840
-		function ($matches) use ($smileyPregReplacements)
2840
+		function($matches) use ($smileyPregReplacements)
2841 2841
 		{
2842 2842
 			return $smileyPregReplacements[$matches[1]];
2843 2843
 		}, $message);
@@ -2903,13 +2903,13 @@  discard block
 block discarded – undo
2903 2903
 	{
2904 2904
 		if (defined('SID') && SID != '')
2905 2905
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2906
-				function ($m) use ($scripturl)
2906
+				function($m) use ($scripturl)
2907 2907
 				{
2908
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2908
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2909 2909
 				}, $setLocation);
2910 2910
 		else
2911 2911
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2912
-				function ($m) use ($scripturl)
2912
+				function($m) use ($scripturl)
2913 2913
 				{
2914 2914
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2915 2915
 				}, $setLocation);
@@ -3232,7 +3232,7 @@  discard block
 block discarded – undo
3232 3232
 
3233 3233
 	// Add a generic "Are you sure?" confirmation message.
3234 3234
 	addInlineJavaScript('
3235
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3235
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3236 3236
 
3237 3237
 	// Now add the capping code for avatars.
3238 3238
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3676,7 +3676,7 @@  discard block
 block discarded – undo
3676 3676
 	if (!empty($normal))
3677 3677
 		foreach ($normal as $nf)
3678 3678
 			echo '
3679
-	<link rel="stylesheet" href="', $nf ,'">';
3679
+	<link rel="stylesheet" href="', $nf, '">';
3680 3680
 
3681 3681
 	if ($db_show_debug === true)
3682 3682
 	{
@@ -3692,7 +3692,7 @@  discard block
 block discarded – undo
3692 3692
 	<style>';
3693 3693
 
3694 3694
 		foreach ($context['css_header'] as $css)
3695
-			echo $css .'
3695
+			echo $css . '
3696 3696
 	';
3697 3697
 
3698 3698
 		echo'
@@ -3731,7 +3731,7 @@  discard block
 block discarded – undo
3731 3731
 		return true;
3732 3732
 
3733 3733
 	// No namespaces, sorry!
3734
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3734
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3735 3735
 
3736 3736
 	// Temp path.
3737 3737
 	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
@@ -3857,7 +3857,7 @@  discard block
 block discarded – undo
3857 3857
 	else
3858 3858
 		$path = $modSettings['attachmentUploadDir'];
3859 3859
 
3860
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3860
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3861 3861
 }
3862 3862
 
3863 3863
 /**
@@ -3901,10 +3901,10 @@  discard block
 block discarded – undo
3901 3901
 		$valid_low = isValidIP($ip_parts[0]);
3902 3902
 		$valid_high = isValidIP($ip_parts[1]);
3903 3903
 		$count = 0;
3904
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
3904
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
3905 3905
 		$max = ($mode == ':' ? 'ffff' : '255');
3906 3906
 		$min = 0;
3907
-		if(!$valid_low)
3907
+		if (!$valid_low)
3908 3908
 		{
3909 3909
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
3910 3910
 			$valid_low = isValidIP($ip_parts[0]);
@@ -3918,7 +3918,7 @@  discard block
 block discarded – undo
3918 3918
 		}
3919 3919
 
3920 3920
 		$count = 0;
3921
-		if(!$valid_high)
3921
+		if (!$valid_high)
3922 3922
 		{
3923 3923
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
3924 3924
 			$valid_high = isValidIP($ip_parts[1]);
@@ -3931,7 +3931,7 @@  discard block
 block discarded – undo
3931 3931
 			}
3932 3932
 		}
3933 3933
 
3934
-		if($valid_high && $valid_low)
3934
+		if ($valid_high && $valid_low)
3935 3935
 		{
3936 3936
 			$ip_array['low'] = $ip_parts[0];
3937 3937
 			$ip_array['high'] = $ip_parts[1];
@@ -4113,7 +4113,7 @@  discard block
 block discarded – undo
4113 4113
 		addInlineJavaScript('
4114 4114
 	var user_menus = new smc_PopupMenu();
4115 4115
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4116
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4116
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4117 4117
 		if ($context['allow_pm'])
4118 4118
 			addInlineJavaScript('
4119 4119
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4749,7 +4749,7 @@  discard block
 block discarded – undo
4749 4749
 		// No? try a fallback to $sourcedir
4750 4750
 		else
4751 4751
 		{
4752
-			$absPath = $sourcedir .'/'. $file;
4752
+			$absPath = $sourcedir . '/' . $file;
4753 4753
 
4754 4754
 			if (file_exists($absPath))
4755 4755
 				require_once($absPath);
@@ -4830,15 +4830,15 @@  discard block
 block discarded – undo
4830 4830
 
4831 4831
 	// UTF-8 occurences of MS special characters
4832 4832
 	$findchars_utf8 = array(
4833
-		"\xe2\x80\x9a",	// single low-9 quotation mark
4834
-		"\xe2\x80\x9e",	// double low-9 quotation mark
4835
-		"\xe2\x80\xa6",	// horizontal ellipsis
4836
-		"\xe2\x80\x98",	// left single curly quote
4837
-		"\xe2\x80\x99",	// right single curly quote
4838
-		"\xe2\x80\x9c",	// left double curly quote
4839
-		"\xe2\x80\x9d",	// right double curly quote
4840
-		"\xe2\x80\x93",	// en dash
4841
-		"\xe2\x80\x94",	// em dash
4833
+		"\xe2\x80\x9a", // single low-9 quotation mark
4834
+		"\xe2\x80\x9e", // double low-9 quotation mark
4835
+		"\xe2\x80\xa6", // horizontal ellipsis
4836
+		"\xe2\x80\x98", // left single curly quote
4837
+		"\xe2\x80\x99", // right single curly quote
4838
+		"\xe2\x80\x9c", // left double curly quote
4839
+		"\xe2\x80\x9d", // right double curly quote
4840
+		"\xe2\x80\x93", // en dash
4841
+		"\xe2\x80\x94", // em dash
4842 4842
 	);
4843 4843
 
4844 4844
 	// windows 1252 / iso equivalents
@@ -4856,15 +4856,15 @@  discard block
 block discarded – undo
4856 4856
 
4857 4857
 	// safe replacements
4858 4858
 	$replacechars = array(
4859
-		',',	// &sbquo;
4860
-		',,',	// &bdquo;
4861
-		'...',	// &hellip;
4862
-		"'",	// &lsquo;
4863
-		"'",	// &rsquo;
4864
-		'"',	// &ldquo;
4865
-		'"',	// &rdquo;
4866
-		'-',	// &ndash;
4867
-		'--',	// &mdash;
4859
+		',', // &sbquo;
4860
+		',,', // &bdquo;
4861
+		'...', // &hellip;
4862
+		"'", // &lsquo;
4863
+		"'", // &rsquo;
4864
+		'"', // &ldquo;
4865
+		'"', // &rdquo;
4866
+		'-', // &ndash;
4867
+		'--', // &mdash;
4868 4868
 	);
4869 4869
 
4870 4870
 	if ($context['utf8'])
@@ -5282,7 +5282,7 @@  discard block
 block discarded – undo
5282 5282
  */
5283 5283
 function inet_dtop($bin)
5284 5284
 {
5285
-	if(empty($bin))
5285
+	if (empty($bin))
5286 5286
 		return '';
5287 5287
 
5288 5288
 	global $db_type;
@@ -5313,28 +5313,28 @@  discard block
 block discarded – undo
5313 5313
  */
5314 5314
 function _safe_serialize($value)
5315 5315
 {
5316
-	if(is_null($value))
5316
+	if (is_null($value))
5317 5317
 		return 'N;';
5318 5318
 
5319
-	if(is_bool($value))
5320
-		return 'b:'. (int) $value .';';
5319
+	if (is_bool($value))
5320
+		return 'b:' . (int) $value . ';';
5321 5321
 
5322
-	if(is_int($value))
5323
-		return 'i:'. $value .';';
5322
+	if (is_int($value))
5323
+		return 'i:' . $value . ';';
5324 5324
 
5325
-	if(is_float($value))
5326
-		return 'd:'. str_replace(',', '.', $value) .';';
5325
+	if (is_float($value))
5326
+		return 'd:' . str_replace(',', '.', $value) . ';';
5327 5327
 
5328
-	if(is_string($value))
5329
-		return 's:'. strlen($value) .':"'. $value .'";';
5328
+	if (is_string($value))
5329
+		return 's:' . strlen($value) . ':"' . $value . '";';
5330 5330
 
5331
-	if(is_array($value))
5331
+	if (is_array($value))
5332 5332
 	{
5333 5333
 		$out = '';
5334
-		foreach($value as $k => $v)
5334
+		foreach ($value as $k => $v)
5335 5335
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5336 5336
 
5337
-		return 'a:'. count($value) .':{'. $out .'}';
5337
+		return 'a:' . count($value) . ':{' . $out . '}';
5338 5338
 	}
5339 5339
 
5340 5340
 	// safe_serialize cannot serialize resources or objects.
@@ -5376,7 +5376,7 @@  discard block
 block discarded – undo
5376 5376
 function _safe_unserialize($str)
5377 5377
 {
5378 5378
 	// Input  is not a string.
5379
-	if(empty($str) || !is_string($str))
5379
+	if (empty($str) || !is_string($str))
5380 5380
 		return false;
5381 5381
 
5382 5382
 	$stack = array();
@@ -5390,40 +5390,40 @@  discard block
 block discarded – undo
5390 5390
 	 *   3 - in array, expecting value or another array
5391 5391
 	 */
5392 5392
 	$state = 0;
5393
-	while($state != 1)
5393
+	while ($state != 1)
5394 5394
 	{
5395 5395
 		$type = isset($str[0]) ? $str[0] : '';
5396
-		if($type == '}')
5396
+		if ($type == '}')
5397 5397
 			$str = substr($str, 1);
5398 5398
 
5399
-		else if($type == 'N' && $str[1] == ';')
5399
+		else if ($type == 'N' && $str[1] == ';')
5400 5400
 		{
5401 5401
 			$value = null;
5402 5402
 			$str = substr($str, 2);
5403 5403
 		}
5404
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5404
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5405 5405
 		{
5406 5406
 			$value = $matches[1] == '1' ? true : false;
5407 5407
 			$str = substr($str, 4);
5408 5408
 		}
5409
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5409
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5410 5410
 		{
5411
-			$value = (int)$matches[1];
5411
+			$value = (int) $matches[1];
5412 5412
 			$str = $matches[2];
5413 5413
 		}
5414
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5414
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5415 5415
 		{
5416
-			$value = (float)$matches[1];
5416
+			$value = (float) $matches[1];
5417 5417
 			$str = $matches[3];
5418 5418
 		}
5419
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5419
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5420 5420
 		{
5421
-			$value = substr($matches[2], 0, (int)$matches[1]);
5422
-			$str = substr($matches[2], (int)$matches[1] + 2);
5421
+			$value = substr($matches[2], 0, (int) $matches[1]);
5422
+			$str = substr($matches[2], (int) $matches[1] + 2);
5423 5423
 		}
5424
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5424
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5425 5425
 		{
5426
-			$expectedLength = (int)$matches[1];
5426
+			$expectedLength = (int) $matches[1];
5427 5427
 			$str = $matches[2];
5428 5428
 		}
5429 5429
 
@@ -5431,10 +5431,10 @@  discard block
 block discarded – undo
5431 5431
 		else
5432 5432
 			return false;
5433 5433
 
5434
-		switch($state)
5434
+		switch ($state)
5435 5435
 		{
5436 5436
 			case 3: // In array, expecting value or another array.
5437
-				if($type == 'a')
5437
+				if ($type == 'a')
5438 5438
 				{
5439 5439
 					$stack[] = &$list;
5440 5440
 					$list[$key] = array();
@@ -5443,7 +5443,7 @@  discard block
 block discarded – undo
5443 5443
 					$state = 2;
5444 5444
 					break;
5445 5445
 				}
5446
-				if($type != '}')
5446
+				if ($type != '}')
5447 5447
 				{
5448 5448
 					$list[$key] = $value;
5449 5449
 					$state = 2;
@@ -5454,29 +5454,29 @@  discard block
 block discarded – undo
5454 5454
 				return false;
5455 5455
 
5456 5456
 			case 2: // in array, expecting end of array or a key
5457
-				if($type == '}')
5457
+				if ($type == '}')
5458 5458
 				{
5459 5459
 					// Array size is less than expected.
5460
-					if(count($list) < end($expected))
5460
+					if (count($list) < end($expected))
5461 5461
 						return false;
5462 5462
 
5463 5463
 					unset($list);
5464
-					$list = &$stack[count($stack)-1];
5464
+					$list = &$stack[count($stack) - 1];
5465 5465
 					array_pop($stack);
5466 5466
 
5467 5467
 					// Go to terminal state if we're at the end of the root array.
5468 5468
 					array_pop($expected);
5469 5469
 
5470
-					if(count($expected) == 0)
5470
+					if (count($expected) == 0)
5471 5471
 						$state = 1;
5472 5472
 
5473 5473
 					break;
5474 5474
 				}
5475 5475
 
5476
-				if($type == 'i' || $type == 's')
5476
+				if ($type == 'i' || $type == 's')
5477 5477
 				{
5478 5478
 					// Array size exceeds expected length.
5479
-					if(count($list) >= end($expected))
5479
+					if (count($list) >= end($expected))
5480 5480
 						return false;
5481 5481
 
5482 5482
 					$key = $value;
@@ -5489,7 +5489,7 @@  discard block
 block discarded – undo
5489 5489
 
5490 5490
 			// Expecting array or value.
5491 5491
 			case 0:
5492
-				if($type == 'a')
5492
+				if ($type == 'a')
5493 5493
 				{
5494 5494
 					$data = array();
5495 5495
 					$list = &$data;
@@ -5498,7 +5498,7 @@  discard block
 block discarded – undo
5498 5498
 					break;
5499 5499
 				}
5500 5500
 
5501
-				if($type != '}')
5501
+				if ($type != '}')
5502 5502
 				{
5503 5503
 					$data = $value;
5504 5504
 					$state = 1;
@@ -5511,7 +5511,7 @@  discard block
 block discarded – undo
5511 5511
 	}
5512 5512
 
5513 5513
 	// Trailing data in input.
5514
-	if(!empty($str))
5514
+	if (!empty($str))
5515 5515
 		return false;
5516 5516
 
5517 5517
 	return $data;
@@ -5565,7 +5565,7 @@  discard block
 block discarded – undo
5565 5565
 	// Set different modes.
5566 5566
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5567 5567
 
5568
-	foreach($chmodValues as $val)
5568
+	foreach ($chmodValues as $val)
5569 5569
 	{
5570 5570
 		// If it's writable, break out of the loop.
5571 5571
 		if (is_writable($file))
@@ -5600,13 +5600,13 @@  discard block
 block discarded – undo
5600 5600
 	$returnArray = @json_decode($json, $returnAsArray);
5601 5601
 
5602 5602
 	// PHP 5.3 so no json_last_error_msg()
5603
-	switch(json_last_error())
5603
+	switch (json_last_error())
5604 5604
 	{
5605 5605
 		case JSON_ERROR_NONE:
5606 5606
 			$jsonError = false;
5607 5607
 			break;
5608 5608
 		case JSON_ERROR_DEPTH:
5609
-			$jsonError =  'JSON_ERROR_DEPTH';
5609
+			$jsonError = 'JSON_ERROR_DEPTH';
5610 5610
 			break;
5611 5611
 		case JSON_ERROR_STATE_MISMATCH:
5612 5612
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5634,10 +5634,10 @@  discard block
 block discarded – undo
5634 5634
 		loadLanguage('Errors');
5635 5635
 
5636 5636
 		if (!empty($jsonDebug))
5637
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5637
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5638 5638
 
5639 5639
 		else
5640
-			log_error($txt['json_'. $jsonError], 'critical');
5640
+			log_error($txt['json_' . $jsonError], 'critical');
5641 5641
 
5642 5642
 		// Everyone expects an array.
5643 5643
 		return array();
@@ -5749,7 +5749,7 @@  discard block
 block discarded – undo
5749 5749
 		});
5750 5750
 
5751 5751
 		// Convert Punycode to Unicode
5752
-		$tlds = array_map(function ($input) {
5752
+		$tlds = array_map(function($input) {
5753 5753
 			$prefix = 'xn--';
5754 5754
 			$safe_char = 0xFFFC;
5755 5755
 			$base = 36;
@@ -5765,7 +5765,7 @@  discard block
 block discarded – undo
5765 5765
 
5766 5766
 			foreach ($enco_parts as $encoded)
5767 5767
 			{
5768
-				if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0)
5768
+				if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0)
5769 5769
 				{
5770 5770
 					$output_parts[] = $encoded;
5771 5771
 					continue;
@@ -5776,7 +5776,7 @@  discard block
 block discarded – undo
5776 5776
 				$idx = 0;
5777 5777
 				$char = 0x80;
5778 5778
 				$decoded = array();
5779
-				$output='';
5779
+				$output = '';
5780 5780
 				$delim_pos = strrpos($encoded, '-');
5781 5781
 
5782 5782
 				if ($delim_pos > strlen($prefix))
@@ -5792,7 +5792,7 @@  discard block
 block discarded – undo
5792 5792
 
5793 5793
 				for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len)
5794 5794
 				{
5795
-					for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base)
5795
+					for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base)
5796 5796
 					{
5797 5797
 						$cp = ord($encoded{$enco_idx++});
5798 5798
 						$digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base));
@@ -5833,15 +5833,15 @@  discard block
 block discarded – undo
5833 5833
 
5834 5834
 					// 2 bytes
5835 5835
 					elseif ($v < (1 << 11))
5836
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5836
+						$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
5837 5837
 
5838 5838
 					// 3 bytes
5839 5839
 					elseif ($v < (1 << 16))
5840
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5840
+						$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5841 5841
 
5842 5842
 					// 4 bytes
5843 5843
 					elseif ($v < (1 << 21))
5844
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5844
+						$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5845 5845
 
5846 5846
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5847 5847
 					else
@@ -5946,7 +5946,7 @@  discard block
 block discarded – undo
5946 5946
 	}
5947 5947
 
5948 5948
 	// This recursive function creates the index array from the strings
5949
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5949
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5950 5950
 	{
5951 5951
 		static $depth = 0;
5952 5952
 		$depth++;
@@ -5973,7 +5973,7 @@  discard block
 block discarded – undo
5973 5973
 	};
5974 5974
 
5975 5975
 	// This recursive function turns the index array into a regular expression
5976
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
5976
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
5977 5977
 	{
5978 5978
 		static $depth = 0;
5979 5979
 		$depth++;
@@ -5997,11 +5997,11 @@  discard block
 block discarded – undo
5997 5997
 
5998 5998
 				if (count(array_keys($value)) == 1)
5999 5999
 				{
6000
-					$new_key_array = explode('(?'.'>', $sub_regex);
6000
+					$new_key_array = explode('(?' . '>', $sub_regex);
6001 6001
 					$new_key .= $new_key_array[0];
6002 6002
 				}
6003 6003
 				else
6004
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6004
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
6005 6005
 			}
6006 6006
 
6007 6007
 			if ($depth > 1)
@@ -6044,10 +6044,10 @@  discard block
 block discarded – undo
6044 6044
 	{
6045 6045
 		$regex = array();
6046 6046
 		while (!empty($index))
6047
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6047
+			$regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6048 6048
 	}
6049 6049
 	else
6050
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6050
+		$regex = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6051 6051
 
6052 6052
 	// Restore PHP's internal character encoding to whatever it was originally
6053 6053
 	if (!empty($current_encoding))
Please login to merge, or discard this patch.
Braces   +1368 added lines, -1014 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Update some basic statistics.
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
 						$smcFunc['db_free_result']($result);
123 124
 
124 125
 						// Add this to the number of unapproved members
125
-						if (!empty($changes['unapprovedMembers']))
126
-							$changes['unapprovedMembers'] += $coppa_approvals;
127
-						else
128
-							$changes['unapprovedMembers'] = $coppa_approvals;
126
+						if (!empty($changes['unapprovedMembers'])) {
127
+													$changes['unapprovedMembers'] += $coppa_approvals;
128
+						} else {
129
+													$changes['unapprovedMembers'] = $coppa_approvals;
130
+						}
129 131
 					}
130 132
 				}
131 133
 			}
@@ -133,9 +135,9 @@  discard block
 block discarded – undo
133 135
 			break;
134 136
 
135 137
 		case 'message':
136
-			if ($parameter1 === true && $parameter2 !== null)
137
-				updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
138
-			else
138
+			if ($parameter1 === true && $parameter2 !== null) {
139
+							updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
140
+			} else
139 141
 			{
140 142
 				// SUM and MAX on a smaller table is better for InnoDB tables.
141 143
 				$result = $smcFunc['db_query']('', '
@@ -175,23 +177,25 @@  discard block
 block discarded – undo
175 177
 				$parameter2 = text2words($parameter2);
176 178
 
177 179
 				$inserts = array();
178
-				foreach ($parameter2 as $word)
179
-					$inserts[] = array($word, $parameter1);
180
+				foreach ($parameter2 as $word) {
181
+									$inserts[] = array($word, $parameter1);
182
+				}
180 183
 
181
-				if (!empty($inserts))
182
-					$smcFunc['db_insert']('ignore',
184
+				if (!empty($inserts)) {
185
+									$smcFunc['db_insert']('ignore',
183 186
 						'{db_prefix}log_search_subjects',
184 187
 						array('word' => 'string', 'id_topic' => 'int'),
185 188
 						$inserts,
186 189
 						array('word', 'id_topic')
187 190
 					);
191
+				}
188 192
 			}
189 193
 			break;
190 194
 
191 195
 		case 'topic':
192
-			if ($parameter1 === true)
193
-				updateSettings(array('totalTopics' => true), true);
194
-			else
196
+			if ($parameter1 === true) {
197
+							updateSettings(array('totalTopics' => true), true);
198
+			} else
195 199
 			{
196 200
 				// Get the number of topics - a SUM is better for InnoDB tables.
197 201
 				// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
 		case 'postgroups':
214 218
 			// Parameter two is the updated columns: we should check to see if we base groups off any of these.
215
-			if ($parameter2 !== null && !in_array('posts', $parameter2))
216
-				return;
219
+			if ($parameter2 !== null && !in_array('posts', $parameter2)) {
220
+							return;
221
+			}
217 222
 
218 223
 			$postgroups = cache_get_data('updateStats:postgroups', 360);
219 224
 			if ($postgroups == null || $parameter1 == null)
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
 					)
229 234
 				);
230 235
 				$postgroups = array();
231
-				while ($row = $smcFunc['db_fetch_assoc']($request))
232
-					$postgroups[$row['id_group']] = $row['min_posts'];
236
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+									$postgroups[$row['id_group']] = $row['min_posts'];
238
+				}
233 239
 				$smcFunc['db_free_result']($request);
234 240
 
235 241
 				// Sort them this way because if it's done with MySQL it causes a filesort :(.
@@ -239,8 +245,9 @@  discard block
 block discarded – undo
239 245
 			}
240 246
 
241 247
 			// Oh great, they've screwed their post groups.
242
-			if (empty($postgroups))
243
-				return;
248
+			if (empty($postgroups)) {
249
+							return;
250
+			}
244 251
 
245 252
 			// Set all membergroups from most posts to least posts.
246 253
 			$conditions = '';
@@ -298,10 +305,9 @@  discard block
 block discarded – undo
298 305
 	{
299 306
 		$condition = 'id_member IN ({array_int:members})';
300 307
 		$parameters['members'] = $members;
301
-	}
302
-	elseif ($members === null)
303
-		$condition = '1=1';
304
-	else
308
+	} elseif ($members === null) {
309
+			$condition = '1=1';
310
+	} else
305 311
 	{
306 312
 		$condition = 'id_member = {int:member}';
307 313
 		$parameters['member'] = $members;
@@ -341,9 +347,9 @@  discard block
 block discarded – undo
341 347
 		if (count($vars_to_integrate) != 0)
342 348
 		{
343 349
 			// Fetch a list of member_names if necessary
344
-			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
345
-				$member_names = array($user_info['username']);
346
-			else
350
+			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) {
351
+							$member_names = array($user_info['username']);
352
+			} else
347 353
 			{
348 354
 				$member_names = array();
349 355
 				$request = $smcFunc['db_query']('', '
@@ -352,14 +358,16 @@  discard block
 block discarded – undo
352 358
 					WHERE ' . $condition,
353 359
 					$parameters
354 360
 				);
355
-				while ($row = $smcFunc['db_fetch_assoc']($request))
356
-					$member_names[] = $row['member_name'];
361
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
362
+									$member_names[] = $row['member_name'];
363
+				}
357 364
 				$smcFunc['db_free_result']($request);
358 365
 			}
359 366
 
360
-			if (!empty($member_names))
361
-				foreach ($vars_to_integrate as $var)
367
+			if (!empty($member_names)) {
368
+							foreach ($vars_to_integrate as $var)
362 369
 					call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats));
370
+			}
363 371
 		}
364 372
 	}
365 373
 
@@ -367,16 +375,17 @@  discard block
 block discarded – undo
367 375
 	foreach ($data as $var => $val)
368 376
 	{
369 377
 		$type = 'string';
370
-		if (in_array($var, $knownInts))
371
-			$type = 'int';
372
-		elseif (in_array($var, $knownFloats))
373
-			$type = 'float';
374
-		elseif ($var == 'birthdate')
375
-			$type = 'date';
376
-		elseif ($var == 'member_ip')
377
-			$type = 'inet';
378
-		elseif ($var == 'member_ip2')
379
-			$type = 'inet';
378
+		if (in_array($var, $knownInts)) {
379
+					$type = 'int';
380
+		} elseif (in_array($var, $knownFloats)) {
381
+					$type = 'float';
382
+		} elseif ($var == 'birthdate') {
383
+					$type = 'date';
384
+		} elseif ($var == 'member_ip') {
385
+					$type = 'inet';
386
+		} elseif ($var == 'member_ip2') {
387
+					$type = 'inet';
388
+		}
380 389
 
381 390
 		// Doing an increment?
382 391
 		if ($var == 'alerts' && ($val === '+' || $val === '-'))
@@ -385,18 +394,17 @@  discard block
 block discarded – undo
385 394
 			if (is_array($members))
386 395
 			{
387 396
 				$val = 'CASE ';
388
-				foreach ($members as $k => $v)
389
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
397
+				foreach ($members as $k => $v) {
398
+									$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
399
+				}
390 400
 				$val = $val . ' END';
391 401
 				$type = 'raw';
392
-			}
393
-			else
402
+			} else
394 403
 			{
395 404
 				$blub = fetch_alerts($members, false, 0, array(), false);
396 405
 				$val = count($blub);
397 406
 			}
398
-		}
399
-		else if ($type == 'int' && ($val === '+' || $val === '-'))
407
+		} else if ($type == 'int' && ($val === '+' || $val === '-'))
400 408
 		{
401 409
 			$val = $var . ' ' . $val . ' 1';
402 410
 			$type = 'raw';
@@ -407,8 +415,9 @@  discard block
 block discarded – undo
407 415
 		{
408 416
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
409 417
 			{
410
-				if ($match[1] != '+ ')
411
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
418
+				if ($match[1] != '+ ') {
419
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
420
+				}
412 421
 				$type = 'raw';
413 422
 			}
414 423
 		}
@@ -429,8 +438,9 @@  discard block
 block discarded – undo
429 438
 	// Clear any caching?
430 439
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members))
431 440
 	{
432
-		if (!is_array($members))
433
-			$members = array($members);
441
+		if (!is_array($members)) {
442
+					$members = array($members);
443
+		}
434 444
 
435 445
 		foreach ($members as $member)
436 446
 		{
@@ -463,29 +473,32 @@  discard block
 block discarded – undo
463 473
 {
464 474
 	global $modSettings, $smcFunc;
465 475
 
466
-	if (empty($changeArray) || !is_array($changeArray))
467
-		return;
476
+	if (empty($changeArray) || !is_array($changeArray)) {
477
+			return;
478
+	}
468 479
 
469 480
 	$toRemove = array();
470 481
 
471 482
 	// Go check if there is any setting to be removed.
472
-	foreach ($changeArray as $k => $v)
473
-		if ($v === null)
483
+	foreach ($changeArray as $k => $v) {
484
+			if ($v === null)
474 485
 		{
475 486
 			// Found some, remove them from the original array and add them to ours.
476 487
 			unset($changeArray[$k]);
488
+	}
477 489
 			$toRemove[] = $k;
478 490
 		}
479 491
 
480 492
 	// Proceed with the deletion.
481
-	if (!empty($toRemove))
482
-		$smcFunc['db_query']('', '
493
+	if (!empty($toRemove)) {
494
+			$smcFunc['db_query']('', '
483 495
 			DELETE FROM {db_prefix}settings
484 496
 			WHERE variable IN ({array_string:remove})',
485 497
 			array(
486 498
 				'remove' => $toRemove,
487 499
 			)
488 500
 		);
501
+	}
489 502
 
490 503
 	// In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.
491 504
 	if ($update)
@@ -514,19 +527,22 @@  discard block
 block discarded – undo
514 527
 	foreach ($changeArray as $variable => $value)
515 528
 	{
516 529
 		// Don't bother if it's already like that ;).
517
-		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value)
518
-			continue;
530
+		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) {
531
+					continue;
532
+		}
519 533
 		// If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it.
520
-		elseif (!isset($modSettings[$variable]) && empty($value))
521
-			continue;
534
+		elseif (!isset($modSettings[$variable]) && empty($value)) {
535
+					continue;
536
+		}
522 537
 
523 538
 		$replaceArray[] = array($variable, $value);
524 539
 
525 540
 		$modSettings[$variable] = $value;
526 541
 	}
527 542
 
528
-	if (empty($replaceArray))
529
-		return;
543
+	if (empty($replaceArray)) {
544
+			return;
545
+	}
530 546
 
531 547
 	$smcFunc['db_insert']('replace',
532 548
 		'{db_prefix}settings',
@@ -572,14 +588,17 @@  discard block
 block discarded – undo
572 588
 	$start_invalid = $start < 0;
573 589
 
574 590
 	// Make sure $start is a proper variable - not less than 0.
575
-	if ($start_invalid)
576
-		$start = 0;
591
+	if ($start_invalid) {
592
+			$start = 0;
593
+	}
577 594
 	// Not greater than the upper bound.
578
-	elseif ($start >= $max_value)
579
-		$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
595
+	elseif ($start >= $max_value) {
596
+			$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
597
+	}
580 598
 	// And it has to be a multiple of $num_per_page!
581
-	else
582
-		$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
599
+	else {
600
+			$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
601
+	}
583 602
 
584 603
 	$context['current_page'] = $start / $num_per_page;
585 604
 
@@ -609,77 +628,87 @@  discard block
 block discarded – undo
609 628
 
610 629
 		// Show all the pages.
611 630
 		$display_page = 1;
612
-		for ($counter = 0; $counter < $max_value; $counter += $num_per_page)
613
-			$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
631
+		for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
632
+					$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
633
+		}
614 634
 
615 635
 		// Show the right arrow.
616 636
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
617
-		if ($start != $counter - $max_value && !$start_invalid)
618
-			$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
619
-	}
620
-	else
637
+		if ($start != $counter - $max_value && !$start_invalid) {
638
+					$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
639
+		}
640
+	} else
621 641
 	{
622 642
 		// If they didn't enter an odd value, pretend they did.
623 643
 		$PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2;
624 644
 
625 645
 		// Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page)
626
-		if (!empty($start) && $show_prevnext)
627
-			$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
628
-		else
629
-			$pageindex .= '';
646
+		if (!empty($start) && $show_prevnext) {
647
+					$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
648
+		} else {
649
+					$pageindex .= '';
650
+		}
630 651
 
631 652
 		// Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15)
632
-		if ($start > $num_per_page * $PageContiguous)
633
-			$pageindex .= sprintf($base_link, 0, '1');
653
+		if ($start > $num_per_page * $PageContiguous) {
654
+					$pageindex .= sprintf($base_link, 0, '1');
655
+		}
634 656
 
635 657
 		// Show the ... after the first page.  (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page)
636
-		if ($start > $num_per_page * ($PageContiguous + 1))
637
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
658
+		if ($start > $num_per_page * ($PageContiguous + 1)) {
659
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
638 660
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
639 661
 				'{FIRST_PAGE}' => $num_per_page,
640 662
 				'{LAST_PAGE}' => $start - $num_per_page * $PageContiguous,
641 663
 				'{PER_PAGE}' => $num_per_page,
642 664
 			));
665
+		}
643 666
 
644 667
 		// Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page)
645
-		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
646
-			if ($start >= $num_per_page * $nCont)
668
+		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) {
669
+					if ($start >= $num_per_page * $nCont)
647 670
 			{
648 671
 				$tmpStart = $start - $num_per_page * $nCont;
672
+		}
649 673
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
650 674
 			}
651 675
 
652 676
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
653
-		if (!$start_invalid)
654
-			$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
655
-		else
656
-			$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
677
+		if (!$start_invalid) {
678
+					$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
679
+		} else {
680
+					$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
681
+		}
657 682
 
658 683
 		// Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page)
659 684
 		$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
660
-		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
661
-			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
685
+		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) {
686
+					if ($start + $num_per_page * $nCont <= $tmpMaxPages)
662 687
 			{
663 688
 				$tmpStart = $start + $num_per_page * $nCont;
689
+		}
664 690
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
665 691
 			}
666 692
 
667 693
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
668
-		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
669
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
694
+		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) {
695
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
670 696
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
671 697
 				'{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1),
672 698
 				'{LAST_PAGE}' => $tmpMaxPages,
673 699
 				'{PER_PAGE}' => $num_per_page,
674 700
 			));
701
+		}
675 702
 
676 703
 		// Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15<  next page)
677
-		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
678
-			$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
704
+		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) {
705
+					$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
706
+		}
679 707
 
680 708
 		// Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<)
681
-		if ($start != $tmpMaxPages && $show_prevnext)
682
-			$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
709
+		if ($start != $tmpMaxPages && $show_prevnext) {
710
+					$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
711
+		}
683 712
 	}
684 713
 	$pageindex .= $settings['page_index']['extra_after'];
685 714
 
@@ -705,8 +734,9 @@  discard block
 block discarded – undo
705 734
 	if ($decimal_separator === null)
706 735
 	{
707 736
 		// Not set for whatever reason?
708
-		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1)
709
-			return $number;
737
+		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) {
738
+					return $number;
739
+		}
710 740
 
711 741
 		// Cache these each load...
712 742
 		$thousands_separator = $matches[1];
@@ -740,17 +770,20 @@  discard block
 block discarded – undo
740 770
 	static $unsupportedFormats, $finalizedFormats;
741 771
 
742 772
 	// Offset the time.
743
-	if (!$offset_type)
744
-		$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
773
+	if (!$offset_type) {
774
+			$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
775
+	}
745 776
 	// Just the forum offset?
746
-	elseif ($offset_type == 'forum')
747
-		$time = $log_time + $modSettings['time_offset'] * 3600;
748
-	else
749
-		$time = $log_time;
777
+	elseif ($offset_type == 'forum') {
778
+			$time = $log_time + $modSettings['time_offset'] * 3600;
779
+	} else {
780
+			$time = $log_time;
781
+	}
750 782
 
751 783
 	// We can't have a negative date (on Windows, at least.)
752
-	if ($log_time < 0)
753
-		$log_time = 0;
784
+	if ($log_time < 0) {
785
+			$log_time = 0;
786
+	}
754 787
 
755 788
 	// Today and Yesterday?
756 789
 	if ($modSettings['todayMod'] >= 1 && $show_today === true)
@@ -767,24 +800,27 @@  discard block
 block discarded – undo
767 800
 		{
768 801
 			$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
769 802
 			$today_fmt = $h . ':%M' . $s . ' %p';
803
+		} else {
804
+					$today_fmt = '%H:%M' . $s;
770 805
 		}
771
-		else
772
-			$today_fmt = '%H:%M' . $s;
773 806
 
774 807
 		// Same day of the year, same year.... Today!
775
-		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
776
-			return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
808
+		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
809
+					return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
810
+		}
777 811
 
778 812
 		// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
779
-		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
780
-			return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
813
+		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) {
814
+					return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
815
+		}
781 816
 	}
782 817
 
783 818
 	$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];
784 819
 
785 820
 	// Use the cached formats if available
786
-	if (is_null($finalizedFormats))
787
-		$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
821
+	if (is_null($finalizedFormats)) {
822
+			$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
823
+	}
788 824
 
789 825
 	// Make a supported version for this format if we don't already have one
790 826
 	if (empty($finalizedFormats[$str]))
@@ -813,8 +849,9 @@  discard block
 block discarded – undo
813 849
 		);
814 850
 
815 851
 		// No need to do this part again if we already did it once
816
-		if (is_null($unsupportedFormats))
817
-			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
852
+		if (is_null($unsupportedFormats)) {
853
+					$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
854
+		}
818 855
 		if (empty($unsupportedFormats))
819 856
 		{
820 857
 			foreach($strftimeFormatSubstitutions as $format => $substitution)
@@ -823,20 +860,23 @@  discard block
 block discarded – undo
823 860
 
824 861
 				// Windows will return false for unsupported formats
825 862
 				// Other operating systems return the format string as a literal
826
-				if ($value === false || $value === $format)
827
-					$unsupportedFormats[] = $format;
863
+				if ($value === false || $value === $format) {
864
+									$unsupportedFormats[] = $format;
865
+				}
828 866
 			}
829 867
 			cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400);
830 868
 		}
831 869
 
832 870
 		// Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q'
833
-		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
834
-			$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
871
+		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
872
+					$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
873
+		}
835 874
 
836 875
 		// Substitute unsupported formats with supported ones
837
-		if (!empty($unsupportedFormats))
838
-			while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
876
+		if (!empty($unsupportedFormats)) {
877
+					while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
839 878
 				$timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat);
879
+		}
840 880
 
841 881
 		// Remember this so we don't need to do it again
842 882
 		$finalizedFormats[$str] = $timeformat;
@@ -845,33 +885,39 @@  discard block
 block discarded – undo
845 885
 
846 886
 	$str = $finalizedFormats[$str];
847 887
 
848
-	if (!isset($locale_cache))
849
-		$locale_cache = setlocale(LC_TIME, $txt['lang_locale']);
888
+	if (!isset($locale_cache)) {
889
+			$locale_cache = setlocale(LC_TIME, $txt['lang_locale']);
890
+	}
850 891
 
851 892
 	if ($locale_cache !== false)
852 893
 	{
853 894
 		// Check if another process changed the locale
854
-		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache)
855
-			setlocale(LC_TIME, $txt['lang_locale']);
895
+		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) {
896
+					setlocale(LC_TIME, $txt['lang_locale']);
897
+		}
856 898
 
857
-		if (!isset($non_twelve_hour))
858
-			$non_twelve_hour = trim(strftime('%p')) === '';
859
-		if ($non_twelve_hour && strpos($str, '%p') !== false)
860
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
899
+		if (!isset($non_twelve_hour)) {
900
+					$non_twelve_hour = trim(strftime('%p')) === '';
901
+		}
902
+		if ($non_twelve_hour && strpos($str, '%p') !== false) {
903
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
904
+		}
861 905
 
862
-		foreach (array('%a', '%A', '%b', '%B') as $token)
863
-			if (strpos($str, $token) !== false)
906
+		foreach (array('%a', '%A', '%b', '%B') as $token) {
907
+					if (strpos($str, $token) !== false)
864 908
 				$str = str_replace($token, strftime($token, $time), $str);
865
-	}
866
-	else
909
+		}
910
+	} else
867 911
 	{
868 912
 		// Do-it-yourself time localization.  Fun.
869
-		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
870
-			if (strpos($str, $token) !== false)
913
+		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
914
+					if (strpos($str, $token) !== false)
871 915
 				$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
916
+		}
872 917
 
873
-		if (strpos($str, '%p') !== false)
874
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
918
+		if (strpos($str, '%p') !== false) {
919
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
920
+		}
875 921
 	}
876 922
 
877 923
 	// Format the time and then restore any literal percent characters
@@ -894,16 +940,19 @@  discard block
 block discarded – undo
894 940
 	static $translation = array();
895 941
 
896 942
 	// Determine the character set... Default to UTF-8
897
-	if (empty($context['character_set']))
898
-		$charset = 'UTF-8';
943
+	if (empty($context['character_set'])) {
944
+			$charset = 'UTF-8';
945
+	}
899 946
 	// Use ISO-8859-1 in place of non-supported ISO-8859 charsets...
900
-	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15')))
901
-		$charset = 'ISO-8859-1';
902
-	else
903
-		$charset = $context['character_set'];
947
+	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) {
948
+			$charset = 'ISO-8859-1';
949
+	} else {
950
+			$charset = $context['character_set'];
951
+	}
904 952
 
905
-	if (empty($translation))
906
-		$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
953
+	if (empty($translation)) {
954
+			$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
955
+	}
907 956
 
908 957
 	return strtr($string, $translation);
909 958
 }
@@ -925,8 +974,9 @@  discard block
 block discarded – undo
925 974
 	global $smcFunc;
926 975
 
927 976
 	// It was already short enough!
928
-	if ($smcFunc['strlen']($subject) <= $len)
929
-		return $subject;
977
+	if ($smcFunc['strlen']($subject) <= $len) {
978
+			return $subject;
979
+	}
930 980
 
931 981
 	// Shorten it by the length it was too long, and strip off junk from the end.
932 982
 	return $smcFunc['substr']($subject, 0, $len) . '...';
@@ -945,10 +995,11 @@  discard block
 block discarded – undo
945 995
 {
946 996
 	global $user_info, $modSettings;
947 997
 
948
-	if ($timestamp === null)
949
-		$timestamp = time();
950
-	elseif ($timestamp == 0)
951
-		return 0;
998
+	if ($timestamp === null) {
999
+			$timestamp = time();
1000
+	} elseif ($timestamp == 0) {
1001
+			return 0;
1002
+	}
952 1003
 
953 1004
 	return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
954 1005
 }
@@ -977,8 +1028,9 @@  discard block
 block discarded – undo
977 1028
 		$array[$i] = $array[$j];
978 1029
 		$array[$j] = $temp;
979 1030
 
980
-		for ($i = 1; $p[$i] == 0; $i++)
981
-			$p[$i] = 1;
1031
+		for ($i = 1; $p[$i] == 0; $i++) {
1032
+					$p[$i] = 1;
1033
+		}
982 1034
 
983 1035
 		$orders[] = $array;
984 1036
 	}
@@ -1010,12 +1062,14 @@  discard block
 block discarded – undo
1010 1062
 	static $disabled;
1011 1063
 
1012 1064
 	// Don't waste cycles
1013
-	if ($message === '')
1014
-		return '';
1065
+	if ($message === '') {
1066
+			return '';
1067
+	}
1015 1068
 
1016 1069
 	// Just in case it wasn't determined yet whether UTF-8 is enabled.
1017
-	if (!isset($context['utf8']))
1018
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1070
+	if (!isset($context['utf8'])) {
1071
+			$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1072
+	}
1019 1073
 
1020 1074
 	// Clean up any cut/paste issues we may have
1021 1075
 	$message = sanitizeMSCutPaste($message);
@@ -1027,13 +1081,15 @@  discard block
 block discarded – undo
1027 1081
 		return $message;
1028 1082
 	}
1029 1083
 
1030
-	if ($smileys !== null && ($smileys == '1' || $smileys == '0'))
1031
-		$smileys = (bool) $smileys;
1084
+	if ($smileys !== null && ($smileys == '1' || $smileys == '0')) {
1085
+			$smileys = (bool) $smileys;
1086
+	}
1032 1087
 
1033 1088
 	if (empty($modSettings['enableBBC']) && $message !== false)
1034 1089
 	{
1035
-		if ($smileys === true)
1036
-			parsesmileys($message);
1090
+		if ($smileys === true) {
1091
+					parsesmileys($message);
1092
+		}
1037 1093
 
1038 1094
 		return $message;
1039 1095
 	}
@@ -1046,8 +1102,9 @@  discard block
 block discarded – undo
1046 1102
 	}
1047 1103
 
1048 1104
 	// Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker
1049
-	if (!empty($modSettings['autoLinkUrls']))
1050
-		set_tld_regex();
1105
+	if (!empty($modSettings['autoLinkUrls'])) {
1106
+			set_tld_regex();
1107
+	}
1051 1108
 
1052 1109
 	// Allow mods access before entering the main parse_bbc loop
1053 1110
 	call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
@@ -1061,12 +1118,14 @@  discard block
 block discarded – undo
1061 1118
 
1062 1119
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
1063 1120
 
1064
-			foreach ($temp as $tag)
1065
-				$disabled[trim($tag)] = true;
1121
+			foreach ($temp as $tag) {
1122
+							$disabled[trim($tag)] = true;
1123
+			}
1066 1124
 		}
1067 1125
 
1068
-		if (empty($modSettings['enableEmbeddedFlash']))
1069
-			$disabled['flash'] = true;
1126
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1127
+					$disabled['flash'] = true;
1128
+		}
1070 1129
 
1071 1130
 		/* The following bbc are formatted as an array, with keys as follows:
1072 1131
 
@@ -1187,8 +1246,9 @@  discard block
 block discarded – undo
1187 1246
 					$returnContext = '';
1188 1247
 
1189 1248
 					// BBC or the entire attachments feature is disabled
1190
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1191
-						return $data;
1249
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1250
+											return $data;
1251
+					}
1192 1252
 
1193 1253
 					// Save the attach ID.
1194 1254
 					$attachID = $data;
@@ -1199,8 +1259,9 @@  discard block
 block discarded – undo
1199 1259
 					$currentAttachment = parseAttachBBC($attachID);
1200 1260
 
1201 1261
 					// parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do.
1202
-					if (is_string($currentAttachment))
1203
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1262
+					if (is_string($currentAttachment)) {
1263
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1264
+					}
1204 1265
 
1205 1266
 					if (!empty($currentAttachment['is_image']))
1206 1267
 					{
@@ -1216,15 +1277,17 @@  discard block
 block discarded – undo
1216 1277
 							$height = ' height="' . $currentAttachment['height'] . '"';
1217 1278
 						}
1218 1279
 
1219
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1220
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1221
-						else
1222
-							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1280
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1281
+													$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1282
+						} else {
1283
+													$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1284
+						}
1223 1285
 					}
1224 1286
 
1225 1287
 					// No image. Show a link.
1226
-					else
1227
-						$returnContext .= $currentAttachment['link'];
1288
+					else {
1289
+											$returnContext .= $currentAttachment['link'];
1290
+					}
1228 1291
 
1229 1292
 					// Gotta append what we just did.
1230 1293
 					$data = $returnContext;
@@ -1255,8 +1318,9 @@  discard block
 block discarded – undo
1255 1318
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1256 1319
 						{
1257 1320
 							// Do PHP code coloring?
1258
-							if ($php_parts[$php_i] != '&lt;?php')
1259
-								continue;
1321
+							if ($php_parts[$php_i] != '&lt;?php') {
1322
+															continue;
1323
+							}
1260 1324
 
1261 1325
 							$php_string = '';
1262 1326
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1272,8 +1336,9 @@  discard block
 block discarded – undo
1272 1336
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1273 1337
 
1274 1338
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1275
-						if ($context['browser']['is_opera'])
1276
-							$data .= '&nbsp;';
1339
+						if ($context['browser']['is_opera']) {
1340
+													$data .= '&nbsp;';
1341
+						}
1277 1342
 					}
1278 1343
 				},
1279 1344
 				'block_level' => true,
@@ -1292,8 +1357,9 @@  discard block
 block discarded – undo
1292 1357
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1293 1358
 						{
1294 1359
 							// Do PHP code coloring?
1295
-							if ($php_parts[$php_i] != '&lt;?php')
1296
-								continue;
1360
+							if ($php_parts[$php_i] != '&lt;?php') {
1361
+															continue;
1362
+							}
1297 1363
 
1298 1364
 							$php_string = '';
1299 1365
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1309,8 +1375,9 @@  discard block
 block discarded – undo
1309 1375
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1310 1376
 
1311 1377
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1312
-						if ($context['browser']['is_opera'])
1313
-							$data[0] .= '&nbsp;';
1378
+						if ($context['browser']['is_opera']) {
1379
+													$data[0] .= '&nbsp;';
1380
+						}
1314 1381
 					}
1315 1382
 				},
1316 1383
 				'block_level' => true,
@@ -1348,11 +1415,13 @@  discard block
 block discarded – undo
1348 1415
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1349 1416
 				'validate' => function (&$tag, &$data, $disabled)
1350 1417
 				{
1351
-					if (isset($disabled['url']))
1352
-						$tag['content'] = '$1';
1418
+					if (isset($disabled['url'])) {
1419
+											$tag['content'] = '$1';
1420
+					}
1353 1421
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1354
-					if (empty($scheme))
1355
-						$data[0] = '//' . ltrim($data[0], ':/');
1422
+					if (empty($scheme)) {
1423
+											$data[0] = '//' . ltrim($data[0], ':/');
1424
+					}
1356 1425
 				},
1357 1426
 				'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1358 1427
 			),
@@ -1366,10 +1435,11 @@  discard block
 block discarded – undo
1366 1435
 				{
1367 1436
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1368 1437
 
1369
-					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches))
1370
-						$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1371
-					else
1372
-						$css = '';
1438
+					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) {
1439
+											$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1440
+					} else {
1441
+											$css = '';
1442
+					}
1373 1443
 
1374 1444
 					$data = $class . $css;
1375 1445
 				},
@@ -1419,20 +1489,23 @@  discard block
 block discarded – undo
1419 1489
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1420 1490
 					if ($image_proxy_enabled)
1421 1491
 					{
1422
-						if (!empty($user_info['possibly_robot']))
1423
-							return;
1492
+						if (!empty($user_info['possibly_robot'])) {
1493
+													return;
1494
+						}
1424 1495
 
1425
-						if (empty($scheme))
1426
-							$data = 'http://' . ltrim($data, ':/');
1496
+						if (empty($scheme)) {
1497
+													$data = 'http://' . ltrim($data, ':/');
1498
+						}
1427 1499
 
1428
-						if ($scheme != 'https')
1429
-							if ($image_proxy_enabled === 2 && !empty($image_proxy_url))
1500
+						if ($scheme != 'https') {
1501
+													if ($image_proxy_enabled === 2 && !empty($image_proxy_url))
1430 1502
 								$data = $image_proxy_url . urlencode($data);
1431
-							else
1432
-								$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1503
+						} else {
1504
+															$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1505
+							}
1506
+					} elseif (empty($scheme)) {
1507
+											$data = '//' . ltrim($data, ':/');
1433 1508
 					}
1434
-					elseif (empty($scheme))
1435
-						$data = '//' . ltrim($data, ':/');
1436 1509
 				},
1437 1510
 				'disabled_content' => '($1)',
1438 1511
 			),
@@ -1448,20 +1521,23 @@  discard block
 block discarded – undo
1448 1521
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1449 1522
 					if ($image_proxy_enabled)
1450 1523
 					{
1451
-						if (!empty($user_info['possibly_robot']))
1452
-							return;
1524
+						if (!empty($user_info['possibly_robot'])) {
1525
+													return;
1526
+						}
1453 1527
 
1454
-						if (empty($scheme))
1455
-							$data = 'http://' . ltrim($data, ':/');
1528
+						if (empty($scheme)) {
1529
+													$data = 'http://' . ltrim($data, ':/');
1530
+						}
1456 1531
 
1457
-						if ($scheme != 'https')
1458
-							if ($image_proxy_enabled === 2 && !empty($image_proxy_url))
1532
+						if ($scheme != 'https') {
1533
+													if ($image_proxy_enabled === 2 && !empty($image_proxy_url))
1459 1534
 								$data = $image_proxy_url . urlencode($data);
1460
-							else
1461
-								$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1535
+						} else {
1536
+															$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1537
+							}
1538
+					} elseif (empty($scheme)) {
1539
+											$data = '//' . ltrim($data, ':/');
1462 1540
 					}
1463
-					elseif (empty($scheme))
1464
-						$data = '//' . ltrim($data, ':/');
1465 1541
 				},
1466 1542
 				'disabled_content' => '($1)',
1467 1543
 			),
@@ -1473,8 +1549,9 @@  discard block
 block discarded – undo
1473 1549
 				{
1474 1550
 					$data = strtr($data, array('<br>' => ''));
1475 1551
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1476
-					if (empty($scheme))
1477
-						$data = '//' . ltrim($data, ':/');
1552
+					if (empty($scheme)) {
1553
+											$data = '//' . ltrim($data, ':/');
1554
+					}
1478 1555
 				},
1479 1556
 			),
1480 1557
 			array(
@@ -1485,13 +1562,14 @@  discard block
 block discarded – undo
1485 1562
 				'after' => '</a>',
1486 1563
 				'validate' => function (&$tag, &$data, $disabled)
1487 1564
 				{
1488
-					if (substr($data, 0, 1) == '#')
1489
-						$data = '#post_' . substr($data, 1);
1490
-					else
1565
+					if (substr($data, 0, 1) == '#') {
1566
+											$data = '#post_' . substr($data, 1);
1567
+					} else
1491 1568
 					{
1492 1569
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1493
-						if (empty($scheme))
1494
-							$data = '//' . ltrim($data, ':/');
1570
+						if (empty($scheme)) {
1571
+													$data = '//' . ltrim($data, ':/');
1572
+						}
1495 1573
 					}
1496 1574
 				},
1497 1575
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1569,8 +1647,9 @@  discard block
 block discarded – undo
1569 1647
 					{
1570 1648
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1571 1649
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1572
-						if ($add_begin)
1573
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1650
+						if ($add_begin) {
1651
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1652
+						}
1574 1653
 					}
1575 1654
 				},
1576 1655
 				'block_level' => false,
@@ -1701,10 +1780,11 @@  discard block
 block discarded – undo
1701 1780
 				'content' => '$1',
1702 1781
 				'validate' => function (&$tag, &$data, $disabled)
1703 1782
 				{
1704
-					if (is_numeric($data))
1705
-						$data = timeformat($data);
1706
-					else
1707
-						$tag['content'] = '[time]$1[/time]';
1783
+					if (is_numeric($data)) {
1784
+											$data = timeformat($data);
1785
+					} else {
1786
+											$tag['content'] = '[time]$1[/time]';
1787
+					}
1708 1788
 				},
1709 1789
 			),
1710 1790
 			array(
@@ -1731,8 +1811,9 @@  discard block
 block discarded – undo
1731 1811
 				{
1732 1812
 					$data = strtr($data, array('<br>' => ''));
1733 1813
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1734
-					if (empty($scheme))
1735
-						$data = '//' . ltrim($data, ':/');
1814
+					if (empty($scheme)) {
1815
+											$data = '//' . ltrim($data, ':/');
1816
+					}
1736 1817
 				},
1737 1818
 			),
1738 1819
 			array(
@@ -1744,8 +1825,9 @@  discard block
 block discarded – undo
1744 1825
 				'validate' => function (&$tag, &$data, $disabled)
1745 1826
 				{
1746 1827
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1747
-					if (empty($scheme))
1748
-						$data = '//' . ltrim($data, ':/');
1828
+					if (empty($scheme)) {
1829
+											$data = '//' . ltrim($data, ':/');
1830
+					}
1749 1831
 				},
1750 1832
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1751 1833
 				'disabled_after' => ' ($1)',
@@ -1765,8 +1847,9 @@  discard block
 block discarded – undo
1765 1847
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1766 1848
 		if ($message === false)
1767 1849
 		{
1768
-			if (isset($temp_bbc))
1769
-				$bbc_codes = $temp_bbc;
1850
+			if (isset($temp_bbc)) {
1851
+							$bbc_codes = $temp_bbc;
1852
+			}
1770 1853
 			usort($codes, function ($a, $b) {
1771 1854
 				return strcmp($a['tag'], $b['tag']);
1772 1855
 			});
@@ -1786,8 +1869,9 @@  discard block
 block discarded – undo
1786 1869
 		);
1787 1870
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1788 1871
 		{
1789
-			foreach ($itemcodes as $c => $dummy)
1790
-				$bbc_codes[$c] = array();
1872
+			foreach ($itemcodes as $c => $dummy) {
1873
+							$bbc_codes[$c] = array();
1874
+			}
1791 1875
 		}
1792 1876
 
1793 1877
 		// Shhhh!
@@ -1808,12 +1892,14 @@  discard block
 block discarded – undo
1808 1892
 		foreach ($codes as $code)
1809 1893
 		{
1810 1894
 			// Make it easier to process parameters later
1811
-			if (!empty($code['parameters']))
1812
-				ksort($code['parameters'], SORT_STRING);
1895
+			if (!empty($code['parameters'])) {
1896
+							ksort($code['parameters'], SORT_STRING);
1897
+			}
1813 1898
 
1814 1899
 			// If we are not doing every tag only do ones we are interested in.
1815
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1816
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1900
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
1901
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1902
+			}
1817 1903
 		}
1818 1904
 		$codes = null;
1819 1905
 	}
@@ -1824,8 +1910,9 @@  discard block
 block discarded – undo
1824 1910
 		// It's likely this will change if the message is modified.
1825 1911
 		$cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']);
1826 1912
 
1827
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1828
-			return $temp;
1913
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
1914
+					return $temp;
1915
+		}
1829 1916
 
1830 1917
 		$cache_t = microtime();
1831 1918
 	}
@@ -1857,8 +1944,9 @@  discard block
 block discarded – undo
1857 1944
 		$disabled['flash'] = true;
1858 1945
 
1859 1946
 		// @todo Change maybe?
1860
-		if (!isset($_GET['images']))
1861
-			$disabled['img'] = true;
1947
+		if (!isset($_GET['images'])) {
1948
+					$disabled['img'] = true;
1949
+		}
1862 1950
 
1863 1951
 		// @todo Interface/setting to add more?
1864 1952
 	}
@@ -1882,8 +1970,9 @@  discard block
 block discarded – undo
1882 1970
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
1883 1971
 
1884 1972
 		// Failsafe.
1885
-		if ($pos === false || $last_pos > $pos)
1886
-			$pos = strlen($message) + 1;
1973
+		if ($pos === false || $last_pos > $pos) {
1974
+					$pos = strlen($message) + 1;
1975
+		}
1887 1976
 
1888 1977
 		// Can't have a one letter smiley, URL, or email! (sorry.)
1889 1978
 		if ($last_pos < $pos - 1)
@@ -1901,8 +1990,9 @@  discard block
 block discarded – undo
1901 1990
 
1902 1991
 				// <br> should be empty.
1903 1992
 				$empty_tags = array('br', 'hr');
1904
-				foreach ($empty_tags as $tag)
1905
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
1993
+				foreach ($empty_tags as $tag) {
1994
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
1995
+				}
1906 1996
 
1907 1997
 				// b, u, i, s, pre... basic tags.
1908 1998
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong');
@@ -1911,8 +2001,9 @@  discard block
 block discarded – undo
1911 2001
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
1912 2002
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
1913 2003
 
1914
-					if ($diff > 0)
1915
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2004
+					if ($diff > 0) {
2005
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
2006
+					}
1916 2007
 				}
1917 2008
 
1918 2009
 				// Do <img ...> - with security... action= -> action-.
@@ -1925,8 +2016,9 @@  discard block
 block discarded – undo
1925 2016
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
1926 2017
 
1927 2018
 						// Remove action= from the URL - no funny business, now.
1928
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
1929
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2019
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
2020
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2021
+						}
1930 2022
 
1931 2023
 						// Check if the image is larger than allowed.
1932 2024
 						if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
@@ -1947,9 +2039,9 @@  discard block
 block discarded – undo
1947 2039
 
1948 2040
 							// Set the new image tag.
1949 2041
 							$replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]';
2042
+						} else {
2043
+													$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1950 2044
 						}
1951
-						else
1952
-							$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1953 2045
 					}
1954 2046
 
1955 2047
 					$data = strtr($data, $replaces);
@@ -1962,16 +2054,18 @@  discard block
 block discarded – undo
1962 2054
 				$no_autolink_area = false;
1963 2055
 				if (!empty($open_tags))
1964 2056
 				{
1965
-					foreach ($open_tags as $open_tag)
1966
-						if (in_array($open_tag['tag'], $no_autolink_tags))
2057
+					foreach ($open_tags as $open_tag) {
2058
+											if (in_array($open_tag['tag'], $no_autolink_tags))
1967 2059
 							$no_autolink_area = true;
2060
+					}
1968 2061
 				}
1969 2062
 
1970 2063
 				// Don't go backwards.
1971 2064
 				// @todo Don't think is the real solution....
1972 2065
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
1973
-				if ($pos < $lastAutoPos)
1974
-					$no_autolink_area = true;
2066
+				if ($pos < $lastAutoPos) {
2067
+									$no_autolink_area = true;
2068
+				}
1975 2069
 				$lastAutoPos = $pos;
1976 2070
 
1977 2071
 				if (!$no_autolink_area)
@@ -2080,17 +2174,19 @@  discard block
 block discarded – undo
2080 2174
 							if ($scheme == 'mailto')
2081 2175
 							{
2082 2176
 								$email_address = str_replace('mailto:', '', $url);
2083
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
2084
-									return '[email=' . $email_address . ']' . $url . '[/email]';
2085
-								else
2086
-									return $url;
2177
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2178
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2179
+								} else {
2180
+																	return $url;
2181
+								}
2087 2182
 							}
2088 2183
 
2089 2184
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
2090
-							if (empty($scheme))
2091
-								$fullUrl = '//' . ltrim($url, ':/');
2092
-							else
2093
-								$fullUrl = $url;
2185
+							if (empty($scheme)) {
2186
+															$fullUrl = '//' . ltrim($url, ':/');
2187
+							} else {
2188
+															$fullUrl = $url;
2189
+							}
2094 2190
 
2095 2191
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
2096 2192
 						}, $data);
@@ -2139,22 +2235,25 @@  discard block
 block discarded – undo
2139 2235
 		}
2140 2236
 
2141 2237
 		// Are we there yet?  Are we there yet?
2142
-		if ($pos >= strlen($message) - 1)
2143
-			break;
2238
+		if ($pos >= strlen($message) - 1) {
2239
+					break;
2240
+		}
2144 2241
 
2145 2242
 		$tags = strtolower($message[$pos + 1]);
2146 2243
 
2147 2244
 		if ($tags == '/' && !empty($open_tags))
2148 2245
 		{
2149 2246
 			$pos2 = strpos($message, ']', $pos + 1);
2150
-			if ($pos2 == $pos + 2)
2151
-				continue;
2247
+			if ($pos2 == $pos + 2) {
2248
+							continue;
2249
+			}
2152 2250
 
2153 2251
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2154 2252
 
2155 2253
 			// A closing tag that doesn't match any open tags? Skip it.
2156
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2157
-				continue;
2254
+			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) {
2255
+							continue;
2256
+			}
2158 2257
 
2159 2258
 			$to_close = array();
2160 2259
 			$block_level = null;
@@ -2162,8 +2261,9 @@  discard block
 block discarded – undo
2162 2261
 			do
2163 2262
 			{
2164 2263
 				$tag = array_pop($open_tags);
2165
-				if (!$tag)
2166
-					break;
2264
+				if (!$tag) {
2265
+									break;
2266
+				}
2167 2267
 
2168 2268
 				if (!empty($tag['block_level']))
2169 2269
 				{
@@ -2177,10 +2277,11 @@  discard block
 block discarded – undo
2177 2277
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2178 2278
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2179 2279
 					{
2180
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2181
-							if ($temp['tag'] == $look_for)
2280
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2281
+													if ($temp['tag'] == $look_for)
2182 2282
 							{
2183 2283
 								$block_level = !empty($temp['block_level']);
2284
+						}
2184 2285
 								break;
2185 2286
 							}
2186 2287
 					}
@@ -2202,15 +2303,15 @@  discard block
 block discarded – undo
2202 2303
 			{
2203 2304
 				$open_tags = $to_close;
2204 2305
 				continue;
2205
-			}
2206
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2306
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2207 2307
 			{
2208 2308
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2209 2309
 				{
2210
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2211
-						if ($temp['tag'] == $look_for)
2310
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2311
+											if ($temp['tag'] == $look_for)
2212 2312
 						{
2213 2313
 							$block_level = !empty($temp['block_level']);
2314
+					}
2214 2315
 							break;
2215 2316
 						}
2216 2317
 				}
@@ -2218,8 +2319,9 @@  discard block
 block discarded – undo
2218 2319
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2219 2320
 				if (!$block_level)
2220 2321
 				{
2221
-					foreach ($to_close as $tag)
2222
-						array_push($open_tags, $tag);
2322
+					foreach ($to_close as $tag) {
2323
+											array_push($open_tags, $tag);
2324
+					}
2223 2325
 					continue;
2224 2326
 				}
2225 2327
 			}
@@ -2232,14 +2334,17 @@  discard block
 block discarded – undo
2232 2334
 
2233 2335
 				// See the comment at the end of the big loop - just eating whitespace ;).
2234 2336
 				$whitespace_regex = '';
2235
-				if (!empty($tag['block_level']))
2236
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2337
+				if (!empty($tag['block_level'])) {
2338
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2339
+				}
2237 2340
 				// Trim one line of whitespace after unnested tags, but all of it after nested ones
2238
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2239
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2341
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2342
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2343
+				}
2240 2344
 
2241
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2242
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2345
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2346
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2347
+				}
2243 2348
 			}
2244 2349
 
2245 2350
 			if (!empty($to_close))
@@ -2252,8 +2357,9 @@  discard block
 block discarded – undo
2252 2357
 		}
2253 2358
 
2254 2359
 		// No tags for this character, so just keep going (fastest possible course.)
2255
-		if (!isset($bbc_codes[$tags]))
2256
-			continue;
2360
+		if (!isset($bbc_codes[$tags])) {
2361
+					continue;
2362
+		}
2257 2363
 
2258 2364
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2259 2365
 		$tag = null;
@@ -2262,48 +2368,57 @@  discard block
 block discarded – undo
2262 2368
 			$pt_strlen = strlen($possible['tag']);
2263 2369
 
2264 2370
 			// Not a match?
2265
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2266
-				continue;
2371
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2372
+							continue;
2373
+			}
2267 2374
 
2268 2375
 			$next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : '';
2269 2376
 
2270 2377
 			// A tag is the last char maybe
2271
-			if ($next_c == '')
2272
-				break;
2378
+			if ($next_c == '') {
2379
+							break;
2380
+			}
2273 2381
 
2274 2382
 			// A test validation?
2275
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2276
-				continue;
2383
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2384
+							continue;
2385
+			}
2277 2386
 			// Do we want parameters?
2278 2387
 			elseif (!empty($possible['parameters']))
2279 2388
 			{
2280
-				if ($next_c != ' ')
2281
-					continue;
2282
-			}
2283
-			elseif (isset($possible['type']))
2389
+				if ($next_c != ' ') {
2390
+									continue;
2391
+				}
2392
+			} elseif (isset($possible['type']))
2284 2393
 			{
2285 2394
 				// Do we need an equal sign?
2286
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2287
-					continue;
2395
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2396
+									continue;
2397
+				}
2288 2398
 				// Maybe we just want a /...
2289
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2290
-					continue;
2399
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2400
+									continue;
2401
+				}
2291 2402
 				// An immediate ]?
2292
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2293
-					continue;
2403
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2404
+									continue;
2405
+				}
2294 2406
 			}
2295 2407
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2296
-			elseif ($next_c != ']')
2297
-				continue;
2408
+			elseif ($next_c != ']') {
2409
+							continue;
2410
+			}
2298 2411
 
2299 2412
 			// Check allowed tree?
2300
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2301
-				continue;
2302
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2303
-				continue;
2413
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2414
+							continue;
2415
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2416
+							continue;
2417
+			}
2304 2418
 			// If this is in the list of disallowed child tags, don't parse it.
2305
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2306
-				continue;
2419
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2420
+							continue;
2421
+			}
2307 2422
 
2308 2423
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2309 2424
 
@@ -2315,8 +2430,9 @@  discard block
 block discarded – undo
2315 2430
 				foreach ($open_tags as $open_quote)
2316 2431
 				{
2317 2432
 					// Every parent quote this quote has flips the styling
2318
-					if ($open_quote['tag'] == 'quote')
2319
-						$quote_alt = !$quote_alt;
2433
+					if ($open_quote['tag'] == 'quote') {
2434
+											$quote_alt = !$quote_alt;
2435
+					}
2320 2436
 				}
2321 2437
 				// Add a class to the quote to style alternating blockquotes
2322 2438
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2327,8 +2443,9 @@  discard block
 block discarded – undo
2327 2443
 			{
2328 2444
 				// Build a regular expression for each parameter for the current tag.
2329 2445
 				$preg = array();
2330
-				foreach ($possible['parameters'] as $p => $info)
2331
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2446
+				foreach ($possible['parameters'] as $p => $info) {
2447
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2448
+				}
2332 2449
 
2333 2450
 				// Extract the string that potentially holds our parameters.
2334 2451
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2348,24 +2465,27 @@  discard block
 block discarded – undo
2348 2465
 
2349 2466
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2350 2467
 
2351
-					if ($match)
2352
-						$blob_counter = count($blobs) + 1;
2468
+					if ($match) {
2469
+											$blob_counter = count($blobs) + 1;
2470
+					}
2353 2471
 				}
2354 2472
 
2355 2473
 				// Didn't match our parameter list, try the next possible.
2356
-				if (!$match)
2357
-					continue;
2474
+				if (!$match) {
2475
+									continue;
2476
+				}
2358 2477
 
2359 2478
 				$params = array();
2360 2479
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2361 2480
 				{
2362 2481
 					$key = strtok(ltrim($matches[$i]), '=');
2363
-					if (isset($possible['parameters'][$key]['value']))
2364
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2365
-					elseif (isset($possible['parameters'][$key]['validate']))
2366
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2367
-					else
2368
-						$params['{' . $key . '}'] = $matches[$i + 1];
2482
+					if (isset($possible['parameters'][$key]['value'])) {
2483
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2484
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2485
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2486
+					} else {
2487
+											$params['{' . $key . '}'] = $matches[$i + 1];
2488
+					}
2369 2489
 
2370 2490
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2371 2491
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2373,23 +2493,26 @@  discard block
 block discarded – undo
2373 2493
 
2374 2494
 				foreach ($possible['parameters'] as $p => $info)
2375 2495
 				{
2376
-					if (!isset($params['{' . $p . '}']))
2377
-						$params['{' . $p . '}'] = '';
2496
+					if (!isset($params['{' . $p . '}'])) {
2497
+											$params['{' . $p . '}'] = '';
2498
+					}
2378 2499
 				}
2379 2500
 
2380 2501
 				$tag = $possible;
2381 2502
 
2382 2503
 				// Put the parameters into the string.
2383
-				if (isset($tag['before']))
2384
-					$tag['before'] = strtr($tag['before'], $params);
2385
-				if (isset($tag['after']))
2386
-					$tag['after'] = strtr($tag['after'], $params);
2387
-				if (isset($tag['content']))
2388
-					$tag['content'] = strtr($tag['content'], $params);
2504
+				if (isset($tag['before'])) {
2505
+									$tag['before'] = strtr($tag['before'], $params);
2506
+				}
2507
+				if (isset($tag['after'])) {
2508
+									$tag['after'] = strtr($tag['after'], $params);
2509
+				}
2510
+				if (isset($tag['content'])) {
2511
+									$tag['content'] = strtr($tag['content'], $params);
2512
+				}
2389 2513
 
2390 2514
 				$pos1 += strlen($given_param_string);
2391
-			}
2392
-			else
2515
+			} else
2393 2516
 			{
2394 2517
 				$tag = $possible;
2395 2518
 				$params = array();
@@ -2400,8 +2523,9 @@  discard block
 block discarded – undo
2400 2523
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2401 2524
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2402 2525
 		{
2403
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2404
-				continue;
2526
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2527
+							continue;
2528
+			}
2405 2529
 
2406 2530
 			$tag = $itemcodes[$message[$pos + 1]];
2407 2531
 
@@ -2422,9 +2546,9 @@  discard block
 block discarded – undo
2422 2546
 			{
2423 2547
 				array_pop($open_tags);
2424 2548
 				$code = '</li>';
2549
+			} else {
2550
+							$code = '';
2425 2551
 			}
2426
-			else
2427
-				$code = '';
2428 2552
 
2429 2553
 			// Now we open a new tag.
2430 2554
 			$open_tags[] = array(
@@ -2471,12 +2595,14 @@  discard block
 block discarded – undo
2471 2595
 		}
2472 2596
 
2473 2597
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2474
-		if ($tag === null)
2475
-			continue;
2598
+		if ($tag === null) {
2599
+					continue;
2600
+		}
2476 2601
 
2477 2602
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2478
-		if (isset($inside['disallow_children']))
2479
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2603
+		if (isset($inside['disallow_children'])) {
2604
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2605
+		}
2480 2606
 
2481 2607
 		// Is this tag disabled?
2482 2608
 		if (isset($disabled[$tag['tag']]))
@@ -2486,14 +2612,13 @@  discard block
 block discarded – undo
2486 2612
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2487 2613
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2488 2614
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2489
-			}
2490
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2615
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2491 2616
 			{
2492 2617
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2493 2618
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2619
+			} else {
2620
+							$tag['content'] = $tag['disabled_content'];
2494 2621
 			}
2495
-			else
2496
-				$tag['content'] = $tag['disabled_content'];
2497 2622
 		}
2498 2623
 
2499 2624
 		// we use this a lot
@@ -2503,8 +2628,9 @@  discard block
 block discarded – undo
2503 2628
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2504 2629
 		{
2505 2630
 			$n = count($open_tags) - 1;
2506
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2507
-				$n--;
2631
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2632
+							$n--;
2633
+			}
2508 2634
 
2509 2635
 			// Close all the non block level tags so this tag isn't surrounded by them.
2510 2636
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2516,12 +2642,15 @@  discard block
 block discarded – undo
2516 2642
 
2517 2643
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2518 2644
 				$whitespace_regex = '';
2519
-				if (!empty($tag['block_level']))
2520
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2521
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2522
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2523
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2524
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2645
+				if (!empty($tag['block_level'])) {
2646
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2647
+				}
2648
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2649
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2650
+				}
2651
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2652
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2653
+				}
2525 2654
 
2526 2655
 				array_pop($open_tags);
2527 2656
 			}
@@ -2542,16 +2671,19 @@  discard block
 block discarded – undo
2542 2671
 		elseif ($tag['type'] == 'unparsed_content')
2543 2672
 		{
2544 2673
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2545
-			if ($pos2 === false)
2546
-				continue;
2674
+			if ($pos2 === false) {
2675
+							continue;
2676
+			}
2547 2677
 
2548 2678
 			$data = substr($message, $pos1, $pos2 - $pos1);
2549 2679
 
2550
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2551
-				$data = substr($data, 4);
2680
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2681
+							$data = substr($data, 4);
2682
+			}
2552 2683
 
2553
-			if (isset($tag['validate']))
2554
-				$tag['validate']($tag, $data, $disabled, $params);
2684
+			if (isset($tag['validate'])) {
2685
+							$tag['validate']($tag, $data, $disabled, $params);
2686
+			}
2555 2687
 
2556 2688
 			$code = strtr($tag['content'], array('$1' => $data));
2557 2689
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2567,34 +2699,40 @@  discard block
 block discarded – undo
2567 2699
 			if (isset($tag['quoted']))
2568 2700
 			{
2569 2701
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2570
-				if ($tag['quoted'] != 'optional' && !$quoted)
2571
-					continue;
2702
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2703
+									continue;
2704
+				}
2572 2705
 
2573
-				if ($quoted)
2574
-					$pos1 += 6;
2706
+				if ($quoted) {
2707
+									$pos1 += 6;
2708
+				}
2709
+			} else {
2710
+							$quoted = false;
2575 2711
 			}
2576
-			else
2577
-				$quoted = false;
2578 2712
 
2579 2713
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2580
-			if ($pos2 === false)
2581
-				continue;
2714
+			if ($pos2 === false) {
2715
+							continue;
2716
+			}
2582 2717
 
2583 2718
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2584
-			if ($pos3 === false)
2585
-				continue;
2719
+			if ($pos3 === false) {
2720
+							continue;
2721
+			}
2586 2722
 
2587 2723
 			$data = array(
2588 2724
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2589 2725
 				substr($message, $pos1, $pos2 - $pos1)
2590 2726
 			);
2591 2727
 
2592
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2593
-				$data[0] = substr($data[0], 4);
2728
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2729
+							$data[0] = substr($data[0], 4);
2730
+			}
2594 2731
 
2595 2732
 			// Validation for my parking, please!
2596
-			if (isset($tag['validate']))
2597
-				$tag['validate']($tag, $data, $disabled, $params);
2733
+			if (isset($tag['validate'])) {
2734
+							$tag['validate']($tag, $data, $disabled, $params);
2735
+			}
2598 2736
 
2599 2737
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2600 2738
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2611,23 +2749,27 @@  discard block
 block discarded – undo
2611 2749
 		elseif ($tag['type'] == 'unparsed_commas_content')
2612 2750
 		{
2613 2751
 			$pos2 = strpos($message, ']', $pos1);
2614
-			if ($pos2 === false)
2615
-				continue;
2752
+			if ($pos2 === false) {
2753
+							continue;
2754
+			}
2616 2755
 
2617 2756
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2618
-			if ($pos3 === false)
2619
-				continue;
2757
+			if ($pos3 === false) {
2758
+							continue;
2759
+			}
2620 2760
 
2621 2761
 			// We want $1 to be the content, and the rest to be csv.
2622 2762
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2623 2763
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2624 2764
 
2625
-			if (isset($tag['validate']))
2626
-				$tag['validate']($tag, $data, $disabled, $params);
2765
+			if (isset($tag['validate'])) {
2766
+							$tag['validate']($tag, $data, $disabled, $params);
2767
+			}
2627 2768
 
2628 2769
 			$code = $tag['content'];
2629
-			foreach ($data as $k => $d)
2630
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2770
+			foreach ($data as $k => $d) {
2771
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2772
+			}
2631 2773
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2632 2774
 			$pos += strlen($code) - 1 + 2;
2633 2775
 		}
@@ -2635,24 +2777,28 @@  discard block
 block discarded – undo
2635 2777
 		elseif ($tag['type'] == 'unparsed_commas')
2636 2778
 		{
2637 2779
 			$pos2 = strpos($message, ']', $pos1);
2638
-			if ($pos2 === false)
2639
-				continue;
2780
+			if ($pos2 === false) {
2781
+							continue;
2782
+			}
2640 2783
 
2641 2784
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2642 2785
 
2643
-			if (isset($tag['validate']))
2644
-				$tag['validate']($tag, $data, $disabled, $params);
2786
+			if (isset($tag['validate'])) {
2787
+							$tag['validate']($tag, $data, $disabled, $params);
2788
+			}
2645 2789
 
2646 2790
 			// Fix after, for disabled code mainly.
2647
-			foreach ($data as $k => $d)
2648
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2791
+			foreach ($data as $k => $d) {
2792
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2793
+			}
2649 2794
 
2650 2795
 			$open_tags[] = $tag;
2651 2796
 
2652 2797
 			// Replace them out, $1, $2, $3, $4, etc.
2653 2798
 			$code = $tag['before'];
2654
-			foreach ($data as $k => $d)
2655
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2799
+			foreach ($data as $k => $d) {
2800
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2801
+			}
2656 2802
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2657 2803
 			$pos += strlen($code) - 1 + 2;
2658 2804
 		}
@@ -2663,28 +2809,33 @@  discard block
 block discarded – undo
2663 2809
 			if (isset($tag['quoted']))
2664 2810
 			{
2665 2811
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2666
-				if ($tag['quoted'] != 'optional' && !$quoted)
2667
-					continue;
2812
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2813
+									continue;
2814
+				}
2668 2815
 
2669
-				if ($quoted)
2670
-					$pos1 += 6;
2816
+				if ($quoted) {
2817
+									$pos1 += 6;
2818
+				}
2819
+			} else {
2820
+							$quoted = false;
2671 2821
 			}
2672
-			else
2673
-				$quoted = false;
2674 2822
 
2675 2823
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2676
-			if ($pos2 === false)
2677
-				continue;
2824
+			if ($pos2 === false) {
2825
+							continue;
2826
+			}
2678 2827
 
2679 2828
 			$data = substr($message, $pos1, $pos2 - $pos1);
2680 2829
 
2681 2830
 			// Validation for my parking, please!
2682
-			if (isset($tag['validate']))
2683
-				$tag['validate']($tag, $data, $disabled, $params);
2831
+			if (isset($tag['validate'])) {
2832
+							$tag['validate']($tag, $data, $disabled, $params);
2833
+			}
2684 2834
 
2685 2835
 			// For parsed content, we must recurse to avoid security problems.
2686
-			if ($tag['type'] != 'unparsed_equals')
2687
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2836
+			if ($tag['type'] != 'unparsed_equals') {
2837
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2838
+			}
2688 2839
 
2689 2840
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2690 2841
 
@@ -2696,34 +2847,40 @@  discard block
 block discarded – undo
2696 2847
 		}
2697 2848
 
2698 2849
 		// If this is block level, eat any breaks after it.
2699
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2700
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2850
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2851
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2852
+		}
2701 2853
 
2702 2854
 		// Are we trimming outside this tag?
2703
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2704
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2855
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2856
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2857
+		}
2705 2858
 	}
2706 2859
 
2707 2860
 	// Close any remaining tags.
2708
-	while ($tag = array_pop($open_tags))
2709
-		$message .= "\n" . $tag['after'] . "\n";
2861
+	while ($tag = array_pop($open_tags)) {
2862
+			$message .= "\n" . $tag['after'] . "\n";
2863
+	}
2710 2864
 
2711 2865
 	// Parse the smileys within the parts where it can be done safely.
2712 2866
 	if ($smileys === true)
2713 2867
 	{
2714 2868
 		$message_parts = explode("\n", $message);
2715
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2716
-			parsesmileys($message_parts[$i]);
2869
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2870
+					parsesmileys($message_parts[$i]);
2871
+		}
2717 2872
 
2718 2873
 		$message = implode('', $message_parts);
2719 2874
 	}
2720 2875
 
2721 2876
 	// No smileys, just get rid of the markers.
2722
-	else
2723
-		$message = strtr($message, array("\n" => ''));
2877
+	else {
2878
+			$message = strtr($message, array("\n" => ''));
2879
+	}
2724 2880
 
2725
-	if ($message !== '' && $message[0] === ' ')
2726
-		$message = '&nbsp;' . substr($message, 1);
2881
+	if ($message !== '' && $message[0] === ' ') {
2882
+			$message = '&nbsp;' . substr($message, 1);
2883
+	}
2727 2884
 
2728 2885
 	// Cleanup whitespace.
2729 2886
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2732,15 +2889,16 @@  discard block
 block discarded – undo
2732 2889
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2733 2890
 
2734 2891
 	// Cache the output if it took some time...
2735
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2736
-		cache_put_data($cache_key, $message, 240);
2892
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
2893
+			cache_put_data($cache_key, $message, 240);
2894
+	}
2737 2895
 
2738 2896
 	// If this was a force parse revert if needed.
2739 2897
 	if (!empty($parse_tags))
2740 2898
 	{
2741
-		if (empty($temp_bbc))
2742
-			$bbc_codes = array();
2743
-		else
2899
+		if (empty($temp_bbc)) {
2900
+					$bbc_codes = array();
2901
+		} else
2744 2902
 		{
2745 2903
 			$bbc_codes = $temp_bbc;
2746 2904
 			unset($temp_bbc);
@@ -2767,8 +2925,9 @@  discard block
 block discarded – undo
2767 2925
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2768 2926
 
2769 2927
 	// No smiley set at all?!
2770
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2771
-		return;
2928
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
2929
+			return;
2930
+	}
2772 2931
 
2773 2932
 	// If smileyPregSearch hasn't been set, do it now.
2774 2933
 	if (empty($smileyPregSearch))
@@ -2779,8 +2938,7 @@  discard block
 block discarded – undo
2779 2938
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2780 2939
 			$smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png');
2781 2940
 			$smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
2782
-		}
2783
-		else
2941
+		} else
2784 2942
 		{
2785 2943
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2786 2944
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2804,9 +2962,9 @@  discard block
 block discarded – undo
2804 2962
 				$smcFunc['db_free_result']($result);
2805 2963
 
2806 2964
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
2965
+			} else {
2966
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2807 2967
 			}
2808
-			else
2809
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2810 2968
 		}
2811 2969
 
2812 2970
 		// The non-breaking-space is a complex thing...
@@ -2883,35 +3041,41 @@  discard block
 block discarded – undo
2883 3041
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
2884 3042
 
2885 3043
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
2886
-	if (!empty($context['flush_mail']))
2887
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3044
+	if (!empty($context['flush_mail'])) {
3045
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2888 3046
 		AddMailQueue(true);
3047
+	}
2889 3048
 
2890 3049
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
2891 3050
 
2892
-	if ($add)
2893
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3051
+	if ($add) {
3052
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3053
+	}
2894 3054
 
2895 3055
 	// Put the session ID in.
2896
-	if (defined('SID') && SID != '')
2897
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3056
+	if (defined('SID') && SID != '') {
3057
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3058
+	}
2898 3059
 	// Keep that debug in their for template debugging!
2899
-	elseif (isset($_GET['debug']))
2900
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3060
+	elseif (isset($_GET['debug'])) {
3061
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3062
+	}
2901 3063
 
2902 3064
 	if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
2903 3065
 	{
2904
-		if (defined('SID') && SID != '')
2905
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3066
+		if (defined('SID') && SID != '') {
3067
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2906 3068
 				function ($m) use ($scripturl)
2907 3069
 				{
2908 3070
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3071
+		}
2909 3072
 				}, $setLocation);
2910
-		else
2911
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3073
+		else {
3074
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2912 3075
 				function ($m) use ($scripturl)
2913 3076
 				{
2914 3077
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3078
+		}
2915 3079
 				}, $setLocation);
2916 3080
 	}
2917 3081
 
@@ -2922,8 +3086,9 @@  discard block
 block discarded – undo
2922 3086
 	header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
2923 3087
 
2924 3088
 	// Debugging.
2925
-	if (isset($db_show_debug) && $db_show_debug === true)
2926
-		$_SESSION['debug_redirect'] = $db_cache;
3089
+	if (isset($db_show_debug) && $db_show_debug === true) {
3090
+			$_SESSION['debug_redirect'] = $db_cache;
3091
+	}
2927 3092
 
2928 3093
 	obExit(false);
2929 3094
 }
@@ -2942,51 +3107,60 @@  discard block
 block discarded – undo
2942 3107
 
2943 3108
 	// Attempt to prevent a recursive loop.
2944 3109
 	++$level;
2945
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
2946
-		exit;
2947
-	if ($from_fatal_error)
2948
-		$has_fatal_error = true;
3110
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
3111
+			exit;
3112
+	}
3113
+	if ($from_fatal_error) {
3114
+			$has_fatal_error = true;
3115
+	}
2949 3116
 
2950 3117
 	// Clear out the stat cache.
2951 3118
 	trackStats();
2952 3119
 
2953 3120
 	// If we have mail to send, send it.
2954
-	if (!empty($context['flush_mail']))
2955
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3121
+	if (!empty($context['flush_mail'])) {
3122
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2956 3123
 		AddMailQueue(true);
3124
+	}
2957 3125
 
2958 3126
 	$do_header = $header === null ? !$header_done : $header;
2959
-	if ($do_footer === null)
2960
-		$do_footer = $do_header;
3127
+	if ($do_footer === null) {
3128
+			$do_footer = $do_header;
3129
+	}
2961 3130
 
2962 3131
 	// Has the template/header been done yet?
2963 3132
 	if ($do_header)
2964 3133
 	{
2965 3134
 		// Was the page title set last minute? Also update the HTML safe one.
2966
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
2967
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3135
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3136
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3137
+		}
2968 3138
 
2969 3139
 		// Start up the session URL fixer.
2970 3140
 		ob_start('ob_sessrewrite');
2971 3141
 
2972
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
2973
-			$buffers = explode(',', $settings['output_buffers']);
2974
-		elseif (!empty($settings['output_buffers']))
2975
-			$buffers = $settings['output_buffers'];
2976
-		else
2977
-			$buffers = array();
3142
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3143
+					$buffers = explode(',', $settings['output_buffers']);
3144
+		} elseif (!empty($settings['output_buffers'])) {
3145
+					$buffers = $settings['output_buffers'];
3146
+		} else {
3147
+					$buffers = array();
3148
+		}
2978 3149
 
2979
-		if (isset($modSettings['integrate_buffer']))
2980
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3150
+		if (isset($modSettings['integrate_buffer'])) {
3151
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3152
+		}
2981 3153
 
2982
-		if (!empty($buffers))
2983
-			foreach ($buffers as $function)
3154
+		if (!empty($buffers)) {
3155
+					foreach ($buffers as $function)
2984 3156
 			{
2985 3157
 				$call = call_helper($function, true);
3158
+		}
2986 3159
 
2987 3160
 				// Is it valid?
2988
-				if (!empty($call))
2989
-					ob_start($call);
3161
+				if (!empty($call)) {
3162
+									ob_start($call);
3163
+				}
2990 3164
 			}
2991 3165
 
2992 3166
 		// Display the screen in the logical order.
@@ -2998,8 +3172,9 @@  discard block
 block discarded – undo
2998 3172
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
2999 3173
 
3000 3174
 		// Anything special to put out?
3001
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
3002
-			echo $context['insert_after_template'];
3175
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3176
+					echo $context['insert_after_template'];
3177
+		}
3003 3178
 
3004 3179
 		// Just so we don't get caught in an endless loop of errors from the footer...
3005 3180
 		if (!$footer_done)
@@ -3008,14 +3183,16 @@  discard block
 block discarded – undo
3008 3183
 			template_footer();
3009 3184
 
3010 3185
 			// (since this is just debugging... it's okay that it's after </html>.)
3011
-			if (!isset($_REQUEST['xml']))
3012
-				displayDebug();
3186
+			if (!isset($_REQUEST['xml'])) {
3187
+							displayDebug();
3188
+			}
3013 3189
 		}
3014 3190
 	}
3015 3191
 
3016 3192
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
3017
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
3018
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3193
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3194
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3195
+	}
3019 3196
 
3020 3197
 	// For session check verification.... don't switch browsers...
3021 3198
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -3024,9 +3201,10 @@  discard block
 block discarded – undo
3024 3201
 	call_integration_hook('integrate_exit', array($do_footer));
3025 3202
 
3026 3203
 	// Don't exit if we're coming from index.php; that will pass through normally.
3027
-	if (!$from_index)
3028
-		exit;
3029
-}
3204
+	if (!$from_index) {
3205
+			exit;
3206
+	}
3207
+	}
3030 3208
 
3031 3209
 /**
3032 3210
  * Get the size of a specified image with better error handling.
@@ -3045,8 +3223,9 @@  discard block
 block discarded – undo
3045 3223
 	$url = str_replace(' ', '%20', $url);
3046 3224
 
3047 3225
 	// Can we pull this from the cache... please please?
3048
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
3049
-		return $temp;
3226
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3227
+			return $temp;
3228
+	}
3050 3229
 	$t = microtime();
3051 3230
 
3052 3231
 	// Get the host to pester...
@@ -3056,12 +3235,10 @@  discard block
 block discarded – undo
3056 3235
 	if ($url == '' || $url == 'http://' || $url == 'https://')
3057 3236
 	{
3058 3237
 		return false;
3059
-	}
3060
-	elseif (!isset($match[1]))
3238
+	} elseif (!isset($match[1]))
3061 3239
 	{
3062 3240
 		$size = @getimagesize($url);
3063
-	}
3064
-	else
3241
+	} else
3065 3242
 	{
3066 3243
 		// Try to connect to the server... give it half a second.
3067 3244
 		$temp = 0;
@@ -3100,12 +3277,14 @@  discard block
 block discarded – undo
3100 3277
 	}
3101 3278
 
3102 3279
 	// If we didn't get it, we failed.
3103
-	if (!isset($size))
3104
-		$size = false;
3280
+	if (!isset($size)) {
3281
+			$size = false;
3282
+	}
3105 3283
 
3106 3284
 	// If this took a long time, we may never have to do it again, but then again we might...
3107
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
3108
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3285
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3286
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3287
+	}
3109 3288
 
3110 3289
 	// Didn't work.
3111 3290
 	return $size;
@@ -3123,8 +3302,9 @@  discard block
 block discarded – undo
3123 3302
 
3124 3303
 	// Under SSI this function can be called more then once.  That can cause some problems.
3125 3304
 	//   So only run the function once unless we are forced to run it again.
3126
-	if ($loaded && !$forceload)
3127
-		return;
3305
+	if ($loaded && !$forceload) {
3306
+			return;
3307
+	}
3128 3308
 
3129 3309
 	$loaded = true;
3130 3310
 
@@ -3136,14 +3316,16 @@  discard block
 block discarded – undo
3136 3316
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3137 3317
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3138 3318
 	{
3139
-		if (trim($context['news_lines'][$i]) == '')
3140
-			continue;
3319
+		if (trim($context['news_lines'][$i]) == '') {
3320
+					continue;
3321
+		}
3141 3322
 
3142 3323
 		// Clean it up for presentation ;).
3143 3324
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3144 3325
 	}
3145
-	if (!empty($context['news_lines']))
3146
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3326
+	if (!empty($context['news_lines'])) {
3327
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3328
+	}
3147 3329
 
3148 3330
 	if (!$user_info['is_guest'])
3149 3331
 	{
@@ -3152,40 +3334,48 @@  discard block
 block discarded – undo
3152 3334
 		$context['user']['alerts'] = &$user_info['alerts'];
3153 3335
 
3154 3336
 		// Personal message popup...
3155
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3156
-			$context['user']['popup_messages'] = true;
3157
-		else
3158
-			$context['user']['popup_messages'] = false;
3337
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3338
+					$context['user']['popup_messages'] = true;
3339
+		} else {
3340
+					$context['user']['popup_messages'] = false;
3341
+		}
3159 3342
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3160 3343
 
3161
-		if (allowedTo('moderate_forum'))
3162
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3344
+		if (allowedTo('moderate_forum')) {
3345
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3346
+		}
3163 3347
 
3164 3348
 		$context['user']['avatar'] = array();
3165 3349
 
3166 3350
 		// Check for gravatar first since we might be forcing them...
3167 3351
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3168 3352
 		{
3169
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3170
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3171
-			else
3172
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3353
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3354
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3355
+			} else {
3356
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3357
+			}
3173 3358
 		}
3174 3359
 		// Uploaded?
3175
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3176
-			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3360
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3361
+					$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3362
+		}
3177 3363
 		// Full URL?
3178
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3179
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3364
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3365
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3366
+		}
3180 3367
 		// Otherwise we assume it's server stored.
3181
-		elseif ($user_info['avatar']['url'] != '')
3182
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3368
+		elseif ($user_info['avatar']['url'] != '') {
3369
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3370
+		}
3183 3371
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3184
-		else
3185
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3372
+		else {
3373
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3374
+		}
3186 3375
 
3187
-		if (!empty($context['user']['avatar']))
3188
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3376
+		if (!empty($context['user']['avatar'])) {
3377
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3378
+		}
3189 3379
 
3190 3380
 		// Figure out how long they've been logged in.
3191 3381
 		$context['user']['total_time_logged_in'] = array(
@@ -3193,8 +3383,7 @@  discard block
 block discarded – undo
3193 3383
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3194 3384
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3195 3385
 		);
3196
-	}
3197
-	else
3386
+	} else
3198 3387
 	{
3199 3388
 		$context['user']['messages'] = 0;
3200 3389
 		$context['user']['unread_messages'] = 0;
@@ -3202,12 +3391,14 @@  discard block
 block discarded – undo
3202 3391
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3203 3392
 		$context['user']['popup_messages'] = false;
3204 3393
 
3205
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3206
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3394
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3395
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3396
+		}
3207 3397
 
3208 3398
 		// If we've upgraded recently, go easy on the passwords.
3209
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3210
-			$context['disable_login_hashing'] = true;
3399
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3400
+					$context['disable_login_hashing'] = true;
3401
+		}
3211 3402
 	}
3212 3403
 
3213 3404
 	// Setup the main menu items.
@@ -3220,8 +3411,8 @@  discard block
 block discarded – undo
3220 3411
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3221 3412
 
3222 3413
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3223
-	if ($context['show_pm_popup'])
3224
-		addInlineJavaScript('
3414
+	if ($context['show_pm_popup']) {
3415
+			addInlineJavaScript('
3225 3416
 		jQuery(document).ready(function($) {
3226 3417
 			new smc_Popup({
3227 3418
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3229,15 +3420,17 @@  discard block
 block discarded – undo
3229 3420
 				icon_class: \'generic_icons mail_new\'
3230 3421
 			});
3231 3422
 		});');
3423
+	}
3232 3424
 
3233 3425
 	// Add a generic "Are you sure?" confirmation message.
3234 3426
 	addInlineJavaScript('
3235 3427
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3236 3428
 
3237 3429
 	// Now add the capping code for avatars.
3238
-	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
3239
-		addInlineCss('
3430
+	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') {
3431
+			addInlineCss('
3240 3432
 img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3433
+	}
3241 3434
 
3242 3435
 	// This looks weird, but it's because BoardIndex.php references the variable.
3243 3436
 	$context['common_stats']['latest_member'] = array(
@@ -3254,11 +3447,13 @@  discard block
 block discarded – undo
3254 3447
 	);
3255 3448
 	$context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']);
3256 3449
 
3257
-	if (empty($settings['theme_version']))
3258
-		addJavaScriptVar('smf_scripturl', $scripturl);
3450
+	if (empty($settings['theme_version'])) {
3451
+			addJavaScriptVar('smf_scripturl', $scripturl);
3452
+	}
3259 3453
 
3260
-	if (!isset($context['page_title']))
3261
-		$context['page_title'] = '';
3454
+	if (!isset($context['page_title'])) {
3455
+			$context['page_title'] = '';
3456
+	}
3262 3457
 
3263 3458
 	// Set some specific vars.
3264 3459
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3268,21 +3463,23 @@  discard block
 block discarded – undo
3268 3463
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3269 3464
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3270 3465
 
3271
-	if (!empty($context['meta_keywords']))
3272
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3466
+	if (!empty($context['meta_keywords'])) {
3467
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3468
+	}
3273 3469
 
3274
-	if (!empty($context['canonical_url']))
3275
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3470
+	if (!empty($context['canonical_url'])) {
3471
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3472
+	}
3276 3473
 
3277
-	if (!empty($settings['og_image']))
3278
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3474
+	if (!empty($settings['og_image'])) {
3475
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3476
+	}
3279 3477
 
3280 3478
 	if (!empty($context['meta_description']))
3281 3479
 	{
3282 3480
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3283 3481
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3284
-	}
3285
-	else
3482
+	} else
3286 3483
 	{
3287 3484
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3288 3485
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3307,8 +3504,9 @@  discard block
 block discarded – undo
3307 3504
 	$memory_needed = memoryReturnBytes($needed);
3308 3505
 
3309 3506
 	// should we account for how much is currently being used?
3310
-	if ($in_use)
3311
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3507
+	if ($in_use) {
3508
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3509
+	}
3312 3510
 
3313 3511
 	// if more is needed, request it
3314 3512
 	if ($memory_current < $memory_needed)
@@ -3331,8 +3529,9 @@  discard block
 block discarded – undo
3331 3529
  */
3332 3530
 function memoryReturnBytes($val)
3333 3531
 {
3334
-	if (is_integer($val))
3335
-		return $val;
3532
+	if (is_integer($val)) {
3533
+			return $val;
3534
+	}
3336 3535
 
3337 3536
 	// Separate the number from the designator
3338 3537
 	$val = trim($val);
@@ -3368,10 +3567,11 @@  discard block
 block discarded – undo
3368 3567
 		header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3369 3568
 
3370 3569
 		// Are we debugging the template/html content?
3371
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3372
-			header('content-type: application/xhtml+xml');
3373
-		elseif (!isset($_REQUEST['xml']))
3374
-			header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3570
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3571
+					header('content-type: application/xhtml+xml');
3572
+		} elseif (!isset($_REQUEST['xml'])) {
3573
+					header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3574
+		}
3375 3575
 	}
3376 3576
 
3377 3577
 	header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3380,8 +3580,9 @@  discard block
 block discarded – undo
3380 3580
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3381 3581
 	{
3382 3582
 		$position = array_search('body', $context['template_layers']);
3383
-		if ($position === false)
3384
-			$position = array_search('main', $context['template_layers']);
3583
+		if ($position === false) {
3584
+					$position = array_search('main', $context['template_layers']);
3585
+		}
3385 3586
 
3386 3587
 		if ($position !== false)
3387 3588
 		{
@@ -3409,23 +3610,25 @@  discard block
 block discarded – undo
3409 3610
 
3410 3611
 			foreach ($securityFiles as $i => $securityFile)
3411 3612
 			{
3412
-				if (!file_exists($boarddir . '/' . $securityFile))
3413
-					unset($securityFiles[$i]);
3613
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3614
+									unset($securityFiles[$i]);
3615
+				}
3414 3616
 			}
3415 3617
 
3416 3618
 			// We are already checking so many files...just few more doesn't make any difference! :P
3417
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3418
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3419
-
3420
-			else
3421
-				$path = $modSettings['attachmentUploadDir'];
3619
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3620
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3621
+			} else {
3622
+							$path = $modSettings['attachmentUploadDir'];
3623
+			}
3422 3624
 
3423 3625
 			secureDirectory($path, true);
3424 3626
 			secureDirectory($cachedir);
3425 3627
 
3426 3628
 			// If agreement is enabled, at least the english version shall exists
3427
-			if ($modSettings['requireAgreement'])
3428
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3629
+			if ($modSettings['requireAgreement']) {
3630
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3631
+			}
3429 3632
 
3430 3633
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3431 3634
 			{
@@ -3440,18 +3643,21 @@  discard block
 block discarded – undo
3440 3643
 					echo '
3441 3644
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3442 3645
 
3443
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3444
-						echo '
3646
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3647
+											echo '
3445 3648
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3649
+					}
3446 3650
 				}
3447 3651
 
3448
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3449
-					echo '
3652
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3653
+									echo '
3450 3654
 				<strong>', $txt['cache_writable'], '</strong><br>';
3655
+				}
3451 3656
 
3452
-				if (!empty($agreement))
3453
-					echo '
3657
+				if (!empty($agreement)) {
3658
+									echo '
3454 3659
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3660
+				}
3455 3661
 
3456 3662
 				echo '
3457 3663
 			</p>
@@ -3466,16 +3672,18 @@  discard block
 block discarded – undo
3466 3672
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3467 3673
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3468 3674
 
3469
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3470
-				echo '
3675
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3676
+							echo '
3471 3677
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3678
+			}
3472 3679
 
3473
-			if (!empty($_SESSION['ban']['expire_time']))
3474
-				echo '
3680
+			if (!empty($_SESSION['ban']['expire_time'])) {
3681
+							echo '
3475 3682
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3476
-			else
3477
-				echo '
3683
+			} else {
3684
+							echo '
3478 3685
 					<div>', $txt['your_ban_expires_never'], '</div>';
3686
+			}
3479 3687
 
3480 3688
 			echo '
3481 3689
 				</div>';
@@ -3491,8 +3699,9 @@  discard block
 block discarded – undo
3491 3699
 	global $forum_copyright, $software_year, $forum_version;
3492 3700
 
3493 3701
 	// Don't display copyright for things like SSI.
3494
-	if (!isset($forum_version) || !isset($software_year))
3495
-		return;
3702
+	if (!isset($forum_version) || !isset($software_year)) {
3703
+			return;
3704
+	}
3496 3705
 
3497 3706
 	// Put in the version...
3498 3707
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3510,9 +3719,10 @@  discard block
 block discarded – undo
3510 3719
 	$context['load_time'] = round(microtime(true) - $time_start, 3);
3511 3720
 	$context['load_queries'] = $db_count;
3512 3721
 
3513
-	foreach (array_reverse($context['template_layers']) as $layer)
3514
-		loadSubTemplate($layer . '_below', true);
3515
-}
3722
+	foreach (array_reverse($context['template_layers']) as $layer) {
3723
+			loadSubTemplate($layer . '_below', true);
3724
+	}
3725
+	}
3516 3726
 
3517 3727
 /**
3518 3728
  * Output the Javascript files
@@ -3543,8 +3753,7 @@  discard block
 block discarded – undo
3543 3753
 			{
3544 3754
 				echo '
3545 3755
 		var ', $key, ';';
3546
-			}
3547
-			else
3756
+			} else
3548 3757
 			{
3549 3758
 				echo '
3550 3759
 		var ', $key, ' = ', $value, ';';
@@ -3559,26 +3768,27 @@  discard block
 block discarded – undo
3559 3768
 	foreach ($context['javascript_files'] as $id => $js_file)
3560 3769
 	{
3561 3770
 		// Last minute call! allow theme authors to disable single files.
3562
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3563
-			continue;
3771
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3772
+					continue;
3773
+		}
3564 3774
 
3565 3775
 		// By default all files don't get minimized unless the file explicitly says so!
3566 3776
 		if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3567 3777
 		{
3568
-			if ($do_deferred && !empty($js_file['options']['defer']))
3569
-				$toMinifyDefer[] = $js_file;
3570
-
3571
-			elseif (!$do_deferred && empty($js_file['options']['defer']))
3572
-				$toMinify[] = $js_file;
3778
+			if ($do_deferred && !empty($js_file['options']['defer'])) {
3779
+							$toMinifyDefer[] = $js_file;
3780
+			} elseif (!$do_deferred && empty($js_file['options']['defer'])) {
3781
+							$toMinify[] = $js_file;
3782
+			}
3573 3783
 
3574 3784
 			// Grab a random seed.
3575
-			if (!isset($minSeed) && isset($js_file['options']['seed']))
3576
-				$minSeed = $js_file['options']['seed'];
3577
-		}
3578
-
3579
-		elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer'])))
3580
-			echo '
3785
+			if (!isset($minSeed) && isset($js_file['options']['seed'])) {
3786
+							$minSeed = $js_file['options']['seed'];
3787
+			}
3788
+		} elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) {
3789
+					echo '
3581 3790
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
3791
+		}
3582 3792
 	}
3583 3793
 
3584 3794
 	if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer)))
@@ -3587,9 +3797,10 @@  discard block
 block discarded – undo
3587 3797
 
3588 3798
 		$minSuccessful = array_keys($result) === array('smf_minified');
3589 3799
 
3590
-		foreach ($result as $minFile)
3591
-			echo '
3800
+		foreach ($result as $minFile) {
3801
+					echo '
3592 3802
 	<script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async="async"' : '', '></script>';
3803
+		}
3593 3804
 
3594 3805
 	}
3595 3806
 
@@ -3601,8 +3812,9 @@  discard block
 block discarded – undo
3601 3812
 			echo '
3602 3813
 <script>';
3603 3814
 
3604
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3605
-				echo $js_code;
3815
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
3816
+							echo $js_code;
3817
+			}
3606 3818
 
3607 3819
 			echo '
3608 3820
 </script>';
@@ -3613,8 +3825,9 @@  discard block
 block discarded – undo
3613 3825
 			echo '
3614 3826
 	<script>';
3615 3827
 
3616
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3617
-				echo $js_code;
3828
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
3829
+							echo $js_code;
3830
+			}
3618 3831
 
3619 3832
 			echo '
3620 3833
 	</script>';
@@ -3642,23 +3855,26 @@  discard block
 block discarded – undo
3642 3855
 	foreach ($context['css_files'] as $id => $file)
3643 3856
 	{
3644 3857
 		// Last minute call! allow theme authors to disable single files.
3645
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3646
-			continue;
3858
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3859
+					continue;
3860
+		}
3647 3861
 
3648 3862
 		// Files are minimized unless they explicitly opt out.
3649
-		if (!isset($file['options']['minimize']))
3650
-			$file['options']['minimize'] = true;
3863
+		if (!isset($file['options']['minimize'])) {
3864
+					$file['options']['minimize'] = true;
3865
+		}
3651 3866
 
3652 3867
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
3653 3868
 		{
3654 3869
 			$toMinify[] = $file;
3655 3870
 
3656 3871
 			// Grab a random seed.
3657
-			if (!isset($minSeed) && isset($file['options']['seed']))
3658
-				$minSeed = $file['options']['seed'];
3872
+			if (!isset($minSeed) && isset($file['options']['seed'])) {
3873
+							$minSeed = $file['options']['seed'];
3874
+			}
3875
+		} else {
3876
+					$normal[] = $file['fileUrl'];
3659 3877
 		}
3660
-		else
3661
-			$normal[] = $file['fileUrl'];
3662 3878
 	}
3663 3879
 
3664 3880
 	if (!empty($toMinify))
@@ -3667,23 +3883,26 @@  discard block
 block discarded – undo
3667 3883
 
3668 3884
 		$minSuccessful = array_keys($result) === array('smf_minified');
3669 3885
 
3670
-		foreach ($result as $minFile)
3671
-			echo '
3886
+		foreach ($result as $minFile) {
3887
+					echo '
3672 3888
 	<link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">';
3889
+		}
3673 3890
 	}
3674 3891
 
3675 3892
 	// Print the rest after the minified files.
3676
-	if (!empty($normal))
3677
-		foreach ($normal as $nf)
3893
+	if (!empty($normal)) {
3894
+			foreach ($normal as $nf)
3678 3895
 			echo '
3679 3896
 	<link rel="stylesheet" href="', $nf ,'">';
3897
+	}
3680 3898
 
3681 3899
 	if ($db_show_debug === true)
3682 3900
 	{
3683 3901
 		// Try to keep only what's useful.
3684 3902
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3685
-		foreach ($context['css_files'] as $file)
3686
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3903
+		foreach ($context['css_files'] as $file) {
3904
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3905
+		}
3687 3906
 	}
3688 3907
 
3689 3908
 	if (!empty($context['css_header']))
@@ -3691,9 +3910,10 @@  discard block
 block discarded – undo
3691 3910
 		echo '
3692 3911
 	<style>';
3693 3912
 
3694
-		foreach ($context['css_header'] as $css)
3695
-			echo $css .'
3913
+		foreach ($context['css_header'] as $css) {
3914
+					echo $css .'
3696 3915
 	';
3916
+		}
3697 3917
 
3698 3918
 		echo'
3699 3919
 	</style>';
@@ -3717,8 +3937,9 @@  discard block
 block discarded – undo
3717 3937
 	$type = !empty($type) && in_array($type, $types) ? $type : false;
3718 3938
 	$data = !empty($data) ? $data : false;
3719 3939
 
3720
-	if (empty($type) || empty($data))
3721
-		return false;
3940
+	if (empty($type) || empty($data)) {
3941
+			return false;
3942
+	}
3722 3943
 
3723 3944
 	// Different pages include different files, so we use a hash to label the different combinations
3724 3945
 	$hash = md5(implode(' ', array_keys($data)));
@@ -3727,8 +3948,9 @@  discard block
 block discarded – undo
3727 3948
 	$toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400);
3728 3949
 
3729 3950
 	// Already done?
3730
-	if (!empty($toCache))
3731
-		return true;
3951
+	if (!empty($toCache)) {
3952
+			return true;
3953
+	}
3732 3954
 
3733 3955
 	// No namespaces, sorry!
3734 3956
 	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
@@ -3760,8 +3982,9 @@  discard block
 block discarded – undo
3760 3982
 		$toAdd = file_exists($tempFile) ? $tempFile : false;
3761 3983
 
3762 3984
 		// A minified script should only be loaded asynchronously if all its components wanted to be.
3763
-		if (empty($file['options']['async']))
3764
-			$async = false;
3985
+		if (empty($file['options']['async'])) {
3986
+					$async = false;
3987
+		}
3765 3988
 
3766 3989
 		// The file couldn't be located so it won't be added. Log this error.
3767 3990
 		if (empty($toAdd))
@@ -3821,8 +4044,9 @@  discard block
 block discarded – undo
3821 4044
 	global $modSettings, $smcFunc;
3822 4045
 
3823 4046
 	// Just make up a nice hash...
3824
-	if ($new)
3825
-		return sha1(md5($filename . time()) . mt_rand());
4047
+	if ($new) {
4048
+			return sha1(md5($filename . time()) . mt_rand());
4049
+	}
3826 4050
 
3827 4051
 	// Just make sure that attachment id is only a int
3828 4052
 	$attachment_id = (int) $attachment_id;
@@ -3839,23 +4063,25 @@  discard block
 block discarded – undo
3839 4063
 				'id_attach' => $attachment_id,
3840 4064
 			));
3841 4065
 
3842
-		if ($smcFunc['db_num_rows']($request) === 0)
3843
-			return false;
4066
+		if ($smcFunc['db_num_rows']($request) === 0) {
4067
+					return false;
4068
+		}
3844 4069
 
3845 4070
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
3846 4071
 		$smcFunc['db_free_result']($request);
3847 4072
 	}
3848 4073
 
3849 4074
 	// Still no hash? mmm...
3850
-	if (empty($file_hash))
3851
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
4075
+	if (empty($file_hash)) {
4076
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
4077
+	}
3852 4078
 
3853 4079
 	// Are we using multiple directories?
3854
-	if (is_array($modSettings['attachmentUploadDir']))
3855
-		$path = $modSettings['attachmentUploadDir'][$dir];
3856
-
3857
-	else
3858
-		$path = $modSettings['attachmentUploadDir'];
4080
+	if (is_array($modSettings['attachmentUploadDir'])) {
4081
+			$path = $modSettings['attachmentUploadDir'][$dir];
4082
+	} else {
4083
+			$path = $modSettings['attachmentUploadDir'];
4084
+	}
3859 4085
 
3860 4086
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3861 4087
 }
@@ -3870,8 +4096,9 @@  discard block
 block discarded – undo
3870 4096
 function ip2range($fullip)
3871 4097
 {
3872 4098
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
3873
-	if ($fullip == 'unknown')
3874
-		$fullip = '255.255.255.255';
4099
+	if ($fullip == 'unknown') {
4100
+			$fullip = '255.255.255.255';
4101
+	}
3875 4102
 
3876 4103
 	$ip_parts = explode('-', $fullip);
3877 4104
 	$ip_array = array();
@@ -3895,10 +4122,11 @@  discard block
 block discarded – undo
3895 4122
 		$ip_array['low'] = $ip_parts[0];
3896 4123
 		$ip_array['high'] = $ip_parts[1];
3897 4124
 		return $ip_array;
3898
-	}
3899
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
4125
+	} elseif (count($ip_parts) == 2) {
4126
+		// if ip 22.22.*-22.22.*
3900 4127
 	{
3901 4128
 		$valid_low = isValidIP($ip_parts[0]);
4129
+	}
3902 4130
 		$valid_high = isValidIP($ip_parts[1]);
3903 4131
 		$count = 0;
3904 4132
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -3913,7 +4141,9 @@  discard block
 block discarded – undo
3913 4141
 				$ip_parts[0] .= $mode . $min;
3914 4142
 				$valid_low = isValidIP($ip_parts[0]);
3915 4143
 				$count++;
3916
-				if ($count > 9) break;
4144
+				if ($count > 9) {
4145
+					break;
4146
+				}
3917 4147
 			}
3918 4148
 		}
3919 4149
 
@@ -3927,7 +4157,9 @@  discard block
 block discarded – undo
3927 4157
 				$ip_parts[1] .= $mode . $max;
3928 4158
 				$valid_high = isValidIP($ip_parts[1]);
3929 4159
 				$count++;
3930
-				if ($count > 9) break;
4160
+				if ($count > 9) {
4161
+					break;
4162
+				}
3931 4163
 			}
3932 4164
 		}
3933 4165
 
@@ -3952,46 +4184,54 @@  discard block
 block discarded – undo
3952 4184
 {
3953 4185
 	global $modSettings;
3954 4186
 
3955
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
3956
-		return $host;
4187
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4188
+			return $host;
4189
+	}
3957 4190
 	$t = microtime();
3958 4191
 
3959 4192
 	// Try the Linux host command, perhaps?
3960 4193
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
3961 4194
 	{
3962
-		if (!isset($modSettings['host_to_dis']))
3963
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3964
-		else
3965
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4195
+		if (!isset($modSettings['host_to_dis'])) {
4196
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4197
+		} else {
4198
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4199
+		}
3966 4200
 
3967 4201
 		// Did host say it didn't find anything?
3968
-		if (strpos($test, 'not found') !== false)
3969
-			$host = '';
4202
+		if (strpos($test, 'not found') !== false) {
4203
+					$host = '';
4204
+		}
3970 4205
 		// Invalid server option?
3971
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
3972
-			updateSettings(array('host_to_dis' => 1));
4206
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4207
+					updateSettings(array('host_to_dis' => 1));
4208
+		}
3973 4209
 		// Maybe it found something, after all?
3974
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
3975
-			$host = $match[1];
4210
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4211
+					$host = $match[1];
4212
+		}
3976 4213
 	}
3977 4214
 
3978 4215
 	// This is nslookup; usually only Windows, but possibly some Unix?
3979 4216
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
3980 4217
 	{
3981 4218
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
3982
-		if (strpos($test, 'Non-existent domain') !== false)
3983
-			$host = '';
3984
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
3985
-			$host = $match[1];
4219
+		if (strpos($test, 'Non-existent domain') !== false) {
4220
+					$host = '';
4221
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4222
+					$host = $match[1];
4223
+		}
3986 4224
 	}
3987 4225
 
3988 4226
 	// This is the last try :/.
3989
-	if (!isset($host) || $host === false)
3990
-		$host = @gethostbyaddr($ip);
4227
+	if (!isset($host) || $host === false) {
4228
+			$host = @gethostbyaddr($ip);
4229
+	}
3991 4230
 
3992 4231
 	// It took a long time, so let's cache it!
3993
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
3994
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4232
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4233
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4234
+	}
3995 4235
 
3996 4236
 	return $host;
3997 4237
 }
@@ -4027,20 +4267,21 @@  discard block
 block discarded – undo
4027 4267
 			{
4028 4268
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
4029 4269
 				$total = 0;
4030
-				for ($i = 0; $i < $max_chars; $i++)
4031
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4270
+				for ($i = 0; $i < $max_chars; $i++) {
4271
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4272
+				}
4032 4273
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
4033 4274
 			}
4034 4275
 		}
4035 4276
 		return array_unique($returned_ints);
4036
-	}
4037
-	else
4277
+	} else
4038 4278
 	{
4039 4279
 		// Trim characters before and after and add slashes for database insertion.
4040 4280
 		$returned_words = array();
4041
-		foreach ($words as $word)
4042
-			if (($word = trim($word, '-_\'')) !== '')
4281
+		foreach ($words as $word) {
4282
+					if (($word = trim($word, '-_\'')) !== '')
4043 4283
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4284
+		}
4044 4285
 
4045 4286
 		// Filter out all words that occur more than once.
4046 4287
 		return array_unique($returned_words);
@@ -4062,16 +4303,18 @@  discard block
 block discarded – undo
4062 4303
 	global $settings, $txt;
4063 4304
 
4064 4305
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
4065
-	if (function_exists('template_create_button') && !$force_use)
4066
-		return template_create_button($name, $alt, $label = '', $custom = '');
4306
+	if (function_exists('template_create_button') && !$force_use) {
4307
+			return template_create_button($name, $alt, $label = '', $custom = '');
4308
+	}
4067 4309
 
4068
-	if (!$settings['use_image_buttons'])
4069
-		return $txt[$alt];
4070
-	elseif (!empty($settings['use_buttons']))
4071
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4072
-	else
4073
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4074
-}
4310
+	if (!$settings['use_image_buttons']) {
4311
+			return $txt[$alt];
4312
+	} elseif (!empty($settings['use_buttons'])) {
4313
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4314
+	} else {
4315
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4316
+	}
4317
+	}
4075 4318
 
4076 4319
 /**
4077 4320
  * Sets up all of the top menu buttons
@@ -4114,9 +4357,10 @@  discard block
 block discarded – undo
4114 4357
 	var user_menus = new smc_PopupMenu();
4115 4358
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4116 4359
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4117
-		if ($context['allow_pm'])
4118
-			addInlineJavaScript('
4360
+		if ($context['allow_pm']) {
4361
+					addInlineJavaScript('
4119 4362
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4363
+		}
4120 4364
 
4121 4365
 		if (!empty($modSettings['enable_ajax_alerts']))
4122 4366
 		{
@@ -4276,88 +4520,96 @@  discard block
 block discarded – undo
4276 4520
 
4277 4521
 		// Now we put the buttons in the context so the theme can use them.
4278 4522
 		$menu_buttons = array();
4279
-		foreach ($buttons as $act => $button)
4280
-			if (!empty($button['show']))
4523
+		foreach ($buttons as $act => $button) {
4524
+					if (!empty($button['show']))
4281 4525
 			{
4282 4526
 				$button['active_button'] = false;
4527
+		}
4283 4528
 
4284 4529
 				// This button needs some action.
4285
-				if (isset($button['action_hook']))
4286
-					$needs_action_hook = true;
4530
+				if (isset($button['action_hook'])) {
4531
+									$needs_action_hook = true;
4532
+				}
4287 4533
 
4288 4534
 				// Make sure the last button truly is the last button.
4289 4535
 				if (!empty($button['is_last']))
4290 4536
 				{
4291
-					if (isset($last_button))
4292
-						unset($menu_buttons[$last_button]['is_last']);
4537
+					if (isset($last_button)) {
4538
+											unset($menu_buttons[$last_button]['is_last']);
4539
+					}
4293 4540
 					$last_button = $act;
4294 4541
 				}
4295 4542
 
4296 4543
 				// Go through the sub buttons if there are any.
4297
-				if (!empty($button['sub_buttons']))
4298
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4544
+				if (!empty($button['sub_buttons'])) {
4545
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4299 4546
 					{
4300 4547
 						if (empty($subbutton['show']))
4301 4548
 							unset($button['sub_buttons'][$key]);
4549
+				}
4302 4550
 
4303 4551
 						// 2nd level sub buttons next...
4304 4552
 						if (!empty($subbutton['sub_buttons']))
4305 4553
 						{
4306 4554
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4307 4555
 							{
4308
-								if (empty($sub_button2['show']))
4309
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4556
+								if (empty($sub_button2['show'])) {
4557
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4558
+								}
4310 4559
 							}
4311 4560
 						}
4312 4561
 					}
4313 4562
 
4314 4563
 				// Does this button have its own icon?
4315
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4316
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4317
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4318
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4319
-				elseif (isset($button['icon']))
4320
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4321
-				else
4322
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4564
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4565
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4566
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4567
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4568
+				} elseif (isset($button['icon'])) {
4569
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4570
+				} else {
4571
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4572
+				}
4323 4573
 
4324 4574
 				$menu_buttons[$act] = $button;
4325 4575
 			}
4326 4576
 
4327
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4328
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4577
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4578
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4579
+		}
4329 4580
 	}
4330 4581
 
4331 4582
 	$context['menu_buttons'] = $menu_buttons;
4332 4583
 
4333 4584
 	// Logging out requires the session id in the url.
4334
-	if (isset($context['menu_buttons']['logout']))
4335
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4585
+	if (isset($context['menu_buttons']['logout'])) {
4586
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4587
+	}
4336 4588
 
4337 4589
 	// Figure out which action we are doing so we can set the active tab.
4338 4590
 	// Default to home.
4339 4591
 	$current_action = 'home';
4340 4592
 
4341
-	if (isset($context['menu_buttons'][$context['current_action']]))
4342
-		$current_action = $context['current_action'];
4343
-	elseif ($context['current_action'] == 'search2')
4344
-		$current_action = 'search';
4345
-	elseif ($context['current_action'] == 'theme')
4346
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4347
-	elseif ($context['current_action'] == 'register2')
4348
-		$current_action = 'register';
4349
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4350
-		$current_action = 'login';
4351
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4352
-		$current_action = 'moderate';
4593
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4594
+			$current_action = $context['current_action'];
4595
+	} elseif ($context['current_action'] == 'search2') {
4596
+			$current_action = 'search';
4597
+	} elseif ($context['current_action'] == 'theme') {
4598
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4599
+	} elseif ($context['current_action'] == 'register2') {
4600
+			$current_action = 'register';
4601
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4602
+			$current_action = 'login';
4603
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4604
+			$current_action = 'moderate';
4605
+	}
4353 4606
 
4354 4607
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4355 4608
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4356 4609
 	{
4357 4610
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4358 4611
 		$context[$current_action] = true;
4359
-	}
4360
-	elseif ($context['current_action'] == 'pm')
4612
+	} elseif ($context['current_action'] == 'pm')
4361 4613
 	{
4362 4614
 		$current_action = 'self_pm';
4363 4615
 		$context['self_pm'] = true;
@@ -4414,12 +4666,14 @@  discard block
 block discarded – undo
4414 4666
 	}
4415 4667
 
4416 4668
 	// Not all actions are simple.
4417
-	if (!empty($needs_action_hook))
4418
-		call_integration_hook('integrate_current_action', array(&$current_action));
4669
+	if (!empty($needs_action_hook)) {
4670
+			call_integration_hook('integrate_current_action', array(&$current_action));
4671
+	}
4419 4672
 
4420
-	if (isset($context['menu_buttons'][$current_action]))
4421
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4422
-}
4673
+	if (isset($context['menu_buttons'][$current_action])) {
4674
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4675
+	}
4676
+	}
4423 4677
 
4424 4678
 /**
4425 4679
  * Generate a random seed and ensure it's stored in settings.
@@ -4443,30 +4697,35 @@  discard block
 block discarded – undo
4443 4697
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4444 4698
 	global $context, $txt;
4445 4699
 
4446
-	if ($db_show_debug === true)
4447
-		$context['debug']['hooks'][] = $hook;
4700
+	if ($db_show_debug === true) {
4701
+			$context['debug']['hooks'][] = $hook;
4702
+	}
4448 4703
 
4449 4704
 	// Need to have some control.
4450
-	if (!isset($context['instances']))
4451
-		$context['instances'] = array();
4705
+	if (!isset($context['instances'])) {
4706
+			$context['instances'] = array();
4707
+	}
4452 4708
 
4453 4709
 	$results = array();
4454
-	if (empty($modSettings[$hook]))
4455
-		return $results;
4710
+	if (empty($modSettings[$hook])) {
4711
+			return $results;
4712
+	}
4456 4713
 
4457 4714
 	$functions = explode(',', $modSettings[$hook]);
4458 4715
 	// Loop through each function.
4459 4716
 	foreach ($functions as $function)
4460 4717
 	{
4461 4718
 		// Hook has been marked as "disabled". Skip it!
4462
-		if (strpos($function, '!') !== false)
4463
-			continue;
4719
+		if (strpos($function, '!') !== false) {
4720
+					continue;
4721
+		}
4464 4722
 
4465 4723
 		$call = call_helper($function, true);
4466 4724
 
4467 4725
 		// Is it valid?
4468
-		if (!empty($call))
4469
-			$results[$function] = call_user_func_array($call, $parameters);
4726
+		if (!empty($call)) {
4727
+					$results[$function] = call_user_func_array($call, $parameters);
4728
+		}
4470 4729
 
4471 4730
 		// Whatever it was suppose to call, it failed :(
4472 4731
 		elseif (!empty($function))
@@ -4482,8 +4741,9 @@  discard block
 block discarded – undo
4482 4741
 			}
4483 4742
 
4484 4743
 			// "Assume" the file resides on $boarddir somewhere...
4485
-			else
4486
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4744
+			else {
4745
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4746
+			}
4487 4747
 		}
4488 4748
 	}
4489 4749
 
@@ -4505,12 +4765,14 @@  discard block
 block discarded – undo
4505 4765
 	global $smcFunc, $modSettings;
4506 4766
 
4507 4767
 	// Any objects?
4508
-	if ($object)
4509
-		$function = $function . '#';
4768
+	if ($object) {
4769
+			$function = $function . '#';
4770
+	}
4510 4771
 
4511 4772
 	// Any files  to load?
4512
-	if (!empty($file) && is_string($file))
4513
-		$function = $file . (!empty($function) ? '|' . $function : '');
4773
+	if (!empty($file) && is_string($file)) {
4774
+			$function = $file . (!empty($function) ? '|' . $function : '');
4775
+	}
4514 4776
 
4515 4777
 	// Get the correct string.
4516 4778
 	$integration_call = $function;
@@ -4532,13 +4794,14 @@  discard block
 block discarded – undo
4532 4794
 		if (!empty($current_functions))
4533 4795
 		{
4534 4796
 			$current_functions = explode(',', $current_functions);
4535
-			if (in_array($integration_call, $current_functions))
4536
-				return;
4797
+			if (in_array($integration_call, $current_functions)) {
4798
+							return;
4799
+			}
4537 4800
 
4538 4801
 			$permanent_functions = array_merge($current_functions, array($integration_call));
4802
+		} else {
4803
+					$permanent_functions = array($integration_call);
4539 4804
 		}
4540
-		else
4541
-			$permanent_functions = array($integration_call);
4542 4805
 
4543 4806
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4544 4807
 	}
@@ -4547,8 +4810,9 @@  discard block
 block discarded – undo
4547 4810
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4548 4811
 
4549 4812
 	// Do nothing, if it's already there.
4550
-	if (in_array($integration_call, $functions))
4551
-		return;
4813
+	if (in_array($integration_call, $functions)) {
4814
+			return;
4815
+	}
4552 4816
 
4553 4817
 	$functions[] = $integration_call;
4554 4818
 	$modSettings[$hook] = implode(',', $functions);
@@ -4571,12 +4835,14 @@  discard block
 block discarded – undo
4571 4835
 	global $smcFunc, $modSettings;
4572 4836
 
4573 4837
 	// Any objects?
4574
-	if ($object)
4575
-		$function = $function . '#';
4838
+	if ($object) {
4839
+			$function = $function . '#';
4840
+	}
4576 4841
 
4577 4842
 	// Any files  to load?
4578
-	if (!empty($file) && is_string($file))
4579
-		$function = $file . '|' . $function;
4843
+	if (!empty($file) && is_string($file)) {
4844
+			$function = $file . '|' . $function;
4845
+	}
4580 4846
 
4581 4847
 	// Get the correct string.
4582 4848
 	$integration_call = $function;
@@ -4597,16 +4863,18 @@  discard block
 block discarded – undo
4597 4863
 	{
4598 4864
 		$current_functions = explode(',', $current_functions);
4599 4865
 
4600
-		if (in_array($integration_call, $current_functions))
4601
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4866
+		if (in_array($integration_call, $current_functions)) {
4867
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4868
+		}
4602 4869
 	}
4603 4870
 
4604 4871
 	// Turn the function list into something usable.
4605 4872
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4606 4873
 
4607 4874
 	// You can only remove it if it's available.
4608
-	if (!in_array($integration_call, $functions))
4609
-		return;
4875
+	if (!in_array($integration_call, $functions)) {
4876
+			return;
4877
+	}
4610 4878
 
4611 4879
 	$functions = array_diff($functions, array($integration_call));
4612 4880
 	$modSettings[$hook] = implode(',', $functions);
@@ -4627,17 +4895,20 @@  discard block
 block discarded – undo
4627 4895
 	global $context, $smcFunc, $txt, $db_show_debug;
4628 4896
 
4629 4897
 	// Really?
4630
-	if (empty($string))
4631
-		return false;
4898
+	if (empty($string)) {
4899
+			return false;
4900
+	}
4632 4901
 
4633 4902
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4634 4903
 	// A closure? should be a callable one.
4635
-	if (is_array($string) || $string instanceof Closure)
4636
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4904
+	if (is_array($string) || $string instanceof Closure) {
4905
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4906
+	}
4637 4907
 
4638 4908
 	// No full objects, sorry! pass a method or a property instead!
4639
-	if (is_object($string))
4640
-		return false;
4909
+	if (is_object($string)) {
4910
+			return false;
4911
+	}
4641 4912
 
4642 4913
 	// Stay vitaminized my friends...
4643 4914
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4646,8 +4917,9 @@  discard block
 block discarded – undo
4646 4917
 	$string = load_file($string);
4647 4918
 
4648 4919
 	// Loaded file failed
4649
-	if (empty($string))
4650
-		return false;
4920
+	if (empty($string)) {
4921
+			return false;
4922
+	}
4651 4923
 
4652 4924
 	// Found a method.
4653 4925
 	if (strpos($string, '::') !== false)
@@ -4668,8 +4940,9 @@  discard block
 block discarded – undo
4668 4940
 				// Add another one to the list.
4669 4941
 				if ($db_show_debug === true)
4670 4942
 				{
4671
-					if (!isset($context['debug']['instances']))
4672
-						$context['debug']['instances'] = array();
4943
+					if (!isset($context['debug']['instances'])) {
4944
+											$context['debug']['instances'] = array();
4945
+					}
4673 4946
 
4674 4947
 					$context['debug']['instances'][$class] = $class;
4675 4948
 				}
@@ -4679,13 +4952,15 @@  discard block
 block discarded – undo
4679 4952
 		}
4680 4953
 
4681 4954
 		// Right then. This is a call to a static method.
4682
-		else
4683
-			$func = array($class, $method);
4955
+		else {
4956
+					$func = array($class, $method);
4957
+		}
4684 4958
 	}
4685 4959
 
4686 4960
 	// Nope! just a plain regular function.
4687
-	else
4688
-		$func = $string;
4961
+	else {
4962
+			$func = $string;
4963
+	}
4689 4964
 
4690 4965
 	// Right, we got what we need, time to do some checks.
4691 4966
 	if (!is_callable($func, false, $callable_name))
@@ -4701,17 +4976,18 @@  discard block
 block discarded – undo
4701 4976
 	else
4702 4977
 	{
4703 4978
 		// What are we gonna do about it?
4704
-		if ($return)
4705
-			return $func;
4979
+		if ($return) {
4980
+					return $func;
4981
+		}
4706 4982
 
4707 4983
 		// If this is a plain function, avoid the heat of calling call_user_func().
4708 4984
 		else
4709 4985
 		{
4710
-			if (is_array($func))
4711
-				call_user_func($func);
4712
-
4713
-			else
4714
-				$func();
4986
+			if (is_array($func)) {
4987
+							call_user_func($func);
4988
+			} else {
4989
+							$func();
4990
+			}
4715 4991
 		}
4716 4992
 	}
4717 4993
 }
@@ -4728,31 +5004,34 @@  discard block
 block discarded – undo
4728 5004
 {
4729 5005
 	global $sourcedir, $txt, $boarddir, $settings;
4730 5006
 
4731
-	if (empty($string))
4732
-		return false;
5007
+	if (empty($string)) {
5008
+			return false;
5009
+	}
4733 5010
 
4734 5011
 	if (strpos($string, '|') !== false)
4735 5012
 	{
4736 5013
 		list ($file, $string) = explode('|', $string);
4737 5014
 
4738 5015
 		// Match the wildcards to their regular vars.
4739
-		if (empty($settings['theme_dir']))
4740
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4741
-
4742
-		else
4743
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5016
+		if (empty($settings['theme_dir'])) {
5017
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
5018
+		} else {
5019
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
5020
+		}
4744 5021
 
4745 5022
 		// Load the file if it can be loaded.
4746
-		if (file_exists($absPath))
4747
-			require_once($absPath);
5023
+		if (file_exists($absPath)) {
5024
+					require_once($absPath);
5025
+		}
4748 5026
 
4749 5027
 		// No? try a fallback to $sourcedir
4750 5028
 		else
4751 5029
 		{
4752 5030
 			$absPath = $sourcedir .'/'. $file;
4753 5031
 
4754
-			if (file_exists($absPath))
4755
-				require_once($absPath);
5032
+			if (file_exists($absPath)) {
5033
+							require_once($absPath);
5034
+			}
4756 5035
 
4757 5036
 			// Sorry, can't do much for you at this point.
4758 5037
 			else
@@ -4779,8 +5058,9 @@  discard block
 block discarded – undo
4779 5058
 	global $user_info, $smcFunc;
4780 5059
 
4781 5060
 	// Make sure we have something to work with.
4782
-	if (empty($topic))
4783
-		return array();
5061
+	if (empty($topic)) {
5062
+			return array();
5063
+	}
4784 5064
 
4785 5065
 
4786 5066
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -4803,8 +5083,9 @@  discard block
 block discarded – undo
4803 5083
 				'topic' => $topic,
4804 5084
 			)
4805 5085
 		);
4806
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4807
-			$temp[] = (int) $row['content_id'];
5086
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5087
+					$temp[] = (int) $row['content_id'];
5088
+		}
4808 5089
 
4809 5090
 		cache_put_data($cache_key, $temp, $ttl);
4810 5091
 	}
@@ -4825,8 +5106,9 @@  discard block
 block discarded – undo
4825 5106
 {
4826 5107
 	global $context;
4827 5108
 
4828
-	if (empty($string))
4829
-		return $string;
5109
+	if (empty($string)) {
5110
+			return $string;
5111
+	}
4830 5112
 
4831 5113
 	// UTF-8 occurences of MS special characters
4832 5114
 	$findchars_utf8 = array(
@@ -4867,10 +5149,11 @@  discard block
 block discarded – undo
4867 5149
 		'--',	// &mdash;
4868 5150
 	);
4869 5151
 
4870
-	if ($context['utf8'])
4871
-		$string = str_replace($findchars_utf8, $replacechars, $string);
4872
-	else
4873
-		$string = str_replace($findchars_iso, $replacechars, $string);
5152
+	if ($context['utf8']) {
5153
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5154
+	} else {
5155
+			$string = str_replace($findchars_iso, $replacechars, $string);
5156
+	}
4874 5157
 
4875 5158
 	return $string;
4876 5159
 }
@@ -4889,49 +5172,59 @@  discard block
 block discarded – undo
4889 5172
 {
4890 5173
 	global $context;
4891 5174
 
4892
-	if (!isset($matches[2]))
4893
-		return '';
5175
+	if (!isset($matches[2])) {
5176
+			return '';
5177
+	}
4894 5178
 
4895 5179
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4896 5180
 
4897 5181
 	// remove left to right / right to left overrides
4898
-	if ($num === 0x202D || $num === 0x202E)
4899
-		return '';
5182
+	if ($num === 0x202D || $num === 0x202E) {
5183
+			return '';
5184
+	}
4900 5185
 
4901 5186
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
4902
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
4903
-		return '&#' . $num . ';';
5187
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5188
+			return '&#' . $num . ';';
5189
+	}
4904 5190
 
4905 5191
 	if (empty($context['utf8']))
4906 5192
 	{
4907 5193
 		// no control characters
4908
-		if ($num < 0x20)
4909
-			return '';
5194
+		if ($num < 0x20) {
5195
+					return '';
5196
+		}
4910 5197
 		// text is text
4911
-		elseif ($num < 0x80)
4912
-			return chr($num);
5198
+		elseif ($num < 0x80) {
5199
+					return chr($num);
5200
+		}
4913 5201
 		// all others get html-ised
4914
-		else
4915
-			return '&#' . $matches[2] . ';';
4916
-	}
4917
-	else
5202
+		else {
5203
+					return '&#' . $matches[2] . ';';
5204
+		}
5205
+	} else
4918 5206
 	{
4919 5207
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
4920 5208
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
4921
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
4922
-			return '';
5209
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5210
+					return '';
5211
+		}
4923 5212
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4924
-		elseif ($num < 0x80)
4925
-			return chr($num);
5213
+		elseif ($num < 0x80) {
5214
+					return chr($num);
5215
+		}
4926 5216
 		// <0x800 (2048)
4927
-		elseif ($num < 0x800)
4928
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5217
+		elseif ($num < 0x800) {
5218
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5219
+		}
4929 5220
 		// < 0x10000 (65536)
4930
-		elseif ($num < 0x10000)
4931
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5221
+		elseif ($num < 0x10000) {
5222
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5223
+		}
4932 5224
 		// <= 0x10FFFF (1114111)
4933
-		else
4934
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5225
+		else {
5226
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5227
+		}
4935 5228
 	}
4936 5229
 }
4937 5230
 
@@ -4947,28 +5240,34 @@  discard block
 block discarded – undo
4947 5240
  */
4948 5241
 function fixchar__callback($matches)
4949 5242
 {
4950
-	if (!isset($matches[1]))
4951
-		return '';
5243
+	if (!isset($matches[1])) {
5244
+			return '';
5245
+	}
4952 5246
 
4953 5247
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
4954 5248
 
4955 5249
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
4956 5250
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
4957
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
4958
-		return '';
5251
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5252
+			return '';
5253
+	}
4959 5254
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4960
-	elseif ($num < 0x80)
4961
-		return chr($num);
5255
+	elseif ($num < 0x80) {
5256
+			return chr($num);
5257
+	}
4962 5258
 	// <0x800 (2048)
4963
-	elseif ($num < 0x800)
4964
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5259
+	elseif ($num < 0x800) {
5260
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5261
+	}
4965 5262
 	// < 0x10000 (65536)
4966
-	elseif ($num < 0x10000)
4967
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5263
+	elseif ($num < 0x10000) {
5264
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5265
+	}
4968 5266
 	// <= 0x10FFFF (1114111)
4969
-	else
4970
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4971
-}
5267
+	else {
5268
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5269
+	}
5270
+	}
4972 5271
 
4973 5272
 /**
4974 5273
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -4981,17 +5280,19 @@  discard block
 block discarded – undo
4981 5280
  */
4982 5281
 function entity_fix__callback($matches)
4983 5282
 {
4984
-	if (!isset($matches[2]))
4985
-		return '';
5283
+	if (!isset($matches[2])) {
5284
+			return '';
5285
+	}
4986 5286
 
4987 5287
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4988 5288
 
4989 5289
 	// we don't allow control characters, characters out of range, byte markers, etc
4990
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
4991
-		return '';
4992
-	else
4993
-		return '&#' . $num . ';';
4994
-}
5290
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5291
+			return '';
5292
+	} else {
5293
+			return '&#' . $num . ';';
5294
+	}
5295
+	}
4995 5296
 
4996 5297
 /**
4997 5298
  * Return a Gravatar URL based on
@@ -5015,18 +5316,23 @@  discard block
 block discarded – undo
5015 5316
 		$ratings = array('G', 'PG', 'R', 'X');
5016 5317
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
5017 5318
 		$url_params = array();
5018
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
5019
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5020
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
5021
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5022
-		if (!empty($modSettings['avatar_max_width_external']))
5023
-			$size_string = (int) $modSettings['avatar_max_width_external'];
5024
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
5025
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5319
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5320
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5321
+		}
5322
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5323
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5324
+		}
5325
+		if (!empty($modSettings['avatar_max_width_external'])) {
5326
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5327
+		}
5328
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5329
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5026 5330
 				$size_string = $modSettings['avatar_max_height_external'];
5331
+		}
5027 5332
 
5028
-		if (!empty($size_string))
5029
-			$url_params[] = 's=' . $size_string;
5333
+		if (!empty($size_string)) {
5334
+					$url_params[] = 's=' . $size_string;
5335
+		}
5030 5336
 	}
5031 5337
 	$http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www';
5032 5338
 
@@ -5045,22 +5351,26 @@  discard block
 block discarded – undo
5045 5351
 	static $timezones = null, $lastwhen = null;
5046 5352
 
5047 5353
 	// No point doing this over if we already did it once
5048
-	if (!empty($timezones) && $when == $lastwhen)
5049
-		return $timezones;
5050
-	else
5051
-		$lastwhen = $when;
5354
+	if (!empty($timezones) && $when == $lastwhen) {
5355
+			return $timezones;
5356
+	} else {
5357
+			$lastwhen = $when;
5358
+	}
5052 5359
 
5053 5360
 	// Parseable datetime string?
5054
-	if (is_int($timestamp = strtotime($when)))
5055
-		$when = $timestamp;
5361
+	if (is_int($timestamp = strtotime($when))) {
5362
+			$when = $timestamp;
5363
+	}
5056 5364
 
5057 5365
 	// A Unix timestamp?
5058
-	elseif (is_numeric($when))
5059
-		$when = intval($when);
5366
+	elseif (is_numeric($when)) {
5367
+			$when = intval($when);
5368
+	}
5060 5369
 
5061 5370
 	// Invalid value? Just get current Unix timestamp.
5062
-	else
5063
-		$when = time();
5371
+	else {
5372
+			$when = time();
5373
+	}
5064 5374
 
5065 5375
 	// We'll need these too
5066 5376
 	$date_when = date_create('@' . $when);
@@ -5124,8 +5434,9 @@  discard block
 block discarded – undo
5124 5434
 	foreach ($priority_countries as $country)
5125 5435
 	{
5126 5436
 		$country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country)));
5127
-		if (!empty($country_tzids))
5128
-			$priority_tzids = array_merge($priority_tzids, $country_tzids);
5437
+		if (!empty($country_tzids)) {
5438
+					$priority_tzids = array_merge($priority_tzids, $country_tzids);
5439
+		}
5129 5440
 	}
5130 5441
 
5131 5442
 	// Process the preferred timezones first, then the rest.
@@ -5135,8 +5446,9 @@  discard block
 block discarded – undo
5135 5446
 	foreach ($tzids as $tzid)
5136 5447
 	{
5137 5448
 		// We don't want UTC right now
5138
-		if ($tzid == 'UTC')
5139
-			continue;
5449
+		if ($tzid == 'UTC') {
5450
+					continue;
5451
+		}
5140 5452
 
5141 5453
 		$tz = timezone_open($tzid);
5142 5454
 
@@ -5157,8 +5469,9 @@  discard block
 block discarded – undo
5157 5469
 		}
5158 5470
 
5159 5471
 		// A time zone from a prioritized country?
5160
-		if (in_array($tzid, $priority_tzids))
5161
-			$priority_zones[$tzkey] = true;
5472
+		if (in_array($tzid, $priority_tzids)) {
5473
+					$priority_zones[$tzkey] = true;
5474
+		}
5162 5475
 
5163 5476
 		// Keep track of the location and offset for this tzid
5164 5477
 		$tzid_parts = explode('/', $tzid);
@@ -5177,15 +5490,17 @@  discard block
 block discarded – undo
5177 5490
 	{
5178 5491
 		date_timezone_set($date_when, timezone_open($tzvalue['tzid']));
5179 5492
 
5180
-		if (!empty($timezone_descriptions[$tzvalue['tzid']]))
5181
-			$desc = $timezone_descriptions[$tzvalue['tzid']];
5182
-		else
5183
-			$desc = implode(', ', array_unique($tzvalue['locations']));
5493
+		if (!empty($timezone_descriptions[$tzvalue['tzid']])) {
5494
+					$desc = $timezone_descriptions[$tzvalue['tzid']];
5495
+		} else {
5496
+					$desc = implode(', ', array_unique($tzvalue['locations']));
5497
+		}
5184 5498
 
5185
-		if (isset($priority_zones[$tzkey]))
5186
-			$priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5187
-		else
5188
-			$timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5499
+		if (isset($priority_zones[$tzkey])) {
5500
+					$priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5501
+		} else {
5502
+					$timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5503
+		}
5189 5504
 	}
5190 5505
 
5191 5506
 	$timezones = array_merge(
@@ -5239,9 +5554,9 @@  discard block
 block discarded – undo
5239 5554
 			'Indian/Kerguelen' => 'TFT',
5240 5555
 		);
5241 5556
 
5242
-		if (!empty($missing_tz_abbrs[$tzid]))
5243
-			$tz_abbrev = $missing_tz_abbrs[$tzid];
5244
-		else
5557
+		if (!empty($missing_tz_abbrs[$tzid])) {
5558
+					$tz_abbrev = $missing_tz_abbrs[$tzid];
5559
+		} else
5245 5560
 		{
5246 5561
 			// Russia likes to experiment with time zones often, and names them as offsets from Moscow
5247 5562
 			$tz_location = timezone_location_get(timezone_open($tzid));
@@ -5269,8 +5584,9 @@  discard block
 block discarded – undo
5269 5584
  */
5270 5585
 function inet_ptod($ip_address)
5271 5586
 {
5272
-	if (!isValidIP($ip_address))
5273
-		return $ip_address;
5587
+	if (!isValidIP($ip_address)) {
5588
+			return $ip_address;
5589
+	}
5274 5590
 
5275 5591
 	$bin = inet_pton($ip_address);
5276 5592
 	return $bin;
@@ -5282,13 +5598,15 @@  discard block
 block discarded – undo
5282 5598
  */
5283 5599
 function inet_dtop($bin)
5284 5600
 {
5285
-	if(empty($bin))
5286
-		return '';
5601
+	if(empty($bin)) {
5602
+			return '';
5603
+	}
5287 5604
 
5288 5605
 	global $db_type;
5289 5606
 
5290
-	if ($db_type == 'postgresql')
5291
-		return $bin;
5607
+	if ($db_type == 'postgresql') {
5608
+			return $bin;
5609
+	}
5292 5610
 
5293 5611
 	$ip_address = inet_ntop($bin);
5294 5612
 
@@ -5313,26 +5631,32 @@  discard block
 block discarded – undo
5313 5631
  */
5314 5632
 function _safe_serialize($value)
5315 5633
 {
5316
-	if(is_null($value))
5317
-		return 'N;';
5634
+	if(is_null($value)) {
5635
+			return 'N;';
5636
+	}
5318 5637
 
5319
-	if(is_bool($value))
5320
-		return 'b:'. (int) $value .';';
5638
+	if(is_bool($value)) {
5639
+			return 'b:'. (int) $value .';';
5640
+	}
5321 5641
 
5322
-	if(is_int($value))
5323
-		return 'i:'. $value .';';
5642
+	if(is_int($value)) {
5643
+			return 'i:'. $value .';';
5644
+	}
5324 5645
 
5325
-	if(is_float($value))
5326
-		return 'd:'. str_replace(',', '.', $value) .';';
5646
+	if(is_float($value)) {
5647
+			return 'd:'. str_replace(',', '.', $value) .';';
5648
+	}
5327 5649
 
5328
-	if(is_string($value))
5329
-		return 's:'. strlen($value) .':"'. $value .'";';
5650
+	if(is_string($value)) {
5651
+			return 's:'. strlen($value) .':"'. $value .'";';
5652
+	}
5330 5653
 
5331 5654
 	if(is_array($value))
5332 5655
 	{
5333 5656
 		$out = '';
5334
-		foreach($value as $k => $v)
5335
-			$out .= _safe_serialize($k) . _safe_serialize($v);
5657
+		foreach($value as $k => $v) {
5658
+					$out .= _safe_serialize($k) . _safe_serialize($v);
5659
+		}
5336 5660
 
5337 5661
 		return 'a:'. count($value) .':{'. $out .'}';
5338 5662
 	}
@@ -5358,8 +5682,9 @@  discard block
 block discarded – undo
5358 5682
 
5359 5683
 	$out = _safe_serialize($value);
5360 5684
 
5361
-	if (isset($mbIntEnc))
5362
-		mb_internal_encoding($mbIntEnc);
5685
+	if (isset($mbIntEnc)) {
5686
+			mb_internal_encoding($mbIntEnc);
5687
+	}
5363 5688
 
5364 5689
 	return $out;
5365 5690
 }
@@ -5376,8 +5701,9 @@  discard block
 block discarded – undo
5376 5701
 function _safe_unserialize($str)
5377 5702
 {
5378 5703
 	// Input  is not a string.
5379
-	if(empty($str) || !is_string($str))
5380
-		return false;
5704
+	if(empty($str) || !is_string($str)) {
5705
+			return false;
5706
+	}
5381 5707
 
5382 5708
 	$stack = array();
5383 5709
 	$expected = array();
@@ -5393,43 +5719,38 @@  discard block
 block discarded – undo
5393 5719
 	while($state != 1)
5394 5720
 	{
5395 5721
 		$type = isset($str[0]) ? $str[0] : '';
5396
-		if($type == '}')
5397
-			$str = substr($str, 1);
5398
-
5399
-		else if($type == 'N' && $str[1] == ';')
5722
+		if($type == '}') {
5723
+					$str = substr($str, 1);
5724
+		} else if($type == 'N' && $str[1] == ';')
5400 5725
 		{
5401 5726
 			$value = null;
5402 5727
 			$str = substr($str, 2);
5403
-		}
5404
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5728
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5405 5729
 		{
5406 5730
 			$value = $matches[1] == '1' ? true : false;
5407 5731
 			$str = substr($str, 4);
5408
-		}
5409
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5732
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5410 5733
 		{
5411 5734
 			$value = (int)$matches[1];
5412 5735
 			$str = $matches[2];
5413
-		}
5414
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5736
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5415 5737
 		{
5416 5738
 			$value = (float)$matches[1];
5417 5739
 			$str = $matches[3];
5418
-		}
5419
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5740
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5420 5741
 		{
5421 5742
 			$value = substr($matches[2], 0, (int)$matches[1]);
5422 5743
 			$str = substr($matches[2], (int)$matches[1] + 2);
5423
-		}
5424
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5744
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5425 5745
 		{
5426 5746
 			$expectedLength = (int)$matches[1];
5427 5747
 			$str = $matches[2];
5428 5748
 		}
5429 5749
 
5430 5750
 		// Object or unknown/malformed type.
5431
-		else
5432
-			return false;
5751
+		else {
5752
+					return false;
5753
+		}
5433 5754
 
5434 5755
 		switch($state)
5435 5756
 		{
@@ -5457,8 +5778,9 @@  discard block
 block discarded – undo
5457 5778
 				if($type == '}')
5458 5779
 				{
5459 5780
 					// Array size is less than expected.
5460
-					if(count($list) < end($expected))
5461
-						return false;
5781
+					if(count($list) < end($expected)) {
5782
+											return false;
5783
+					}
5462 5784
 
5463 5785
 					unset($list);
5464 5786
 					$list = &$stack[count($stack)-1];
@@ -5467,8 +5789,9 @@  discard block
 block discarded – undo
5467 5789
 					// Go to terminal state if we're at the end of the root array.
5468 5790
 					array_pop($expected);
5469 5791
 
5470
-					if(count($expected) == 0)
5471
-						$state = 1;
5792
+					if(count($expected) == 0) {
5793
+											$state = 1;
5794
+					}
5472 5795
 
5473 5796
 					break;
5474 5797
 				}
@@ -5476,8 +5799,9 @@  discard block
 block discarded – undo
5476 5799
 				if($type == 'i' || $type == 's')
5477 5800
 				{
5478 5801
 					// Array size exceeds expected length.
5479
-					if(count($list) >= end($expected))
5480
-						return false;
5802
+					if(count($list) >= end($expected)) {
5803
+											return false;
5804
+					}
5481 5805
 
5482 5806
 					$key = $value;
5483 5807
 					$state = 3;
@@ -5511,8 +5835,9 @@  discard block
 block discarded – undo
5511 5835
 	}
5512 5836
 
5513 5837
 	// Trailing data in input.
5514
-	if(!empty($str))
5515
-		return false;
5838
+	if(!empty($str)) {
5839
+			return false;
5840
+	}
5516 5841
 
5517 5842
 	return $data;
5518 5843
 }
@@ -5535,8 +5860,9 @@  discard block
 block discarded – undo
5535 5860
 
5536 5861
 	$out = _safe_unserialize($str);
5537 5862
 
5538
-	if (isset($mbIntEnc))
5539
-		mb_internal_encoding($mbIntEnc);
5863
+	if (isset($mbIntEnc)) {
5864
+			mb_internal_encoding($mbIntEnc);
5865
+	}
5540 5866
 
5541 5867
 	return $out;
5542 5868
 }
@@ -5551,12 +5877,14 @@  discard block
 block discarded – undo
5551 5877
 function smf_chmod($file, $value = 0)
5552 5878
 {
5553 5879
 	// No file? no checks!
5554
-	if (empty($file))
5555
-		return false;
5880
+	if (empty($file)) {
5881
+			return false;
5882
+	}
5556 5883
 
5557 5884
 	// Already writable?
5558
-	if (is_writable($file))
5559
-		return true;
5885
+	if (is_writable($file)) {
5886
+			return true;
5887
+	}
5560 5888
 
5561 5889
 	// Do we have a file or a dir?
5562 5890
 	$isDir = is_dir($file);
@@ -5572,10 +5900,9 @@  discard block
 block discarded – undo
5572 5900
 		{
5573 5901
 			$isWritable = true;
5574 5902
 			break;
5903
+		} else {
5904
+					@chmod($file, $val);
5575 5905
 		}
5576
-
5577
-		else
5578
-			@chmod($file, $val);
5579 5906
 	}
5580 5907
 
5581 5908
 	return $isWritable;
@@ -5594,8 +5921,9 @@  discard block
 block discarded – undo
5594 5921
 	global $txt;
5595 5922
 
5596 5923
 	// Come on...
5597
-	if (empty($json) || !is_string($json))
5598
-		return array();
5924
+	if (empty($json) || !is_string($json)) {
5925
+			return array();
5926
+	}
5599 5927
 
5600 5928
 	$returnArray = @json_decode($json, $returnAsArray);
5601 5929
 
@@ -5633,11 +5961,11 @@  discard block
 block discarded – undo
5633 5961
 		$jsonDebug = $jsonDebug[0];
5634 5962
 		loadLanguage('Errors');
5635 5963
 
5636
-		if (!empty($jsonDebug))
5637
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5638
-
5639
-		else
5640
-			log_error($txt['json_'. $jsonError], 'critical');
5964
+		if (!empty($jsonDebug)) {
5965
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5966
+		} else {
5967
+					log_error($txt['json_'. $jsonError], 'critical');
5968
+		}
5641 5969
 
5642 5970
 		// Everyone expects an array.
5643 5971
 		return array();
@@ -5671,8 +5999,9 @@  discard block
 block discarded – undo
5671 5999
 	global $db_show_debug, $modSettings;
5672 6000
 
5673 6001
 	// Defensive programming anyone?
5674
-	if (empty($data))
5675
-		return false;
6002
+	if (empty($data)) {
6003
+			return false;
6004
+	}
5676 6005
 
5677 6006
 	// Don't need extra stuff...
5678 6007
 	$db_show_debug = false;
@@ -5680,11 +6009,11 @@  discard block
 block discarded – undo
5680 6009
 	// Kill anything else.
5681 6010
 	ob_end_clean();
5682 6011
 
5683
-	if (!empty($modSettings['CompressedOutput']))
5684
-		@ob_start('ob_gzhandler');
5685
-
5686
-	else
5687
-		ob_start();
6012
+	if (!empty($modSettings['CompressedOutput'])) {
6013
+			@ob_start('ob_gzhandler');
6014
+	} else {
6015
+			ob_start();
6016
+	}
5688 6017
 
5689 6018
 	// Set the header.
5690 6019
 	header($type);
@@ -5716,8 +6045,9 @@  discard block
 block discarded – undo
5716 6045
 	static $done = false;
5717 6046
 
5718 6047
 	// If we don't need to do anything, don't
5719
-	if (!$update && $done)
5720
-		return;
6048
+	if (!$update && $done) {
6049
+			return;
6050
+	}
5721 6051
 
5722 6052
 	// Should we get a new copy of the official list of TLDs?
5723 6053
 	if ($update)
@@ -5726,8 +6056,9 @@  discard block
 block discarded – undo
5726 6056
 		$tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt');
5727 6057
 
5728 6058
 		// If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored.
5729
-		if ($tlds === false)
5730
-			$postapocalypticNightmare = true;
6059
+		if ($tlds === false) {
6060
+					$postapocalypticNightmare = true;
6061
+		}
5731 6062
 	}
5732 6063
 	// If we aren't updating and the regex is valid, we're done
5733 6064
 	elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false)
@@ -5742,10 +6073,11 @@  discard block
 block discarded – undo
5742 6073
 		// Clean $tlds and convert it to an array
5743 6074
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
5744 6075
 			$line = trim($line);
5745
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
5746
-				return false;
5747
-			else
5748
-				return true;
6076
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
6077
+							return false;
6078
+			} else {
6079
+							return true;
6080
+			}
5749 6081
 		});
5750 6082
 
5751 6083
 		// Convert Punycode to Unicode
@@ -5799,8 +6131,9 @@  discard block
 block discarded – undo
5799 6131
 						$idx += $digit * $w;
5800 6132
 						$t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias));
5801 6133
 
5802
-						if ($digit < $t)
5803
-							break;
6134
+						if ($digit < $t) {
6135
+													break;
6136
+						}
5804 6137
 
5805 6138
 						$w = (int) ($w * ($base - $t));
5806 6139
 					}
@@ -5809,8 +6142,9 @@  discard block
 block discarded – undo
5809 6142
 					$delta = intval($is_first ? ($delta / $damp) : ($delta / 2));
5810 6143
 					$delta += intval($delta / ($deco_len + 1));
5811 6144
 
5812
-					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base)
5813
-						$delta = intval($delta / ($base - $tmin));
6145
+					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) {
6146
+											$delta = intval($delta / ($base - $tmin));
6147
+					}
5814 6148
 
5815 6149
 					$bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew));
5816 6150
 					$is_first = false;
@@ -5819,8 +6153,9 @@  discard block
 block discarded – undo
5819 6153
 
5820 6154
 					if ($deco_len > 0)
5821 6155
 					{
5822
-						for ($i = $deco_len; $i > $idx; $i--)
5823
-							$decoded[$i] = $decoded[($i - 1)];
6156
+						for ($i = $deco_len; $i > $idx; $i--) {
6157
+													$decoded[$i] = $decoded[($i - 1)];
6158
+						}
5824 6159
 					}
5825 6160
 					$decoded[$idx++] = $char;
5826 6161
 				}
@@ -5828,24 +6163,29 @@  discard block
 block discarded – undo
5828 6163
 				foreach ($decoded as $k => $v)
5829 6164
 				{
5830 6165
 					// 7bit are transferred literally
5831
-					if ($v < 128)
5832
-						$output .= chr($v);
6166
+					if ($v < 128) {
6167
+											$output .= chr($v);
6168
+					}
5833 6169
 
5834 6170
 					// 2 bytes
5835
-					elseif ($v < (1 << 11))
5836
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6171
+					elseif ($v < (1 << 11)) {
6172
+											$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6173
+					}
5837 6174
 
5838 6175
 					// 3 bytes
5839
-					elseif ($v < (1 << 16))
5840
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6176
+					elseif ($v < (1 << 16)) {
6177
+											$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6178
+					}
5841 6179
 
5842 6180
 					// 4 bytes
5843
-					elseif ($v < (1 << 21))
5844
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6181
+					elseif ($v < (1 << 21)) {
6182
+											$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6183
+					}
5845 6184
 
5846 6185
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5847
-					else
5848
-						$output .= $safe_char;
6186
+					else {
6187
+											$output .= $safe_char;
6188
+					}
5849 6189
 				}
5850 6190
 
5851 6191
 				$output_parts[] = $output;
@@ -5938,8 +6278,7 @@  discard block
 block discarded – undo
5938 6278
 
5939 6279
 		$strlen = 'mb_strlen';
5940 6280
 		$substr = 'mb_substr';
5941
-	}
5942
-	else
6281
+	} else
5943 6282
 	{
5944 6283
 		$strlen = $smcFunc['strlen'];
5945 6284
 		$substr = $smcFunc['substr'];
@@ -5953,20 +6292,21 @@  discard block
 block discarded – undo
5953 6292
 
5954 6293
 		$first = $substr($string, 0, 1);
5955 6294
 
5956
-		if (empty($index[$first]))
5957
-			$index[$first] = array();
6295
+		if (empty($index[$first])) {
6296
+					$index[$first] = array();
6297
+		}
5958 6298
 
5959 6299
 		if ($strlen($string) > 1)
5960 6300
 		{
5961 6301
 			// Sanity check on recursion
5962
-			if ($depth > 99)
5963
-				$index[$first][$substr($string, 1)] = '';
5964
-
5965
-			else
5966
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6302
+			if ($depth > 99) {
6303
+							$index[$first][$substr($string, 1)] = '';
6304
+			} else {
6305
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6306
+			}
6307
+		} else {
6308
+					$index[$first][''] = '';
5967 6309
 		}
5968
-		else
5969
-			$index[$first][''] = '';
5970 6310
 
5971 6311
 		$depth--;
5972 6312
 		return $index;
@@ -5989,9 +6329,9 @@  discard block
 block discarded – undo
5989 6329
 			$key_regex = preg_quote($key, $delim);
5990 6330
 			$new_key = $key;
5991 6331
 
5992
-			if (empty($value))
5993
-				$sub_regex = '';
5994
-			else
6332
+			if (empty($value)) {
6333
+							$sub_regex = '';
6334
+			} else
5995 6335
 			{
5996 6336
 				$sub_regex = $index_to_regex($value, $delim);
5997 6337
 
@@ -5999,22 +6339,22 @@  discard block
 block discarded – undo
5999 6339
 				{
6000 6340
 					$new_key_array = explode('(?'.'>', $sub_regex);
6001 6341
 					$new_key .= $new_key_array[0];
6342
+				} else {
6343
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
6002 6344
 				}
6003
-				else
6004
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6005 6345
 			}
6006 6346
 
6007
-			if ($depth > 1)
6008
-				$regex[$new_key] = $key_regex . $sub_regex;
6009
-			else
6347
+			if ($depth > 1) {
6348
+							$regex[$new_key] = $key_regex . $sub_regex;
6349
+			} else
6010 6350
 			{
6011 6351
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
6012 6352
 				{
6013 6353
 					$regex[$new_key] = $key_regex . $sub_regex;
6014 6354
 					unset($index[$key]);
6355
+				} else {
6356
+									break;
6015 6357
 				}
6016
-				else
6017
-					break;
6018 6358
 			}
6019 6359
 		}
6020 6360
 
@@ -6023,10 +6363,11 @@  discard block
 block discarded – undo
6023 6363
 			$l1 = $strlen($k1);
6024 6364
 			$l2 = $strlen($k2);
6025 6365
 
6026
-			if ($l1 == $l2)
6027
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
6028
-			else
6029
-				return $l1 > $l2 ? -1 : 1;
6366
+			if ($l1 == $l2) {
6367
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6368
+			} else {
6369
+							return $l1 > $l2 ? -1 : 1;
6370
+			}
6030 6371
 		});
6031 6372
 
6032 6373
 		$depth--;
@@ -6037,21 +6378,24 @@  discard block
 block discarded – undo
6037 6378
 	$index = array();
6038 6379
 	$regex = '';
6039 6380
 
6040
-	foreach ($strings as $string)
6041
-		$index = $add_string_to_index($string, $index);
6381
+	foreach ($strings as $string) {
6382
+			$index = $add_string_to_index($string, $index);
6383
+	}
6042 6384
 
6043 6385
 	if ($returnArray === true)
6044 6386
 	{
6045 6387
 		$regex = array();
6046
-		while (!empty($index))
6047
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6388
+		while (!empty($index)) {
6389
+					$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6390
+		}
6391
+	} else {
6392
+			$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6048 6393
 	}
6049
-	else
6050
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6051 6394
 
6052 6395
 	// Restore PHP's internal character encoding to whatever it was originally
6053
-	if (!empty($current_encoding))
6054
-		mb_internal_encoding($current_encoding);
6396
+	if (!empty($current_encoding)) {
6397
+			mb_internal_encoding($current_encoding);
6398
+	}
6055 6399
 
6056 6400
 	return $regex;
6057 6401
 }
@@ -6094,13 +6438,15 @@  discard block
 block discarded – undo
6094 6438
 	// Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't...
6095 6439
 	$url = str_ireplace('https://', 'http://', $url) . '/';
6096 6440
 	$headers = @get_headers($url);
6097
-	if ($headers === false)
6098
-		return false;
6441
+	if ($headers === false) {
6442
+			return false;
6443
+	}
6099 6444
 
6100 6445
 	// Now to see if it came back https...
6101 6446
 	// First check for a redirect status code in first row (301, 302, 307)
6102
-	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false)
6103
-		return false;
6447
+	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) {
6448
+			return false;
6449
+	}
6104 6450
 
6105 6451
 	// Search for the location entry to confirm https
6106 6452
 	$result = false;
@@ -6136,8 +6482,7 @@  discard block
 block discarded – undo
6136 6482
 		$is_admin = $user_info['is_admin'];
6137 6483
 		$mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null;
6138 6484
 		$ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null;
6139
-	}
6140
-	else
6485
+	} else
6141 6486
 	{
6142 6487
 		$request = $smcFunc['db_query']('', '
6143 6488
 				SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group
@@ -6151,17 +6496,19 @@  discard block
 block discarded – undo
6151 6496
 
6152 6497
 		$row = $smcFunc['db_fetch_assoc']($request);
6153 6498
 
6154
-		if (empty($row['additional_groups']))
6155
-			$groups = array($row['id_group'], $row['id_post_group']);
6156
-		else
6157
-			$groups = array_merge(
6499
+		if (empty($row['additional_groups'])) {
6500
+					$groups = array($row['id_group'], $row['id_post_group']);
6501
+		} else {
6502
+					$groups = array_merge(
6158 6503
 					array($row['id_group'], $row['id_post_group']),
6159 6504
 					explode(',', $row['additional_groups'])
6160 6505
 			);
6506
+		}
6161 6507
 
6162 6508
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
6163
-		foreach ($groups as $k => $v)
6164
-			$groups[$k] = (int) $v;
6509
+		foreach ($groups as $k => $v) {
6510
+					$groups[$k] = (int) $v;
6511
+		}
6165 6512
 
6166 6513
 		$is_admin = in_array(1, $groups);
6167 6514
 
@@ -6178,8 +6525,9 @@  discard block
 block discarded – undo
6178 6525
 				'current_member' => $userid,
6179 6526
 			)
6180 6527
 		);
6181
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6182
-			$boards_mod[] = $row['id_board'];
6528
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6529
+					$boards_mod[] = $row['id_board'];
6530
+		}
6183 6531
 		$smcFunc['db_free_result']($request);
6184 6532
 
6185 6533
 		// Can any of the groups they're in moderate any of the boards?
@@ -6191,8 +6539,9 @@  discard block
 block discarded – undo
6191 6539
 				'groups' => $groups,
6192 6540
 			)
6193 6541
 		);
6194
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6195
-			$boards_mod[] = $row['id_board'];
6542
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6543
+					$boards_mod[] = $row['id_board'];
6544
+		}
6196 6545
 		$smcFunc['db_free_result']($request);
6197 6546
 
6198 6547
 		// Just in case we've got duplicates here...
@@ -6202,21 +6551,25 @@  discard block
 block discarded – undo
6202 6551
 	}
6203 6552
 
6204 6553
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
6205
-	if ($is_admin)
6206
-		$query_part['query_see_board'] = '1=1';
6554
+	if ($is_admin) {
6555
+			$query_part['query_see_board'] = '1=1';
6556
+	}
6207 6557
 	// Otherwise just the groups in $user_info['groups'].
6208
-	else
6209
-		$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6558
+	else {
6559
+			$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6560
+	}
6210 6561
 
6211 6562
 	// Build the list of boards they WANT to see.
6212 6563
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
6213 6564
 
6214 6565
 	// If they aren't ignoring any boards then they want to see all the boards they can see
6215
-	if (empty($ignoreboards))
6216
-		$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6566
+	if (empty($ignoreboards)) {
6567
+			$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6568
+	}
6217 6569
 	// Ok I guess they don't want to see all the boards
6218
-	else
6219
-		$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6570
+	else {
6571
+			$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6572
+	}
6220 6573
 
6221 6574
 	return $query_part;
6222 6575
 }
@@ -6230,10 +6583,11 @@  discard block
 block discarded – undo
6230 6583
 {
6231 6584
 	$secure = false;
6232 6585
 
6233
-	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
6234
-		$secure = true;
6235
-	elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
6236
-		$secure = true;
6586
+	if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
6587
+			$secure = true;
6588
+	} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
6589
+			$secure = true;
6590
+	}
6237 6591
 
6238 6592
 	return $secure;
6239 6593
 }
Please login to merge, or discard this patch.
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 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.